diff --git a/.env.example b/.env.example index 6fa1c4a8e..55516d8cf 100644 --- a/.env.example +++ b/.env.example @@ -16,12 +16,10 @@ DEPLOYER_PRIVATE_KEY= #ARCHIVE_NODE_opbnbmainnet=https://opbnb-mainnet.nodereal.io/v1/ #ARCHIVE_NODE_arbitrumone=https://open-platform.nodereal.io//arbitrum-nitro/ #ARCHIVE_NODE_arbitrumsepolia=https://sepolia-rollup.arbitrum.io/rpc -#ARCHIVE_NODE_xlayertestnet=https://rpc.ankr.com/xlayer_testnet/ -#ARCHIVE_NODE_xlayermainnet=https://rpc.ankr.com/xlayer #ARCHIVE_NODE_zksyncsepolia=https://zksync-sepolia.g.alchemy.com/v2/ #ARCHIVE_NODE_zksyncmainnet=https://open-platform.nodereal.io//zksync -#ARCHIVE_NODE_opsepolia="https://sepolia.optimism.io" -#ARCHIVE_NODE_opmainnet="https://opt-mainnet.nodereal.io/v1/" +#ARCHIVE_NODE_opsepolia=https://sepolia.optimism.io +#ARCHIVE_NODE_opmainnet=https://opt-mainnet.nodereal.io/v1/ ETHERSCAN_API_KEY= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 459de6d34..30b6d88b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,7 +139,7 @@ jobs: - name: Export deployments run: | - for NETWORK in bsctestnet bscmainnet ethereum sepolia opbnbtestnet opbnbmainnet arbitrumsepolia arbitrumone xlayertestnet xlayermainnet opsepolia opmainnet; do + for NETWORK in bsctestnet bscmainnet ethereum sepolia opbnbtestnet opbnbmainnet arbitrumsepolia arbitrumone opsepolia opmainnet; do EXPORT=true yarn hardhat export --network ${NETWORK} --export ./deployments/${NETWORK}.json jq -M '{name, chainId, addresses: .contracts | map_values(.address)}' ./deployments/${NETWORK}.json > ./deployments/${NETWORK}_addresses.json done diff --git a/CHANGELOG.md b/CHANGELOG.md index 8698ee5a4..cb3162c73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,63 @@ +## [9.3.0-dev.6](https://github.com/VenusProtocol/venus-protocol/compare/v9.3.0-dev.5...v9.3.0-dev.6) (2024-10-10) + + +### Features + +* deployment files for plp and prime on opmainnet ([8dffc68](https://github.com/VenusProtocol/venus-protocol/commit/8dffc6851d2849ec651126c80077e840cec85a69)) +* updating deployment files ([a09e96b](https://github.com/VenusProtocol/venus-protocol/commit/a09e96bb6e1d15d49e439b90fb7875cf85072af2)) +* updating deployment files ([8436f6d](https://github.com/VenusProtocol/venus-protocol/commit/8436f6dcee8714e365f219aa1baf1ec02328df0f)) +* use packages that include the Optimism deployment ([75a772d](https://github.com/VenusProtocol/venus-protocol/commit/75a772ddc5149424e4074f0787890ef4aaa7bb82)) + +## [9.3.0-dev.5](https://github.com/VenusProtocol/venus-protocol/compare/v9.3.0-dev.4...v9.3.0-dev.5) (2024-09-27) + + +### Features + +* deployment files of xvs vault on op mainnet ([22f00d4](https://github.com/VenusProtocol/venus-protocol/commit/22f00d4e48fd58638abfe85da6248e92c9c9d018)) +* updating deployment files ([c45ed5d](https://github.com/VenusProtocol/venus-protocol/commit/c45ed5d32201b39db7fda84a4bd5bf15f882ef6f)) + +## [9.3.0-dev.4](https://github.com/VenusProtocol/venus-protocol/compare/v9.3.0-dev.3...v9.3.0-dev.4) (2024-09-20) + + +### Features + +* deployment files for the treasury on op mainnet ([7a48028](https://github.com/VenusProtocol/venus-protocol/commit/7a48028ef6a3d1260c9e05e1cd7fe545a392cb58)) +* updating deployment files ([2d182dc](https://github.com/VenusProtocol/venus-protocol/commit/2d182dce0e7af2b5f24dd63c01b6e4b1449c59b0)) + +## [9.3.0-dev.3](https://github.com/VenusProtocol/venus-protocol/compare/v9.3.0-dev.2...v9.3.0-dev.3) (2024-09-17) + + +### Features + +* deployment files for the prime and plp contracts on opsepolia ([29a293b](https://github.com/VenusProtocol/venus-protocol/commit/29a293b4ed25ddbf482d1badda8c808ce6024008)) +* updating deployment files ([22bb4d4](https://github.com/VenusProtocol/venus-protocol/commit/22bb4d45712a60b918ea11d3248a8e74b6f3cc4e)) + +## [9.3.0-dev.2](https://github.com/VenusProtocol/venus-protocol/compare/v9.3.0-dev.1...v9.3.0-dev.2) (2024-09-17) + + +### Features + +* update IR of VBNB ([d334a3d](https://github.com/VenusProtocol/venus-protocol/commit/d334a3d507c577dc9938535dcfad944911a21ee2)) +* updating deployment files ([8255e99](https://github.com/VenusProtocol/venus-protocol/commit/8255e99b737010e756488cd4c48883111a7a1d64)) + + +### Bug Fixes + +* ci checks ([e3e6644](https://github.com/VenusProtocol/venus-protocol/commit/e3e66440a3b50e0b389db6ff053fe40280c01e40)) + +## [9.3.0-dev.1](https://github.com/VenusProtocol/venus-protocol/compare/v9.2.0...v9.3.0-dev.1) (2024-09-13) + + +### Features + +* updating deployment files ([e1bc769](https://github.com/VenusProtocol/venus-protocol/commit/e1bc769e9462565066828cc5e01f2042f8ccd753)) +* updating deployment files ([026d270](https://github.com/VenusProtocol/venus-protocol/commit/026d270cf3ee582d6544bc6a07124cd069e27d41)) + + +### Bug Fixes + +* pr comment ([52a4c06](https://github.com/VenusProtocol/venus-protocol/commit/52a4c0651569198c5be379ee70e8d612050e7702)) + ## [9.2.0](https://github.com/VenusProtocol/venus-protocol/compare/v9.1.0...v9.2.0) (2024-09-10) diff --git a/deploy/002-interest-rate-model.ts b/deploy/002-interest-rate-model.ts index b49710239..6b74abb24 100644 --- a/deploy/002-interest-rate-model.ts +++ b/deploy/002-interest-rate-model.ts @@ -31,7 +31,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { from: deployer, log: true, autoMine: true, - args: [0, "225000000000000000", "6800000000000000000", "700000000000000000"], + args: [0, "225000000000000000", "6800000000000000000", "500000000000000000"], }); } }; diff --git a/deploy/005-deploy-VTreasuryV8.ts b/deploy/005-deploy-VTreasuryV8.ts index 699fd4b82..d151b1e27 100644 --- a/deploy/005-deploy-VTreasuryV8.ts +++ b/deploy/005-deploy-VTreasuryV8.ts @@ -31,10 +31,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { opbnbmainnet: "0xC46796a21a3A9FAB6546aF3434F2eBfFd0604207", // OPBNBMAINNET MULTISIG arbitrumsepolia: "0x1426A5Ae009c4443188DA8793751024E358A61C2", // ARBITRUM_SEPOLIA MULTISIG arbitrumone: "0x14e0E151b33f9802b3e75b621c1457afc44DcAA0", // ARBITRUM_ONE MULTISIG - xlayertestnet: "0x5961449d63149035aCfC0714D5155f24C9819004", // XLAYER TESTNET MULTISIG zksyncsepolia: "0xa2f83de95E9F28eD443132C331B6a9C9B7a9F866", // ZKSYNC SEPOLIA MULTISIG zksyncmainnet: "0x751Aa759cfBB6CE71A43b48e40e1cCcFC66Ba4aa", // ZKSYNC MAINNET MULTISIG opsepolia: "0xd57365EE4E850e881229e2F8Aa405822f289e78d", // OPSEPOLIA MULTISIG + opmainnet: "0x2e94dd14E81999CdBF5deDE31938beD7308354b3", // OPMAINNET MULTISIG bscmainnet: await getTimelock(), bsctestnet: await getTimelock(), hardhat: deployer, diff --git a/deploy/009-configure-vaults.ts b/deploy/009-configure-vaults.ts index 780c22a53..c53918e31 100644 --- a/deploy/009-configure-vaults.ts +++ b/deploy/009-configure-vaults.ts @@ -22,6 +22,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { bsctestnet: 10_512_000, // 3 sec per block sepolia: 2_628_000, // 12 sec per block arbitrumsepolia: 0, // time based deployment + opsepolia: 0, // time based deployment + opmainnet: 0, // time based deployment arbitrumone: 0, // time based deployment zksyncsepolia: 0, // time based deployment zksyncmainnet: 0, // time based deployment @@ -39,6 +41,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { arbitrumone: "0x14e0E151b33f9802b3e75b621c1457afc44DcAA0", // ARBITRUM ONE MULTISIG zksyncsepolia: "0xa2f83de95E9F28eD443132C331B6a9C9B7a9F866", // ZKSYNC SEPOLIA MULTISIG zksyncmainnet: "0x751Aa759cfBB6CE71A43b48e40e1cCcFC66Ba4aa", // ZKSYNC MAINNET MULTISIG + opsepolia: "0xd57365EE4E850e881229e2F8Aa405822f289e78d", // OPSEPOLIA MULTISIG + opmainnet: "0x2e94dd14E81999CdBF5deDE31938beD7308354b3", // OPMAINNET MULTISIG bscmainnet: await getContractAddressOrNullAddress(deployments, "NormalTimelock"), bsctestnet: await getContractAddressOrNullAddress(deployments, "NormalTimelock"), hardhat: deployer, diff --git a/deploy/012-deploy-prime.ts b/deploy/012-deploy-prime.ts index f8fbf3444..4d45bc56b 100644 --- a/deploy/012-deploy-prime.ts +++ b/deploy/012-deploy-prime.ts @@ -26,10 +26,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { sepolia: TEN_MINUTES, arbitrumsepolia: TEN_MINUTES, zksyncsepolia: TEN_MINUTES, + opsepolia: TEN_MINUTES, bscmainnet: NINETY_DAYS, ethereum: NINETY_DAYS, arbitrumone: NINETY_DAYS, zksyncmainnet: NINETY_DAYS, + opmainnet: NINETY_DAYS, }; const xVSVaultPoolId: Config = { @@ -41,6 +43,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { arbitrumone: 0, zksyncsepolia: 0, zksyncmainnet: 0, + opsepolia: 0, + opmainnet: 0, hardhat: 0, }; @@ -51,6 +55,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { arbitrumone: 0, // time based contracts zksyncsepolia: 0, // time based contracts zksyncmainnet: 0, // time based contracts + opsepolia: 0, // time based contracts + opmainnet: 0, // time based contracts bscmainnet: 10_512_000, ethereum: 2_628_000, hardhat: 100, @@ -81,6 +87,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { arbitrumone: "0x14e0E151b33f9802b3e75b621c1457afc44DcAA0", // ARBITRUM ONE MULTISIG zksyncsepolia: "0xa2f83de95E9F28eD443132C331B6a9C9B7a9F866", // ZKSYNC SEPOLIA MULTISIG zksyncmainnet: "0x751Aa759cfBB6CE71A43b48e40e1cCcFC66Ba4aa", // ZKSYNC MAINNET MULTISIG + opsepolia: "0xd57365EE4E850e881229e2F8Aa405822f289e78d", // OPSEPOLIA MULTISIG + opmainnet: "0x2e94dd14E81999CdBF5deDE31938beD7308354b3", // OPMAINNET MULTISIG bscmainnet: await getContractAddressOrNullAddress(deployments, "NormalTimelock"), bsctestnet: await getContractAddressOrNullAddress(deployments, "NormalTimelock"), }; diff --git a/deploy/013-configure-prime.ts b/deploy/013-configure-prime.ts index a33a2efee..e99883435 100644 --- a/deploy/013-configure-prime.ts +++ b/deploy/013-configure-prime.ts @@ -20,6 +20,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { arbitrumone: "0x14e0E151b33f9802b3e75b621c1457afc44DcAA0", // ARBITRUM ONE MULTISIG zksyncsepolia: "0xa2f83de95E9F28eD443132C331B6a9C9B7a9F866", // ZKSYNC SEPOLIA MULTISIG zksyncmainnet: "0x751Aa759cfBB6CE71A43b48e40e1cCcFC66Ba4aa", // ZKSYNC MAINNET MULTISIG + opsepolia: "0xd57365EE4E850e881229e2F8Aa405822f289e78d", // OPSEPOLIA MULTISIG + opmainnet: "0x2e94dd14E81999CdBF5deDE31938beD7308354b3", // OPMAINNET MULTISIG bscmainnet: await getContractAddressOrNullAddress(deployments, "NormalTimelock"), bsctestnet: await getContractAddressOrNullAddress(deployments, "NormalTimelock"), }; diff --git a/deployments/bscmainnet.json b/deployments/bscmainnet.json index 61d1ec95c..a7acf3853 100644 --- a/deployments/bscmainnet.json +++ b/deployments/bscmainnet.json @@ -6498,7 +6498,7 @@ ] }, "InterestRateModelVBNB": { - "address": "0xe5be8D9f4697dD264e488efD4b29c8CC31616fa5", + "address": "0xDb8347b96c94Be24B9c077A4CDDAAD074F6480cf", "abi": [ { "inputs": [ diff --git a/deployments/bscmainnet/InterestRateModelVBNB.json b/deployments/bscmainnet/InterestRateModelVBNB.json index d0edc77df..96098e616 100644 --- a/deployments/bscmainnet/InterestRateModelVBNB.json +++ b/deployments/bscmainnet/InterestRateModelVBNB.json @@ -1,5 +1,5 @@ { - "address": "0xe5be8D9f4697dD264e488efD4b29c8CC31616fa5", + "address": "0xDb8347b96c94Be24B9c077A4CDDAAD074F6480cf", "abi": [ { "inputs": [ @@ -248,36 +248,36 @@ "type": "function" } ], - "transactionHash": "0x3dbfb3c0dd7f688a48e578fe68ba130be6037d6b6367ac7867ade50bd2669db5", + "transactionHash": "0x7dae5875db1defcd4344938885f577cc29e797ee7eaf6daf057f129979c59974", "receipt": { "to": null, - "from": "0x8BDA9f9E1fEF0DFd404Fef338D9fE4c543d172e1", - "contractAddress": "0xe5be8D9f4697dD264e488efD4b29c8CC31616fa5", - "transactionIndex": 142, + "from": "0x92054EdBb53eCC4f2A1787e92f479CE10392A658", + "contractAddress": "0xDb8347b96c94Be24B9c077A4CDDAAD074F6480cf", + "transactionIndex": 36, "gasUsed": "468712", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000080000000000000000000000000000000000000100400000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x37b5ab4063f8bec8ae68ca2f8495b111cadd563fd2c263dccc35ba89ad1f414a", - "transactionHash": "0x3dbfb3c0dd7f688a48e578fe68ba130be6037d6b6367ac7867ade50bd2669db5", + "logsBloom": "0x00000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000080000000000000000000000000000000000000000000000000000000000040000000000000400000000000000000000000000000000000000000000000000000000000000000008000000000000", + "blockHash": "0xbb37d18e2b329222cfad1b9a57efa8c8ebe24d56788b168fda31dc001275c773", + "transactionHash": "0x7dae5875db1defcd4344938885f577cc29e797ee7eaf6daf057f129979c59974", "logs": [ { - "transactionIndex": 142, - "blockNumber": 40603987, - "transactionHash": "0x3dbfb3c0dd7f688a48e578fe68ba130be6037d6b6367ac7867ade50bd2669db5", - "address": "0xe5be8D9f4697dD264e488efD4b29c8CC31616fa5", + "transactionIndex": 36, + "blockNumber": 42299490, + "transactionHash": "0x7dae5875db1defcd4344938885f577cc29e797ee7eaf6daf057f129979c59974", + "address": "0xDb8347b96c94Be24B9c077A4CDDAAD074F6480cf", "topics": ["0x6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d"], - "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004fbc8cb15000000000000000000000000000000000000000000000000000000969d09c0b400000000000000000000000000000000000000000000000009b6e64a8ec60000", - "logIndex": 416, - "blockHash": "0x37b5ab4063f8bec8ae68ca2f8495b111cadd563fd2c263dccc35ba89ad1f414a" + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004fbc8cb15000000000000000000000000000000000000000000000000000000969d09c0b400000000000000000000000000000000000000000000000006f05b59d3b20000", + "logIndex": 98, + "blockHash": "0xbb37d18e2b329222cfad1b9a57efa8c8ebe24d56788b168fda31dc001275c773" } ], - "blockNumber": 40603987, - "cumulativeGasUsed": "16249455", + "blockNumber": 42299490, + "cumulativeGasUsed": "3772945", "status": 1, "byzantium": true }, - "args": [0, "225000000000000000", "6800000000000000000", "700000000000000000"], - "numDeployments": 2, - "solcInputHash": "f3ebf9e67e90c643d9aab2ce73e7b9f3", + "args": [0, "225000000000000000", "6800000000000000000", "500000000000000000"], + "numDeployments": 3, + "solcInputHash": "a2594572bdae270af6749f50c8019b6c", "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"baseRatePerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"multiplierPerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"jumpMultiplierPerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"kink_\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"baseRatePerBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"multiplierPerBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"jumpMultiplierPerBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"kink\",\"type\":\"uint256\"}],\"name\":\"NewInterestParams\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[],\"name\":\"baseRatePerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"blocksPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"cash\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrows\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserves\",\"type\":\"uint256\"}],\"name\":\"getBorrowRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"cash\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrows\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserves\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserveFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"getSupplyRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isInterestRateModel\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"jumpMultiplierPerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"kink\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"multiplierPerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"cash\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrows\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserves\",\"type\":\"uint256\"}],\"name\":\"utilizationRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"methods\":{\"constructor\":{\"params\":{\"baseRatePerYear\":\"The approximate target base APR, as a mantissa (scaled by 1e18)\",\"jumpMultiplierPerYear\":\"The multiplierPerBlock after hitting a specified utilization point\",\"kink_\":\"The utilization point at which the jump multiplier is applied\",\"multiplierPerYear\":\"The rate of increase in interest rate wrt utilization (scaled by 1e18)\"}},\"getBorrowRate(uint256,uint256,uint256)\":{\"params\":{\"borrows\":\"The amount of borrows in the market\",\"cash\":\"The amount of cash in the market\",\"reserves\":\"The amount of reserves in the market\"},\"return\":\"The borrow rate percentage per block as a mantissa (scaled by 1e18)\"},\"getSupplyRate(uint256,uint256,uint256,uint256)\":{\"params\":{\"borrows\":\"The amount of borrows in the market\",\"cash\":\"The amount of cash in the market\",\"reserveFactorMantissa\":\"The current reserve factor for the market\",\"reserves\":\"The amount of reserves in the market\"},\"return\":\"The supply rate percentage per block as a mantissa (scaled by 1e18)\"},\"utilizationRate(uint256,uint256,uint256)\":{\"params\":{\"borrows\":\"The amount of borrows in the market\",\"cash\":\"The amount of cash in the market\",\"reserves\":\"The amount of reserves in the market (currently unused)\"},\"return\":\"The utilization rate as a mantissa between [0, 1e18]\"}},\"title\":\"Venus's JumpRateModel Contract\"},\"userdoc\":{\"methods\":{\"constructor\":\"Construct an interest rate model\",\"getBorrowRate(uint256,uint256,uint256)\":{\"notice\":\"Calculates the current borrow rate per block, with the error code expected by the market\"},\"getSupplyRate(uint256,uint256,uint256,uint256)\":{\"notice\":\"Calculates the current supply rate per block\"},\"utilizationRate(uint256,uint256,uint256)\":{\"notice\":\"Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\"}}}},\"settings\":{\"compilationTarget\":{\"contracts/InterestRateModels/JumpRateModel.sol\":\"JumpRateModel\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/InterestRateModels/InterestRateModel.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\n/**\\n * @title Venus's InterestRateModel Interface\\n * @author Venus\\n */\\ncontract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amnount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amnount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint cash,\\n uint borrows,\\n uint reserves,\\n uint reserveFactorMantissa\\n ) external view returns (uint);\\n}\\n\",\"keccak256\":\"0x7896290ed5d98f1b744676c0cf5cb0bc656befdd8a79ae4cd2d9f90d83aaa52d\"},\"contracts/InterestRateModels/JumpRateModel.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"../Utils/SafeMath.sol\\\";\\nimport \\\"./InterestRateModel.sol\\\";\\n\\n/**\\n * @title Venus's JumpRateModel Contract\\n * @author Venus\\n */\\ncontract JumpRateModel is InterestRateModel {\\n using SafeMath for uint;\\n\\n event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock, uint jumpMultiplierPerBlock, uint kink);\\n\\n /**\\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\\n */\\n uint public constant blocksPerYear = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\\n\\n /**\\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\\n */\\n uint public multiplierPerBlock;\\n\\n /**\\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\\n */\\n uint public baseRatePerBlock;\\n\\n /**\\n * @notice The multiplierPerBlock after hitting a specified utilization point\\n */\\n uint public jumpMultiplierPerBlock;\\n\\n /**\\n * @notice The utilization point at which the jump multiplier is applied\\n */\\n uint public kink;\\n\\n /**\\n * @notice Construct an interest rate model\\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\\n * @param kink_ The utilization point at which the jump multiplier is applied\\n */\\n constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) public {\\n baseRatePerBlock = baseRatePerYear.div(blocksPerYear);\\n multiplierPerBlock = multiplierPerYear.div(blocksPerYear);\\n jumpMultiplierPerBlock = jumpMultiplierPerYear.div(blocksPerYear);\\n kink = kink_;\\n\\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\\n }\\n\\n /**\\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\\n * @param cash The amount of cash in the market\\n * @param borrows The amount of borrows in the market\\n * @param reserves The amount of reserves in the market (currently unused)\\n * @return The utilization rate as a mantissa between [0, 1e18]\\n */\\n function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {\\n // Utilization rate is 0 when there are no borrows\\n if (borrows == 0) {\\n return 0;\\n }\\n\\n return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));\\n }\\n\\n /**\\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\\n * @param cash The amount of cash in the market\\n * @param borrows The amount of borrows in the market\\n * @param reserves The amount of reserves in the market\\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\\n */\\n function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {\\n uint util = utilizationRate(cash, borrows, reserves);\\n\\n if (util <= kink) {\\n return util.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\\n } else {\\n uint normalRate = kink.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\\n uint excessUtil = util.sub(kink);\\n return excessUtil.mul(jumpMultiplierPerBlock).div(1e18).add(normalRate);\\n }\\n }\\n\\n /**\\n * @notice Calculates the current supply rate per block\\n * @param cash The amount of cash in the market\\n * @param borrows The amount of borrows in the market\\n * @param reserves The amount of reserves in the market\\n * @param reserveFactorMantissa The current reserve factor for the market\\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint cash,\\n uint borrows,\\n uint reserves,\\n uint reserveFactorMantissa\\n ) public view returns (uint) {\\n uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);\\n uint borrowRate = getBorrowRate(cash, borrows, reserves);\\n uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);\\n return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);\\n }\\n}\\n\",\"keccak256\":\"0x0c90d867067f823ca47664590f132385830ed66d2cfccdf242c028d0a85bd7c9\"},\"contracts/Utils/SafeMath.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add(a, b, \\\"SafeMath: addition overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub(a, b, \\\"SafeMath: subtraction overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n uint256 c = a - b;\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) {\\n return 0;\\n }\\n\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div(a, b, \\\"SafeMath: division by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n // Solidity only automatically asserts when dividing by 0\\n require(b > 0, errorMessage);\\n uint256 c = a / b;\\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mod(a, b, \\\"SafeMath: modulo by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts with custom message when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b != 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x9431fd772ed4abc038cdfe9ce6c0066897bd1685ad45848748d1952935d5b8ef\"}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b506040516108113803806108118339818101604052608081101561003357600080fd5b508051602080830151604084015160609094015192939092909161006590859062a066809061039e6100fd821b17901c565b6001556100808362a066806100fd602090811b61039e17901c565b60005561009b8262a066806100fd602090811b61039e17901c565b60028190556003829055600154600054604080519283526020830191909152818101929092526060810183905290517f6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d9181900360800190a1505050506101ee565b600061014583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061014c60201b60201c565b9392505050565b600081836101d85760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561019d578181015183820152602001610185565b50505050905090810190601f1680156101ca5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816101e457fe5b0495945050505050565b610614806101fd6000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063a385fb9611610066578063a385fb9614610120578063b816881614610128578063b9f9850a14610157578063f14039de1461015f578063fd2da3391461016757610093565b806315f24053146100985780632191f92a146100d35780636e71e2d8146100ef5780638726bb8914610118575b600080fd5b6100c1600480360360608110156100ae57600080fd5b508035906020810135906040013561016f565b60408051918252519081900360200190f35b6100db610247565b604080519115158252519081900360200190f35b6100c16004803603606081101561010557600080fd5b508035906020810135906040013561024c565b6100c161029e565b6100c16102a4565b6100c16004803603608081101561013e57600080fd5b50803590602081013590604081013590606001356102ab565b6100c161032a565b6100c1610330565b6100c1610336565b60008061017d85858561024c565b905060035481116101cf576101c76001546101bb670de0b6b3a76400006101af6000548661033c90919063ffffffff16565b9063ffffffff61039e16565b9063ffffffff6103e016565b915050610240565b60006101fa6001546101bb670de0b6b3a76400006101af60005460035461033c90919063ffffffff16565b905060006102136003548461042290919063ffffffff16565b905061023a826101bb670de0b6b3a76400006101af6002548661033c90919063ffffffff16565b93505050505b9392505050565b600181565b60008261025b57506000610240565b61029661027e83610272878763ffffffff6103e016565b9063ffffffff61042216565b6101af85670de0b6b3a764000063ffffffff61033c16565b949350505050565b60005481565b62a0668081565b6000806102c6670de0b6b3a76400008463ffffffff61042216565b905060006102d587878761016f565b905060006102f5670de0b6b3a76400006101af848663ffffffff61033c16565b905061031e670de0b6b3a76400006101af836103128c8c8c61024c565b9063ffffffff61033c16565b98975050505050505050565b60025481565b60015481565b60035481565b60008261034b57506000610398565b8282028284828161035857fe5b04146103955760405162461bcd60e51b81526004018080602001828103825260218152602001806105bf6021913960400191505060405180910390fd5b90505b92915050565b600061039583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610464565b600061039583836040518060400160405280601b81526020017f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815250610506565b600061039583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610564565b600081836104f05760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156104b557818101518382015260200161049d565b50505050905090810190601f1680156104e25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816104fc57fe5b0495945050505050565b6000838301828582101561055b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156104b557818101518382015260200161049d565b50949350505050565b600081848411156105b65760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156104b557818101518382015260200161049d565b50505090039056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a723158208d524531d4bd676b08c415f951c89512128d7ce72185b07b426ac97c6c3b50a564736f6c63430005100032", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063a385fb9611610066578063a385fb9614610120578063b816881614610128578063b9f9850a14610157578063f14039de1461015f578063fd2da3391461016757610093565b806315f24053146100985780632191f92a146100d35780636e71e2d8146100ef5780638726bb8914610118575b600080fd5b6100c1600480360360608110156100ae57600080fd5b508035906020810135906040013561016f565b60408051918252519081900360200190f35b6100db610247565b604080519115158252519081900360200190f35b6100c16004803603606081101561010557600080fd5b508035906020810135906040013561024c565b6100c161029e565b6100c16102a4565b6100c16004803603608081101561013e57600080fd5b50803590602081013590604081013590606001356102ab565b6100c161032a565b6100c1610330565b6100c1610336565b60008061017d85858561024c565b905060035481116101cf576101c76001546101bb670de0b6b3a76400006101af6000548661033c90919063ffffffff16565b9063ffffffff61039e16565b9063ffffffff6103e016565b915050610240565b60006101fa6001546101bb670de0b6b3a76400006101af60005460035461033c90919063ffffffff16565b905060006102136003548461042290919063ffffffff16565b905061023a826101bb670de0b6b3a76400006101af6002548661033c90919063ffffffff16565b93505050505b9392505050565b600181565b60008261025b57506000610240565b61029661027e83610272878763ffffffff6103e016565b9063ffffffff61042216565b6101af85670de0b6b3a764000063ffffffff61033c16565b949350505050565b60005481565b62a0668081565b6000806102c6670de0b6b3a76400008463ffffffff61042216565b905060006102d587878761016f565b905060006102f5670de0b6b3a76400006101af848663ffffffff61033c16565b905061031e670de0b6b3a76400006101af836103128c8c8c61024c565b9063ffffffff61033c16565b98975050505050505050565b60025481565b60015481565b60035481565b60008261034b57506000610398565b8282028284828161035857fe5b04146103955760405162461bcd60e51b81526004018080602001828103825260218152602001806105bf6021913960400191505060405180910390fd5b90505b92915050565b600061039583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610464565b600061039583836040518060400160405280601b81526020017f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815250610506565b600061039583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610564565b600081836104f05760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156104b557818101518382015260200161049d565b50505050905090810190601f1680156104e25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816104fc57fe5b0495945050505050565b6000838301828582101561055b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156104b557818101518382015260200161049d565b50949350505050565b600081848411156105b65760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156104b557818101518382015260200161049d565b50505090039056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a723158208d524531d4bd676b08c415f951c89512128d7ce72185b07b426ac97c6c3b50a564736f6c63430005100032", @@ -337,7 +337,7 @@ "storageLayout": { "storage": [ { - "astId": 9110, + "astId": 9329, "contract": "contracts/InterestRateModels/JumpRateModel.sol:JumpRateModel", "label": "multiplierPerBlock", "offset": 0, @@ -345,7 +345,7 @@ "type": "t_uint256" }, { - "astId": 9112, + "astId": 9331, "contract": "contracts/InterestRateModels/JumpRateModel.sol:JumpRateModel", "label": "baseRatePerBlock", "offset": 0, @@ -353,7 +353,7 @@ "type": "t_uint256" }, { - "astId": 9114, + "astId": 9333, "contract": "contracts/InterestRateModels/JumpRateModel.sol:JumpRateModel", "label": "jumpMultiplierPerBlock", "offset": 0, @@ -361,7 +361,7 @@ "type": "t_uint256" }, { - "astId": 9116, + "astId": 9335, "contract": "contracts/InterestRateModels/JumpRateModel.sol:JumpRateModel", "label": "kink", "offset": 0, diff --git a/deployments/bscmainnet/solcInputs/a2594572bdae270af6749f50c8019b6c.json b/deployments/bscmainnet/solcInputs/a2594572bdae270af6749f50c8019b6c.json new file mode 100644 index 000000000..9b8c5e750 --- /dev/null +++ b/deployments/bscmainnet/solcInputs/a2594572bdae270af6749f50c8019b6c.json @@ -0,0 +1,366 @@ +{ + "language": "Solidity", + "sources": { + "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\nimport \"./IAccessControlManagerV5.sol\";\n\n/**\n * @title AccessControlledV5\n * @author Venus\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.5.16)\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\n */\ncontract AccessControlledV5 {\n /// @notice Access control manager contract\n IAccessControlManagerV5 private _accessControlManager;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when access control manager contract address is changed\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n /**\n * @notice Returns the address of the access control manager contract\n */\n function accessControlManager() external view returns (IAccessControlManagerV5) {\n return _accessControlManager;\n }\n\n /**\n * @dev Internal function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n */\n function _setAccessControlManager(address accessControlManager_) internal {\n require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n address oldAccessControlManager = address(_accessControlManager);\n _accessControlManager = IAccessControlManagerV5(accessControlManager_);\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n }\n\n /**\n * @notice Reverts if the call is not allowed by AccessControlManager\n * @param signature Method signature\n */\n function _checkAccessAllowed(string memory signature) internal view {\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n if (!isAllowedToCall) {\n revert(\"Unauthorized\");\n }\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"./GovernorBravoInterfaces.sol\";\n\n/**\n * @title GovernorBravoDelegate\n * @notice Venus Governance latest on chain governance includes several new features including variable proposal routes and fine grained pause control.\n * Variable routes for proposals allows for governance paramaters such as voting threshold and timelocks to be customized based on the risk level and\n * impact of the proposal. Added granularity to the pause control mechanism allows governance to pause individual actions on specific markets,\n * which reduces impact on the protocol as a whole. This is particularly useful when applied to isolated pools.\n *\n * The goal of **Governance** is to increase governance efficiency, while mitigating and eliminating malicious or erroneous proposals.\n *\n * ## Details\n *\n * Governance has **3 main contracts**: **GovernanceBravoDelegate, XVSVault, XVS** token.\n *\n * - XVS token is the protocol token used for protocol users to cast their vote on submitted proposals.\n * - XVSVault is the main staking contract for XVS. Users first stake their XVS in the vault and receive voting power proportional to their staked\n * tokens that they can use to vote on proposals. Users also can choose to delegate their voting power to other users.\n *\n * # Governor Bravo\n *\n * `GovernanceBravoDelegate` is main Venus Governance contract. Users interact with it to:\n * - Submit new proposal\n * - Vote on a proposal\n * - Cancel a proposal\n * - Queue a proposal for execution with a timelock executor contract.\n * `GovernanceBravoDelegate` uses the XVSVault to get restrict certain actions based on a user's voting power. The governance rules it inforces are:\n * - A user's voting power must be greater than the `proposalThreshold` to submit a proposal\n * - If a user's voting power drops below certain amount, anyone can cancel the the proposal. The governance guardian and proposal creator can also\n * cancel a proposal at anytime before it is queued for execution.\n *\n * ## Venus Improvement Proposal\n *\n * Venus Governance allows for Venus Improvement Proposals (VIPs) to be categorized based on their impact and risk levels. This allows for optimizing proposals\n * execution to allow for things such as expediting interest rate changes and quickly updating risk parameters, while moving slower on other types of proposals\n * that can prevent a larger risk to the protocol and are not urgent. There are three different types of VIPs with different proposal paramters:\n *\n * - `NORMAL`\n * - `FASTTRACK`\n * - `CRITICAL`\n *\n * When initializing the `GovernorBravo` contract, the parameters for the three routes are set. The parameters are:\n *\n * - `votingDelay`: The delay in blocks between submitting a proposal and when voting begins\n * - `votingPeriod`: The number of blocks where voting will be open\n * - `proposalThreshold`: The number of votes required in order submit a proposal\n *\n * There is also a separate timelock executor contract for each route, which is used to dispatch the VIP for execution, giving even more control over the\n * flow of each type of VIP.\n *\n * ## Voting\n *\n * After a VIP is proposed, voting is opened after the `votingDelay` has passed. For example, if `votingDelay = 0`, then voting will begin in the next block\n * after the proposal has been submitted. After the delay, the proposal state is `ACTIVE` and users can cast their vote `for`, `against`, or `abstain`,\n * weighted by their total voting power (tokens + delegated voting power). Abstaining from a voting allows for a vote to be cast and optionally include a\n * comment, without the incrementing for or against vote count. The total voting power for the user is obtained by calling XVSVault's `getPriorVotes`.\n *\n * `GovernorBravoDelegate` also accepts [EIP-712](https://eips.ethereum.org/EIPS/eip-712) signatures for voting on proposals via the external function\n * `castVoteBySig`.\n *\n * ## Delegating\n *\n * A users voting power includes the amount of staked XVS the have staked as well as the votes delegate to them. Delegating is the process of a user loaning\n * their voting power to another, so that the latter has the combined voting power of both users. This is an important feature because it allows for a user\n * to let another user who they trust propose or vote in their place.\n *\n * The delegation of votes happens through the `XVSVault` contract by calling the `delegate` or `delegateBySig` functions. These same functions can revert\n * vote delegation by calling the same function with a value of `0`.\n */\ncontract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoEvents {\n /// @notice The name of this contract\n string public constant name = \"Venus Governor Bravo\";\n\n /// @notice The minimum setable proposal threshold\n uint public constant MIN_PROPOSAL_THRESHOLD = 150000e18; // 150,000 Xvs\n\n /// @notice The maximum setable proposal threshold\n uint public constant MAX_PROPOSAL_THRESHOLD = 300000e18; //300,000 Xvs\n\n /// @notice The minimum setable voting period\n uint public constant MIN_VOTING_PERIOD = 20 * 60 * 3; // About 3 hours, 3 secs per block\n\n /// @notice The max setable voting period\n uint public constant MAX_VOTING_PERIOD = 20 * 60 * 24 * 14; // About 2 weeks, 3 secs per block\n\n /// @notice The min setable voting delay\n uint public constant MIN_VOTING_DELAY = 1;\n\n /// @notice The max setable voting delay\n uint public constant MAX_VOTING_DELAY = 20 * 60 * 24 * 7; // About 1 week, 3 secs per block\n\n /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed\n uint public constant quorumVotes = 600000e18; // 600,000 = 2% of Xvs\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the ballot struct used by the contract\n bytes32 public constant BALLOT_TYPEHASH = keccak256(\"Ballot(uint256 proposalId,uint8 support)\");\n\n /**\n * @notice Used to initialize the contract during delegator contructor\n * @param xvsVault_ The address of the XvsVault\n * @param proposalConfigs_ Governance configs for each governance route\n * @param timelocks Timelock addresses for each governance route\n */\n function initialize(\n address xvsVault_,\n ProposalConfig[] memory proposalConfigs_,\n TimelockInterface[] memory timelocks,\n address guardian_\n ) public {\n require(address(proposalTimelocks[0]) == address(0), \"GovernorBravo::initialize: cannot initialize twice\");\n require(msg.sender == admin, \"GovernorBravo::initialize: admin only\");\n require(xvsVault_ != address(0), \"GovernorBravo::initialize: invalid xvs address\");\n require(guardian_ != address(0), \"GovernorBravo::initialize: invalid guardian\");\n require(\n timelocks.length == uint8(ProposalType.CRITICAL) + 1,\n \"GovernorBravo::initialize:number of timelocks should match number of governance routes\"\n );\n require(\n proposalConfigs_.length == uint8(ProposalType.CRITICAL) + 1,\n \"GovernorBravo::initialize:number of proposal configs should match number of governance routes\"\n );\n\n xvsVault = XvsVaultInterface(xvsVault_);\n proposalMaxOperations = 10;\n guardian = guardian_;\n\n //Set parameters for each Governance Route\n uint256 arrLength = proposalConfigs_.length;\n for (uint256 i; i < arrLength; ++i) {\n require(\n proposalConfigs_[i].votingPeriod >= MIN_VOTING_PERIOD,\n \"GovernorBravo::initialize: invalid min voting period\"\n );\n require(\n proposalConfigs_[i].votingPeriod <= MAX_VOTING_PERIOD,\n \"GovernorBravo::initialize: invalid max voting period\"\n );\n require(\n proposalConfigs_[i].votingDelay >= MIN_VOTING_DELAY,\n \"GovernorBravo::initialize: invalid min voting delay\"\n );\n require(\n proposalConfigs_[i].votingDelay <= MAX_VOTING_DELAY,\n \"GovernorBravo::initialize: invalid max voting delay\"\n );\n require(\n proposalConfigs_[i].proposalThreshold >= MIN_PROPOSAL_THRESHOLD,\n \"GovernorBravo::initialize: invalid min proposal threshold\"\n );\n require(\n proposalConfigs_[i].proposalThreshold <= MAX_PROPOSAL_THRESHOLD,\n \"GovernorBravo::initialize: invalid max proposal threshold\"\n );\n require(address(timelocks[i]) != address(0), \"GovernorBravo::initialize:invalid timelock address\");\n\n proposalConfigs[i] = proposalConfigs_[i];\n proposalTimelocks[i] = timelocks[i];\n }\n }\n\n /**\n * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold.\n * targets, values, signatures, and calldatas must be of equal length\n * @dev NOTE: Proposals with duplicate set of actions can not be queued for execution. If the proposals consists\n * of duplicate actions, it's recommended to split those actions into separate proposals\n * @param targets Target addresses for proposal calls\n * @param values BNB values for proposal calls\n * @param signatures Function signatures for proposal calls\n * @param calldatas Calldatas for proposal calls\n * @param description String description of the proposal\n * @param proposalType the type of the proposal (e.g NORMAL, FASTTRACK, CRITICAL)\n * @return Proposal id of new proposal\n */\n function propose(\n address[] memory targets,\n uint[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n ProposalType proposalType\n ) public returns (uint) {\n // Reject proposals before initiating as Governor\n require(initialProposalId != 0, \"GovernorBravo::propose: Governor Bravo not active\");\n require(\n xvsVault.getPriorVotes(msg.sender, sub256(block.number, 1)) >=\n proposalConfigs[uint8(proposalType)].proposalThreshold,\n \"GovernorBravo::propose: proposer votes below proposal threshold\"\n );\n require(\n targets.length == values.length &&\n targets.length == signatures.length &&\n targets.length == calldatas.length,\n \"GovernorBravo::propose: proposal function information arity mismatch\"\n );\n require(targets.length != 0, \"GovernorBravo::propose: must provide actions\");\n require(targets.length <= proposalMaxOperations, \"GovernorBravo::propose: too many actions\");\n\n uint latestProposalId = latestProposalIds[msg.sender];\n if (latestProposalId != 0) {\n ProposalState proposersLatestProposalState = state(latestProposalId);\n require(\n proposersLatestProposalState != ProposalState.Active,\n \"GovernorBravo::propose: one live proposal per proposer, found an already active proposal\"\n );\n require(\n proposersLatestProposalState != ProposalState.Pending,\n \"GovernorBravo::propose: one live proposal per proposer, found an already pending proposal\"\n );\n }\n\n uint startBlock = add256(block.number, proposalConfigs[uint8(proposalType)].votingDelay);\n uint endBlock = add256(startBlock, proposalConfigs[uint8(proposalType)].votingPeriod);\n\n proposalCount++;\n Proposal memory newProposal = Proposal({\n id: proposalCount,\n proposer: msg.sender,\n eta: 0,\n targets: targets,\n values: values,\n signatures: signatures,\n calldatas: calldatas,\n startBlock: startBlock,\n endBlock: endBlock,\n forVotes: 0,\n againstVotes: 0,\n abstainVotes: 0,\n canceled: false,\n executed: false,\n proposalType: uint8(proposalType)\n });\n\n proposals[newProposal.id] = newProposal;\n latestProposalIds[newProposal.proposer] = newProposal.id;\n\n emit ProposalCreated(\n newProposal.id,\n msg.sender,\n targets,\n values,\n signatures,\n calldatas,\n startBlock,\n endBlock,\n description,\n uint8(proposalType)\n );\n return newProposal.id;\n }\n\n /**\n * @notice Queues a proposal of state succeeded\n * @param proposalId The id of the proposal to queue\n */\n function queue(uint proposalId) external {\n require(\n state(proposalId) == ProposalState.Succeeded,\n \"GovernorBravo::queue: proposal can only be queued if it is succeeded\"\n );\n Proposal storage proposal = proposals[proposalId];\n uint eta = add256(block.timestamp, proposalTimelocks[uint8(proposal.proposalType)].delay());\n for (uint i; i < proposal.targets.length; ++i) {\n queueOrRevertInternal(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n eta,\n uint8(proposal.proposalType)\n );\n }\n proposal.eta = eta;\n emit ProposalQueued(proposalId, eta);\n }\n\n function queueOrRevertInternal(\n address target,\n uint value,\n string memory signature,\n bytes memory data,\n uint eta,\n uint8 proposalType\n ) internal {\n require(\n !proposalTimelocks[proposalType].queuedTransactions(\n keccak256(abi.encode(target, value, signature, data, eta))\n ),\n \"GovernorBravo::queueOrRevertInternal: identical proposal action already queued at eta\"\n );\n proposalTimelocks[proposalType].queueTransaction(target, value, signature, data, eta);\n }\n\n /**\n * @notice Executes a queued proposal if eta has passed\n * @param proposalId The id of the proposal to execute\n */\n function execute(uint proposalId) external {\n require(\n state(proposalId) == ProposalState.Queued,\n \"GovernorBravo::execute: proposal can only be executed if it is queued\"\n );\n Proposal storage proposal = proposals[proposalId];\n proposal.executed = true;\n for (uint i; i < proposal.targets.length; ++i) {\n proposalTimelocks[uint8(proposal.proposalType)].executeTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n emit ProposalExecuted(proposalId);\n }\n\n /**\n * @notice Cancels a proposal only if sender is the proposer, or proposer delegates dropped below proposal threshold\n * @param proposalId The id of the proposal to cancel\n */\n function cancel(uint proposalId) external {\n require(state(proposalId) != ProposalState.Executed, \"GovernorBravo::cancel: cannot cancel executed proposal\");\n\n Proposal storage proposal = proposals[proposalId];\n require(\n msg.sender == guardian ||\n msg.sender == proposal.proposer ||\n xvsVault.getPriorVotes(proposal.proposer, sub256(block.number, 1)) <\n proposalConfigs[proposal.proposalType].proposalThreshold,\n \"GovernorBravo::cancel: proposer above threshold\"\n );\n\n proposal.canceled = true;\n for (uint i = 0; i < proposal.targets.length; i++) {\n proposalTimelocks[proposal.proposalType].cancelTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n\n emit ProposalCanceled(proposalId);\n }\n\n /**\n * @notice Gets actions of a proposal\n * @param proposalId the id of the proposal\n * @return targets, values, signatures, and calldatas of the proposal actions\n */\n function getActions(\n uint proposalId\n )\n external\n view\n returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas)\n {\n Proposal storage p = proposals[proposalId];\n return (p.targets, p.values, p.signatures, p.calldatas);\n }\n\n /**\n * @notice Gets the receipt for a voter on a given proposal\n * @param proposalId the id of proposal\n * @param voter The address of the voter\n * @return The voting receipt\n */\n function getReceipt(uint proposalId, address voter) external view returns (Receipt memory) {\n return proposals[proposalId].receipts[voter];\n }\n\n /**\n * @notice Gets the state of a proposal\n * @param proposalId The id of the proposal\n * @return Proposal state\n */\n function state(uint proposalId) public view returns (ProposalState) {\n require(\n proposalCount >= proposalId && proposalId > initialProposalId,\n \"GovernorBravo::state: invalid proposal id\"\n );\n Proposal storage proposal = proposals[proposalId];\n if (proposal.canceled) {\n return ProposalState.Canceled;\n } else if (block.number <= proposal.startBlock) {\n return ProposalState.Pending;\n } else if (block.number <= proposal.endBlock) {\n return ProposalState.Active;\n } else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes) {\n return ProposalState.Defeated;\n } else if (proposal.eta == 0) {\n return ProposalState.Succeeded;\n } else if (proposal.executed) {\n return ProposalState.Executed;\n } else if (\n block.timestamp >= add256(proposal.eta, proposalTimelocks[uint8(proposal.proposalType)].GRACE_PERIOD())\n ) {\n return ProposalState.Expired;\n } else {\n return ProposalState.Queued;\n }\n }\n\n /**\n * @notice Cast a vote for a proposal\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n */\n function castVote(uint proposalId, uint8 support) external {\n emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), \"\");\n }\n\n /**\n * @notice Cast a vote for a proposal with a reason\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param reason The reason given for the vote by the voter\n */\n function castVoteWithReason(uint proposalId, uint8 support, string calldata reason) external {\n emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), reason);\n }\n\n /**\n * @notice Cast a vote for a proposal by signature\n * @dev External function that accepts EIP-712 signatures for voting on proposals.\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param v recovery id of ECDSA signature\n * @param r part of the ECDSA sig output\n * @param s part of the ECDSA sig output\n */\n function castVoteBySig(uint proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s) external {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"GovernorBravo::castVoteBySig: invalid signature\");\n emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), \"\");\n }\n\n /**\n * @notice Internal function that caries out voting logic\n * @param voter The voter that is casting their vote\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @return The number of votes cast\n */\n function castVoteInternal(address voter, uint proposalId, uint8 support) internal returns (uint96) {\n require(state(proposalId) == ProposalState.Active, \"GovernorBravo::castVoteInternal: voting is closed\");\n require(support <= 2, \"GovernorBravo::castVoteInternal: invalid vote type\");\n Proposal storage proposal = proposals[proposalId];\n Receipt storage receipt = proposal.receipts[voter];\n require(receipt.hasVoted == false, \"GovernorBravo::castVoteInternal: voter already voted\");\n uint96 votes = xvsVault.getPriorVotes(voter, proposal.startBlock);\n\n if (support == 0) {\n proposal.againstVotes = add256(proposal.againstVotes, votes);\n } else if (support == 1) {\n proposal.forVotes = add256(proposal.forVotes, votes);\n } else if (support == 2) {\n proposal.abstainVotes = add256(proposal.abstainVotes, votes);\n }\n\n receipt.hasVoted = true;\n receipt.support = support;\n receipt.votes = votes;\n\n return votes;\n }\n\n /**\n * @notice Sets the new governance guardian\n * @param newGuardian the address of the new guardian\n */\n function _setGuardian(address newGuardian) external {\n require(msg.sender == guardian || msg.sender == admin, \"GovernorBravo::_setGuardian: admin or guardian only\");\n require(newGuardian != address(0), \"GovernorBravo::_setGuardian: cannot live without a guardian\");\n address oldGuardian = guardian;\n guardian = newGuardian;\n\n emit NewGuardian(oldGuardian, newGuardian);\n }\n\n /**\n * @notice Initiate the GovernorBravo contract\n * @dev Admin only. Sets initial proposal id which initiates the contract, ensuring a continuous proposal id count\n * @param governorAlpha The address for the Governor to continue the proposal id count from\n */\n function _initiate(address governorAlpha) external {\n require(msg.sender == admin, \"GovernorBravo::_initiate: admin only\");\n require(initialProposalId == 0, \"GovernorBravo::_initiate: can only initiate once\");\n proposalCount = GovernorAlphaInterface(governorAlpha).proposalCount();\n initialProposalId = proposalCount;\n for (uint256 i; i < uint8(ProposalType.CRITICAL) + 1; ++i) {\n proposalTimelocks[i].acceptAdmin();\n }\n }\n\n /**\n * @notice Set max proposal operations\n * @dev Admin only.\n * @param proposalMaxOperations_ Max proposal operations\n */\n function _setProposalMaxOperations(uint proposalMaxOperations_) external {\n require(msg.sender == admin, \"GovernorBravo::_setProposalMaxOperations: admin only\");\n uint oldProposalMaxOperations = proposalMaxOperations;\n proposalMaxOperations = proposalMaxOperations_;\n\n emit ProposalMaxOperationsUpdated(oldProposalMaxOperations, proposalMaxOperations_);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) external {\n // Check caller = admin\n require(msg.sender == admin, \"GovernorBravo:_setPendingAdmin: admin only\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n */\n function _acceptAdmin() external {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n require(\n msg.sender == pendingAdmin && msg.sender != address(0),\n \"GovernorBravo:_acceptAdmin: pending admin only\"\n );\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n function add256(uint256 a, uint256 b) internal pure returns (uint) {\n uint c = a + b;\n require(c >= a, \"addition overflow\");\n return c;\n }\n\n function sub256(uint256 a, uint256 b) internal pure returns (uint) {\n require(b <= a, \"subtraction underflow\");\n return a - b;\n }\n\n function getChainIdInternal() internal pure returns (uint) {\n uint chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoInterfaces.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\n/**\n * @title GovernorBravoEvents\n * @author Venus\n * @notice Set of events emitted by the GovernorBravo contracts.\n */\ncontract GovernorBravoEvents {\n /// @notice An event emitted when a new proposal is created\n event ProposalCreated(\n uint id,\n address proposer,\n address[] targets,\n uint[] values,\n string[] signatures,\n bytes[] calldatas,\n uint startBlock,\n uint endBlock,\n string description,\n uint8 proposalType\n );\n\n /// @notice An event emitted when a vote has been cast on a proposal\n /// @param voter The address which casted a vote\n /// @param proposalId The proposal id which was voted on\n /// @param support Support value for the vote. 0=against, 1=for, 2=abstain\n /// @param votes Number of votes which were cast by the voter\n /// @param reason The reason given for the vote by the voter\n event VoteCast(address indexed voter, uint proposalId, uint8 support, uint votes, string reason);\n\n /// @notice An event emitted when a proposal has been canceled\n event ProposalCanceled(uint id);\n\n /// @notice An event emitted when a proposal has been queued in the Timelock\n event ProposalQueued(uint id, uint eta);\n\n /// @notice An event emitted when a proposal has been executed in the Timelock\n event ProposalExecuted(uint id);\n\n /// @notice An event emitted when the voting delay is set\n event VotingDelaySet(uint oldVotingDelay, uint newVotingDelay);\n\n /// @notice An event emitted when the voting period is set\n event VotingPeriodSet(uint oldVotingPeriod, uint newVotingPeriod);\n\n /// @notice Emitted when implementation is changed\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /// @notice Emitted when proposal threshold is set\n event ProposalThresholdSet(uint oldProposalThreshold, uint newProposalThreshold);\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Emitted when pendingAdmin is accepted, which means admin is updated\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /// @notice Emitted when the new guardian address is set\n event NewGuardian(address oldGuardian, address newGuardian);\n\n /// @notice Emitted when the maximum number of operations in one proposal is updated\n event ProposalMaxOperationsUpdated(uint oldMaxOperations, uint newMaxOperations);\n}\n\n/**\n * @title GovernorBravoDelegatorStorage\n * @author Venus\n * @notice Storage layout of the `GovernorBravoDelegator` contract\n */\ncontract GovernorBravoDelegatorStorage {\n /// @notice Administrator for this contract\n address public admin;\n\n /// @notice Pending administrator for this contract\n address public pendingAdmin;\n\n /// @notice Active brains of Governor\n address public implementation;\n}\n\n/**\n * @title GovernorBravoDelegateStorageV1\n * @dev For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a new\n * contract which implements GovernorBravoDelegateStorageV1 and following the naming convention\n * GovernorBravoDelegateStorageVX.\n */\ncontract GovernorBravoDelegateStorageV1 is GovernorBravoDelegatorStorage {\n /// @notice DEPRECATED The delay before voting on a proposal may take place, once proposed, in blocks\n uint public votingDelay;\n\n /// @notice DEPRECATED The duration of voting on a proposal, in blocks\n uint public votingPeriod;\n\n /// @notice DEPRECATED The number of votes required in order for a voter to become a proposer\n uint public proposalThreshold;\n\n /// @notice Initial proposal id set at become\n uint public initialProposalId;\n\n /// @notice The total number of proposals\n uint public proposalCount;\n\n /// @notice The address of the Venus Protocol Timelock\n TimelockInterface public timelock;\n\n /// @notice The address of the Venus governance token\n XvsVaultInterface public xvsVault;\n\n /// @notice The official record of all proposals ever proposed\n mapping(uint => Proposal) public proposals;\n\n /// @notice The latest proposal for each proposer\n mapping(address => uint) public latestProposalIds;\n\n struct Proposal {\n /// @notice Unique id for looking up a proposal\n uint id;\n /// @notice Creator of the proposal\n address proposer;\n /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds\n uint eta;\n /// @notice the ordered list of target addresses for calls to be made\n address[] targets;\n /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made\n uint[] values;\n /// @notice The ordered list of function signatures to be called\n string[] signatures;\n /// @notice The ordered list of calldata to be passed to each call\n bytes[] calldatas;\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\n uint startBlock;\n /// @notice The block at which voting ends: votes must be cast prior to this block\n uint endBlock;\n /// @notice Current number of votes in favor of this proposal\n uint forVotes;\n /// @notice Current number of votes in opposition to this proposal\n uint againstVotes;\n /// @notice Current number of votes for abstaining for this proposal\n uint abstainVotes;\n /// @notice Flag marking whether the proposal has been canceled\n bool canceled;\n /// @notice Flag marking whether the proposal has been executed\n bool executed;\n /// @notice Receipts of ballots for the entire set of voters\n mapping(address => Receipt) receipts;\n /// @notice The type of the proposal\n uint8 proposalType;\n }\n\n /// @notice Ballot receipt record for a voter\n struct Receipt {\n /// @notice Whether or not a vote has been cast\n bool hasVoted;\n /// @notice Whether or not the voter supports the proposal or abstains\n uint8 support;\n /// @notice The number of votes the voter had, which were cast\n uint96 votes;\n }\n\n /// @notice Possible states that a proposal may be in\n enum ProposalState {\n Pending,\n Active,\n Canceled,\n Defeated,\n Succeeded,\n Queued,\n Expired,\n Executed\n }\n\n /// @notice The maximum number of actions that can be included in a proposal\n uint public proposalMaxOperations;\n\n /// @notice A privileged role that can cancel any proposal\n address public guardian;\n}\n\n/**\n * @title GovernorBravoDelegateStorageV2\n * @dev For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a new\n * contract which implements GovernorBravoDelegateStorageV2 and following the naming convention\n * GovernorBravoDelegateStorageVX.\n */\ncontract GovernorBravoDelegateStorageV2 is GovernorBravoDelegateStorageV1 {\n enum ProposalType {\n NORMAL,\n FASTTRACK,\n CRITICAL\n }\n\n struct ProposalConfig {\n /// @notice The delay before voting on a proposal may take place, once proposed, in blocks\n uint256 votingDelay;\n /// @notice The duration of voting on a proposal, in blocks\n uint256 votingPeriod;\n /// @notice The number of votes required in order for a voter to become a proposer\n uint256 proposalThreshold;\n }\n\n /// @notice mapping containing configuration for each proposal type\n mapping(uint => ProposalConfig) public proposalConfigs;\n\n /// @notice mapping containing Timelock addresses for each proposal type\n mapping(uint => TimelockInterface) public proposalTimelocks;\n}\n\n/**\n * @title TimelockInterface\n * @author Venus\n * @notice Interface implemented by the Timelock contract.\n */\ninterface TimelockInterface {\n function delay() external view returns (uint);\n\n function GRACE_PERIOD() external view returns (uint);\n\n function acceptAdmin() external;\n\n function queuedTransactions(bytes32 hash) external view returns (bool);\n\n function queueTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external returns (bytes32);\n\n function cancelTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external;\n\n function executeTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external payable returns (bytes memory);\n}\n\ninterface XvsVaultInterface {\n function getPriorVotes(address account, uint blockNumber) external view returns (uint96);\n}\n\ninterface GovernorAlphaInterface {\n /// @notice The total number of proposals\n function proposalCount() external returns (uint);\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\n/**\n * @title IAccessControlManagerV5\n * @author Venus\n * @notice Interface implemented by the `AccessControlManagerV5` contract.\n */\ninterface IAccessControlManagerV5 {\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 */\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 /**\n * @notice Gives a function call permission to one single account\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * \t\tMay emit a {RoleGranted} event.\n * @param contractAddress address of contract for which call permissions will be granted\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n */\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n /**\n * @notice Revokes an account's permission to a particular function call\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * \t\tMay emit a {RoleRevoked} event.\n * @param contractAddress address of contract for which call permissions will be revoked\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n */\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) external;\n\n /**\n * @notice Verifies if the given account can call a praticular contract's function\n * @dev Since the contract is calling itself this function, we can get contracts address with msg.sender\n * @param account address (eoa or contract) for which call permissions will be checked\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n * @return false if the user account cannot call the particular contract function\n *\n */\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) external view returns (bool);\n}\n" + }, + "@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\ncontract TimeManagerV5 {\n /// @dev The approximate number of seconds per year\n uint256 public constant SECONDS_PER_YEAR = 31_536_000;\n\n /// @notice Number of blocks per year or seconds per year\n uint256 public blocksOrSecondsPerYear;\n\n /// @dev Sets true when block timestamp is used\n bool public isTimeBased;\n\n /// @dev Sets true when contract is initialized\n bool private isInitialized;\n\n /// @notice Deprecated slot for _getCurrentSlot function pointer\n bytes8 private __deprecatedSlot1;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[48] private __gap;\n\n /**\n * @dev Function to simply retrieve block number or block timestamp\n * @return Current block number or block timestamp\n */\n function getBlockNumberOrTimestamp() public view returns (uint256) {\n return isTimeBased ? _getBlockTimestamp() : _getBlockNumber();\n }\n\n /**\n * @dev Initializes the contract to use either blocks or seconds\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\n * @param blocksPerYear_ The number of blocks per year\n */\n function _initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) internal {\n if (isInitialized) revert(\"Already initialized TimeManager\");\n\n if (!timeBased_ && blocksPerYear_ == 0) {\n revert(\"Invalid blocks per year\");\n }\n if (timeBased_ && blocksPerYear_ != 0) {\n revert(\"Invalid time based configuration\");\n }\n\n isTimeBased = timeBased_;\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\n isInitialized = true;\n }\n\n /**\n * @dev Returns the current timestamp in seconds\n * @return The current timestamp\n */\n function _getBlockTimestamp() private view returns (uint256) {\n return block.timestamp;\n }\n\n /**\n * @dev Returns the current block number\n * @return The current block number\n */\n function _getBlockNumber() private view returns (uint256) {\n return block.number;\n }\n}\n" + }, + "contracts/Comptroller/ComptrollerInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerTypes } from \"./ComptrollerStorage.sol\";\n\ncontract ComptrollerInterface {\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n bool public constant isComptroller = true;\n\n /*** Assets You Are In ***/\n\n function enterMarkets(address[] calldata vTokens) external returns (uint[] memory);\n\n function exitMarket(address vToken) external returns (uint);\n\n /*** Policy Hooks ***/\n\n function mintAllowed(address vToken, address minter, uint mintAmount) external returns (uint);\n\n function mintVerify(address vToken, address minter, uint mintAmount, uint mintTokens) external;\n\n function redeemAllowed(address vToken, address redeemer, uint redeemTokens) external returns (uint);\n\n function redeemVerify(address vToken, address redeemer, uint redeemAmount, uint redeemTokens) external;\n\n function borrowAllowed(address vToken, address borrower, uint borrowAmount) external returns (uint);\n\n function borrowVerify(address vToken, address borrower, uint borrowAmount) external;\n\n function repayBorrowAllowed(\n address vToken,\n address payer,\n address borrower,\n uint repayAmount\n ) external returns (uint);\n\n function repayBorrowVerify(\n address vToken,\n address payer,\n address borrower,\n uint repayAmount,\n uint borrowerIndex\n ) external;\n\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint repayAmount\n ) external returns (uint);\n\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint repayAmount,\n uint seizeTokens\n ) external;\n\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) external returns (uint);\n\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) external;\n\n function transferAllowed(address vToken, address src, address dst, uint transferTokens) external returns (uint);\n\n function transferVerify(address vToken, address src, address dst, uint transferTokens) external;\n\n /*** Liquidity/Liquidation Calculations ***/\n\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint repayAmount\n ) external view returns (uint, uint);\n\n function setMintedVAIOf(address owner, uint amount) external returns (uint);\n\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint repayAmount\n ) external view returns (uint, uint);\n\n function getXVSAddress() public view returns (address);\n\n function markets(address) external view returns (bool, uint);\n\n function oracle() external view returns (PriceOracle);\n\n function getAccountLiquidity(address) external view returns (uint, uint, uint);\n\n function getAssetsIn(address) external view returns (VToken[] memory);\n\n function claimVenus(address) external;\n\n function venusAccrued(address) external view returns (uint);\n\n function venusSupplySpeeds(address) external view returns (uint);\n\n function venusBorrowSpeeds(address) external view returns (uint);\n\n function getAllMarkets() external view returns (VToken[] memory);\n\n function venusSupplierIndex(address, address) external view returns (uint);\n\n function venusInitialIndex() external view returns (uint224);\n\n function venusBorrowerIndex(address, address) external view returns (uint);\n\n function venusBorrowState(address) external view returns (uint224, uint32);\n\n function venusSupplyState(address) external view returns (uint224, uint32);\n\n function approvedDelegates(address borrower, address delegate) external view returns (bool);\n\n function vaiController() external view returns (VAIControllerInterface);\n\n function liquidationIncentiveMantissa() external view returns (uint);\n\n function protocolPaused() external view returns (bool);\n\n function actionPaused(address market, ComptrollerTypes.Action action) public view returns (bool);\n\n function mintedVAIs(address user) external view returns (uint);\n\n function vaiMintRate() external view returns (uint);\n}\n\ninterface IVAIVault {\n function updatePendingRewards() external;\n}\n\ninterface IComptroller {\n function liquidationIncentiveMantissa() external view returns (uint);\n\n /*** Treasury Data ***/\n function treasuryAddress() external view returns (address);\n\n function treasuryPercent() external view returns (uint);\n}\n" + }, + "contracts/Comptroller/ComptrollerLensInterface.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\ninterface ComptrollerLensInterface {\n function liquidateCalculateSeizeTokens(\n address comptroller,\n address vTokenBorrowed,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint);\n\n function liquidateVAICalculateSeizeTokens(\n address comptroller,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint);\n\n function getHypotheticalAccountLiquidity(\n address comptroller,\n address account,\n VToken vTokenModify,\n uint redeemTokens,\n uint borrowAmount\n ) external view returns (uint, uint, uint);\n}\n" + }, + "contracts/Comptroller/ComptrollerStorage.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity ^0.5.16;\n\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { PriceOracle } from \"../Oracle/PriceOracle.sol\";\nimport { VAIControllerInterface } from \"../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerLensInterface } from \"./ComptrollerLensInterface.sol\";\nimport { IPrime } from \"../Tokens/Prime/IPrime.sol\";\n\ninterface ComptrollerTypes {\n enum Action {\n MINT,\n REDEEM,\n BORROW,\n REPAY,\n SEIZE,\n LIQUIDATE,\n TRANSFER,\n ENTER_MARKET,\n EXIT_MARKET\n }\n}\n\ncontract UnitrollerAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of Unitroller\n */\n address public comptrollerImplementation;\n\n /**\n * @notice Pending brains of Unitroller\n */\n address public pendingComptrollerImplementation;\n}\n\ncontract ComptrollerV1Storage is ComptrollerTypes, UnitrollerAdminStorage {\n /**\n * @notice Oracle which gives the price of any given asset\n */\n PriceOracle public oracle;\n\n /**\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\n */\n uint256 public closeFactorMantissa;\n\n /**\n * @notice Multiplier representing the discount on collateral that a liquidator receives\n */\n uint256 public liquidationIncentiveMantissa;\n\n /**\n * @notice Max number of assets a single account can participate in (borrow or use as collateral)\n */\n uint256 public maxAssets;\n\n /**\n * @notice Per-account mapping of \"assets you are in\", capped by maxAssets\n */\n mapping(address => VToken[]) public accountAssets;\n\n struct Market {\n /// @notice Whether or not this market is listed\n bool isListed;\n /**\n * @notice Multiplier representing the most one can borrow against their collateral in this market.\n * For instance, 0.9 to allow borrowing 90% of collateral value.\n * Must be between 0 and 1, and stored as a mantissa.\n */\n uint256 collateralFactorMantissa;\n /// @notice Per-market mapping of \"accounts in this asset\"\n mapping(address => bool) accountMembership;\n /// @notice Whether or not this market receives XVS\n bool isVenus;\n }\n\n /**\n * @notice Official mapping of vTokens -> Market metadata\n * @dev Used e.g. to determine if a market is supported\n */\n mapping(address => Market) public markets;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n */\n address public pauseGuardian;\n\n /// @notice Whether minting is paused (deprecated, superseded by actionPaused)\n bool private _mintGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool private _borrowGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool internal transferGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool internal seizeGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n mapping(address => bool) internal mintGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n mapping(address => bool) internal borrowGuardianPaused;\n\n struct VenusMarketState {\n /// @notice The market's last updated venusBorrowIndex or venusSupplyIndex\n uint224 index;\n /// @notice The block number the index was last updated at\n uint32 block;\n }\n\n /// @notice A list of all markets\n VToken[] public allMarkets;\n\n /// @notice The rate at which the flywheel distributes XVS, per block\n uint256 internal venusRate;\n\n /// @notice The portion of venusRate that each market currently receives\n mapping(address => uint256) internal venusSpeeds;\n\n /// @notice The Venus market supply state for each market\n mapping(address => VenusMarketState) public venusSupplyState;\n\n /// @notice The Venus market borrow state for each market\n mapping(address => VenusMarketState) public venusBorrowState;\n\n /// @notice The Venus supply index for each market for each supplier as of the last time they accrued XVS\n mapping(address => mapping(address => uint256)) public venusSupplierIndex;\n\n /// @notice The Venus borrow index for each market for each borrower as of the last time they accrued XVS\n mapping(address => mapping(address => uint256)) public venusBorrowerIndex;\n\n /// @notice The XVS accrued but not yet transferred to each user\n mapping(address => uint256) public venusAccrued;\n\n /// @notice The Address of VAIController\n VAIControllerInterface public vaiController;\n\n /// @notice The minted VAI amount to each user\n mapping(address => uint256) public mintedVAIs;\n\n /// @notice VAI Mint Rate as a percentage\n uint256 public vaiMintRate;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n */\n bool public mintVAIGuardianPaused;\n bool public repayVAIGuardianPaused;\n\n /**\n * @notice Pause/Unpause whole protocol actions\n */\n bool public protocolPaused;\n\n /// @notice The rate at which the flywheel distributes XVS to VAI Minters, per block (deprecated)\n uint256 private venusVAIRate;\n}\n\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\n /// @notice The rate at which the flywheel distributes XVS to VAI Vault, per block\n uint256 public venusVAIVaultRate;\n\n // address of VAI Vault\n address public vaiVaultAddress;\n\n // start block of release to VAI Vault\n uint256 public releaseStartBlock;\n\n // minimum release amount to VAI Vault\n uint256 public minReleaseAmount;\n}\n\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\n address public borrowCapGuardian;\n\n /// @notice Borrow caps enforced by borrowAllowed for each vToken address.\n mapping(address => uint256) public borrowCaps;\n}\n\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\n /// @notice Treasury Guardian address\n address public treasuryGuardian;\n\n /// @notice Treasury address\n address public treasuryAddress;\n\n /// @notice Fee percent of accrued interest with decimal 18\n uint256 public treasuryPercent;\n}\n\ncontract ComptrollerV5Storage is ComptrollerV4Storage {\n /// @notice The portion of XVS that each contributor receives per block (deprecated)\n mapping(address => uint256) private venusContributorSpeeds;\n\n /// @notice Last block at which a contributor's XVS rewards have been allocated (deprecated)\n mapping(address => uint256) private lastContributorBlock;\n}\n\ncontract ComptrollerV6Storage is ComptrollerV5Storage {\n address public liquidatorContract;\n}\n\ncontract ComptrollerV7Storage is ComptrollerV6Storage {\n ComptrollerLensInterface public comptrollerLens;\n}\n\ncontract ComptrollerV8Storage is ComptrollerV7Storage {\n /// @notice Supply caps enforced by mintAllowed for each vToken address. Defaults to zero which corresponds to minting notAllowed\n mapping(address => uint256) public supplyCaps;\n}\n\ncontract ComptrollerV9Storage is ComptrollerV8Storage {\n /// @notice AccessControlManager address\n address internal accessControl;\n\n /// @notice True if a certain action is paused on a certain market\n mapping(address => mapping(uint256 => bool)) internal _actionPaused;\n}\n\ncontract ComptrollerV10Storage is ComptrollerV9Storage {\n /// @notice The rate at which venus is distributed to the corresponding borrow market (per block)\n mapping(address => uint256) public venusBorrowSpeeds;\n\n /// @notice The rate at which venus is distributed to the corresponding supply market (per block)\n mapping(address => uint256) public venusSupplySpeeds;\n}\n\ncontract ComptrollerV11Storage is ComptrollerV10Storage {\n /// @notice Whether the delegate is allowed to borrow or redeem on behalf of the user\n //mapping(address user => mapping (address delegate => bool approved)) public approvedDelegates;\n mapping(address => mapping(address => bool)) public approvedDelegates;\n}\n\ncontract ComptrollerV12Storage is ComptrollerV11Storage {\n /// @notice Whether forced liquidation is enabled for all users borrowing in a certain market\n mapping(address => bool) public isForcedLiquidationEnabled;\n}\n\ncontract ComptrollerV13Storage is ComptrollerV12Storage {\n struct FacetAddressAndPosition {\n address facetAddress;\n uint96 functionSelectorPosition; // position in _facetFunctionSelectors.functionSelectors array\n }\n\n struct FacetFunctionSelectors {\n bytes4[] functionSelectors;\n uint256 facetAddressPosition; // position of facetAddress in _facetAddresses array\n }\n\n mapping(bytes4 => FacetAddressAndPosition) internal _selectorToFacetAndPosition;\n // maps facet addresses to function selectors\n mapping(address => FacetFunctionSelectors) internal _facetFunctionSelectors;\n // facet addresses\n address[] internal _facetAddresses;\n}\n\ncontract ComptrollerV14Storage is ComptrollerV13Storage {\n /// @notice Prime token address\n IPrime public prime;\n}\n\ncontract ComptrollerV15Storage is ComptrollerV14Storage {\n /// @notice Whether forced liquidation is enabled for the borrows of a user in a market\n mapping(address /* user */ => mapping(address /* market */ => bool)) public isForcedLiquidationEnabledForUser;\n}\n\ncontract ComptrollerV16Storage is ComptrollerV15Storage {\n /// @notice The XVS token contract address\n address internal xvs;\n\n /// @notice The XVS vToken contract address\n address internal xvsVToken;\n}\n" + }, + "contracts/Comptroller/Diamond/Diamond.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\nimport { IDiamondCut } from \"./interfaces/IDiamondCut.sol\";\nimport { Unitroller, ComptrollerV16Storage } from \"../Unitroller.sol\";\n\n/**\n * @title Diamond\n * @author Venus\n * @notice This contract contains functions related to facets\n */\ncontract Diamond is IDiamondCut, ComptrollerV16Storage {\n /// @notice Emitted when functions are added, replaced or removed to facets\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut);\n\n struct Facet {\n address facetAddress;\n bytes4[] functionSelectors;\n }\n\n /**\n * @notice Call _acceptImplementation to accept the diamond proxy as new implementaion\n * @param unitroller Address of the unitroller\n */\n function _become(Unitroller unitroller) public {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can\");\n require(unitroller._acceptImplementation() == 0, \"not authorized\");\n }\n\n /**\n * @notice To add function selectors to the facet's mapping\n * @dev Allows the contract admin to add function selectors\n * @param diamondCut_ IDiamondCut contains facets address, action and function selectors\n */\n function diamondCut(IDiamondCut.FacetCut[] memory diamondCut_) public {\n require(msg.sender == admin, \"only unitroller admin can\");\n libDiamondCut(diamondCut_);\n }\n\n /**\n * @notice Get all function selectors mapped to the facet address\n * @param facet Address of the facet\n * @return selectors Array of function selectors\n */\n function facetFunctionSelectors(address facet) external view returns (bytes4[] memory) {\n return _facetFunctionSelectors[facet].functionSelectors;\n }\n\n /**\n * @notice Get facet position in the _facetFunctionSelectors through facet address\n * @param facet Address of the facet\n * @return Position of the facet\n */\n function facetPosition(address facet) external view returns (uint256) {\n return _facetFunctionSelectors[facet].facetAddressPosition;\n }\n\n /**\n * @notice Get all facet addresses\n * @return facetAddresses Array of facet addresses\n */\n function facetAddresses() external view returns (address[] memory) {\n return _facetAddresses;\n }\n\n /**\n * @notice Get facet address and position through function selector\n * @param functionSelector function selector\n * @return FacetAddressAndPosition facet address and position\n */\n function facetAddress(\n bytes4 functionSelector\n ) external view returns (ComptrollerV16Storage.FacetAddressAndPosition memory) {\n return _selectorToFacetAndPosition[functionSelector];\n }\n\n /**\n * @notice Get all facets address and their function selector\n * @return facets_ Array of Facet\n */\n function facets() external view returns (Facet[] memory) {\n uint256 facetsLength = _facetAddresses.length;\n Facet[] memory facets_ = new Facet[](facetsLength);\n for (uint256 i; i < facetsLength; ++i) {\n address facet = _facetAddresses[i];\n facets_[i].facetAddress = facet;\n facets_[i].functionSelectors = _facetFunctionSelectors[facet].functionSelectors;\n }\n return facets_;\n }\n\n /**\n * @notice To add function selectors to the facets' mapping\n * @param diamondCut_ IDiamondCut contains facets address, action and function selectors\n */\n function libDiamondCut(IDiamondCut.FacetCut[] memory diamondCut_) internal {\n uint256 diamondCutLength = diamondCut_.length;\n for (uint256 facetIndex; facetIndex < diamondCutLength; ++facetIndex) {\n IDiamondCut.FacetCutAction action = diamondCut_[facetIndex].action;\n if (action == IDiamondCut.FacetCutAction.Add) {\n addFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else if (action == IDiamondCut.FacetCutAction.Replace) {\n replaceFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else if (action == IDiamondCut.FacetCutAction.Remove) {\n removeFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else {\n revert(\"LibDiamondCut: Incorrect FacetCutAction\");\n }\n }\n emit DiamondCut(diamondCut_);\n }\n\n /**\n * @notice Add function selectors to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to add in the mapping\n */\n function addFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n require(functionSelectors.length != 0, \"LibDiamondCut: No selectors in facet to cut\");\n require(facetAddress != address(0), \"LibDiamondCut: Add facet can't be address(0)\");\n uint96 selectorPosition = uint96(_facetFunctionSelectors[facetAddress].functionSelectors.length);\n // add new facet address if it does not exist\n if (selectorPosition == 0) {\n addFacet(facetAddress);\n }\n uint256 functionSelectorsLength = functionSelectors.length;\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n require(oldFacetAddress == address(0), \"LibDiamondCut: Can't add function that already exists\");\n addFunction(selector, selectorPosition, facetAddress);\n ++selectorPosition;\n }\n }\n\n /**\n * @notice Replace facet's address mapping for function selectors i.e selectors already associate to any other existing facet\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to replace in the mapping\n */\n function replaceFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n require(functionSelectors.length != 0, \"LibDiamondCut: No selectors in facet to cut\");\n require(facetAddress != address(0), \"LibDiamondCut: Add facet can't be address(0)\");\n uint96 selectorPosition = uint96(_facetFunctionSelectors[facetAddress].functionSelectors.length);\n // add new facet address if it does not exist\n if (selectorPosition == 0) {\n addFacet(facetAddress);\n }\n uint256 functionSelectorsLength = functionSelectors.length;\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n require(oldFacetAddress != facetAddress, \"LibDiamondCut: Can't replace function with same function\");\n removeFunction(oldFacetAddress, selector);\n addFunction(selector, selectorPosition, facetAddress);\n ++selectorPosition;\n }\n }\n\n /**\n * @notice Remove function selectors to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to remove in the mapping\n */\n function removeFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n uint256 functionSelectorsLength = functionSelectors.length;\n require(functionSelectorsLength != 0, \"LibDiamondCut: No selectors in facet to cut\");\n // if function does not exist then do nothing and revert\n require(facetAddress == address(0), \"LibDiamondCut: Remove facet address must be address(0)\");\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n removeFunction(oldFacetAddress, selector);\n }\n }\n\n /**\n * @notice Add new facet to the proxy\n * @param facetAddress Address of the facet\n */\n function addFacet(address facetAddress) internal {\n enforceHasContractCode(facetAddress, \"Diamond: New facet has no code\");\n _facetFunctionSelectors[facetAddress].facetAddressPosition = _facetAddresses.length;\n _facetAddresses.push(facetAddress);\n }\n\n /**\n * @notice Add function selector to the facet's address mapping\n * @param selector funciton selector need to be added\n * @param selectorPosition funciton selector position\n * @param facetAddress Address of the facet\n */\n function addFunction(bytes4 selector, uint96 selectorPosition, address facetAddress) internal {\n _selectorToFacetAndPosition[selector].functionSelectorPosition = selectorPosition;\n _facetFunctionSelectors[facetAddress].functionSelectors.push(selector);\n _selectorToFacetAndPosition[selector].facetAddress = facetAddress;\n }\n\n /**\n * @notice Remove function selector to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param selector function selectors need to remove in the mapping\n */\n function removeFunction(address facetAddress, bytes4 selector) internal {\n require(facetAddress != address(0), \"LibDiamondCut: Can't remove function that doesn't exist\");\n\n // replace selector with last selector, then delete last selector\n uint256 selectorPosition = _selectorToFacetAndPosition[selector].functionSelectorPosition;\n uint256 lastSelectorPosition = _facetFunctionSelectors[facetAddress].functionSelectors.length - 1;\n // if not the same then replace selector with lastSelector\n if (selectorPosition != lastSelectorPosition) {\n bytes4 lastSelector = _facetFunctionSelectors[facetAddress].functionSelectors[lastSelectorPosition];\n _facetFunctionSelectors[facetAddress].functionSelectors[selectorPosition] = lastSelector;\n _selectorToFacetAndPosition[lastSelector].functionSelectorPosition = uint96(selectorPosition);\n }\n // delete the last selector\n _facetFunctionSelectors[facetAddress].functionSelectors.pop();\n delete _selectorToFacetAndPosition[selector];\n\n // if no more selectors for facet address then delete the facet address\n if (lastSelectorPosition == 0) {\n // replace facet address with last facet address and delete last facet address\n uint256 lastFacetAddressPosition = _facetAddresses.length - 1;\n uint256 facetAddressPosition = _facetFunctionSelectors[facetAddress].facetAddressPosition;\n if (facetAddressPosition != lastFacetAddressPosition) {\n address lastFacetAddress = _facetAddresses[lastFacetAddressPosition];\n _facetAddresses[facetAddressPosition] = lastFacetAddress;\n _facetFunctionSelectors[lastFacetAddress].facetAddressPosition = facetAddressPosition;\n }\n _facetAddresses.pop();\n delete _facetFunctionSelectors[facetAddress];\n }\n }\n\n /**\n * @dev Ensure that the given address has contract code deployed\n * @param _contract The address to check for contract code\n * @param _errorMessage The error message to display if the contract code is not deployed\n */\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\n uint256 contractSize;\n assembly {\n contractSize := extcodesize(_contract)\n }\n require(contractSize != 0, _errorMessage);\n }\n\n // Find facet for function that is called and execute the\n // function if a facet is found and return any value.\n function() external payable {\n address facet = _selectorToFacetAndPosition[msg.sig].facetAddress;\n require(facet != address(0), \"Diamond: Function does not exist\");\n // Execute public function from facet using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the facet\n let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" + }, + "contracts/Comptroller/Diamond/DiamondConsolidated.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"./facets/MarketFacet.sol\";\nimport \"./facets/PolicyFacet.sol\";\nimport \"./facets/RewardFacet.sol\";\nimport \"./facets/SetterFacet.sol\";\nimport \"./Diamond.sol\";\n\n/**\n * @title DiamondConsolidated\n * @author Venus\n * @notice This contract contains the functions defined in the different facets of the Diamond, plus the getters to the public variables.\n * This contract cannot be deployed, due to its size. Its main purpose is to allow the easy generation of an ABI and the typechain to interact with the\n * Unitroller contract in a simple way\n */\ncontract DiamondConsolidated is Diamond, MarketFacet, PolicyFacet, RewardFacet, SetterFacet {}\n" + }, + "contracts/Comptroller/Diamond/facets/FacetBase.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken, ComptrollerErrorReporter, ExponentialNoError } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IVAIVault } from \"../../../Comptroller/ComptrollerInterface.sol\";\nimport { ComptrollerV16Storage } from \"../../../Comptroller/ComptrollerStorage.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\n\nimport { SafeBEP20, IBEP20 } from \"../../../Utils/SafeBEP20.sol\";\n\n/**\n * @title FacetBase\n * @author Venus\n * @notice This facet contract contains functions related to access and checks\n */\ncontract FacetBase is ComptrollerV16Storage, ExponentialNoError, ComptrollerErrorReporter {\n using SafeBEP20 for IBEP20;\n\n /// @notice The initial Venus index for a market\n uint224 public constant venusInitialIndex = 1e36;\n // closeFactorMantissa must be strictly greater than this value\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\n // closeFactorMantissa must not exceed this value\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\n // No collateralFactorMantissa may exceed this value\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\n\n /// @notice Emitted when an account enters a market\n event MarketEntered(VToken indexed vToken, address indexed account);\n\n /// @notice Emitted when XVS is distributed to VAI Vault\n event DistributedVAIVaultVenus(uint256 amount);\n\n /// @notice Reverts if the protocol is paused\n function checkProtocolPauseState() internal view {\n require(!protocolPaused, \"protocol is paused\");\n }\n\n /// @notice Reverts if a certain action is paused on a market\n function checkActionPauseState(address market, Action action) internal view {\n require(!actionPaused(market, action), \"action is paused\");\n }\n\n /// @notice Reverts if the caller is not admin\n function ensureAdmin() internal view {\n require(msg.sender == admin, \"only admin can\");\n }\n\n /// @notice Checks the passed address is nonzero\n function ensureNonzeroAddress(address someone) internal pure {\n require(someone != address(0), \"can't be zero address\");\n }\n\n /// @notice Reverts if the market is not listed\n function ensureListed(Market storage market) internal view {\n require(market.isListed, \"market not listed\");\n }\n\n /// @notice Reverts if the caller is neither admin nor the passed address\n function ensureAdminOr(address privilegedAddress) internal view {\n require(msg.sender == admin || msg.sender == privilegedAddress, \"access denied\");\n }\n\n /// @notice Checks the caller is allowed to call the specified fuction\n function ensureAllowed(string memory functionSig) internal view {\n require(IAccessControlManagerV5(accessControl).isAllowedToCall(msg.sender, functionSig), \"access denied\");\n }\n\n /**\n * @notice Checks if a certain action is paused on a market\n * @param action Action id\n * @param market vToken address\n */\n function actionPaused(address market, Action action) public view returns (bool) {\n return _actionPaused[market][uint256(action)];\n }\n\n /**\n * @notice Get the latest block number\n */\n function getBlockNumber() internal view returns (uint256) {\n return block.number;\n }\n\n /**\n * @notice Get the latest block number with the safe32 check\n */\n function getBlockNumberAsUint32() internal view returns (uint32) {\n return safe32(getBlockNumber(), \"block # > 32 bits\");\n }\n\n /**\n * @notice Transfer XVS to VAI Vault\n */\n function releaseToVault() internal {\n if (releaseStartBlock == 0 || getBlockNumber() < releaseStartBlock) {\n return;\n }\n\n IBEP20 xvs_ = IBEP20(xvs);\n\n uint256 xvsBalance = xvs_.balanceOf(address(this));\n if (xvsBalance == 0) {\n return;\n }\n\n uint256 actualAmount;\n uint256 deltaBlocks = sub_(getBlockNumber(), releaseStartBlock);\n // releaseAmount = venusVAIVaultRate * deltaBlocks\n uint256 releaseAmount_ = mul_(venusVAIVaultRate, deltaBlocks);\n\n if (xvsBalance >= releaseAmount_) {\n actualAmount = releaseAmount_;\n } else {\n actualAmount = xvsBalance;\n }\n\n if (actualAmount < minReleaseAmount) {\n return;\n }\n\n releaseStartBlock = getBlockNumber();\n\n xvs_.safeTransfer(vaiVaultAddress, actualAmount);\n emit DistributedVAIVaultVenus(actualAmount);\n\n IVAIVault(vaiVaultAddress).updatePendingRewards();\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param vTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @dev Note that we calculate the exchangeRateStored for each collateral vToken using stored data,\n * without calculating accumulated interest.\n * @return (possible error code,\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidityInternal(\n address account,\n VToken vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) internal view returns (Error, uint256, uint256) {\n (uint256 err, uint256 liquidity, uint256 shortfall) = comptrollerLens.getHypotheticalAccountLiquidity(\n address(this),\n account,\n vTokenModify,\n redeemTokens,\n borrowAmount\n );\n return (Error(err), liquidity, shortfall);\n }\n\n /**\n * @notice Add the market to the borrower's \"assets in\" for liquidity calculations\n * @param vToken The market to enter\n * @param borrower The address of the account to modify\n * @return Success indicator for whether the market was entered\n */\n function addToMarketInternal(VToken vToken, address borrower) internal returns (Error) {\n checkActionPauseState(address(vToken), Action.ENTER_MARKET);\n Market storage marketToJoin = markets[address(vToken)];\n ensureListed(marketToJoin);\n if (marketToJoin.accountMembership[borrower]) {\n // already joined\n return Error.NO_ERROR;\n }\n // survived the gauntlet, add to list\n // NOTE: we store these somewhat redundantly as a significant optimization\n // this avoids having to iterate through the list for the most common use cases\n // that is, only when we need to perform liquidity checks\n // and not whenever we want to check if an account is in a particular market\n marketToJoin.accountMembership[borrower] = true;\n accountAssets[borrower].push(vToken);\n\n emit MarketEntered(vToken, borrower);\n\n return Error.NO_ERROR;\n }\n\n /**\n * @notice Checks for the user is allowed to redeem tokens\n * @param vToken Address of the market\n * @param redeemer Address of the user\n * @param redeemTokens Amount of tokens to redeem\n * @return Success indicator for redeem is allowed or not\n */\n function redeemAllowedInternal(\n address vToken,\n address redeemer,\n uint256 redeemTokens\n ) internal view returns (uint256) {\n ensureListed(markets[vToken]);\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\n if (!markets[vToken].accountMembership[redeemer]) {\n return uint256(Error.NO_ERROR);\n }\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n redeemer,\n VToken(vToken),\n redeemTokens,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall != 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the XVS address\n * @return The address of XVS token\n */\n function getXVSAddress() external view returns (address) {\n return xvs;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/MarketFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { IMarketFacet } from \"../interfaces/IMarketFacet.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title MarketFacet\n * @author Venus\n * @dev This facet contains all the methods related to the market's management in the pool\n * @notice This facet contract contains functions regarding markets\n */\ncontract MarketFacet is IMarketFacet, FacetBase {\n /// @notice Emitted when an admin supports a market\n event MarketListed(VToken indexed vToken);\n\n /// @notice Emitted when an account exits a market\n event MarketExited(VToken indexed vToken, address indexed account);\n\n /// @notice Emitted when the borrowing or redeeming delegate rights are updated for an account\n event DelegateUpdated(address indexed approver, address indexed delegate, bool approved);\n\n /// @notice Emitted when an admin unlists a market\n event MarketUnlisted(address indexed vToken);\n\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n function isComptroller() public pure returns (bool) {\n return true;\n }\n\n /**\n * @notice Returns the assets an account has entered\n * @param account The address of the account to pull assets for\n * @return A dynamic list with the assets the account has entered\n */\n function getAssetsIn(address account) external view returns (VToken[] memory) {\n uint256 len;\n VToken[] memory _accountAssets = accountAssets[account];\n uint256 _accountAssetsLength = _accountAssets.length;\n\n VToken[] memory assetsIn = new VToken[](_accountAssetsLength);\n\n for (uint256 i; i < _accountAssetsLength; ++i) {\n Market memory market = markets[address(_accountAssets[i])];\n if (market.isListed) {\n assetsIn[len] = _accountAssets[i];\n ++len;\n }\n }\n\n assembly {\n mstore(assetsIn, len)\n }\n\n return assetsIn;\n }\n\n /**\n * @notice Return all of the markets\n * @dev The automatic getter may be used to access an individual market\n * @return The list of market addresses\n */\n function getAllMarkets() external view returns (VToken[] memory) {\n return allMarkets;\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in vToken.liquidateBorrowFresh)\n * @param vTokenBorrowed The address of the borrowed vToken\n * @param vTokenCollateral The address of the collateral vToken\n * @param actualRepayAmount The amount of vTokenBorrowed underlying to convert into vTokenCollateral tokens\n * @return (errorCode, number of vTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256) {\n (uint256 err, uint256 seizeTokens) = comptrollerLens.liquidateCalculateSeizeTokens(\n address(this),\n vTokenBorrowed,\n vTokenCollateral,\n actualRepayAmount\n );\n return (err, seizeTokens);\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in vToken.liquidateBorrowFresh)\n * @param vTokenCollateral The address of the collateral vToken\n * @param actualRepayAmount The amount of vTokenBorrowed underlying to convert into vTokenCollateral tokens\n * @return (errorCode, number of vTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256) {\n (uint256 err, uint256 seizeTokens) = comptrollerLens.liquidateVAICalculateSeizeTokens(\n address(this),\n vTokenCollateral,\n actualRepayAmount\n );\n return (err, seizeTokens);\n }\n\n /**\n * @notice Returns whether the given account is entered in the given asset\n * @param account The address of the account to check\n * @param vToken The vToken to check\n * @return True if the account is in the asset, otherwise false\n */\n function checkMembership(address account, VToken vToken) external view returns (bool) {\n return markets[address(vToken)].accountMembership[account];\n }\n\n /**\n * @notice Add assets to be included in account liquidity calculation\n * @param vTokens The list of addresses of the vToken markets to be enabled\n * @return Success indicator for whether each corresponding market was entered\n */\n function enterMarkets(address[] calldata vTokens) external returns (uint256[] memory) {\n uint256 len = vTokens.length;\n\n uint256[] memory results = new uint256[](len);\n for (uint256 i; i < len; ++i) {\n results[i] = uint256(addToMarketInternal(VToken(vTokens[i]), msg.sender));\n }\n\n return results;\n }\n\n /**\n * @notice Unlist a market by setting isListed to false\n * @dev Checks if market actions are paused and borrowCap/supplyCap/CF are set to 0\n * @param market The address of the market (vToken) to unlist\n * @return uint256 0=success, otherwise a failure. (See enum Error for details)\n */\n function unlistMarket(address market) external returns (uint256) {\n ensureAllowed(\"unlistMarket(address)\");\n\n Market storage _market = markets[market];\n\n if (!_market.isListed) {\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.UNLIST_MARKET_NOT_LISTED);\n }\n\n require(actionPaused(market, Action.BORROW), \"borrow action is not paused\");\n require(actionPaused(market, Action.MINT), \"mint action is not paused\");\n require(actionPaused(market, Action.REDEEM), \"redeem action is not paused\");\n require(actionPaused(market, Action.REPAY), \"repay action is not paused\");\n require(actionPaused(market, Action.ENTER_MARKET), \"enter market action is not paused\");\n require(actionPaused(market, Action.LIQUIDATE), \"liquidate action is not paused\");\n require(actionPaused(market, Action.SEIZE), \"seize action is not paused\");\n require(actionPaused(market, Action.TRANSFER), \"transfer action is not paused\");\n require(actionPaused(market, Action.EXIT_MARKET), \"exit market action is not paused\");\n\n require(borrowCaps[market] == 0, \"borrow cap is not 0\");\n require(supplyCaps[market] == 0, \"supply cap is not 0\");\n\n require(_market.collateralFactorMantissa == 0, \"collateral factor is not 0\");\n\n _market.isListed = false;\n emit MarketUnlisted(market);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Removes asset from sender's account liquidity calculation\n * @dev Sender must not have an outstanding borrow balance in the asset,\n * or be providing necessary collateral for an outstanding borrow\n * @param vTokenAddress The address of the asset to be removed\n * @return Whether or not the account successfully exited the market\n */\n function exitMarket(address vTokenAddress) external returns (uint256) {\n checkActionPauseState(vTokenAddress, Action.EXIT_MARKET);\n\n VToken vToken = VToken(vTokenAddress);\n /* Get sender tokensHeld and amountOwed underlying from the vToken */\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = vToken.getAccountSnapshot(msg.sender);\n require(oErr == 0, \"getAccountSnapshot failed\"); // semi-opaque error code\n\n /* Fail if the sender has a borrow balance */\n if (amountOwed != 0) {\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\n }\n\n /* Fail if the sender is not permitted to redeem all of their tokens */\n uint256 allowed = redeemAllowedInternal(vTokenAddress, msg.sender, tokensHeld);\n if (allowed != 0) {\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\n }\n\n Market storage marketToExit = markets[address(vToken)];\n\n /* Return true if the sender is not already ‘in’ the market */\n if (!marketToExit.accountMembership[msg.sender]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Set vToken account membership to false */\n delete marketToExit.accountMembership[msg.sender];\n\n /* Delete vToken from the account’s list of assets */\n // In order to delete vToken, copy last item in list to location of item to be removed, reduce length by 1\n VToken[] storage userAssetList = accountAssets[msg.sender];\n uint256 len = userAssetList.length;\n uint256 i;\n for (; i < len; ++i) {\n if (userAssetList[i] == vToken) {\n userAssetList[i] = userAssetList[len - 1];\n userAssetList.length--;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(i < len);\n\n emit MarketExited(vToken, msg.sender);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Add the market to the markets mapping and set it as listed\n * @dev Allows a privileged role to add and list markets to the Comptroller\n * @param vToken The address of the market (token) to list\n * @return uint256 0=success, otherwise a failure. (See enum Error for details)\n */\n function _supportMarket(VToken vToken) external returns (uint256) {\n ensureAllowed(\"_supportMarket(address)\");\n\n if (markets[address(vToken)].isListed) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n vToken.isVToken(); // Sanity check to make sure its really a VToken\n\n // Note that isVenus is not in active use anymore\n Market storage newMarket = markets[address(vToken)];\n newMarket.isListed = true;\n newMarket.isVenus = false;\n newMarket.collateralFactorMantissa = 0;\n\n _addMarketInternal(vToken);\n _initializeMarket(address(vToken));\n\n emit MarketListed(vToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Grants or revokes the borrowing or redeeming delegate rights to / from an account\n * If allowed, the delegate will be able to borrow funds on behalf of the sender\n * Upon a delegated borrow, the delegate will receive the funds, and the borrower\n * will see the debt on their account\n * Upon a delegated redeem, the delegate will receive the redeemed amount and the approver\n * will see a deduction in his vToken balance\n * @param delegate The address to update the rights for\n * @param approved Whether to grant (true) or revoke (false) the borrowing or redeeming rights\n */\n function updateDelegate(address delegate, bool approved) external {\n ensureNonzeroAddress(delegate);\n require(approvedDelegates[msg.sender][delegate] != approved, \"Delegation status unchanged\");\n\n _updateDelegate(msg.sender, delegate, approved);\n }\n\n function _updateDelegate(address approver, address delegate, bool approved) internal {\n approvedDelegates[approver][delegate] = approved;\n emit DelegateUpdated(approver, delegate, approved);\n }\n\n function _addMarketInternal(VToken vToken) internal {\n uint256 allMarketsLength = allMarkets.length;\n for (uint256 i; i < allMarketsLength; ++i) {\n require(allMarkets[i] != vToken, \"already added\");\n }\n allMarkets.push(vToken);\n }\n\n function _initializeMarket(address vToken) internal {\n uint32 blockNumber = getBlockNumberAsUint32();\n\n VenusMarketState storage supplyState = venusSupplyState[vToken];\n VenusMarketState storage borrowState = venusBorrowState[vToken];\n\n /*\n * Update market state indices\n */\n if (supplyState.index == 0) {\n // Initialize supply state index with default value\n supplyState.index = venusInitialIndex;\n }\n\n if (borrowState.index == 0) {\n // Initialize borrow state index with default value\n borrowState.index = venusInitialIndex;\n }\n\n /*\n * Update market state block numbers\n */\n supplyState.block = borrowState.block = blockNumber;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/PolicyFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IPolicyFacet } from \"../interfaces/IPolicyFacet.sol\";\n\nimport { XVSRewardsHelper } from \"./XVSRewardsHelper.sol\";\n\n/**\n * @title PolicyFacet\n * @author Venus\n * @dev This facet contains all the hooks used while transferring the assets\n * @notice This facet contract contains all the external pre-hook functions related to vToken\n */\ncontract PolicyFacet is IPolicyFacet, XVSRewardsHelper {\n /// @notice Emitted when a new borrow-side XVS speed is calculated for a market\n event VenusBorrowSpeedUpdated(VToken indexed vToken, uint256 newSpeed);\n\n /// @notice Emitted when a new supply-side XVS speed is calculated for a market\n event VenusSupplySpeedUpdated(VToken indexed vToken, uint256 newSpeed);\n\n /**\n * @notice Checks if the account should be allowed to mint tokens in the given market\n * @param vToken The market to verify the mint against\n * @param minter The account which would get the minted tokens\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function mintAllowed(address vToken, address minter, uint256 mintAmount) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.MINT);\n ensureListed(markets[vToken]);\n\n uint256 supplyCap = supplyCaps[vToken];\n require(supplyCap != 0, \"market supply cap is 0\");\n\n uint256 vTokenSupply = VToken(vToken).totalSupply();\n Exp memory exchangeRate = Exp({ mantissa: VToken(vToken).exchangeRateStored() });\n uint256 nextTotalSupply = mul_ScalarTruncateAddUInt(exchangeRate, vTokenSupply, mintAmount);\n require(nextTotalSupply <= supplyCap, \"market supply cap reached\");\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, minter);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates mint, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being minted\n * @param minter The address minting the tokens\n * @param actualMintAmount The amount of the underlying asset being minted\n * @param mintTokens The number of tokens being minted\n */\n // solhint-disable-next-line no-unused-vars\n function mintVerify(address vToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(minter, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to redeem tokens in the given market\n * @param vToken The market to verify the redeem against\n * @param redeemer The account which would redeem the tokens\n * @param redeemTokens The number of vTokens to exchange for the underlying asset in the market\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function redeemAllowed(address vToken, address redeemer, uint256 redeemTokens) external returns (uint256) {\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.REDEEM);\n\n uint256 allowed = redeemAllowedInternal(vToken, redeemer, redeemTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, redeemer);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates redeem, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being redeemed\n * @param redeemer The address redeeming the tokens\n * @param redeemAmount The amount of the underlying asset being redeemed\n * @param redeemTokens The number of tokens being redeemed\n */\n function redeemVerify(address vToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external {\n require(redeemTokens != 0 || redeemAmount == 0, \"redeemTokens zero\");\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(redeemer, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param vToken The market to verify the borrow against\n * @param borrower The account which would borrow the asset\n * @param borrowAmount The amount of underlying the account would borrow\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function borrowAllowed(address vToken, address borrower, uint256 borrowAmount) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.BORROW);\n ensureListed(markets[vToken]);\n\n uint256 borrowCap = borrowCaps[vToken];\n require(borrowCap != 0, \"market borrow cap is 0\");\n\n if (!markets[vToken].accountMembership[borrower]) {\n // only vTokens may call borrowAllowed if borrower not in market\n require(msg.sender == vToken, \"sender must be vToken\");\n\n // attempt to add borrower to the market\n Error err = addToMarketInternal(VToken(vToken), borrower);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n }\n\n if (oracle.getUnderlyingPrice(VToken(vToken)) == 0) {\n return uint256(Error.PRICE_ERROR);\n }\n\n uint256 nextTotalBorrows = add_(VToken(vToken).totalBorrows(), borrowAmount);\n require(nextTotalBorrows <= borrowCap, \"market borrow cap reached\");\n\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n borrower,\n VToken(vToken),\n 0,\n borrowAmount\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall != 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n // Keep the flywheel moving\n Exp memory borrowIndex = Exp({ mantissa: VToken(vToken).borrowIndex() });\n updateVenusBorrowIndex(vToken, borrowIndex);\n distributeBorrowerVenus(vToken, borrower, borrowIndex);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates borrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset whose underlying is being borrowed\n * @param borrower The address borrowing the underlying\n * @param borrowAmount The amount of the underlying asset requested to borrow\n */\n // solhint-disable-next-line no-unused-vars\n function borrowVerify(address vToken, address borrower, uint256 borrowAmount) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to repay a borrow in the given market\n * @param vToken The market to verify the repay against\n * @param payer The account which would repay the asset\n * @param borrower The account which borrowed the asset\n * @param repayAmount The amount of the underlying asset the account would repay\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function repayBorrowAllowed(\n address vToken,\n address payer, // solhint-disable-line no-unused-vars\n address borrower,\n uint256 repayAmount // solhint-disable-line no-unused-vars\n ) external returns (uint256) {\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.REPAY);\n ensureListed(markets[vToken]);\n\n // Keep the flywheel moving\n Exp memory borrowIndex = Exp({ mantissa: VToken(vToken).borrowIndex() });\n updateVenusBorrowIndex(vToken, borrowIndex);\n distributeBorrowerVenus(vToken, borrower, borrowIndex);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates repayBorrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being repaid\n * @param payer The address repaying the borrow\n * @param borrower The address of the borrower\n * @param actualRepayAmount The amount of underlying being repaid\n */\n function repayBorrowVerify(\n address vToken,\n address payer, // solhint-disable-line no-unused-vars\n address borrower,\n uint256 actualRepayAmount, // solhint-disable-line no-unused-vars\n uint256 borrowerIndex // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vToken);\n }\n }\n\n /**\n * @notice Checks if the liquidation should be allowed to occur\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param repayAmount The amount of underlying being repaid\n */\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external view returns (uint256) {\n checkProtocolPauseState();\n\n // if we want to pause liquidating to vTokenCollateral, we should pause seizing\n checkActionPauseState(vTokenBorrowed, Action.LIQUIDATE);\n\n if (liquidatorContract != address(0) && liquidator != liquidatorContract) {\n return uint256(Error.UNAUTHORIZED);\n }\n\n ensureListed(markets[vTokenCollateral]);\n\n uint256 borrowBalance;\n if (address(vTokenBorrowed) != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n borrowBalance = VToken(vTokenBorrowed).borrowBalanceStored(borrower);\n } else {\n borrowBalance = vaiController.getVAIRepayAmount(borrower);\n }\n\n if (isForcedLiquidationEnabled[vTokenBorrowed] || isForcedLiquidationEnabledForUser[borrower][vTokenBorrowed]) {\n if (repayAmount > borrowBalance) {\n return uint(Error.TOO_MUCH_REPAY);\n }\n return uint(Error.NO_ERROR);\n }\n\n /* The borrower must have shortfall in order to be liquidatable */\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(borrower, VToken(address(0)), 0, 0);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall == 0) {\n return uint256(Error.INSUFFICIENT_SHORTFALL);\n }\n\n // The liquidator may not repay more than what is allowed by the closeFactor\n //-- maxClose = multipy of closeFactorMantissa and borrowBalance\n if (repayAmount > mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance)) {\n return uint256(Error.TOO_MUCH_REPAY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates liquidateBorrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param actualRepayAmount The amount of underlying being repaid\n * @param seizeTokens The amount of collateral token that will be seized\n */\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral, // solhint-disable-line no-unused-vars\n address liquidator,\n address borrower,\n uint256 actualRepayAmount, // solhint-disable-line no-unused-vars\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vTokenBorrowed);\n prime.accrueInterestAndUpdateScore(liquidator, vTokenBorrowed);\n }\n }\n\n /**\n * @notice Checks if the seizing of assets should be allowed to occur\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vTokenCollateral, Action.SEIZE);\n\n Market storage market = markets[vTokenCollateral];\n\n // We've added VAIController as a borrowed token list check for seize\n ensureListed(market);\n\n if (!market.accountMembership[borrower]) {\n return uint256(Error.MARKET_NOT_COLLATERAL);\n }\n\n if (address(vTokenBorrowed) != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n\n if (VToken(vTokenCollateral).comptroller() != VToken(vTokenBorrowed).comptroller()) {\n return uint256(Error.COMPTROLLER_MISMATCH);\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vTokenCollateral);\n distributeSupplierVenus(vTokenCollateral, borrower);\n distributeSupplierVenus(vTokenCollateral, liquidator);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates seize, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed, // solhint-disable-line no-unused-vars\n address liquidator,\n address borrower,\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vTokenCollateral);\n prime.accrueInterestAndUpdateScore(liquidator, vTokenCollateral);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to transfer tokens in the given market\n * @param vToken The market to verify the transfer against\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of vTokens to transfer\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function transferAllowed(\n address vToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.TRANSFER);\n\n // Currently the only consideration is whether or not\n // the src is allowed to redeem this many tokens\n uint256 allowed = redeemAllowedInternal(vToken, src, transferTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, src);\n distributeSupplierVenus(vToken, dst);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates transfer, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being transferred\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of vTokens to transfer\n */\n // solhint-disable-next-line no-unused-vars\n function transferVerify(address vToken, address src, address dst, uint256 transferTokens) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(src, vToken);\n prime.accrueInterestAndUpdateScore(dst, vToken);\n }\n }\n\n /**\n * @notice Determine the current account liquidity wrt collateral requirements\n * @return (possible error code (semi-opaque),\n account liquidity in excess of collateral requirements,\n * account shortfall below collateral requirements)\n */\n function getAccountLiquidity(address account) external view returns (uint256, uint256, uint256) {\n (Error err, uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n VToken(address(0)),\n 0,\n 0\n );\n\n return (uint256(err), liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param vTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code (semi-opaque),\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidity(\n address account,\n address vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) external view returns (uint256, uint256, uint256) {\n (Error err, uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n VToken(vTokenModify),\n redeemTokens,\n borrowAmount\n );\n return (uint256(err), liquidity, shortfall);\n }\n\n // setter functionality\n /**\n * @notice Set XVS speed for a single market\n * @dev Allows the contract admin to set XVS speed for a market\n * @param vTokens The market whose XVS speed to update\n * @param supplySpeeds New XVS speed for supply\n * @param borrowSpeeds New XVS speed for borrow\n */\n function _setVenusSpeeds(\n VToken[] calldata vTokens,\n uint256[] calldata supplySpeeds,\n uint256[] calldata borrowSpeeds\n ) external {\n ensureAdmin();\n\n uint256 numTokens = vTokens.length;\n require(numTokens == supplySpeeds.length && numTokens == borrowSpeeds.length, \"invalid input\");\n\n for (uint256 i; i < numTokens; ++i) {\n ensureNonzeroAddress(address(vTokens[i]));\n setVenusSpeedInternal(vTokens[i], supplySpeeds[i], borrowSpeeds[i]);\n }\n }\n\n function setVenusSpeedInternal(VToken vToken, uint256 supplySpeed, uint256 borrowSpeed) internal {\n ensureListed(markets[address(vToken)]);\n\n if (venusSupplySpeeds[address(vToken)] != supplySpeed) {\n // Supply speed updated so let's update supply state to ensure that\n // 1. XVS accrued properly for the old speed, and\n // 2. XVS accrued at the new speed starts after this block.\n\n updateVenusSupplyIndex(address(vToken));\n // Update speed and emit event\n venusSupplySpeeds[address(vToken)] = supplySpeed;\n emit VenusSupplySpeedUpdated(vToken, supplySpeed);\n }\n\n if (venusBorrowSpeeds[address(vToken)] != borrowSpeed) {\n // Borrow speed updated so let's update borrow state to ensure that\n // 1. XVS accrued properly for the old speed, and\n // 2. XVS accrued at the new speed starts after this block.\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n\n // Update speed and emit event\n venusBorrowSpeeds[address(vToken)] = borrowSpeed;\n emit VenusBorrowSpeedUpdated(vToken, borrowSpeed);\n }\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/RewardFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IRewardFacet } from \"../interfaces/IRewardFacet.sol\";\nimport { XVSRewardsHelper } from \"./XVSRewardsHelper.sol\";\nimport { SafeBEP20, IBEP20 } from \"../../../Utils/SafeBEP20.sol\";\nimport { VBep20Interface } from \"../../../Tokens/VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title RewardFacet\n * @author Venus\n * @dev This facet contains all the methods related to the reward functionality\n * @notice This facet contract provides the external functions related to all claims and rewards of the protocol\n */\ncontract RewardFacet is IRewardFacet, XVSRewardsHelper {\n /// @notice Emitted when Venus is granted by admin\n event VenusGranted(address indexed recipient, uint256 amount);\n\n /// @notice Emitted when XVS are seized for the holder\n event VenusSeized(address indexed holder, uint256 amount);\n\n using SafeBEP20 for IBEP20;\n\n /**\n * @notice Claim all the xvs accrued by holder in all markets and VAI\n * @param holder The address to claim XVS for\n */\n function claimVenus(address holder) public {\n return claimVenus(holder, allMarkets);\n }\n\n /**\n * @notice Claim all the xvs accrued by holder in the specified markets\n * @param holder The address to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n */\n function claimVenus(address holder, VToken[] memory vTokens) public {\n address[] memory holders = new address[](1);\n holders[0] = holder;\n claimVenus(holders, vTokens, true, true);\n }\n\n /**\n * @notice Claim all xvs accrued by the holders\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n */\n function claimVenus(address[] memory holders, VToken[] memory vTokens, bool borrowers, bool suppliers) public {\n claimVenus(holders, vTokens, borrowers, suppliers, false);\n }\n\n /**\n * @notice Claim all the xvs accrued by holder in all markets, a shorthand for `claimVenus` with collateral set to `true`\n * @param holder The address to claim XVS for\n */\n function claimVenusAsCollateral(address holder) external {\n address[] memory holders = new address[](1);\n holders[0] = holder;\n claimVenus(holders, allMarkets, true, true, true);\n }\n\n /**\n * @notice Transfer XVS to the user with user's shortfall considered\n * @dev Note: If there is not enough XVS, we do not perform the transfer all\n * @param user The address of the user to transfer XVS to\n * @param amount The amount of XVS to (possibly) transfer\n * @param shortfall The shortfall of the user\n * @param collateral Whether or not we will use user's venus reward as collateral to pay off the debt\n * @return The amount of XVS which was NOT transferred to the user\n */\n function grantXVSInternal(\n address user,\n uint256 amount,\n uint256 shortfall,\n bool collateral\n ) internal returns (uint256) {\n // If the user is blacklisted, they can't get XVS rewards\n require(\n user != 0xEF044206Db68E40520BfA82D45419d498b4bc7Bf &&\n user != 0x7589dD3355DAE848FDbF75044A3495351655cB1A &&\n user != 0x33df7a7F6D44307E1e5F3B15975b47515e5524c0 &&\n user != 0x24e77E5b74B30b026E9996e4bc3329c881e24968,\n \"Blacklisted\"\n );\n\n IBEP20 xvs_ = IBEP20(xvs);\n\n if (amount == 0 || amount > xvs_.balanceOf(address(this))) {\n return amount;\n }\n\n if (shortfall == 0) {\n xvs_.safeTransfer(user, amount);\n return 0;\n }\n // If user's bankrupt and doesn't use pending xvs as collateral, don't grant\n // anything, otherwise, we will transfer the pending xvs as collateral to\n // vXVS token and mint vXVS for the user\n //\n // If mintBehalf failed, don't grant any xvs\n require(collateral, \"bankrupt\");\n\n address xvsVToken_ = xvsVToken;\n\n xvs_.safeApprove(xvsVToken_, 0);\n xvs_.safeApprove(xvsVToken_, amount);\n require(VBep20Interface(xvsVToken_).mintBehalf(user, amount) == uint256(Error.NO_ERROR), \"mint behalf error\");\n\n // set venusAccrued[user] to 0\n return 0;\n }\n\n /*** Venus Distribution Admin ***/\n\n /**\n * @notice Transfer XVS to the recipient\n * @dev Allows the contract admin to transfer XVS to any recipient based on the recipient's shortfall\n * Note: If there is not enough XVS, we do not perform the transfer all\n * @param recipient The address of the recipient to transfer XVS to\n * @param amount The amount of XVS to (possibly) transfer\n */\n function _grantXVS(address recipient, uint256 amount) external {\n ensureAdmin();\n uint256 amountLeft = grantXVSInternal(recipient, amount, 0, false);\n require(amountLeft == 0, \"no xvs\");\n emit VenusGranted(recipient, amount);\n }\n\n /**\n * @dev Seize XVS tokens from the specified holders and transfer to recipient\n * @notice Seize XVS rewards allocated to holders\n * @param holders Addresses of the XVS holders\n * @param recipient Address of the XVS token recipient\n * @return The total amount of XVS tokens seized and transferred to recipient\n */\n function seizeVenus(address[] calldata holders, address recipient) external returns (uint256) {\n ensureAllowed(\"seizeVenus(address[],address)\");\n\n uint256 holdersLength = holders.length;\n uint256 totalHoldings;\n\n updateAndDistributeRewardsInternal(holders, allMarkets, true, true);\n for (uint256 j; j < holdersLength; ++j) {\n address holder = holders[j];\n uint256 userHolding = venusAccrued[holder];\n\n if (userHolding != 0) {\n totalHoldings += userHolding;\n delete venusAccrued[holder];\n }\n\n emit VenusSeized(holder, userHolding);\n }\n\n if (totalHoldings != 0) {\n IBEP20(xvs).safeTransfer(recipient, totalHoldings);\n emit VenusGranted(recipient, totalHoldings);\n }\n\n return totalHoldings;\n }\n\n /**\n * @notice Claim all xvs accrued by the holders\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n * @param collateral Whether or not to use XVS earned as collateral, only takes effect when the holder has a shortfall\n */\n function claimVenus(\n address[] memory holders,\n VToken[] memory vTokens,\n bool borrowers,\n bool suppliers,\n bool collateral\n ) public {\n uint256 holdersLength = holders.length;\n\n updateAndDistributeRewardsInternal(holders, vTokens, borrowers, suppliers);\n for (uint256 j; j < holdersLength; ++j) {\n address holder = holders[j];\n\n // If there is a positive shortfall, the XVS reward is accrued,\n // but won't be granted to this holder\n (, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(holder, VToken(address(0)), 0, 0);\n\n uint256 value = venusAccrued[holder];\n delete venusAccrued[holder];\n\n uint256 returnAmount = grantXVSInternal(holder, value, shortfall, collateral);\n\n // returnAmount can only be positive if balance of xvsAddress is less than grant amount(venusAccrued[holder])\n if (returnAmount != 0) {\n venusAccrued[holder] = returnAmount;\n }\n }\n }\n\n /**\n * @notice Update and distribute tokens\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n */\n function updateAndDistributeRewardsInternal(\n address[] memory holders,\n VToken[] memory vTokens,\n bool borrowers,\n bool suppliers\n ) internal {\n uint256 j;\n uint256 holdersLength = holders.length;\n uint256 vTokensLength = vTokens.length;\n\n for (uint256 i; i < vTokensLength; ++i) {\n VToken vToken = vTokens[i];\n ensureListed(markets[address(vToken)]);\n if (borrowers) {\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n for (j = 0; j < holdersLength; ++j) {\n distributeBorrowerVenus(address(vToken), holders[j], borrowIndex);\n }\n }\n\n if (suppliers) {\n updateVenusSupplyIndex(address(vToken));\n for (j = 0; j < holdersLength; ++j) {\n distributeSupplierVenus(address(vToken), holders[j]);\n }\n }\n }\n }\n\n /**\n * @notice Returns the XVS vToken address\n * @return The address of XVS vToken\n */\n function getXVSVTokenAddress() external view returns (address) {\n return xvsVToken;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/SetterFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ISetterFacet } from \"../interfaces/ISetterFacet.sol\";\nimport { PriceOracle } from \"../../../Oracle/PriceOracle.sol\";\nimport { ComptrollerLensInterface } from \"../../ComptrollerLensInterface.sol\";\nimport { VAIControllerInterface } from \"../../../Tokens/VAI/VAIControllerInterface.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\nimport { IPrime } from \"../../../Tokens/Prime/IPrime.sol\";\n\n/**\n * @title SetterFacet\n * @author Venus\n * @dev This facet contains all the setters for the states\n * @notice This facet contract contains all the configurational setter functions\n */\ncontract SetterFacet is ISetterFacet, FacetBase {\n /// @notice Emitted when close factor is changed by admin\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\n\n /// @notice Emitted when a collateral factor is changed by admin\n event NewCollateralFactor(\n VToken indexed vToken,\n uint256 oldCollateralFactorMantissa,\n uint256 newCollateralFactorMantissa\n );\n\n /// @notice Emitted when liquidation incentive is changed by admin\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\n\n /// @notice Emitted when price oracle is changed\n event NewPriceOracle(PriceOracle oldPriceOracle, PriceOracle newPriceOracle);\n\n /// @notice Emitted when borrow cap for a vToken is changed\n event NewBorrowCap(VToken indexed vToken, uint256 newBorrowCap);\n\n /// @notice Emitted when VAIController is changed\n event NewVAIController(VAIControllerInterface oldVAIController, VAIControllerInterface newVAIController);\n\n /// @notice Emitted when VAI mint rate is changed by admin\n event NewVAIMintRate(uint256 oldVAIMintRate, uint256 newVAIMintRate);\n\n /// @notice Emitted when protocol state is changed by admin\n event ActionProtocolPaused(bool state);\n\n /// @notice Emitted when treasury guardian is changed\n event NewTreasuryGuardian(address oldTreasuryGuardian, address newTreasuryGuardian);\n\n /// @notice Emitted when treasury address is changed\n event NewTreasuryAddress(address oldTreasuryAddress, address newTreasuryAddress);\n\n /// @notice Emitted when treasury percent is changed\n event NewTreasuryPercent(uint256 oldTreasuryPercent, uint256 newTreasuryPercent);\n\n /// @notice Emitted when liquidator adress is changed\n event NewLiquidatorContract(address oldLiquidatorContract, address newLiquidatorContract);\n\n /// @notice Emitted when ComptrollerLens address is changed\n event NewComptrollerLens(address oldComptrollerLens, address newComptrollerLens);\n\n /// @notice Emitted when supply cap for a vToken is changed\n event NewSupplyCap(VToken indexed vToken, uint256 newSupplyCap);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControl(address oldAccessControlAddress, address newAccessControlAddress);\n\n /// @notice Emitted when pause guardian is changed\n event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);\n\n /// @notice Emitted when an action is paused on a market\n event ActionPausedMarket(VToken indexed vToken, Action indexed action, bool pauseState);\n\n /// @notice Emitted when VAI Vault info is changed\n event NewVAIVaultInfo(address indexed vault_, uint256 releaseStartBlock_, uint256 releaseInterval_);\n\n /// @notice Emitted when Venus VAI Vault rate is changed\n event NewVenusVAIVaultRate(uint256 oldVenusVAIVaultRate, uint256 newVenusVAIVaultRate);\n\n /// @notice Emitted when prime token contract address is changed\n event NewPrimeToken(IPrime oldPrimeToken, IPrime newPrimeToken);\n\n /// @notice Emitted when forced liquidation is enabled or disabled for all users in a market\n event IsForcedLiquidationEnabledUpdated(address indexed vToken, bool enable);\n\n /// @notice Emitted when forced liquidation is enabled or disabled for a user borrowing in a market\n event IsForcedLiquidationEnabledForUserUpdated(address indexed borrower, address indexed vToken, bool enable);\n\n /// @notice Emitted when XVS token address is changed\n event NewXVSToken(address indexed oldXVS, address indexed newXVS);\n\n /// @notice Emitted when XVS vToken address is changed\n event NewXVSVToken(address indexed oldXVSVToken, address indexed newXVSVToken);\n\n /**\n * @notice Compare two addresses to ensure they are different\n * @param oldAddress The original address to compare\n * @param newAddress The new address to compare\n */\n modifier compareAddress(address oldAddress, address newAddress) {\n require(oldAddress != newAddress, \"old address is same as new address\");\n _;\n }\n\n /**\n * @notice Compare two values to ensure they are different\n * @param oldValue The original value to compare\n * @param newValue The new value to compare\n */\n modifier compareValue(uint256 oldValue, uint256 newValue) {\n require(oldValue != newValue, \"old value is same as new value\");\n _;\n }\n\n /**\n * @notice Sets a new price oracle for the comptroller\n * @dev Allows the contract admin to set a new price oracle used by the Comptroller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPriceOracle(\n PriceOracle newOracle\n ) external compareAddress(address(oracle), address(newOracle)) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(address(newOracle));\n\n // Track the old oracle for the comptroller\n PriceOracle oldOracle = oracle;\n\n // Set comptroller's oracle to newOracle\n oracle = newOracle;\n\n // Emit NewPriceOracle(oldOracle, newOracle)\n emit NewPriceOracle(oldOracle, newOracle);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the closeFactor used when liquidating borrows\n * @dev Allows the contract admin to set the closeFactor used to liquidate borrows\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\n * @return uint256 0=success, otherwise will revert\n */\n function _setCloseFactor(\n uint256 newCloseFactorMantissa\n ) external compareValue(closeFactorMantissa, newCloseFactorMantissa) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\n\n //-- Check close factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\n //-- Check close factor >= 0.05\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\n\n if (lessThanExp(highLimit, newCloseFactorExp) || greaterThanExp(lowLimit, newCloseFactorExp)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\n closeFactorMantissa = newCloseFactorMantissa;\n emit NewCloseFactor(oldCloseFactorMantissa, newCloseFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Allows the contract admin to set the address of access control of this contract\n * @param newAccessControlAddress New address for the access control\n * @return uint256 0=success, otherwise will revert\n */\n function _setAccessControl(\n address newAccessControlAddress\n ) external compareAddress(accessControl, newAccessControlAddress) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(newAccessControlAddress);\n\n address oldAccessControlAddress = accessControl;\n\n accessControl = newAccessControlAddress;\n emit NewAccessControl(oldAccessControlAddress, newAccessControlAddress);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the collateralFactor for a market\n * @dev Allows a privileged role to set the collateralFactorMantissa\n * @param vToken The market to set the factor on\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\n * @return uint256 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCollateralFactor(\n VToken vToken,\n uint256 newCollateralFactorMantissa\n )\n external\n compareValue(markets[address(vToken)].collateralFactorMantissa, newCollateralFactorMantissa)\n returns (uint256)\n {\n // Check caller is allowed by access control manager\n ensureAllowed(\"_setCollateralFactor(address,uint256)\");\n ensureNonzeroAddress(address(vToken));\n\n // Verify market is listed\n Market storage market = markets[address(vToken)];\n ensureListed(market);\n\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\n\n //-- Check collateral factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\n }\n\n // If collateral factor != 0, fail if price == 0\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(vToken) == 0) {\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\n }\n\n // Set market's collateral factor to new collateral factor, remember old value\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\n market.collateralFactorMantissa = newCollateralFactorMantissa;\n\n // Emit event with asset, old collateral factor, and new collateral factor\n emit NewCollateralFactor(vToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets liquidationIncentive\n * @dev Allows a privileged role to set the liquidationIncentiveMantissa\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\n * @return uint256 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setLiquidationIncentive(\n uint256 newLiquidationIncentiveMantissa\n ) external compareValue(liquidationIncentiveMantissa, newLiquidationIncentiveMantissa) returns (uint256) {\n ensureAllowed(\"_setLiquidationIncentive(uint256)\");\n\n require(newLiquidationIncentiveMantissa >= 1e18, \"incentive < 1e18\");\n\n // Save current value for use in log\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\n // Set liquidation incentive to new incentive\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\n\n // Emit event with old incentive, new incentive\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Update the address of the liquidator contract\n * @dev Allows the contract admin to update the address of liquidator contract\n * @param newLiquidatorContract_ The new address of the liquidator contract\n */\n function _setLiquidatorContract(\n address newLiquidatorContract_\n ) external compareAddress(liquidatorContract, newLiquidatorContract_) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(newLiquidatorContract_);\n address oldLiquidatorContract = liquidatorContract;\n liquidatorContract = newLiquidatorContract_;\n emit NewLiquidatorContract(oldLiquidatorContract, newLiquidatorContract_);\n }\n\n /**\n * @notice Admin function to change the Pause Guardian\n * @dev Allows the contract admin to change the Pause Guardian\n * @param newPauseGuardian The address of the new Pause Guardian\n * @return uint256 0=success, otherwise a failure. (See enum Error for details)\n */\n function _setPauseGuardian(\n address newPauseGuardian\n ) external compareAddress(pauseGuardian, newPauseGuardian) returns (uint256) {\n ensureAdmin();\n ensureNonzeroAddress(newPauseGuardian);\n\n // Save current value for inclusion in log\n address oldPauseGuardian = pauseGuardian;\n // Store pauseGuardian with value newPauseGuardian\n pauseGuardian = newPauseGuardian;\n\n // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)\n emit NewPauseGuardian(oldPauseGuardian, newPauseGuardian);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the given borrow caps for the given vToken market Borrowing that brings total borrows to or above borrow cap will revert\n * @dev Allows a privileged role to set the borrowing cap for a vToken market. A borrow cap of 0 corresponds to Borrow not allowed\n * @param vTokens The addresses of the markets (tokens) to change the borrow caps for\n * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to Borrow not allowed\n */\n function _setMarketBorrowCaps(VToken[] calldata vTokens, uint256[] calldata newBorrowCaps) external {\n ensureAllowed(\"_setMarketBorrowCaps(address[],uint256[])\");\n\n uint256 numMarkets = vTokens.length;\n uint256 numBorrowCaps = newBorrowCaps.length;\n\n require(numMarkets != 0 && numMarkets == numBorrowCaps, \"invalid input\");\n\n for (uint256 i; i < numMarkets; ++i) {\n borrowCaps[address(vTokens[i])] = newBorrowCaps[i];\n emit NewBorrowCap(vTokens[i], newBorrowCaps[i]);\n }\n }\n\n /**\n * @notice Set the given supply caps for the given vToken market Supply that brings total Supply to or above supply cap will revert\n * @dev Allows a privileged role to set the supply cap for a vToken. A supply cap of 0 corresponds to Minting NotAllowed\n * @param vTokens The addresses of the markets (tokens) to change the supply caps for\n * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to Minting NotAllowed\n */\n function _setMarketSupplyCaps(VToken[] calldata vTokens, uint256[] calldata newSupplyCaps) external {\n ensureAllowed(\"_setMarketSupplyCaps(address[],uint256[])\");\n\n uint256 numMarkets = vTokens.length;\n uint256 numSupplyCaps = newSupplyCaps.length;\n\n require(numMarkets != 0 && numMarkets == numSupplyCaps, \"invalid input\");\n\n for (uint256 i; i < numMarkets; ++i) {\n supplyCaps[address(vTokens[i])] = newSupplyCaps[i];\n emit NewSupplyCap(vTokens[i], newSupplyCaps[i]);\n }\n }\n\n /**\n * @notice Set whole protocol pause/unpause state\n * @dev Allows a privileged role to pause/unpause protocol\n * @param state The new state (true=paused, false=unpaused)\n * @return bool The updated state of the protocol\n */\n function _setProtocolPaused(bool state) external returns (bool) {\n ensureAllowed(\"_setProtocolPaused(bool)\");\n\n protocolPaused = state;\n emit ActionProtocolPaused(state);\n return state;\n }\n\n /**\n * @notice Pause/unpause certain actions\n * @dev Allows a privileged role to pause/unpause the protocol action state\n * @param markets_ Markets to pause/unpause the actions on\n * @param actions_ List of action ids to pause/unpause\n * @param paused_ The new paused state (true=paused, false=unpaused)\n */\n function _setActionsPaused(address[] calldata markets_, Action[] calldata actions_, bool paused_) external {\n ensureAllowed(\"_setActionsPaused(address[],uint8[],bool)\");\n\n uint256 numMarkets = markets_.length;\n uint256 numActions = actions_.length;\n for (uint256 marketIdx; marketIdx < numMarkets; ++marketIdx) {\n for (uint256 actionIdx; actionIdx < numActions; ++actionIdx) {\n setActionPausedInternal(markets_[marketIdx], actions_[actionIdx], paused_);\n }\n }\n }\n\n /**\n * @dev Pause/unpause an action on a market\n * @param market Market to pause/unpause the action on\n * @param action Action id to pause/unpause\n * @param paused The new paused state (true=paused, false=unpaused)\n */\n function setActionPausedInternal(address market, Action action, bool paused) internal {\n ensureListed(markets[market]);\n _actionPaused[market][uint256(action)] = paused;\n emit ActionPausedMarket(VToken(market), action, paused);\n }\n\n /**\n * @notice Sets a new VAI controller\n * @dev Admin function to set a new VAI controller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setVAIController(\n VAIControllerInterface vaiController_\n ) external compareAddress(address(vaiController), address(vaiController_)) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(address(vaiController_));\n\n VAIControllerInterface oldVaiController = vaiController;\n vaiController = vaiController_;\n emit NewVAIController(oldVaiController, vaiController_);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the VAI mint rate\n * @param newVAIMintRate The new VAI mint rate to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setVAIMintRate(\n uint256 newVAIMintRate\n ) external compareValue(vaiMintRate, newVAIMintRate) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n uint256 oldVAIMintRate = vaiMintRate;\n vaiMintRate = newVAIMintRate;\n emit NewVAIMintRate(oldVAIMintRate, newVAIMintRate);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the minted VAI amount of the `owner`\n * @param owner The address of the account to set\n * @param amount The amount of VAI to set to the account\n * @return The number of minted VAI by `owner`\n */\n function setMintedVAIOf(address owner, uint256 amount) external returns (uint256) {\n checkProtocolPauseState();\n\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!mintVAIGuardianPaused && !repayVAIGuardianPaused, \"VAI is paused\");\n // Check caller is vaiController\n if (msg.sender != address(vaiController)) {\n return fail(Error.REJECTION, FailureInfo.SET_MINTED_VAI_REJECTION);\n }\n mintedVAIs[owner] = amount;\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the treasury data.\n * @param newTreasuryGuardian The new address of the treasury guardian to be set\n * @param newTreasuryAddress The new address of the treasury to be set\n * @param newTreasuryPercent The new treasury percent to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256) {\n // Check caller is admin\n ensureAdminOr(treasuryGuardian);\n\n require(newTreasuryPercent < 1e18, \"percent >= 100%\");\n ensureNonzeroAddress(newTreasuryGuardian);\n ensureNonzeroAddress(newTreasuryAddress);\n\n address oldTreasuryGuardian = treasuryGuardian;\n address oldTreasuryAddress = treasuryAddress;\n uint256 oldTreasuryPercent = treasuryPercent;\n\n treasuryGuardian = newTreasuryGuardian;\n treasuryAddress = newTreasuryAddress;\n treasuryPercent = newTreasuryPercent;\n\n emit NewTreasuryGuardian(oldTreasuryGuardian, newTreasuryGuardian);\n emit NewTreasuryAddress(oldTreasuryAddress, newTreasuryAddress);\n emit NewTreasuryPercent(oldTreasuryPercent, newTreasuryPercent);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Venus Distribution ***/\n\n /**\n * @dev Set ComptrollerLens contract address\n * @param comptrollerLens_ The new ComptrollerLens contract address to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptrollerLens(\n ComptrollerLensInterface comptrollerLens_\n ) external compareAddress(address(comptrollerLens), address(comptrollerLens_)) returns (uint256) {\n ensureAdmin();\n ensureNonzeroAddress(address(comptrollerLens_));\n address oldComptrollerLens = address(comptrollerLens);\n comptrollerLens = comptrollerLens_;\n emit NewComptrollerLens(oldComptrollerLens, address(comptrollerLens));\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the amount of XVS distributed per block to VAI Vault\n * @param venusVAIVaultRate_ The amount of XVS wei per block to distribute to VAI Vault\n */\n function _setVenusVAIVaultRate(\n uint256 venusVAIVaultRate_\n ) external compareValue(venusVAIVaultRate, venusVAIVaultRate_) {\n ensureAdmin();\n if (vaiVaultAddress != address(0)) {\n releaseToVault();\n }\n uint256 oldVenusVAIVaultRate = venusVAIVaultRate;\n venusVAIVaultRate = venusVAIVaultRate_;\n emit NewVenusVAIVaultRate(oldVenusVAIVaultRate, venusVAIVaultRate_);\n }\n\n /**\n * @notice Set the VAI Vault infos\n * @param vault_ The address of the VAI Vault\n * @param releaseStartBlock_ The start block of release to VAI Vault\n * @param minReleaseAmount_ The minimum release amount to VAI Vault\n */\n function _setVAIVaultInfo(\n address vault_,\n uint256 releaseStartBlock_,\n uint256 minReleaseAmount_\n ) external compareAddress(vaiVaultAddress, vault_) {\n ensureAdmin();\n ensureNonzeroAddress(vault_);\n if (vaiVaultAddress != address(0)) {\n releaseToVault();\n }\n\n vaiVaultAddress = vault_;\n releaseStartBlock = releaseStartBlock_;\n minReleaseAmount = minReleaseAmount_;\n emit NewVAIVaultInfo(vault_, releaseStartBlock_, minReleaseAmount_);\n }\n\n /**\n * @notice Sets the prime token contract for the comptroller\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPrimeToken(IPrime _prime) external returns (uint) {\n ensureAdmin();\n ensureNonzeroAddress(address(_prime));\n\n IPrime oldPrime = prime;\n prime = _prime;\n emit NewPrimeToken(oldPrime, _prime);\n\n return uint(Error.NO_ERROR);\n }\n\n /** @notice Enables forced liquidations for a market. If forced liquidation is enabled,\n * borrows in the market may be liquidated regardless of the account liquidity\n * @dev Allows a privileged role to set enable/disable forced liquidations\n * @param vTokenBorrowed Borrowed vToken\n * @param enable Whether to enable forced liquidations\n */\n function _setForcedLiquidation(address vTokenBorrowed, bool enable) external {\n ensureAllowed(\"_setForcedLiquidation(address,bool)\");\n if (vTokenBorrowed != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n isForcedLiquidationEnabled[vTokenBorrowed] = enable;\n emit IsForcedLiquidationEnabledUpdated(vTokenBorrowed, enable);\n }\n\n /**\n * @notice Enables forced liquidations for user's borrows in a certain market. If forced\n * liquidation is enabled, user's borrows in the market may be liquidated regardless of\n * the account liquidity. Forced liquidation may be enabled for a user even if it is not\n * enabled for the entire market.\n * @param borrower The address of the borrower\n * @param vTokenBorrowed Borrowed vToken\n * @param enable Whether to enable forced liquidations\n */\n function _setForcedLiquidationForUser(address borrower, address vTokenBorrowed, bool enable) external {\n ensureAllowed(\"_setForcedLiquidationForUser(address,address,bool)\");\n if (vTokenBorrowed != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n isForcedLiquidationEnabledForUser[borrower][vTokenBorrowed] = enable;\n emit IsForcedLiquidationEnabledForUserUpdated(borrower, vTokenBorrowed, enable);\n }\n\n /**\n * @notice Set the address of the XVS token\n * @param xvs_ The address of the XVS token\n */\n function _setXVSToken(address xvs_) external {\n ensureAdmin();\n ensureNonzeroAddress(xvs_);\n\n emit NewXVSToken(xvs, xvs_);\n xvs = xvs_;\n }\n\n /**\n * @notice Set the address of the XVS vToken\n * @param xvsVToken_ The address of the XVS vToken\n */\n function _setXVSVToken(address xvsVToken_) external {\n ensureAdmin();\n ensureNonzeroAddress(xvsVToken_);\n\n address underlying = VToken(xvsVToken_).underlying();\n require(underlying == xvs, \"invalid xvs vtoken address\");\n\n emit NewXVSVToken(xvsVToken, xvsVToken_);\n xvsVToken = xvsVToken_;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/XVSRewardsHelper.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\n\n/**\n * @title XVSRewardsHelper\n * @author Venus\n * @dev This contract contains internal functions used in RewardFacet and PolicyFacet\n * @notice This facet contract contains the shared functions used by the RewardFacet and PolicyFacet\n */\ncontract XVSRewardsHelper is FacetBase {\n /// @notice Emitted when XVS is distributed to a borrower\n event DistributedBorrowerVenus(\n VToken indexed vToken,\n address indexed borrower,\n uint256 venusDelta,\n uint256 venusBorrowIndex\n );\n\n /// @notice Emitted when XVS is distributed to a supplier\n event DistributedSupplierVenus(\n VToken indexed vToken,\n address indexed supplier,\n uint256 venusDelta,\n uint256 venusSupplyIndex\n );\n\n /**\n * @notice Accrue XVS to the market by updating the borrow index\n * @param vToken The market whose borrow index to update\n */\n function updateVenusBorrowIndex(address vToken, Exp memory marketBorrowIndex) internal {\n VenusMarketState storage borrowState = venusBorrowState[vToken];\n uint256 borrowSpeed = venusBorrowSpeeds[vToken];\n uint32 blockNumber = getBlockNumberAsUint32();\n uint256 deltaBlocks = sub_(blockNumber, borrowState.block);\n if (deltaBlocks != 0 && borrowSpeed != 0) {\n uint256 borrowAmount = div_(VToken(vToken).totalBorrows(), marketBorrowIndex);\n uint256 accruedVenus = mul_(deltaBlocks, borrowSpeed);\n Double memory ratio = borrowAmount != 0 ? fraction(accruedVenus, borrowAmount) : Double({ mantissa: 0 });\n borrowState.index = safe224(add_(Double({ mantissa: borrowState.index }), ratio).mantissa, \"224\");\n borrowState.block = blockNumber;\n } else if (deltaBlocks != 0) {\n borrowState.block = blockNumber;\n }\n }\n\n /**\n * @notice Accrue XVS to the market by updating the supply index\n * @param vToken The market whose supply index to update\n */\n function updateVenusSupplyIndex(address vToken) internal {\n VenusMarketState storage supplyState = venusSupplyState[vToken];\n uint256 supplySpeed = venusSupplySpeeds[vToken];\n uint32 blockNumber = getBlockNumberAsUint32();\n\n uint256 deltaBlocks = sub_(blockNumber, supplyState.block);\n if (deltaBlocks != 0 && supplySpeed != 0) {\n uint256 supplyTokens = VToken(vToken).totalSupply();\n uint256 accruedVenus = mul_(deltaBlocks, supplySpeed);\n Double memory ratio = supplyTokens != 0 ? fraction(accruedVenus, supplyTokens) : Double({ mantissa: 0 });\n supplyState.index = safe224(add_(Double({ mantissa: supplyState.index }), ratio).mantissa, \"224\");\n supplyState.block = blockNumber;\n } else if (deltaBlocks != 0) {\n supplyState.block = blockNumber;\n }\n }\n\n /**\n * @notice Calculate XVS accrued by a supplier and possibly transfer it to them\n * @param vToken The market in which the supplier is interacting\n * @param supplier The address of the supplier to distribute XVS to\n */\n function distributeSupplierVenus(address vToken, address supplier) internal {\n if (address(vaiVaultAddress) != address(0)) {\n releaseToVault();\n }\n uint256 supplyIndex = venusSupplyState[vToken].index;\n uint256 supplierIndex = venusSupplierIndex[vToken][supplier];\n // Update supplier's index to the current index since we are distributing accrued XVS\n venusSupplierIndex[vToken][supplier] = supplyIndex;\n if (supplierIndex == 0 && supplyIndex >= venusInitialIndex) {\n // Covers the case where users supplied tokens before the market's supply state index was set.\n // Rewards the user with XVS accrued from the start of when supplier rewards were first\n // set for the market.\n supplierIndex = venusInitialIndex;\n }\n // Calculate change in the cumulative sum of the XVS per vToken accrued\n Double memory deltaIndex = Double({ mantissa: sub_(supplyIndex, supplierIndex) });\n // Multiply of supplierTokens and supplierDelta\n uint256 supplierDelta = mul_(VToken(vToken).balanceOf(supplier), deltaIndex);\n // Addition of supplierAccrued and supplierDelta\n venusAccrued[supplier] = add_(venusAccrued[supplier], supplierDelta);\n emit DistributedSupplierVenus(VToken(vToken), supplier, supplierDelta, supplyIndex);\n }\n\n /**\n * @notice Calculate XVS accrued by a borrower and possibly transfer it to them\n * @dev Borrowers will not begin to accrue until after the first interaction with the protocol\n * @param vToken The market in which the borrower is interacting\n * @param borrower The address of the borrower to distribute XVS to\n */\n function distributeBorrowerVenus(address vToken, address borrower, Exp memory marketBorrowIndex) internal {\n if (address(vaiVaultAddress) != address(0)) {\n releaseToVault();\n }\n uint256 borrowIndex = venusBorrowState[vToken].index;\n uint256 borrowerIndex = venusBorrowerIndex[vToken][borrower];\n // Update borrowers's index to the current index since we are distributing accrued XVS\n venusBorrowerIndex[vToken][borrower] = borrowIndex;\n if (borrowerIndex == 0 && borrowIndex >= venusInitialIndex) {\n // Covers the case where users borrowed tokens before the market's borrow state index was set.\n // Rewards the user with XVS accrued from the start of when borrower rewards were first\n // set for the market.\n borrowerIndex = venusInitialIndex;\n }\n // Calculate change in the cumulative sum of the XVS per borrowed unit accrued\n Double memory deltaIndex = Double({ mantissa: sub_(borrowIndex, borrowerIndex) });\n uint256 borrowerDelta = mul_(div_(VToken(vToken).borrowBalanceStored(borrower), marketBorrowIndex), deltaIndex);\n venusAccrued[borrower] = add_(venusAccrued[borrower], borrowerDelta);\n emit DistributedBorrowerVenus(VToken(vToken), borrower, borrowerDelta, borrowIndex);\n }\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IDiamondCut.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\ninterface IDiamondCut {\n enum FacetCutAction {\n Add,\n Replace,\n Remove\n }\n // Add=0, Replace=1, Remove=2\n\n struct FacetCut {\n address facetAddress;\n FacetCutAction action;\n bytes4[] functionSelectors;\n }\n\n /// @notice Add/replace/remove any number of functions and optionally execute\n /// a function with delegatecall\n /// @param _diamondCut Contains the facet addresses and function selectors\n function diamondCut(FacetCut[] calldata _diamondCut) external;\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IMarketFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\ninterface IMarketFacet {\n function isComptroller() external pure returns (bool);\n\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256);\n\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256);\n\n function checkMembership(address account, VToken vToken) external view returns (bool);\n\n function enterMarkets(address[] calldata vTokens) external returns (uint256[] memory);\n\n function exitMarket(address vToken) external returns (uint256);\n\n function _supportMarket(VToken vToken) external returns (uint256);\n\n function getAssetsIn(address account) external view returns (VToken[] memory);\n\n function getAllMarkets() external view returns (VToken[] memory);\n\n function updateDelegate(address delegate, bool allowBorrows) external;\n\n function unlistMarket(address market) external returns (uint256);\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IPolicyFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\ninterface IPolicyFacet {\n function mintAllowed(address vToken, address minter, uint256 mintAmount) external returns (uint256);\n\n function mintVerify(address vToken, address minter, uint256 mintAmount, uint256 mintTokens) external;\n\n function redeemAllowed(address vToken, address redeemer, uint256 redeemTokens) external returns (uint256);\n\n function redeemVerify(address vToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\n\n function borrowAllowed(address vToken, address borrower, uint256 borrowAmount) external returns (uint256);\n\n function borrowVerify(address vToken, address borrower, uint256 borrowAmount) external;\n\n function repayBorrowAllowed(\n address vToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function repayBorrowVerify(\n address vToken,\n address payer,\n address borrower,\n uint256 repayAmount,\n uint256 borrowerIndex\n ) external;\n\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external view returns (uint256);\n\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount,\n uint256 seizeTokens\n ) external;\n\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external;\n\n function transferAllowed(\n address vToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external returns (uint256);\n\n function transferVerify(address vToken, address src, address dst, uint256 transferTokens) external;\n\n function getAccountLiquidity(address account) external view returns (uint256, uint256, uint256);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) external view returns (uint256, uint256, uint256);\n\n function _setVenusSpeeds(\n VToken[] calldata vTokens,\n uint256[] calldata supplySpeeds,\n uint256[] calldata borrowSpeeds\n ) external;\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IRewardFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ComptrollerTypes } from \"../../ComptrollerStorage.sol\";\n\ninterface IRewardFacet {\n function claimVenus(address holder) external;\n\n function claimVenus(address holder, VToken[] calldata vTokens) external;\n\n function claimVenus(address[] calldata holders, VToken[] calldata vTokens, bool borrowers, bool suppliers) external;\n\n function claimVenusAsCollateral(address holder) external;\n\n function _grantXVS(address recipient, uint256 amount) external;\n\n function getXVSAddress() external view returns (address);\n\n function getXVSVTokenAddress() external view returns (address);\n\n function actionPaused(address market, ComptrollerTypes.Action action) external view returns (bool);\n\n function claimVenus(\n address[] calldata holders,\n VToken[] calldata vTokens,\n bool borrowers,\n bool suppliers,\n bool collateral\n ) external;\n function seizeVenus(address[] calldata holders, address recipient) external returns (uint256);\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/ISetterFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { PriceOracle } from \"../../../Oracle/PriceOracle.sol\";\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ComptrollerTypes } from \"../../ComptrollerStorage.sol\";\nimport { VAIControllerInterface } from \"../../../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerLensInterface } from \"../../../Comptroller/ComptrollerLensInterface.sol\";\nimport { IPrime } from \"../../../Tokens/Prime/IPrime.sol\";\n\ninterface ISetterFacet {\n function _setPriceOracle(PriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setAccessControl(address newAccessControlAddress) external returns (uint256);\n\n function _setCollateralFactor(VToken vToken, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _setLiquidatorContract(address newLiquidatorContract_) external;\n\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\n\n function _setMarketBorrowCaps(VToken[] calldata vTokens, uint256[] calldata newBorrowCaps) external;\n\n function _setMarketSupplyCaps(VToken[] calldata vTokens, uint256[] calldata newSupplyCaps) external;\n\n function _setProtocolPaused(bool state) external returns (bool);\n\n function _setActionsPaused(\n address[] calldata markets,\n ComptrollerTypes.Action[] calldata actions,\n bool paused\n ) external;\n\n function _setVAIController(VAIControllerInterface vaiController_) external returns (uint256);\n\n function _setVAIMintRate(uint256 newVAIMintRate) external returns (uint256);\n\n function setMintedVAIOf(address owner, uint256 amount) external returns (uint256);\n\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256);\n\n function _setComptrollerLens(ComptrollerLensInterface comptrollerLens_) external returns (uint256);\n\n function _setVenusVAIVaultRate(uint256 venusVAIVaultRate_) external;\n\n function _setVAIVaultInfo(address vault_, uint256 releaseStartBlock_, uint256 minReleaseAmount_) external;\n\n function _setForcedLiquidation(address vToken, bool enable) external;\n\n function _setPrimeToken(IPrime _prime) external returns (uint);\n\n function _setForcedLiquidationForUser(address borrower, address vTokenBorrowed, bool enable) external;\n\n function _setXVSToken(address xvs_) external;\n\n function _setXVSVToken(address xvsVToken_) external;\n}\n" + }, + "contracts/Comptroller/Unitroller.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerStorage.sol\";\nimport \"../Utils/ErrorReporter.sol\";\n\n/**\n * @title ComptrollerCore\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\n * VTokens should reference this contract as their comptroller.\n */\ncontract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {\n /**\n * @notice Emitted when pendingComptrollerImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingComptrollerImplementation;\n\n pendingComptrollerImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation and pendingImplementation ≠ address(0)\n if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = comptrollerImplementation;\n address oldPendingImplementation = pendingComptrollerImplementation;\n\n comptrollerImplementation = pendingComptrollerImplementation;\n\n pendingComptrollerImplementation = address(0);\n\n emit NewImplementation(oldImplementation, comptrollerImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = comptrollerImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Governance/VTreasury.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/IBEP20.sol\";\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/Ownable.sol\";\n\n/**\n * @title VTreasury\n * @author Venus\n * @notice Protocol treasury that holds tokens owned by Venus\n */\ncontract VTreasury is Ownable {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n // WithdrawTreasuryBEP20 Event\n event WithdrawTreasuryBEP20(address tokenAddress, uint256 withdrawAmount, address withdrawAddress);\n\n // WithdrawTreasuryBNB Event\n event WithdrawTreasuryBNB(uint256 withdrawAmount, address withdrawAddress);\n\n /**\n * @notice To receive BNB\n */\n function() external payable {}\n\n /**\n * @notice Withdraw Treasury BEP20 Tokens, Only owner call it\n * @param tokenAddress The address of treasury token\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n */\n function withdrawTreasuryBEP20(\n address tokenAddress,\n uint256 withdrawAmount,\n address withdrawAddress\n ) external onlyOwner {\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury Token Balance\n uint256 treasuryBalance = IBEP20(tokenAddress).balanceOf(address(this));\n\n // Check Withdraw Amount\n if (withdrawAmount > treasuryBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = treasuryBalance;\n }\n\n // Transfer BEP20 Token to withdrawAddress\n IBEP20(tokenAddress).safeTransfer(withdrawAddress, actualWithdrawAmount);\n\n emit WithdrawTreasuryBEP20(tokenAddress, actualWithdrawAmount, withdrawAddress);\n }\n\n /**\n * @notice Withdraw Treasury BNB, Only owner call it\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n */\n function withdrawTreasuryBNB(uint256 withdrawAmount, address payable withdrawAddress) external payable onlyOwner {\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury BNB Balance\n uint256 bnbBalance = address(this).balance;\n\n // Check Withdraw Amount\n if (withdrawAmount > bnbBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = bnbBalance;\n }\n // Transfer BNB to withdrawAddress\n withdrawAddress.transfer(actualWithdrawAmount);\n\n emit WithdrawTreasuryBNB(actualWithdrawAmount, withdrawAddress);\n }\n}\n" + }, + "contracts/InterestRateModels/InterestRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Venus's InterestRateModel Interface\n * @author Venus\n */\ncontract InterestRateModel {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) external view returns (uint);\n}\n" + }, + "contracts/InterestRateModels/JumpRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Venus's JumpRateModel Contract\n * @author Venus\n */\ncontract JumpRateModel is InterestRateModel {\n using SafeMath for uint;\n\n event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock, uint jumpMultiplierPerBlock, uint kink);\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint public constant blocksPerYear = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint public baseRatePerBlock;\n\n /**\n * @notice The multiplierPerBlock after hitting a specified utilization point\n */\n uint public jumpMultiplierPerBlock;\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n uint public kink;\n\n /**\n * @notice Construct an interest rate model\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\n * @param kink_ The utilization point at which the jump multiplier is applied\n */\n constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) public {\n baseRatePerBlock = baseRatePerYear.div(blocksPerYear);\n multiplierPerBlock = multiplierPerYear.div(blocksPerYear);\n jumpMultiplierPerBlock = jumpMultiplierPerYear.div(blocksPerYear);\n kink = kink_;\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {\n uint util = utilizationRate(cash, borrows, reserves);\n\n if (util <= kink) {\n return util.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n } else {\n uint normalRate = kink.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n uint excessUtil = util.sub(kink);\n return excessUtil.mul(jumpMultiplierPerBlock).div(1e18).add(normalRate);\n }\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) public view returns (uint) {\n uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);\n uint borrowRate = getBorrowRate(cash, borrows, reserves);\n uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);\n return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);\n }\n}\n" + }, + "contracts/InterestRateModels/WhitePaperInterestRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Venus's WhitePaperInterestRateModel Contract\n * @author Venus\n * @notice The parameterized model described in section 2.4 of the original Venus Protocol whitepaper\n */\ncontract WhitePaperInterestRateModel is InterestRateModel {\n using SafeMath for uint;\n\n event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock);\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint public constant blocksPerYear = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint public baseRatePerBlock;\n\n /**\n * @notice Construct an interest rate model\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n */\n constructor(uint baseRatePerYear, uint multiplierPerYear) public {\n baseRatePerBlock = baseRatePerYear.div(blocksPerYear);\n multiplierPerBlock = multiplierPerYear.div(blocksPerYear);\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {\n uint ur = utilizationRate(cash, borrows, reserves);\n return ur.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) public view returns (uint) {\n uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);\n uint borrowRate = getBorrowRate(cash, borrows, reserves);\n uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);\n return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);\n }\n}\n" + }, + "contracts/Lens/ComptrollerLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VBep20.sol\";\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { ExponentialNoError } from \"../Utils/ExponentialNoError.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Utils/ErrorReporter.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Comptroller/ComptrollerLensInterface.sol\";\nimport \"../Tokens/VAI/VAIControllerInterface.sol\";\n\n/**\n * @title ComptrollerLens Contract\n * @author Venus\n * @notice The ComptrollerLens contract has functions to get the number of tokens that\n * can be seized through liquidation, hypothetical account liquidity and shortfall of an account.\n */\ncontract ComptrollerLens is ComptrollerLensInterface, ComptrollerErrorReporter, ExponentialNoError {\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountLiquidityLocalVars {\n uint sumCollateral;\n uint sumBorrowPlusEffects;\n uint vTokenBalance;\n uint borrowBalance;\n uint exchangeRateMantissa;\n uint oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n }\n\n /**\n * @notice Computes the number of collateral tokens to be seized in a liquidation event\n * @param comptroller Address of comptroller\n * @param vTokenBorrowed Address of the borrowed vToken\n * @param vTokenCollateral Address of collateral for the borrow\n * @param actualRepayAmount Repayment amount i.e amount to be repaid of total borrowed amount\n * @return A tuple of error code, and tokens to seize\n */\n function liquidateCalculateSeizeTokens(\n address comptroller,\n address vTokenBorrowed,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint) {\n /* Read oracle prices for borrowed and collateral markets */\n uint priceBorrowedMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenBorrowed)\n );\n uint priceCollateralMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenCollateral)\n );\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n uint exchangeRateMantissa = VToken(vTokenCollateral).exchangeRateStored(); // Note: reverts on error\n uint seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n numerator = mul_(\n Exp({ mantissa: ComptrollerInterface(comptroller).liquidationIncentiveMantissa() }),\n Exp({ mantissa: priceBorrowedMantissa })\n );\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n\n return (uint(Error.NO_ERROR), seizeTokens);\n }\n\n /**\n * @notice Computes the number of VAI tokens to be seized in a liquidation event\n * @param comptroller Address of comptroller\n * @param vTokenCollateral Address of collateral for vToken\n * @param actualRepayAmount Repayment amount i.e amount to be repaid of the total borrowed amount\n * @return A tuple of error code, and tokens to seize\n */\n function liquidateVAICalculateSeizeTokens(\n address comptroller,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint) {\n /* Read oracle prices for borrowed and collateral markets */\n uint priceBorrowedMantissa = 1e18; // Note: this is VAI\n uint priceCollateralMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenCollateral)\n );\n if (priceCollateralMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n uint exchangeRateMantissa = VToken(vTokenCollateral).exchangeRateStored(); // Note: reverts on error\n uint seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n numerator = mul_(\n Exp({ mantissa: ComptrollerInterface(comptroller).liquidationIncentiveMantissa() }),\n Exp({ mantissa: priceBorrowedMantissa })\n );\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n\n return (uint(Error.NO_ERROR), seizeTokens);\n }\n\n /**\n * @notice Computes the hypothetical liquidity and shortfall of an account given a hypothetical borrow\n * A snapshot of the account is taken and the total borrow amount of the account is calculated\n * @param comptroller Address of comptroller\n * @param account Address of the borrowed vToken\n * @param vTokenModify Address of collateral for vToken\n * @param redeemTokens Number of vTokens being redeemed\n * @param borrowAmount Amount borrowed\n * @return Returns a tuple of error code, liquidity, and shortfall\n */\n function getHypotheticalAccountLiquidity(\n address comptroller,\n address account,\n VToken vTokenModify,\n uint redeemTokens,\n uint borrowAmount\n ) external view returns (uint, uint, uint) {\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\n uint oErr;\n\n // For each asset the account is in\n VToken[] memory assets = ComptrollerInterface(comptroller).getAssetsIn(account);\n uint assetsCount = assets.length;\n for (uint i = 0; i < assetsCount; ++i) {\n VToken asset = assets[i];\n\n // Read the balances and exchange rate from the vToken\n (oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = asset.getAccountSnapshot(\n account\n );\n if (oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (uint(Error.SNAPSHOT_ERROR), 0, 0);\n }\n (, uint collateralFactorMantissa) = ComptrollerInterface(comptroller).markets(address(asset));\n vars.collateralFactor = Exp({ mantissa: collateralFactorMantissa });\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(asset);\n if (vars.oraclePriceMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0, 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> bnb (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n\n // sumCollateral += tokensToDenom * vTokenBalance\n vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.vTokenBalance, vars.sumCollateral);\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n\n // Calculate effects of interacting with vTokenModify\n if (asset == vTokenModify) {\n // redeem effect\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.tokensToDenom,\n redeemTokens,\n vars.sumBorrowPlusEffects\n );\n\n // borrow effect\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n borrowAmount,\n vars.sumBorrowPlusEffects\n );\n }\n }\n\n VAIControllerInterface vaiController = ComptrollerInterface(comptroller).vaiController();\n\n if (address(vaiController) != address(0)) {\n vars.sumBorrowPlusEffects = add_(vars.sumBorrowPlusEffects, vaiController.getVAIRepayAmount(account));\n }\n\n // These are safe, as the underflow condition is checked first\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\n return (uint(Error.NO_ERROR), vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\n } else {\n return (uint(Error.NO_ERROR), 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\n }\n }\n}\n" + }, + "contracts/Lens/SnapshotLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { ExponentialNoError } from \"../Utils/ExponentialNoError.sol\";\nimport \"../Utils/SafeMath.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Tokens/VTokens/VBep20.sol\";\n\ncontract SnapshotLens is ExponentialNoError {\n using SafeMath for uint256;\n\n struct AccountSnapshot {\n address account;\n string assetName;\n address vTokenAddress;\n address underlyingAssetAddress;\n uint256 supply;\n uint256 supplyInUsd;\n uint256 collateral;\n uint256 borrows;\n uint256 borrowsInUsd;\n uint256 assetPrice;\n uint256 accruedInterest;\n uint vTokenDecimals;\n uint underlyingDecimals;\n uint exchangeRate;\n bool isACollateral;\n }\n\n /** Snapshot calculation **/\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account snapshot.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountSnapshotLocalVars {\n uint collateral;\n uint vTokenBalance;\n uint borrowBalance;\n uint borrowsInUsd;\n uint balanceOfUnderlying;\n uint supplyInUsd;\n uint exchangeRateMantissa;\n uint oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n bool isACollateral;\n }\n\n function getAccountSnapshot(\n address payable account,\n address comptrollerAddress\n ) public returns (AccountSnapshot[] memory) {\n // For each asset the account is in\n VToken[] memory assets = ComptrollerInterface(comptrollerAddress).getAllMarkets();\n AccountSnapshot[] memory accountSnapshots = new AccountSnapshot[](assets.length);\n for (uint256 i = 0; i < assets.length; ++i) {\n accountSnapshots[i] = getAccountSnapshot(account, comptrollerAddress, assets[i]);\n }\n return accountSnapshots;\n }\n\n function isACollateral(address account, address asset, address comptrollerAddress) public view returns (bool) {\n VToken[] memory assetsAsCollateral = ComptrollerInterface(comptrollerAddress).getAssetsIn(account);\n for (uint256 j = 0; j < assetsAsCollateral.length; ++j) {\n if (address(assetsAsCollateral[j]) == asset) {\n return true;\n }\n }\n\n return false;\n }\n\n function getAccountSnapshot(\n address payable account,\n address comptrollerAddress,\n VToken vToken\n ) public returns (AccountSnapshot memory) {\n AccountSnapshotLocalVars memory vars; // Holds all our calculation results\n uint oErr;\n\n // Read the balances and exchange rate from the vToken\n (oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vToken.getAccountSnapshot(account);\n require(oErr == 0, \"Snapshot Error\");\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n (, uint collateralFactorMantissa) = ComptrollerInterface(comptrollerAddress).markets(address(vToken));\n vars.collateralFactor = Exp({ mantissa: collateralFactorMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = ComptrollerInterface(comptrollerAddress).oracle().getUnderlyingPrice(vToken);\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> bnb (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n\n //Collateral = tokensToDenom * vTokenBalance\n vars.collateral = mul_ScalarTruncate(vars.tokensToDenom, vars.vTokenBalance);\n\n vars.balanceOfUnderlying = vToken.balanceOfUnderlying(account);\n vars.supplyInUsd = mul_ScalarTruncate(vars.oraclePrice, vars.balanceOfUnderlying);\n\n vars.borrowsInUsd = mul_ScalarTruncate(vars.oraclePrice, vars.borrowBalance);\n\n address underlyingAssetAddress;\n uint underlyingDecimals;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n underlyingAssetAddress = address(0);\n underlyingDecimals = 18;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n underlyingAssetAddress = vBep20.underlying();\n underlyingDecimals = EIP20Interface(vBep20.underlying()).decimals();\n }\n\n vars.isACollateral = isACollateral(account, address(vToken), comptrollerAddress);\n\n return\n AccountSnapshot({\n account: account,\n assetName: vToken.name(),\n vTokenAddress: address(vToken),\n underlyingAssetAddress: underlyingAssetAddress,\n supply: vars.balanceOfUnderlying,\n supplyInUsd: vars.supplyInUsd,\n collateral: vars.collateral,\n borrows: vars.borrowBalance,\n borrowsInUsd: vars.borrowsInUsd,\n assetPrice: vars.oraclePriceMantissa,\n accruedInterest: vToken.borrowIndex(),\n vTokenDecimals: vToken.decimals(),\n underlyingDecimals: underlyingDecimals,\n exchangeRate: vToken.exchangeRateCurrent(),\n isACollateral: vars.isACollateral\n });\n }\n\n // utilities\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/Lens/VenusLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VBep20.sol\";\nimport \"../Tokens/VTokens/VToken.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Tokens/XVS/XVS.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Utils/SafeMath.sol\";\nimport { ComptrollerTypes } from \"../Comptroller/ComptrollerStorage.sol\";\n\ncontract VenusLens is ExponentialNoError {\n using SafeMath for uint;\n\n /// @notice Blocks Per Day\n uint public constant BLOCKS_PER_DAY = 28800;\n\n /// @notice Total actions available on VToken\n uint public constant VTOKEN_ACTIONS = 8;\n\n struct VenusMarketState {\n uint224 index;\n uint32 block;\n }\n\n struct VTokenMetadata {\n address vToken;\n uint exchangeRateCurrent;\n uint supplyRatePerBlock;\n uint borrowRatePerBlock;\n uint reserveFactorMantissa;\n uint totalBorrows;\n uint totalReserves;\n uint totalSupply;\n uint totalCash;\n bool isListed;\n uint collateralFactorMantissa;\n address underlyingAssetAddress;\n uint vTokenDecimals;\n uint underlyingDecimals;\n uint venusSupplySpeed;\n uint venusBorrowSpeed;\n uint dailySupplyXvs;\n uint dailyBorrowXvs;\n uint pausedActions;\n }\n\n struct VTokenBalances {\n address vToken;\n uint balanceOf;\n uint borrowBalanceCurrent;\n uint balanceOfUnderlying;\n uint tokenBalance;\n uint tokenAllowance;\n }\n\n struct VTokenUnderlyingPrice {\n address vToken;\n uint underlyingPrice;\n }\n\n struct AccountLimits {\n VToken[] markets;\n uint liquidity;\n uint shortfall;\n }\n\n struct XVSBalanceMetadata {\n uint balance;\n uint votes;\n address delegate;\n }\n\n struct XVSBalanceMetadataExt {\n uint balance;\n uint votes;\n address delegate;\n uint allocated;\n }\n\n struct VenusVotes {\n uint blockNumber;\n uint votes;\n }\n\n struct ClaimVenusLocalVariables {\n uint totalRewards;\n uint224 borrowIndex;\n uint32 borrowBlock;\n uint224 supplyIndex;\n uint32 supplyBlock;\n }\n\n /**\n * @dev Struct for Pending Rewards for per market\n */\n struct PendingReward {\n address vTokenAddress;\n uint256 amount;\n }\n\n /**\n * @dev Struct for Reward of a single reward token.\n */\n struct RewardSummary {\n address distributorAddress;\n address rewardTokenAddress;\n uint256 totalRewards;\n PendingReward[] pendingRewards;\n }\n\n /**\n * @notice Query the metadata of a vToken by its address\n * @param vToken The address of the vToken to fetch VTokenMetadata\n * @return VTokenMetadata struct with vToken supply and borrow information.\n */\n function vTokenMetadata(VToken vToken) public returns (VTokenMetadata memory) {\n uint exchangeRateCurrent = vToken.exchangeRateCurrent();\n address comptrollerAddress = address(vToken.comptroller());\n ComptrollerInterface comptroller = ComptrollerInterface(comptrollerAddress);\n (bool isListed, uint collateralFactorMantissa) = comptroller.markets(address(vToken));\n address underlyingAssetAddress;\n uint underlyingDecimals;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n underlyingAssetAddress = address(0);\n underlyingDecimals = 18;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n underlyingAssetAddress = vBep20.underlying();\n underlyingDecimals = EIP20Interface(vBep20.underlying()).decimals();\n }\n\n uint venusSupplySpeedPerBlock = comptroller.venusSupplySpeeds(address(vToken));\n uint venusBorrowSpeedPerBlock = comptroller.venusBorrowSpeeds(address(vToken));\n\n uint256 pausedActions;\n\n for (uint8 i; i <= VTOKEN_ACTIONS; ++i) {\n uint256 paused = comptroller.actionPaused(address(vToken), ComptrollerTypes.Action(i)) ? 1 : 0;\n pausedActions |= paused << i;\n }\n\n return\n VTokenMetadata({\n vToken: address(vToken),\n exchangeRateCurrent: exchangeRateCurrent,\n supplyRatePerBlock: vToken.supplyRatePerBlock(),\n borrowRatePerBlock: vToken.borrowRatePerBlock(),\n reserveFactorMantissa: vToken.reserveFactorMantissa(),\n totalBorrows: vToken.totalBorrows(),\n totalReserves: vToken.totalReserves(),\n totalSupply: vToken.totalSupply(),\n totalCash: vToken.getCash(),\n isListed: isListed,\n collateralFactorMantissa: collateralFactorMantissa,\n underlyingAssetAddress: underlyingAssetAddress,\n vTokenDecimals: vToken.decimals(),\n underlyingDecimals: underlyingDecimals,\n venusSupplySpeed: venusSupplySpeedPerBlock,\n venusBorrowSpeed: venusBorrowSpeedPerBlock,\n dailySupplyXvs: venusSupplySpeedPerBlock.mul(BLOCKS_PER_DAY),\n dailyBorrowXvs: venusBorrowSpeedPerBlock.mul(BLOCKS_PER_DAY),\n pausedActions: pausedActions\n });\n }\n\n /**\n * @notice Get VTokenMetadata for an array of vToken addresses\n * @param vTokens Array of vToken addresses to fetch VTokenMetadata\n * @return Array of structs with vToken supply and borrow information.\n */\n function vTokenMetadataAll(VToken[] calldata vTokens) external returns (VTokenMetadata[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenMetadata[] memory res = new VTokenMetadata[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenMetadata(vTokens[i]);\n }\n return res;\n }\n\n /**\n * @notice Get amount of XVS distributed daily to an account\n * @param account Address of account to fetch the daily XVS distribution\n * @param comptrollerAddress Address of the comptroller proxy\n * @return Amount of XVS distributed daily to an account\n */\n function getDailyXVS(address payable account, address comptrollerAddress) external returns (uint) {\n ComptrollerInterface comptrollerInstance = ComptrollerInterface(comptrollerAddress);\n VToken[] memory vTokens = comptrollerInstance.getAllMarkets();\n uint dailyXvsPerAccount = 0;\n\n for (uint i = 0; i < vTokens.length; i++) {\n VToken vToken = vTokens[i];\n if (!compareStrings(vToken.symbol(), \"vUST\") && !compareStrings(vToken.symbol(), \"vLUNA\")) {\n VTokenMetadata memory metaDataItem = vTokenMetadata(vToken);\n\n //get balanceOfUnderlying and borrowBalanceCurrent from vTokenBalance\n VTokenBalances memory vTokenBalanceInfo = vTokenBalances(vToken, account);\n\n VTokenUnderlyingPrice memory underlyingPriceResponse = vTokenUnderlyingPrice(vToken);\n uint underlyingPrice = underlyingPriceResponse.underlyingPrice;\n Exp memory underlyingPriceMantissa = Exp({ mantissa: underlyingPrice });\n\n //get dailyXvsSupplyMarket\n uint dailyXvsSupplyMarket = 0;\n uint supplyInUsd = mul_ScalarTruncate(underlyingPriceMantissa, vTokenBalanceInfo.balanceOfUnderlying);\n uint marketTotalSupply = (metaDataItem.totalSupply.mul(metaDataItem.exchangeRateCurrent)).div(1e18);\n uint marketTotalSupplyInUsd = mul_ScalarTruncate(underlyingPriceMantissa, marketTotalSupply);\n\n if (marketTotalSupplyInUsd > 0) {\n dailyXvsSupplyMarket = (metaDataItem.dailySupplyXvs.mul(supplyInUsd)).div(marketTotalSupplyInUsd);\n }\n\n //get dailyXvsBorrowMarket\n uint dailyXvsBorrowMarket = 0;\n uint borrowsInUsd = mul_ScalarTruncate(underlyingPriceMantissa, vTokenBalanceInfo.borrowBalanceCurrent);\n uint marketTotalBorrowsInUsd = mul_ScalarTruncate(underlyingPriceMantissa, metaDataItem.totalBorrows);\n\n if (marketTotalBorrowsInUsd > 0) {\n dailyXvsBorrowMarket = (metaDataItem.dailyBorrowXvs.mul(borrowsInUsd)).div(marketTotalBorrowsInUsd);\n }\n\n dailyXvsPerAccount += dailyXvsSupplyMarket + dailyXvsBorrowMarket;\n }\n }\n\n return dailyXvsPerAccount;\n }\n\n /**\n * @notice Get the current vToken balance (outstanding borrows) for an account\n * @param vToken Address of the token to check the balance of\n * @param account Account address to fetch the balance of\n * @return VTokenBalances with token balance information\n */\n function vTokenBalances(VToken vToken, address payable account) public returns (VTokenBalances memory) {\n uint balanceOf = vToken.balanceOf(account);\n uint borrowBalanceCurrent = vToken.borrowBalanceCurrent(account);\n uint balanceOfUnderlying = vToken.balanceOfUnderlying(account);\n uint tokenBalance;\n uint tokenAllowance;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n tokenBalance = account.balance;\n tokenAllowance = account.balance;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n EIP20Interface underlying = EIP20Interface(vBep20.underlying());\n tokenBalance = underlying.balanceOf(account);\n tokenAllowance = underlying.allowance(account, address(vToken));\n }\n\n return\n VTokenBalances({\n vToken: address(vToken),\n balanceOf: balanceOf,\n borrowBalanceCurrent: borrowBalanceCurrent,\n balanceOfUnderlying: balanceOfUnderlying,\n tokenBalance: tokenBalance,\n tokenAllowance: tokenAllowance\n });\n }\n\n /**\n * @notice Get the current vToken balances (outstanding borrows) for all vTokens on an account\n * @param vTokens Addresses of the tokens to check the balance of\n * @param account Account address to fetch the balance of\n * @return VTokenBalances Array with token balance information\n */\n function vTokenBalancesAll(\n VToken[] calldata vTokens,\n address payable account\n ) external returns (VTokenBalances[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenBalances[] memory res = new VTokenBalances[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenBalances(vTokens[i], account);\n }\n return res;\n }\n\n /**\n * @notice Get the price for the underlying asset of a vToken\n * @param vToken address of the vToken\n * @return response struct with underlyingPrice info of vToken\n */\n function vTokenUnderlyingPrice(VToken vToken) public view returns (VTokenUnderlyingPrice memory) {\n ComptrollerInterface comptroller = ComptrollerInterface(address(vToken.comptroller()));\n PriceOracle priceOracle = comptroller.oracle();\n\n return\n VTokenUnderlyingPrice({ vToken: address(vToken), underlyingPrice: priceOracle.getUnderlyingPrice(vToken) });\n }\n\n /**\n * @notice Query the underlyingPrice of an array of vTokens\n * @param vTokens Array of vToken addresses\n * @return array of response structs with underlying price information of vTokens\n */\n function vTokenUnderlyingPriceAll(\n VToken[] calldata vTokens\n ) external view returns (VTokenUnderlyingPrice[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenUnderlyingPrice[] memory res = new VTokenUnderlyingPrice[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenUnderlyingPrice(vTokens[i]);\n }\n return res;\n }\n\n /**\n * @notice Query the account liquidity and shortfall of an account\n * @param comptroller Address of comptroller proxy\n * @param account Address of the account to query\n * @return Struct with markets user has entered, liquidity, and shortfall of the account\n */\n function getAccountLimits(\n ComptrollerInterface comptroller,\n address account\n ) public view returns (AccountLimits memory) {\n (uint errorCode, uint liquidity, uint shortfall) = comptroller.getAccountLiquidity(account);\n require(errorCode == 0, \"account liquidity error\");\n\n return AccountLimits({ markets: comptroller.getAssetsIn(account), liquidity: liquidity, shortfall: shortfall });\n }\n\n /**\n * @notice Query the XVSBalance info of an account\n * @param xvs XVS contract address\n * @param account Account address\n * @return Struct with XVS balance and voter details\n */\n function getXVSBalanceMetadata(XVS xvs, address account) external view returns (XVSBalanceMetadata memory) {\n return\n XVSBalanceMetadata({\n balance: xvs.balanceOf(account),\n votes: uint256(xvs.getCurrentVotes(account)),\n delegate: xvs.delegates(account)\n });\n }\n\n /**\n * @notice Query the XVSBalance extended info of an account\n * @param xvs XVS contract address\n * @param comptroller Comptroller proxy contract address\n * @param account Account address\n * @return Struct with XVS balance and voter details and XVS allocation\n */\n function getXVSBalanceMetadataExt(\n XVS xvs,\n ComptrollerInterface comptroller,\n address account\n ) external returns (XVSBalanceMetadataExt memory) {\n uint balance = xvs.balanceOf(account);\n comptroller.claimVenus(account);\n uint newBalance = xvs.balanceOf(account);\n uint accrued = comptroller.venusAccrued(account);\n uint total = add_(accrued, newBalance, \"sum xvs total\");\n uint allocated = sub_(total, balance, \"sub allocated\");\n\n return\n XVSBalanceMetadataExt({\n balance: balance,\n votes: uint256(xvs.getCurrentVotes(account)),\n delegate: xvs.delegates(account),\n allocated: allocated\n });\n }\n\n /**\n * @notice Query the voting power for an account at a specific list of block numbers\n * @param xvs XVS contract address\n * @param account Address of the account\n * @param blockNumbers Array of blocks to query\n * @return Array of VenusVotes structs with block number and vote count\n */\n function getVenusVotes(\n XVS xvs,\n address account,\n uint32[] calldata blockNumbers\n ) external view returns (VenusVotes[] memory) {\n VenusVotes[] memory res = new VenusVotes[](blockNumbers.length);\n for (uint i = 0; i < blockNumbers.length; i++) {\n res[i] = VenusVotes({\n blockNumber: uint256(blockNumbers[i]),\n votes: uint256(xvs.getPriorVotes(account, blockNumbers[i]))\n });\n }\n return res;\n }\n\n /**\n * @dev Queries the current supply to calculate rewards for an account\n * @param supplyState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param comptroller Address of the comptroller proxy\n */\n function updateVenusSupplyIndex(\n VenusMarketState memory supplyState,\n address vToken,\n ComptrollerInterface comptroller\n ) internal view {\n uint supplySpeed = comptroller.venusSupplySpeeds(vToken);\n uint blockNumber = block.number;\n uint deltaBlocks = sub_(blockNumber, uint(supplyState.block));\n if (deltaBlocks > 0 && supplySpeed > 0) {\n uint supplyTokens = VToken(vToken).totalSupply();\n uint venusAccrued = mul_(deltaBlocks, supplySpeed);\n Double memory ratio = supplyTokens > 0 ? fraction(venusAccrued, supplyTokens) : Double({ mantissa: 0 });\n Double memory index = add_(Double({ mantissa: supplyState.index }), ratio);\n supplyState.index = safe224(index.mantissa, \"new index overflows\");\n supplyState.block = safe32(blockNumber, \"block number overflows\");\n } else if (deltaBlocks > 0) {\n supplyState.block = safe32(blockNumber, \"block number overflows\");\n }\n }\n\n /**\n * @dev Queries the current borrow to calculate rewards for an account\n * @param borrowState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param comptroller Address of the comptroller proxy\n */\n function updateVenusBorrowIndex(\n VenusMarketState memory borrowState,\n address vToken,\n Exp memory marketBorrowIndex,\n ComptrollerInterface comptroller\n ) internal view {\n uint borrowSpeed = comptroller.venusBorrowSpeeds(vToken);\n uint blockNumber = block.number;\n uint deltaBlocks = sub_(blockNumber, uint(borrowState.block));\n if (deltaBlocks > 0 && borrowSpeed > 0) {\n uint borrowAmount = div_(VToken(vToken).totalBorrows(), marketBorrowIndex);\n uint venusAccrued = mul_(deltaBlocks, borrowSpeed);\n Double memory ratio = borrowAmount > 0 ? fraction(venusAccrued, borrowAmount) : Double({ mantissa: 0 });\n Double memory index = add_(Double({ mantissa: borrowState.index }), ratio);\n borrowState.index = safe224(index.mantissa, \"new index overflows\");\n borrowState.block = safe32(blockNumber, \"block number overflows\");\n } else if (deltaBlocks > 0) {\n borrowState.block = safe32(blockNumber, \"block number overflows\");\n }\n }\n\n /**\n * @dev Calculate available rewards for an account's supply\n * @param supplyState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param supplier Address of the account supplying\n * @param comptroller Address of the comptroller proxy\n * @return Undistributed earned XVS from supplies\n */\n function distributeSupplierVenus(\n VenusMarketState memory supplyState,\n address vToken,\n address supplier,\n ComptrollerInterface comptroller\n ) internal view returns (uint) {\n Double memory supplyIndex = Double({ mantissa: supplyState.index });\n Double memory supplierIndex = Double({ mantissa: comptroller.venusSupplierIndex(vToken, supplier) });\n if (supplierIndex.mantissa == 0 && supplyIndex.mantissa > 0) {\n supplierIndex.mantissa = comptroller.venusInitialIndex();\n }\n\n Double memory deltaIndex = sub_(supplyIndex, supplierIndex);\n uint supplierTokens = VToken(vToken).balanceOf(supplier);\n uint supplierDelta = mul_(supplierTokens, deltaIndex);\n return supplierDelta;\n }\n\n /**\n * @dev Calculate available rewards for an account's borrows\n * @param borrowState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param borrower Address of the account borrowing\n * @param marketBorrowIndex vToken Borrow index\n * @param comptroller Address of the comptroller proxy\n * @return Undistributed earned XVS from borrows\n */\n function distributeBorrowerVenus(\n VenusMarketState memory borrowState,\n address vToken,\n address borrower,\n Exp memory marketBorrowIndex,\n ComptrollerInterface comptroller\n ) internal view returns (uint) {\n Double memory borrowIndex = Double({ mantissa: borrowState.index });\n Double memory borrowerIndex = Double({ mantissa: comptroller.venusBorrowerIndex(vToken, borrower) });\n if (borrowerIndex.mantissa > 0) {\n Double memory deltaIndex = sub_(borrowIndex, borrowerIndex);\n uint borrowerAmount = div_(VToken(vToken).borrowBalanceStored(borrower), marketBorrowIndex);\n uint borrowerDelta = mul_(borrowerAmount, deltaIndex);\n return borrowerDelta;\n }\n return 0;\n }\n\n /**\n * @notice Calculate the total XVS tokens pending and accrued by a user account\n * @param holder Account to query pending XVS\n * @param comptroller Address of the comptroller\n * @return Reward object contraining the totalRewards and pending rewards for each market\n */\n function pendingRewards(\n address holder,\n ComptrollerInterface comptroller\n ) external view returns (RewardSummary memory) {\n VToken[] memory vTokens = comptroller.getAllMarkets();\n ClaimVenusLocalVariables memory vars;\n RewardSummary memory rewardSummary;\n rewardSummary.distributorAddress = address(comptroller);\n rewardSummary.rewardTokenAddress = comptroller.getXVSAddress();\n rewardSummary.totalRewards = comptroller.venusAccrued(holder);\n rewardSummary.pendingRewards = new PendingReward[](vTokens.length);\n for (uint i; i < vTokens.length; ++i) {\n (vars.borrowIndex, vars.borrowBlock) = comptroller.venusBorrowState(address(vTokens[i]));\n VenusMarketState memory borrowState = VenusMarketState({\n index: vars.borrowIndex,\n block: vars.borrowBlock\n });\n\n (vars.supplyIndex, vars.supplyBlock) = comptroller.venusSupplyState(address(vTokens[i]));\n VenusMarketState memory supplyState = VenusMarketState({\n index: vars.supplyIndex,\n block: vars.supplyBlock\n });\n\n Exp memory borrowIndex = Exp({ mantissa: vTokens[i].borrowIndex() });\n\n PendingReward memory marketReward;\n marketReward.vTokenAddress = address(vTokens[i]);\n\n updateVenusBorrowIndex(borrowState, address(vTokens[i]), borrowIndex, comptroller);\n uint256 borrowReward = distributeBorrowerVenus(\n borrowState,\n address(vTokens[i]),\n holder,\n borrowIndex,\n comptroller\n );\n\n updateVenusSupplyIndex(supplyState, address(vTokens[i]), comptroller);\n uint256 supplyReward = distributeSupplierVenus(supplyState, address(vTokens[i]), holder, comptroller);\n\n marketReward.amount = add_(borrowReward, supplyReward);\n rewardSummary.pendingRewards[i] = marketReward;\n }\n return rewardSummary;\n }\n\n // utilities\n /**\n * @notice Compares if two strings are equal\n * @param a First string to compare\n * @param b Second string to compare\n * @return Boolean depending on if the strings are equal\n */\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/Oracle/PriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\ncontract PriceOracle {\n /// @notice Indicator that this is a PriceOracle contract (for inspection)\n bool public constant isPriceOracle = true;\n\n /**\n * @notice Get the underlying price of a vToken asset\n * @param vToken The vToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(VToken vToken) external view returns (uint);\n}\n" + }, + "contracts/test/BEP20.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\n\n// Mock import\nimport { GovernorBravoDelegate } from \"@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol\";\n\ninterface BEP20Base {\n event Approval(address indexed owner, address indexed spender, uint256 value);\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function totalSupply() external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function balanceOf(address who) external view returns (uint256);\n}\n\ncontract BEP20 is BEP20Base {\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n\ncontract BEP20NS is BEP20Base {\n function transfer(address to, uint256 value) external;\n\n function transferFrom(address from, address to, uint256 value) external;\n}\n\n/**\n * @title Standard BEP20 token\n * @dev Implementation of the basic standard token.\n * See https://github.com/ethereum/EIPs/issues/20\n */\ncontract StandardToken is BEP20 {\n using SafeMath for uint256;\n\n string public name;\n string public symbol;\n uint8 public decimals;\n uint256 public totalSupply;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public balanceOf;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public {\n totalSupply = _initialAmount;\n balanceOf[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool) {\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n return true;\n }\n\n function approve(address _spender, uint256 amount) external returns (bool) {\n allowance[msg.sender][_spender] = amount;\n emit Approval(msg.sender, _spender, amount);\n return true;\n }\n}\n\n/**\n * @title Non-Standard BEP20 token\n * @dev Version of BEP20 with no return values for `transfer` and `transferFrom`\n * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\ncontract NonStandardToken is BEP20NS {\n using SafeMath for uint256;\n\n string public name;\n uint8 public decimals;\n string public symbol;\n uint256 public totalSupply;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public balanceOf;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public {\n totalSupply = _initialAmount;\n balanceOf[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n }\n\n function transfer(address dst, uint256 amount) external {\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n }\n\n function transferFrom(address src, address dst, uint256 amount) external {\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n }\n\n function approve(address _spender, uint256 amount) external returns (bool) {\n allowance[msg.sender][_spender] = amount;\n emit Approval(msg.sender, _spender, amount);\n return true;\n }\n}\n\ncontract BEP20Harness is StandardToken {\n // To support testing, we can specify addresses for which transferFrom should fail and return false\n mapping(address => bool) public failTransferFromAddresses;\n\n // To support testing, we allow the contract to always fail `transfer`.\n mapping(address => bool) public failTransferToAddresses;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public StandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function harnessSetFailTransferFromAddress(address src, bool _fail) public {\n failTransferFromAddresses[src] = _fail;\n }\n\n function harnessSetFailTransferToAddress(address dst, bool _fail) public {\n failTransferToAddresses[dst] = _fail;\n }\n\n function harnessSetBalance(address _account, uint _amount) public {\n balanceOf[_account] = _amount;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool success) {\n // Added for testing purposes\n if (failTransferToAddresses[dst]) {\n return false;\n }\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool success) {\n // Added for testing purposes\n if (failTransferFromAddresses[src]) {\n return false;\n }\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/ComptrollerHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerMock.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Comptroller/Unitroller.sol\";\n\ncontract ComptrollerHarness is ComptrollerMock {\n address internal xvsAddress;\n address internal vXVSAddress;\n uint public blockNumber;\n\n constructor() public ComptrollerMock() {}\n\n function setVenusSupplyState(address vToken, uint224 index, uint32 blockNumber_) public {\n venusSupplyState[vToken].index = index;\n venusSupplyState[vToken].block = blockNumber_;\n }\n\n function setVenusBorrowState(address vToken, uint224 index, uint32 blockNumber_) public {\n venusBorrowState[vToken].index = index;\n venusBorrowState[vToken].block = blockNumber_;\n }\n\n function setVenusAccrued(address user, uint userAccrued) public {\n venusAccrued[user] = userAccrued;\n }\n\n function setXVSAddress(address xvsAddress_) public {\n xvsAddress = xvsAddress_;\n }\n\n function setXVSVTokenAddress(address vXVSAddress_) public {\n vXVSAddress = vXVSAddress_;\n }\n\n /**\n * @notice Set the amount of XVS distributed per block\n * @param venusRate_ The amount of XVS wei per block to distribute\n */\n function harnessSetVenusRate(uint venusRate_) public {\n venusRate = venusRate_;\n }\n\n /**\n * @notice Recalculate and update XVS speeds for all XVS markets\n */\n function harnessRefreshVenusSpeeds() public {\n VToken[] memory allMarkets_ = allMarkets;\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusSupplyIndex(address(vToken));\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n }\n\n Exp memory totalUtility = Exp({ mantissa: 0 });\n Exp[] memory utilities = new Exp[](allMarkets_.length);\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n if (venusSpeeds[address(vToken)] > 0) {\n Exp memory assetPrice = Exp({ mantissa: oracle.getUnderlyingPrice(vToken) });\n Exp memory utility = mul_(assetPrice, vToken.totalBorrows());\n utilities[i] = utility;\n totalUtility = add_(totalUtility, utility);\n }\n }\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets[i];\n uint newSpeed = totalUtility.mantissa > 0 ? mul_(venusRate, div_(utilities[i], totalUtility)) : 0;\n setVenusSpeedInternal(vToken, newSpeed, newSpeed);\n }\n }\n\n function setVenusBorrowerIndex(address vToken, address borrower, uint index) public {\n venusBorrowerIndex[vToken][borrower] = index;\n }\n\n function setVenusSupplierIndex(address vToken, address supplier, uint index) public {\n venusSupplierIndex[vToken][supplier] = index;\n }\n\n function harnessDistributeAllBorrowerVenus(\n address vToken,\n address borrower,\n uint marketBorrowIndexMantissa\n ) public {\n distributeBorrowerVenus(vToken, borrower, Exp({ mantissa: marketBorrowIndexMantissa }));\n venusAccrued[borrower] = grantXVSInternal(borrower, venusAccrued[borrower], 0, false);\n }\n\n function harnessDistributeAllSupplierVenus(address vToken, address supplier) public {\n distributeSupplierVenus(vToken, supplier);\n venusAccrued[supplier] = grantXVSInternal(supplier, venusAccrued[supplier], 0, false);\n }\n\n function harnessUpdateVenusBorrowIndex(address vToken, uint marketBorrowIndexMantissa) public {\n updateVenusBorrowIndex(vToken, Exp({ mantissa: marketBorrowIndexMantissa }));\n }\n\n function harnessUpdateVenusSupplyIndex(address vToken) public {\n updateVenusSupplyIndex(vToken);\n }\n\n function harnessDistributeBorrowerVenus(address vToken, address borrower, uint marketBorrowIndexMantissa) public {\n distributeBorrowerVenus(vToken, borrower, Exp({ mantissa: marketBorrowIndexMantissa }));\n }\n\n function harnessDistributeSupplierVenus(address vToken, address supplier) public {\n distributeSupplierVenus(vToken, supplier);\n }\n\n function harnessTransferVenus(address user, uint userAccrued, uint threshold) public returns (uint) {\n if (userAccrued > 0 && userAccrued >= threshold) {\n return grantXVSInternal(user, userAccrued, 0, false);\n }\n return userAccrued;\n }\n\n function harnessAddVenusMarkets(address[] memory vTokens) public {\n for (uint i = 0; i < vTokens.length; i++) {\n // temporarily set venusSpeed to 1 (will be fixed by `harnessRefreshVenusSpeeds`)\n setVenusSpeedInternal(VToken(vTokens[i]), 1, 1);\n }\n }\n\n function harnessSetMintedVAIs(address user, uint amount) public {\n mintedVAIs[user] = amount;\n }\n\n function harnessFastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getVenusMarkets() public view returns (address[] memory) {\n uint m = allMarkets.length;\n uint n = 0;\n for (uint i = 0; i < m; i++) {\n if (venusSpeeds[address(allMarkets[i])] > 0) {\n n++;\n }\n }\n\n address[] memory venusMarkets = new address[](n);\n uint k = 0;\n for (uint i = 0; i < m; i++) {\n if (venusSpeeds[address(allMarkets[i])] > 0) {\n venusMarkets[k++] = address(allMarkets[i]);\n }\n }\n return venusMarkets;\n }\n\n function harnessSetReleaseStartBlock(uint startBlock) external {\n releaseStartBlock = startBlock;\n }\n\n function harnessAddVtoken(address vToken) external {\n markets[vToken] = Market({ isListed: true, isVenus: false, collateralFactorMantissa: 0 });\n }\n}\n\ncontract EchoTypesComptroller is UnitrollerAdminStorage {\n function stringy(string memory s) public pure returns (string memory) {\n return s;\n }\n\n function addresses(address a) public pure returns (address) {\n return a;\n }\n\n function booly(bool b) public pure returns (bool) {\n return b;\n }\n\n function listOInts(uint[] memory u) public pure returns (uint[] memory) {\n return u;\n }\n\n function reverty() public pure {\n require(false, \"gotcha sucka\");\n }\n\n function becomeBrains(address payable unitroller) public {\n Unitroller(unitroller)._acceptImplementation();\n }\n}\n" + }, + "contracts/test/ComptrollerMock.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Comptroller/Diamond/facets/MarketFacet.sol\";\nimport \"../Comptroller/Diamond/facets/PolicyFacet.sol\";\nimport \"../Comptroller/Diamond/facets/RewardFacet.sol\";\nimport \"../Comptroller/Diamond/facets/SetterFacet.sol\";\nimport \"../Comptroller/Unitroller.sol\";\n\n// This contract contains all methods of Comptroller implementation in different facets at one place for testing purpose\n// This contract does not have diamond functionality(i.e delegate call to facets methods)\ncontract ComptrollerMock is MarketFacet, PolicyFacet, RewardFacet, SetterFacet {\n constructor() public {\n admin = msg.sender;\n }\n\n function _become(Unitroller unitroller) public {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can\");\n require(unitroller._acceptImplementation() == 0, \"not authorized\");\n }\n\n function _setComptrollerLens(ComptrollerLensInterface comptrollerLens_) external returns (uint) {\n ensureAdmin();\n ensureNonzeroAddress(address(comptrollerLens_));\n address oldComptrollerLens = address(comptrollerLens);\n comptrollerLens = comptrollerLens_;\n emit NewComptrollerLens(oldComptrollerLens, address(comptrollerLens));\n\n return uint(Error.NO_ERROR);\n }\n}\n" + }, + "contracts/test/ComptrollerMockR1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Comptroller/Diamond/facets/MarketFacet.sol\";\nimport \"../Comptroller/Diamond/facets/PolicyFacet.sol\";\nimport \"../Comptroller/Diamond/facets/RewardFacet.sol\";\nimport \"../Comptroller/Diamond/facets/SetterFacet.sol\";\nimport \"../Comptroller/Unitroller.sol\";\n\n// This contract contains all methods of Comptroller implementation in different facets at one place for testing purpose\n// This contract does not have diamond functionality(i.e delegate call to facets methods)\ncontract ComptrollerMockR1 is MarketFacet, PolicyFacet, RewardFacet, SetterFacet {\n event MarketListed(address vToken);\n event NewCollateralFactor(address vToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\n event MarketEntered(address vToken, address account);\n event MarketExited(address vToken, address account);\n\n constructor() public {\n admin = msg.sender;\n }\n\n function _become(Unitroller unitroller) public {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can\");\n require(unitroller._acceptImplementation() == 0, \"not authorized\");\n }\n\n function _setComptrollerLens(ComptrollerLensInterface comptrollerLens_) external returns (uint) {\n ensureAdmin();\n ensureNonzeroAddress(address(comptrollerLens_));\n address oldComptrollerLens = address(comptrollerLens);\n comptrollerLens = comptrollerLens_;\n emit NewComptrollerLens(oldComptrollerLens, address(comptrollerLens));\n\n return uint(Error.NO_ERROR);\n }\n}\n" + }, + "contracts/test/ComptrollerScenario.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerMock.sol\";\n\ncontract ComptrollerScenario is ComptrollerMock {\n uint public blockNumber;\n address public xvsAddress;\n address public vaiAddress;\n\n constructor() public ComptrollerMock() {}\n\n function setXVSAddress(address xvsAddress_) public {\n xvsAddress = xvsAddress_;\n }\n\n // function getXVSAddress() public view returns (address) {\n // return xvsAddress;\n // }\n\n function setVAIAddress(address vaiAddress_) public {\n vaiAddress = vaiAddress_;\n }\n\n function getVAIAddress() public view returns (address) {\n return vaiAddress;\n }\n\n function membershipLength(VToken vToken) public view returns (uint) {\n return accountAssets[address(vToken)].length;\n }\n\n function fastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n\n return blockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getVenusMarkets() public view returns (address[] memory) {\n uint m = allMarkets.length;\n uint n = 0;\n for (uint i = 0; i < m; i++) {\n if (markets[address(allMarkets[i])].isVenus) {\n n++;\n }\n }\n\n address[] memory venusMarkets = new address[](n);\n uint k = 0;\n for (uint i = 0; i < m; i++) {\n if (markets[address(allMarkets[i])].isVenus) {\n venusMarkets[k++] = address(allMarkets[i]);\n }\n }\n return venusMarkets;\n }\n\n function unlist(VToken vToken) public {\n markets[address(vToken)].isListed = false;\n }\n\n /**\n * @notice Recalculate and update XVS speeds for all XVS markets\n */\n function refreshVenusSpeeds() public {\n VToken[] memory allMarkets_ = allMarkets;\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusSupplyIndex(address(vToken));\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n }\n\n Exp memory totalUtility = Exp({ mantissa: 0 });\n Exp[] memory utilities = new Exp[](allMarkets_.length);\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n if (venusSpeeds[address(vToken)] > 0) {\n Exp memory assetPrice = Exp({ mantissa: oracle.getUnderlyingPrice(vToken) });\n Exp memory utility = mul_(assetPrice, vToken.totalBorrows());\n utilities[i] = utility;\n totalUtility = add_(totalUtility, utility);\n }\n }\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets[i];\n uint newSpeed = totalUtility.mantissa > 0 ? mul_(venusRate, div_(utilities[i], totalUtility)) : 0;\n setVenusSpeedInternal(vToken, newSpeed, newSpeed);\n }\n }\n}\n" + }, + "contracts/test/DiamondHarness.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Comptroller/Diamond/Diamond.sol\";\n\ncontract DiamondHarness is Diamond {\n function getFacetAddress(bytes4 sig) public view returns (address) {\n address facet = _selectorToFacetAndPosition[sig].facetAddress;\n require(facet != address(0), \"Diamond: Function does not exist\");\n return facet;\n }\n}\n" + }, + "contracts/test/EvilToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./FaucetToken.sol\";\n\n/**\n * @title The Venus Evil Test Token\n * @author Venus\n * @notice A simple test token that fails certain operations\n */\ncontract EvilToken is FaucetToken {\n bool public fail;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public FaucetToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {\n fail = true;\n }\n\n function setFail(bool _fail) external {\n fail = _fail;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool) {\n if (fail) {\n return false;\n }\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(amount);\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n if (fail) {\n return false;\n }\n balanceOf[src] = balanceOf[src].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(amount);\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount);\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/EvilXDelegator.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegator Contract\n * @notice VTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Venus\n */\ncontract EvilXDelegator is VTokenInterface, VBep20Interface, VDelegatorInterface {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n * @param implementation_ The address of the implementation the contract delegates to\n * @param becomeImplementationData The encoded args for becomeImplementation\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint256 initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,address,uint256,string,string,uint8)\",\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n )\n );\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_, false, becomeImplementationData);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public {\n require(msg.sender == admin, \"VBep20Delegator::_setImplementation: Caller must be admin\");\n\n if (allowResign) {\n delegateToImplementation(abi.encodeWithSignature(\"_resignImplementation()\"));\n }\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n delegateToImplementation(abi.encodeWithSignature(\"_becomeImplementation(bytes)\", becomeImplementationData));\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint256 mintAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"mint(uint256)\", mintAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mintBehalf(address receiver, uint256 mintAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"mintBehalf(address,uint256)\", receiver, mintAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint256 redeemTokens) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"redeem(uint256)\", redeemTokens));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"redeemUnderlying(uint256)\", redeemAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint256 borrowAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrow(uint256)\", borrowAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint256 repayAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"repayBorrow(uint256)\", repayAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"repayBorrowBehalf(address,uint256)\", borrower, repayAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"liquidateBorrow(address,uint256,address)\", borrower, repayAmount, vTokenCollateral)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"transfer(address,uint256)\", dst, amount));\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", src, dst, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"approve(address,uint256)\", spender, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"allowance(address,address)\", owner, spender)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"balanceOf(address)\", owner));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"balanceOfUnderlying(address)\", owner));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint256, uint256, uint256, uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"getAccountSnapshot(address)\", account)\n );\n return abi.decode(data, (uint256, uint256, uint256, uint256));\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"borrowRatePerBlock()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"supplyRatePerBlock()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"totalBorrowsCurrent()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrowBalanceCurrent(address)\", account));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"borrowBalanceStored(address)\", account)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"exchangeRateCurrent()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"exchangeRateStored()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"getCash()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves.\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"accrueInterest()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seize(address liquidator, address borrower, uint256 seizeTokens) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"seize(address,address,uint256)\", liquidator, borrower, seizeTokens)\n );\n return abi.decode(data, (uint256));\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setPendingAdmin(address)\", newPendingAdmin)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setComptroller(address)\", newComptroller)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setReserveFactor(uint256)\", newReserveFactorMantissa)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_acceptAdmin()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from admin\n * @param addAmount Amount of reserves to add\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addReserves(uint256 addAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_addReserves(uint256)\", addAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _reduceReserves(uint256 reduceAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_reduceReserves(uint256)\", reduceAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setInterestRateModel(address)\", newInterestRateModel)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /**\n * @notice Delegates execution to the implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToImplementation(bytes memory data) public returns (bytes memory) {\n return delegateTo(implementation, data);\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {\n (bool success, bytes memory returnData) = address(this).staticcall(\n abi.encodeWithSignature(\"delegateToImplementation(bytes)\", data)\n );\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return abi.decode(returnData, (bytes));\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n */\n function() external payable {\n require(msg.value == 0, \"VBep20Delegator:fallback: cannot send value to fallback\");\n\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/test/EvilXToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VBep20Immutable.sol\";\nimport \"../Tokens/VTokens/VBep20Delegator.sol\";\nimport \"../Tokens/VTokens/VBep20Delegate.sol\";\nimport \"./ComptrollerScenario.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\n\ncontract VBep20Scenario is VBep20Immutable {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\n// doTransferOut method of this token supposed to be compromised and contians malicious code which\n// can be used by attacker to compromise the protocol working.\ncontract EvilXToken is VBep20Delegate {\n event Log(string x, address y);\n event Log(string x, uint y);\n event LogLiquidity(uint liquidity);\n\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n address public comptrollerAddress;\n\n mapping(address => bool) public failTransferToAddresses;\n\n function setComptrollerAddress(address _comptrollerAddress) external {\n comptrollerAddress = _comptrollerAddress;\n }\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n super.doTransferOut(to, amount);\n\n // Checking the Liquidity of the user after the tranfer.\n // solhint-disable-next-line no-unused-vars\n (uint errorCode, uint liquidity, uint shortfall) = ComptrollerInterface(comptrollerAddress).getAccountLiquidity(\n msg.sender\n );\n emit LogLiquidity(liquidity);\n return;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessIncrementTotalBorrows(uint addtlBorrow_) public {\n totalBorrows = totalBorrows + addtlBorrow_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n" + }, + "contracts/test/Fauceteer.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/EIP20NonStandardInterface.sol\";\n\n/**\n * @title Fauceteer\n * @author Venus\n * @notice First computer program to be part of The Giving Pledge\n */\ncontract Fauceteer {\n /**\n * @notice Drips some tokens to caller\n * @dev We send 0.01% of our tokens to the caller. Over time, the amount will tend toward and eventually reach zero.\n * @param token The token to drip. Note: if we have no balance in this token, function will revert.\n */\n function drip(EIP20NonStandardInterface token) public {\n uint tokenBalance = token.balanceOf(address(this));\n require(tokenBalance > 0, \"Fauceteer is empty\");\n token.transfer(msg.sender, tokenBalance / 10000); // 0.01%\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n\n require(success, \"Transfer returned false.\");\n }\n}\n" + }, + "contracts/test/FaucetToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./BEP20.sol\";\n\n/**\n * @title The Venus Faucet Test Token\n * @author Venus\n * @notice A simple test token that lets anyone get more of it.\n */\ncontract FaucetToken is StandardToken {\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public StandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n\n/**\n * @title The Venus Faucet Test Token (non-standard)\n * @author Venus\n * @notice A simple test token that lets anyone get more of it.\n */\ncontract FaucetNonStandardToken is NonStandardToken {\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public NonStandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n\n/**\n * @title The Venus Faucet Re-Entrant Test Token\n * @author Venus\n * @notice A test token that is malicious and tries to re-enter callers\n */\ncontract FaucetTokenReEntrantHarness {\n using SafeMath for uint256;\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n string public name;\n string public symbol;\n uint8 public decimals;\n uint256 internal totalSupply_;\n mapping(address => mapping(address => uint256)) internal allowance_;\n mapping(address => uint256) internal balanceOf_;\n\n bytes public reEntryCallData;\n string public reEntryFun;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol,\n bytes memory _reEntryCallData,\n string memory _reEntryFun\n ) public {\n totalSupply_ = _initialAmount;\n balanceOf_[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n reEntryCallData = _reEntryCallData;\n reEntryFun = _reEntryFun;\n }\n\n modifier reEnter(string memory funName) {\n string memory _reEntryFun = reEntryFun;\n if (compareStrings(_reEntryFun, funName)) {\n reEntryFun = \"\"; // Clear re-entry fun\n (bool success, bytes memory returndata) = msg.sender.call(reEntryCallData);\n assembly {\n if eq(success, 0) {\n revert(add(returndata, 0x20), returndatasize())\n }\n }\n }\n\n _;\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)));\n }\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf_[_owner] += value;\n totalSupply_ += value;\n emit Transfer(address(this), _owner, value);\n }\n\n function totalSupply() public reEnter(\"totalSupply\") returns (uint256) {\n return totalSupply_;\n }\n\n function allowance(address owner, address spender) public reEnter(\"allowance\") returns (uint256 remaining) {\n return allowance_[owner][spender];\n }\n\n function approve(address spender, uint256 amount) public reEnter(\"approve\") returns (bool success) {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n function balanceOf(address owner) public reEnter(\"balanceOf\") returns (uint256 balance) {\n return balanceOf_[owner];\n }\n\n function transfer(address dst, uint256 amount) public reEnter(\"transfer\") returns (bool success) {\n _transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) public reEnter(\"transferFrom\") returns (bool success) {\n _transfer(src, dst, amount);\n _approve(src, msg.sender, allowance_[src][msg.sender].sub(amount));\n return true;\n }\n\n function _approve(address owner, address spender, uint256 amount) internal {\n require(spender != address(0), \"sender should be valid address\");\n require(owner != address(0), \"owner should be valid address\");\n allowance_[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n function _transfer(address src, address dst, uint256 amount) internal {\n require(dst != address(0), \"dst should be valid address\");\n balanceOf_[src] = balanceOf_[src].sub(amount);\n balanceOf_[dst] = balanceOf_[dst].add(amount);\n emit Transfer(src, dst, amount);\n }\n}\n" + }, + "contracts/test/FeeToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./FaucetToken.sol\";\n\n/**\n * @title Fee Token\n * @author Venus\n * @notice A simple test token that charges fees on transfer. Used to mock USDT.\n */\ncontract FeeToken is FaucetToken {\n uint public basisPointFee;\n address public owner;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol,\n uint _basisPointFee,\n address _owner\n ) public FaucetToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {\n basisPointFee = _basisPointFee;\n owner = _owner;\n }\n\n function transfer(address dst, uint amount) public returns (bool) {\n uint fee = amount.mul(basisPointFee).div(10000);\n uint net = amount.sub(fee);\n balanceOf[owner] = balanceOf[owner].add(fee);\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(net);\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint amount) public returns (bool) {\n uint fee = amount.mul(basisPointFee).div(10000);\n uint net = amount.sub(fee);\n balanceOf[owner] = balanceOf[owner].add(fee);\n balanceOf[src] = balanceOf[src].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(net);\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount);\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/FixedPriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Oracle/PriceOracle.sol\";\n\ncontract FixedPriceOracle is PriceOracle {\n uint public price;\n\n constructor(uint _price) public {\n price = _price;\n }\n\n function getUnderlyingPrice(VToken vToken) public view returns (uint) {\n vToken;\n return price;\n }\n\n function assetPrices(address asset) public view returns (uint) {\n asset;\n return price;\n }\n}\n" + }, + "contracts/test/InterestRateModelHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../InterestRateModels/InterestRateModel.sol\";\n\n/**\n * @title An Interest Rate Model for tests that can be instructed to return a failure instead of doing a calculation\n * @author Venus\n */\ncontract InterestRateModelHarness is InterestRateModel {\n uint public constant opaqueBorrowFailureCode = 20;\n bool public failBorrowRate;\n uint public borrowRate;\n\n constructor(uint borrowRate_) public {\n borrowRate = borrowRate_;\n }\n\n function setFailBorrowRate(bool failBorrowRate_) public {\n failBorrowRate = failBorrowRate_;\n }\n\n function setBorrowRate(uint borrowRate_) public {\n borrowRate = borrowRate_;\n }\n\n function getBorrowRate(uint _cash, uint _borrows, uint _reserves) public view returns (uint) {\n _cash; // unused\n _borrows; // unused\n _reserves; // unused\n require(!failBorrowRate, \"INTEREST_RATE_MODEL_ERROR\");\n return borrowRate;\n }\n\n function getSupplyRate(\n uint _cash,\n uint _borrows,\n uint _reserves,\n uint _reserveFactor\n ) external view returns (uint) {\n _cash; // unused\n _borrows; // unused\n _reserves; // unused\n return borrowRate * (1 - _reserveFactor);\n }\n}\n" + }, + "contracts/test/MockDeflationaryToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\n\ncontract DeflatingERC20 {\n using SafeMath for uint;\n\n string public constant name = \"Deflating Test Token\";\n string public constant symbol = \"DTT\";\n uint8 public constant decimals = 18;\n uint public totalSupply;\n mapping(address => uint) public balanceOf;\n mapping(address => mapping(address => uint)) public allowance;\n\n bytes32 public DOMAIN_SEPARATOR;\n // keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;\n mapping(address => uint) public nonces;\n\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n constructor(uint _totalSupply) public {\n uint chainId;\n assembly {\n chainId := chainid()\n }\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n chainId,\n address(this)\n )\n );\n _mint(msg.sender, _totalSupply);\n }\n\n function _mint(address to, uint value) internal {\n totalSupply = totalSupply.add(value);\n balanceOf[to] = balanceOf[to].add(value);\n emit Transfer(address(0), to, value);\n }\n\n function _burn(address from, uint value) internal {\n balanceOf[from] = balanceOf[from].sub(value);\n totalSupply = totalSupply.sub(value);\n emit Transfer(from, address(0), value);\n }\n\n function _approve(address owner, address spender, uint value) private {\n allowance[owner][spender] = value;\n emit Approval(owner, spender, value);\n }\n\n function _transfer(address from, address to, uint value) private {\n uint burnAmount = value / 100;\n _burn(from, burnAmount);\n uint transferAmount = value.sub(burnAmount);\n balanceOf[from] = balanceOf[from].sub(transferAmount);\n balanceOf[to] = balanceOf[to].add(transferAmount);\n emit Transfer(from, to, transferAmount);\n }\n\n function approve(address spender, uint value) external returns (bool) {\n _approve(msg.sender, spender, value);\n return true;\n }\n\n function transfer(address to, uint value) external returns (bool) {\n _transfer(msg.sender, to, value);\n return true;\n }\n\n function transferFrom(address from, address to, uint value) external returns (bool) {\n if (allowance[from][msg.sender] != uint(-1)) {\n allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);\n }\n _transfer(from, to, value);\n return true;\n }\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {\n require(deadline >= block.timestamp, \"EXPIRED\");\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))\n )\n );\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNATURE\");\n _approve(owner, spender, value);\n }\n}\n" + }, + "contracts/test/MockVBNB.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title Venus's vBNB Contract\n * @notice vToken which wraps BNB\n * @author Venus\n */\ncontract MockVBNB is VToken {\n /**\n * @notice Construct a new vBNB money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Send BNB to VBNB to mint\n */\n function() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Reverts upon any failure\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @dev Reverts upon any failure\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow() external payable {\n (uint err, ) = repayBorrowInternal(msg.value);\n requireNoError(err, \"repayBorrow failed\");\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @dev Reverts upon any failure\n * @param borrower The account with the debt being payed off\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower) external payable {\n (uint err, ) = repayBorrowBehalfInternal(borrower, msg.value);\n requireNoError(err, \"repayBorrowBehalf failed\");\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @dev Reverts upon any failure\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(address borrower, VToken vTokenCollateral) external payable {\n (uint err, ) = liquidateBorrowInternal(borrower, msg.value, vTokenCollateral);\n requireNoError(err, \"liquidateBorrow failed\");\n }\n\n function setTotalReserves(uint totalReserves_) external payable {\n totalReserves = totalReserves_;\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Perform the actual transfer in, which is a no-op\n * @param from Address sending the BNB\n * @param amount Amount of BNB being sent\n * @return The actual amount of BNB transferred\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n // Sanity checks\n require(msg.sender == from, \"sender mismatch\");\n require(msg.value == amount, \"value mismatch\");\n return amount;\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n /* Send the BNB, with minimal gas and revert on failure */\n to.transfer(amount);\n }\n\n /**\n * @notice Gets balance of this contract in terms of BNB, before this message\n * @dev This excludes the value of the current message, if any\n * @return The quantity of BNB owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n (MathError err, uint startingBalance) = subUInt(address(this).balance, msg.value);\n require(err == MathError.NO_ERROR, \"cash prior math error\");\n return startingBalance;\n }\n\n function requireNoError(uint errCode, string memory message) internal pure {\n if (errCode == uint(Error.NO_ERROR)) {\n return;\n }\n\n bytes memory fullMessage = new bytes(bytes(message).length + 5);\n uint i;\n\n for (i = 0; i < bytes(message).length; i++) {\n fullMessage[i] = bytes(message)[i];\n }\n\n fullMessage[i + 0] = bytes1(uint8(32));\n fullMessage[i + 1] = bytes1(uint8(40));\n fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10)));\n fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10)));\n fullMessage[i + 4] = bytes1(uint8(41));\n\n require(errCode == uint(Error.NO_ERROR), string(fullMessage));\n }\n\n /**\n * @dev Function to simply retrieve block number\n * This exists mainly for inheriting test contracts to stub this result.\n */\n function getBlockNumber() internal view returns (uint) {\n return block.number;\n }\n\n /**\n * @notice Reduces reserves by transferring to admin\n * @dev Requires fresh interest accrual\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReservesFresh(uint reduceAmount) internal returns (uint) {\n // totalReserves - reduceAmount\n uint totalReservesNew;\n\n // Check caller is admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK);\n }\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != getBlockNumber()) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashPrior() < reduceAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);\n }\n\n // Check reduceAmount ≤ reserves[n] (totalReserves)\n if (reduceAmount > totalReserves) {\n return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n totalReservesNew = totalReserves - reduceAmount;\n\n // Store reserves[n+1] = reserves[n] - reduceAmount\n totalReserves = totalReservesNew;\n\n // // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(admin, reduceAmount);\n\n emit ReservesReduced(admin, reduceAmount, totalReservesNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesReduced event\n function _reduceReserves(uint reduceAmount) external nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.\n return _reduceReservesFresh(reduceAmount);\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n // @custom:event Emits AccrueInterest event\n function accrueInterest() public returns (uint) {\n /* Remember the initial block number */\n uint currentBlockNumber = getBlockNumber();\n uint accrualBlockNumberPrior = accrualBlockNumber;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumberPrior == currentBlockNumber) {\n return uint(Error.NO_ERROR);\n }\n\n /* Read the previous values out of storage */\n uint cashPrior = getCashPrior();\n uint borrowsPrior = totalBorrows;\n uint reservesPrior = totalReserves;\n uint borrowIndexPrior = borrowIndex;\n\n /* Calculate the current borrow interest rate */\n uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior);\n require(borrowRateMantissa <= borrowRateMaxMantissa, \"borrow rate is absurdly high\");\n\n /* Calculate the number of blocks elapsed since the last accrual */\n (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);\n require(mathErr == MathError.NO_ERROR, \"could not calculate block delta\");\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n Exp memory simpleInterestFactor;\n uint interestAccumulated;\n uint totalBorrowsNew;\n uint totalReservesNew;\n uint borrowIndexNew;\n\n (mathErr, simpleInterestFactor) = mulScalar(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n interestAccumulated,\n reservesPrior\n );\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = borrowIndexNew;\n totalBorrows = totalBorrowsNew;\n totalReserves = totalReservesNew;\n\n /* We emit an AccrueInterest event */\n emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);\n\n return uint(Error.NO_ERROR);\n }\n}\n" + }, + "contracts/test/SimplePriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/VTokens/VBep20.sol\";\n\ncontract SimplePriceOracle is PriceOracle {\n mapping(address => uint) internal prices;\n event PricePosted(address asset, uint previousPriceMantissa, uint requestedPriceMantissa, uint newPriceMantissa);\n\n function getUnderlyingPrice(VToken vToken) public view returns (uint) {\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n return 1e18;\n } else if (compareStrings(vToken.symbol(), \"VAI\")) {\n return prices[address(vToken)];\n } else {\n return prices[address(VBep20(address(vToken)).underlying())];\n }\n }\n\n function setUnderlyingPrice(VToken vToken, uint underlyingPriceMantissa) public {\n address asset = address(VBep20(address(vToken)).underlying());\n emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);\n prices[asset] = underlyingPriceMantissa;\n }\n\n function setDirectPrice(address asset, uint price) public {\n emit PricePosted(asset, prices[asset], price, price);\n prices[asset] = price;\n }\n\n // v1 price oracle interface for use as backing of proxy\n function assetPrices(address asset) external view returns (uint) {\n return prices[asset];\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/test/VAIControllerHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VAI/VAIController.sol\";\n\ncontract VAIControllerHarness is VAIController {\n uint public blockNumber;\n uint public blocksPerYear;\n\n constructor() public VAIController() {\n admin = msg.sender;\n }\n\n function setVenusVAIState(uint224 index, uint32 blockNumber_) public {\n venusVAIState.index = index;\n venusVAIState.block = blockNumber_;\n }\n\n function setVAIAddress(address vaiAddress_) public {\n vai = vaiAddress_;\n }\n\n function getVAIAddress() public view returns (address) {\n return vai;\n }\n\n function harnessRepayVAIFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayVAIFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateVAIFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateVAIFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessFastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function setBlocksPerYear(uint number) public {\n blocksPerYear = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBlocksPerYear() public view returns (uint) {\n return blocksPerYear;\n }\n}\n" + }, + "contracts/test/VAIHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VAI/VAI.sol\";\n\ncontract VAIScenario is VAI {\n uint internal blockNumber = 100000;\n\n constructor(uint chainId) public VAI(chainId) {}\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetTotalSupply(uint _totalSupply) public {\n totalSupply = _totalSupply;\n }\n\n function harnessIncrementTotalSupply(uint addtlSupply_) public {\n totalSupply = totalSupply + addtlSupply_;\n }\n\n function harnessSetBalanceOf(address account, uint _amount) public {\n balanceOf[account] = _amount;\n }\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n" + }, + "contracts/test/VBep20Harness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VBep20Immutable.sol\";\nimport \"../Tokens/VTokens/VBep20Delegator.sol\";\nimport \"../Tokens/VTokens/VBep20Delegate.sol\";\nimport \"./ComptrollerScenario.sol\";\n\ncontract VBep20Harness is VBep20Immutable {\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n mapping(address => bool) public failTransferToAddresses;\n\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n return super.doTransferOut(to, amount);\n }\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n\ncontract VBep20Scenario is VBep20Immutable {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\ncontract VEvil is VBep20Scenario {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Scenario(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function evilSeize(VToken treasure, address liquidator, address borrower, uint seizeTokens) public returns (uint) {\n return treasure.seize(liquidator, borrower, seizeTokens);\n }\n}\n\ncontract VBep20DelegatorScenario is VBep20Delegator {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n )\n public\n VBep20Delegator(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_,\n implementation_,\n becomeImplementationData\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n}\n\ncontract VBep20DelegateHarness is VBep20Delegate {\n event Log(string x, address y);\n event Log(string x, uint y);\n\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n mapping(address => bool) public failTransferToAddresses;\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n return super.doTransferOut(to, amount);\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessIncrementTotalBorrows(uint addtlBorrow_) public {\n totalBorrows = totalBorrows + addtlBorrow_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n\ncontract VBep20DelegateScenario is VBep20Delegate {\n constructor() public {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\ncontract VBep20DelegateScenarioExtra is VBep20DelegateScenario {\n function iHaveSpoken() public pure returns (string memory) {\n return \"i have spoken\";\n }\n\n function itIsTheWay() public {\n admin = address(1); // make a change to test effect\n }\n\n function babyYoda() public pure {\n revert(\"protect the baby\");\n }\n}\n" + }, + "contracts/test/VBep20MockDelegate.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title Venus's VBep20 Contract\n * @notice VTokens which wrap an EIP-20 underlying\n * @author Venus\n */\ncontract VBep20MockDelegate is VToken, VBep20Interface {\n address public implementation;\n uint internal blockNumber = 100000;\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n */\n function initialize(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n // VToken initialize does the bulk of the work\n super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public {\n // Shh -- currently unused\n data;\n\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _becomeImplementation\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public {\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _resignImplementation\");\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint mintAmount) external returns (uint) {\n (uint err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver the account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n (uint err, ) = mintBehalfInternal(receiver, mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n (uint err, ) = liquidateBorrowInternal(borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n /**\n * @notice The sender adds to reserves.\n * @param addAmount The amount fo underlying token to add as reserves\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addReserves(uint addAmount) external returns (uint) {\n return _addReservesInternal(addAmount);\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n EIP20Interface token = EIP20Interface(underlying);\n return token.balanceOf(address(this));\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);\n uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n token.transferFrom(from, address(this), amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_IN_FAILED\");\n\n // Calculate the amount that was *actually* transferred\n uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address payable to, uint amount) internal {\n EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);\n token.transfer(to, amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a complaint BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_OUT_FAILED\");\n }\n}\n" + }, + "contracts/test/VRTConverterHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/Tokens/VRT/VRTConverter.sol\";\n\ncontract VRTConverterHarness is VRTConverter {\n constructor() public VRTConverter() {\n admin = msg.sender;\n }\n\n function balanceOfUser() public view returns (uint256, address) {\n uint256 vrtBalanceOfUser = vrt.balanceOf(msg.sender);\n return (vrtBalanceOfUser, msg.sender);\n }\n\n function setConversionRatio(uint256 _conversionRatio) public onlyAdmin {\n conversionRatio = _conversionRatio;\n }\n\n function setConversionTimeline(uint256 _conversionStartTime, uint256 _conversionPeriod) public onlyAdmin {\n conversionStartTime = _conversionStartTime;\n conversionPeriod = _conversionPeriod;\n conversionEndTime = conversionStartTime.add(conversionPeriod);\n }\n\n function getXVSRedeemedAmount(uint256 vrtAmount) public view returns (uint256) {\n return vrtAmount.mul(conversionRatio).mul(xvsDecimalsMultiplier).div(1e18).div(vrtDecimalsMultiplier);\n }\n}\n" + }, + "contracts/test/VRTVaultHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/VRTVault/VRTVault.sol\";\n\ncontract VRTVaultHarness is VRTVault {\n uint public blockNumber;\n\n constructor() public VRTVault() {}\n\n function overrideInterestRatePerBlock(uint256 _interestRatePerBlock) public {\n interestRatePerBlock = _interestRatePerBlock;\n }\n\n function balanceOfUser() public view returns (uint256, address) {\n uint256 vrtBalanceOfUser = vrt.balanceOf(msg.sender);\n return (vrtBalanceOfUser, msg.sender);\n }\n\n function harnessFastForward(uint256 blocks) public returns (uint256) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function setBlockNumber(uint256 number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() public view returns (uint256) {\n return blockNumber;\n }\n}\n" + }, + "contracts/test/XVSHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/XVS/XVS.sol\";\n\ncontract XVSScenario is XVS {\n constructor(address account) public XVS(account) {}\n\n function transferScenario(address[] calldata destinations, uint256 amount) external returns (bool) {\n for (uint i = 0; i < destinations.length; i++) {\n address dst = destinations[i];\n _transferTokens(msg.sender, dst, uint96(amount));\n }\n return true;\n }\n\n function transferFromScenario(address[] calldata froms, uint256 amount) external returns (bool) {\n for (uint i = 0; i < froms.length; i++) {\n address from = froms[i];\n _transferTokens(from, msg.sender, uint96(amount));\n }\n return true;\n }\n\n function generateCheckpoints(uint count, uint offset) external {\n for (uint i = 1 + offset; i <= count + offset; i++) {\n checkpoints[msg.sender][numCheckpoints[msg.sender]++] = Checkpoint(uint32(i), uint96(i));\n }\n }\n}\n" + }, + "contracts/test/XVSVaultScenario.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../XVSVault/XVSVault.sol\";\n\ncontract XVSVaultScenario is XVSVault {\n using SafeMath for uint256;\n\n constructor() public {\n admin = msg.sender;\n }\n\n function pushOldWithdrawalRequest(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests,\n uint _amount,\n uint _lockedUntil\n ) internal {\n uint i = _requests.length;\n _requests.push(WithdrawalRequest(0, 0, 0));\n // Keep it sorted so that the first to get unlocked request is always at the end\n for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) {\n _requests[i] = _requests[i - 1];\n }\n _requests[i] = WithdrawalRequest(_amount, uint128(_lockedUntil), 0);\n _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount);\n }\n\n function requestOldWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant {\n _ensureValidPool(_rewardToken, _pid);\n require(_amount > 0, \"requested amount cannot be zero\");\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n require(user.amount >= user.pendingWithdrawals.add(_amount), \"requested amount is invalid\");\n\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n uint lockedUntil = pool.lockPeriod.add(block.timestamp);\n\n pushOldWithdrawalRequest(user, requests, _amount, lockedUntil);\n\n // Update Delegate Amount\n if (_rewardToken == address(xvsAddress)) {\n _moveDelegates(delegates[msg.sender], address(0), uint96(_amount));\n }\n\n emit RequestedWithdrawal(msg.sender, _rewardToken, _pid, _amount);\n }\n\n function transferReward(address rewardToken, address user, uint256 amount) external {\n _transferReward(rewardToken, user, amount);\n }\n}\n" + }, + "contracts/test/XVSVestingHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/Tokens/XVS/XVSVesting.sol\";\n\ncontract XVSVestingHarness is XVSVesting {\n address public constant ZERO_ADDRESS = 0x0000000000000000000000000000000000000000;\n\n constructor() public XVSVesting() {\n admin = msg.sender;\n }\n\n uint public blockNumber;\n\n function recoverXVS(address recoveryAddress) public payable {\n uint256 xvsBalance = xvs.balanceOf(address(this));\n xvs.safeTransferFrom(address(this), recoveryAddress, xvsBalance);\n }\n\n function overWriteVRTConversionAddress() public {\n vrtConversionAddress = ZERO_ADDRESS;\n }\n\n function computeWithdrawableAmount(\n uint256 amount,\n uint256 vestingStartTime,\n uint256 withdrawnAmount\n ) public view returns (uint256 vestedAmount, uint256 toWithdraw) {\n (vestedAmount, toWithdraw) = super.calculateWithdrawableAmount(amount, vestingStartTime, withdrawnAmount);\n return (vestedAmount, toWithdraw);\n }\n\n function computeVestedAmount(\n uint256 vestingAmount,\n uint256 vestingStartTime,\n uint256 currentTime\n ) public view returns (uint256) {\n return super.calculateVestedAmount(vestingAmount, vestingStartTime, currentTime);\n }\n\n function getVestingCount(address beneficiary) public view returns (uint256) {\n return vestings[beneficiary].length;\n }\n\n function getVestedAmount(address recipient) public view nonZeroAddress(recipient) returns (uint256) {\n VestingRecord[] memory vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n uint256 totalVestedAmount = 0;\n uint256 currentTime = getCurrentTime();\n\n for (uint i = 0; i < vestingCount; i++) {\n VestingRecord memory vesting = vestingsOfRecipient[i];\n uint256 vestedAmount = calculateVestedAmount(vesting.amount, vesting.startTime, currentTime);\n totalVestedAmount = totalVestedAmount.add(vestedAmount);\n }\n\n return totalVestedAmount;\n }\n}\n" + }, + "contracts/Tokens/EIP20Interface.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title BEP 20 Token Standard Interface\n * https://eips.ethereum.org/EIPS/eip-20\n */\ninterface EIP20Interface {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n /**\n * @notice Get the total number of tokens in circulation\n * @return The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return success whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining The number of tokens allowed to be spent\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/Tokens/EIP20NonStandardInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title EIP20NonStandardInterface\n * @dev Version of BEP20 with no return values for `transfer` and `transferFrom`\n * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\ninterface EIP20NonStandardInterface {\n /**\n * @notice Get the total number of tokens in circulation\n * @return The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance of the owner\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n ///\n /// !!!!!!!!!!!!!!\n /// !!! NOTICE !!! `transfer` does not return a value, in violation of the BEP-20 specification\n /// !!!!!!!!!!!!!!\n ///\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n */\n function transfer(address dst, uint256 amount) external;\n\n ///\n /// !!!!!!!!!!!!!!\n /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the BEP-20 specification\n /// !!!!!!!!!!!!!!\n ///\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n */\n function transferFrom(address src, address dst, uint256 amount) external;\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved\n * @return success Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining The number of tokens allowed to be spent\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/Tokens/Prime/IPrime.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\n/**\n * @title IPrime\n * @author Venus\n * @notice Interface for Prime Token\n */\ninterface IPrime {\n /**\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\n * @param user the account address whose balance was updated\n */\n function xvsUpdated(address user) external;\n\n /**\n * @notice accrues interest and updates score for an user for a specific market\n * @param user the account address for which to accrue interest and update score\n * @param market the market for which to accrue interest and update score\n */\n function accrueInterestAndUpdateScore(address user, address market) external;\n\n /**\n * @notice Distributes income from market since last distribution\n * @param vToken the market for which to distribute the income\n */\n function accrueInterest(address vToken) external;\n\n /**\n * @notice Returns if user is a prime holder\n * @param isPrimeHolder returns if the user is a prime holder\n */\n function isUserPrimeHolder(address user) external view returns (bool isPrimeHolder);\n}\n" + }, + "contracts/Tokens/VAI/lib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.5.16;\n\ncontract LibNote {\n event LogNote(\n bytes4 indexed sig,\n address indexed usr,\n bytes32 indexed arg1,\n bytes32 indexed arg2,\n bytes data\n ) anonymous;\n\n modifier note() {\n _;\n assembly {\n // log an 'anonymous' event with a constant 6 words of calldata\n // and four indexed topics: selector, caller, arg1 and arg2\n let mark := msize() // end of memory ensures zero\n mstore(0x40, add(mark, 288)) // update free memory pointer\n mstore(mark, 0x20) // bytes type data offset\n mstore(add(mark, 0x20), 224) // bytes size (padded)\n calldatacopy(add(mark, 0x40), 0, 224) // bytes payload\n log4(\n mark,\n 288, // calldata\n shl(224, shr(224, calldataload(0))), // msg.sig\n caller(), // msg.sender\n calldataload(4), // arg1\n calldataload(36) // arg2\n )\n }\n }\n}\n" + }, + "contracts/Tokens/VAI/VAI.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n// Copyright (C) 2017, 2018, 2019 dbrock, rain, mrchico\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.5.16;\n\nimport \"./lib.sol\";\n\ncontract VAI is LibNote {\n // --- Auth ---\n mapping(address => uint256) public wards;\n\n function rely(address guy) external note auth {\n wards[guy] = 1;\n }\n\n function deny(address guy) external note auth {\n wards[guy] = 0;\n }\n\n modifier auth() {\n require(wards[msg.sender] == 1, \"VAI/not-authorized\");\n _;\n }\n\n // --- BEP20 Data ---\n string public constant name = \"VAI Stablecoin\";\n string public constant symbol = \"VAI\";\n string public constant version = \"1\";\n uint8 public constant decimals = 18;\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public nonces;\n\n event Approval(address indexed src, address indexed guy, uint256 wad);\n event Transfer(address indexed src, address indexed dst, uint256 wad);\n\n // --- Math ---\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x + y) >= x, \"VAI math error\");\n }\n\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x - y) <= x, \"VAI math error\");\n }\n\n // --- EIP712 niceties ---\n bytes32 public DOMAIN_SEPARATOR;\n // bytes32 public constant PERMIT_TYPEHASH = keccak256(\"Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)\");\n bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;\n\n constructor(uint256 chainId_) public {\n wards[msg.sender] = 1;\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(version)),\n chainId_,\n address(this)\n )\n );\n }\n\n // --- Token ---\n function transfer(address dst, uint256 wad) external returns (bool) {\n return transferFrom(msg.sender, dst, wad);\n }\n\n function transferFrom(address src, address dst, uint256 wad) public returns (bool) {\n require(balanceOf[src] >= wad, \"VAI/insufficient-balance\");\n if (src != msg.sender && allowance[src][msg.sender] != uint256(-1)) {\n require(allowance[src][msg.sender] >= wad, \"VAI/insufficient-allowance\");\n allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);\n }\n balanceOf[src] = sub(balanceOf[src], wad);\n balanceOf[dst] = add(balanceOf[dst], wad);\n emit Transfer(src, dst, wad);\n return true;\n }\n\n function mint(address usr, uint256 wad) external auth {\n balanceOf[usr] = add(balanceOf[usr], wad);\n totalSupply = add(totalSupply, wad);\n emit Transfer(address(0), usr, wad);\n }\n\n function burn(address usr, uint256 wad) external {\n require(balanceOf[usr] >= wad, \"VAI/insufficient-balance\");\n if (usr != msg.sender && allowance[usr][msg.sender] != uint256(-1)) {\n require(allowance[usr][msg.sender] >= wad, \"VAI/insufficient-allowance\");\n allowance[usr][msg.sender] = sub(allowance[usr][msg.sender], wad);\n }\n balanceOf[usr] = sub(balanceOf[usr], wad);\n totalSupply = sub(totalSupply, wad);\n emit Transfer(usr, address(0), wad);\n }\n\n function approve(address usr, uint256 wad) external returns (bool) {\n allowance[msg.sender][usr] = wad;\n emit Approval(msg.sender, usr, wad);\n return true;\n }\n\n // --- Alias ---\n function push(address usr, uint256 wad) external {\n transferFrom(msg.sender, usr, wad);\n }\n\n function pull(address usr, uint256 wad) external {\n transferFrom(usr, msg.sender, wad);\n }\n\n function move(address src, address dst, uint256 wad) external {\n transferFrom(src, dst, wad);\n }\n\n // --- Approve by signature ---\n function permit(\n address holder,\n address spender,\n uint256 nonce,\n uint256 expiry,\n bool allowed,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(abi.encode(PERMIT_TYPEHASH, holder, spender, nonce, expiry, allowed))\n )\n );\n\n require(holder != address(0), \"VAI/invalid-address-0\");\n require(holder == ecrecover(digest, v, r, s), \"VAI/invalid-permit\");\n require(expiry == 0 || now <= expiry, \"VAI/permit-expired\");\n require(nonce == nonces[holder]++, \"VAI/invalid-nonce\");\n uint256 wad = allowed ? uint256(-1) : 0;\n allowance[holder][spender] = wad;\n emit Approval(holder, spender, wad);\n }\n}\n" + }, + "contracts/Tokens/VAI/VAIController.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.5.16;\n\nimport { PriceOracle } from \"../../Oracle/PriceOracle.sol\";\nimport { VAIControllerErrorReporter } from \"../../Utils/ErrorReporter.sol\";\nimport { Exponential } from \"../../Utils/Exponential.sol\";\nimport { ComptrollerInterface } from \"../../Comptroller/ComptrollerInterface.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\nimport { VToken, EIP20Interface } from \"../VTokens/VToken.sol\";\nimport { VAIUnitroller, VAIControllerStorageG4 } from \"./VAIUnitroller.sol\";\nimport { VAIControllerInterface } from \"./VAIControllerInterface.sol\";\nimport { VAI } from \"./VAI.sol\";\nimport { IPrime } from \"../Prime/IPrime.sol\";\nimport { VTokenInterface } from \"../VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title VAI Comptroller\n * @author Venus\n * @notice This is the implementation contract for the VAIUnitroller proxy\n */\ncontract VAIController is VAIControllerInterface, VAIControllerStorageG4, VAIControllerErrorReporter, Exponential {\n /// @notice Initial index used in interest computations\n uint256 public constant INITIAL_VAI_MINT_INDEX = 1e18;\n\n /// @notice Emitted when Comptroller is changed\n event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);\n\n /// @notice Emitted when mint for prime holder is changed\n event MintOnlyForPrimeHolder(bool previousMintEnabledOnlyForPrimeHolder, bool newMintEnabledOnlyForPrimeHolder);\n\n /// @notice Emitted when Prime is changed\n event NewPrime(address oldPrime, address newPrime);\n\n /// @notice Event emitted when VAI is minted\n event MintVAI(address minter, uint256 mintVAIAmount);\n\n /// @notice Event emitted when VAI is repaid\n event RepayVAI(address payer, address borrower, uint256 repayVAIAmount);\n\n /// @notice Event emitted when a borrow is liquidated\n event LiquidateVAI(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address vTokenCollateral,\n uint256 seizeTokens\n );\n\n /// @notice Emitted when treasury guardian is changed\n event NewTreasuryGuardian(address oldTreasuryGuardian, address newTreasuryGuardian);\n\n /// @notice Emitted when treasury address is changed\n event NewTreasuryAddress(address oldTreasuryAddress, address newTreasuryAddress);\n\n /// @notice Emitted when treasury percent is changed\n event NewTreasuryPercent(uint256 oldTreasuryPercent, uint256 newTreasuryPercent);\n\n /// @notice Event emitted when VAIs are minted and fee are transferred\n event MintFee(address minter, uint256 feeAmount);\n\n /// @notice Emiitted when VAI base rate is changed\n event NewVAIBaseRate(uint256 oldBaseRateMantissa, uint256 newBaseRateMantissa);\n\n /// @notice Emiitted when VAI float rate is changed\n event NewVAIFloatRate(uint256 oldFloatRateMantissa, uint256 newFlatRateMantissa);\n\n /// @notice Emiitted when VAI receiver address is changed\n event NewVAIReceiver(address oldReceiver, address newReceiver);\n\n /// @notice Emiitted when VAI mint cap is changed\n event NewVAIMintCap(uint256 oldMintCap, uint256 newMintCap);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControl(address oldAccessControlAddress, address newAccessControlAddress);\n\n /// @notice Emitted when VAI token address is changed by admin\n event NewVaiToken(address oldVaiToken, address newVaiToken);\n\n function initialize() external onlyAdmin {\n require(vaiMintIndex == 0, \"already initialized\");\n\n vaiMintIndex = INITIAL_VAI_MINT_INDEX;\n accrualBlockNumber = getBlockNumber();\n mintCap = uint256(-1);\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n function _become(VAIUnitroller unitroller) external {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can change brains\");\n require(unitroller._acceptImplementation() == 0, \"change not authorized\");\n }\n\n /**\n * @notice The mintVAI function mints and transfers VAI from the protocol to the user, and adds a borrow balance.\n * The amount minted must be less than the user's Account Liquidity and the mint vai limit.\n * @dev If the Comptroller address is not set, minting is a no-op and the function returns the success code.\n * @param mintVAIAmount The amount of the VAI to be minted.\n * @return 0 on success, otherwise an error code\n */\n // solhint-disable-next-line code-complexity\n function mintVAI(uint256 mintVAIAmount) external nonReentrant returns (uint256) {\n if (address(comptroller) == address(0)) {\n return uint256(Error.NO_ERROR);\n }\n\n _ensureNonzeroAmount(mintVAIAmount);\n _ensureNotPaused();\n accrueVAIInterest();\n\n uint256 err;\n address minter = msg.sender;\n address _vai = vai;\n uint256 vaiTotalSupply = EIP20Interface(_vai).totalSupply();\n\n uint256 vaiNewTotalSupply = add_(vaiTotalSupply, mintVAIAmount);\n require(vaiNewTotalSupply <= mintCap, \"mint cap reached\");\n\n uint256 accountMintableVAI;\n (err, accountMintableVAI) = getMintableVAI(minter);\n require(err == uint256(Error.NO_ERROR), \"could not compute mintable amount\");\n\n // check that user have sufficient mintableVAI balance\n require(mintVAIAmount <= accountMintableVAI, \"minting more than allowed\");\n\n // Calculate the minted balance based on interest index\n uint256 totalMintedVAI = comptroller.mintedVAIs(minter);\n\n if (totalMintedVAI > 0) {\n uint256 repayAmount = getVAIRepayAmount(minter);\n uint256 remainedAmount = sub_(repayAmount, totalMintedVAI);\n pastVAIInterest[minter] = add_(pastVAIInterest[minter], remainedAmount);\n totalMintedVAI = repayAmount;\n }\n\n uint256 accountMintVAINew = add_(totalMintedVAI, mintVAIAmount);\n err = comptroller.setMintedVAIOf(minter, accountMintVAINew);\n require(err == uint256(Error.NO_ERROR), \"comptroller rejection\");\n\n uint256 remainedAmount;\n if (treasuryPercent != 0) {\n uint256 feeAmount = div_(mul_(mintVAIAmount, treasuryPercent), 1e18);\n remainedAmount = sub_(mintVAIAmount, feeAmount);\n VAI(_vai).mint(treasuryAddress, feeAmount);\n\n emit MintFee(minter, feeAmount);\n } else {\n remainedAmount = mintVAIAmount;\n }\n\n VAI(_vai).mint(minter, remainedAmount);\n vaiMinterInterestIndex[minter] = vaiMintIndex;\n\n emit MintVAI(minter, remainedAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice The repay function transfers VAI interest into the protocol and burns the rest,\n * reducing the borrower's borrow balance. Before repaying VAI, users must first approve\n * VAIController to access their VAI balance.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAI(uint256 amount) external nonReentrant returns (uint256, uint256) {\n return _repayVAI(msg.sender, amount);\n }\n\n /**\n * @notice The repay on behalf function transfers VAI interest into the protocol and burns the rest,\n * reducing the borrower's borrow balance. Borrowed VAIs are repaid by another user (possibly the borrower).\n * Before repaying VAI, the payer must first approve VAIController to access their VAI balance.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param borrower The account to repay the debt for.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAIBehalf(address borrower, uint256 amount) external nonReentrant returns (uint256, uint256) {\n _ensureNonzeroAddress(borrower);\n return _repayVAI(borrower, amount);\n }\n\n /**\n * @dev Checks the parameters and the protocol state, accrues interest, and invokes repayVAIFresh.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param borrower The account to repay the debt for.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function _repayVAI(address borrower, uint256 amount) internal returns (uint256, uint256) {\n if (address(comptroller) == address(0)) {\n return (0, 0);\n }\n _ensureNonzeroAmount(amount);\n _ensureNotPaused();\n\n accrueVAIInterest();\n return repayVAIFresh(msg.sender, borrower, amount);\n }\n\n /**\n * @dev Repay VAI, expecting interest to be accrued\n * @dev Borrowed VAIs are repaid by another user (possibly the borrower).\n * @param payer the account paying off the VAI\n * @param borrower the account with the debt being payed off\n * @param repayAmount the amount of VAI being repaid\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAIFresh(address payer, address borrower, uint256 repayAmount) internal returns (uint256, uint256) {\n (uint256 burn, uint256 partOfCurrentInterest, uint256 partOfPastInterest) = getVAICalculateRepayAmount(\n borrower,\n repayAmount\n );\n\n VAI _vai = VAI(vai);\n _vai.burn(payer, burn);\n bool success = _vai.transferFrom(payer, receiver, partOfCurrentInterest);\n require(success == true, \"failed to transfer VAI fee\");\n\n uint256 vaiBalanceBorrower = comptroller.mintedVAIs(borrower);\n\n uint256 accountVAINew = sub_(sub_(vaiBalanceBorrower, burn), partOfPastInterest);\n pastVAIInterest[borrower] = sub_(pastVAIInterest[borrower], partOfPastInterest);\n\n uint256 error = comptroller.setMintedVAIOf(borrower, accountVAINew);\n // We have to revert upon error since side-effects already happened at this point\n require(error == uint256(Error.NO_ERROR), \"comptroller rejection\");\n\n uint256 repaidAmount = add_(burn, partOfCurrentInterest);\n emit RepayVAI(payer, borrower, repaidAmount);\n\n return (uint256(Error.NO_ERROR), repaidAmount);\n }\n\n /**\n * @notice The sender liquidates the vai minters collateral. The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of vai to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external nonReentrant returns (uint256, uint256) {\n _ensureNotPaused();\n\n uint256 error = vTokenCollateral.accrueInterest();\n if (error != uint256(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.VAI_LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0);\n }\n\n // liquidateVAIFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateVAIFresh(msg.sender, borrower, repayAmount, vTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral by repay borrowers VAI.\n * The collateral seized is transferred to the liquidator.\n * @dev If the Comptroller address is not set, liquidation is a no-op and the function returns the success code.\n * @param liquidator The address repaying the VAI and seizing collateral\n * @param borrower The borrower of this VAI to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the VAI to repay\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function liquidateVAIFresh(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) internal returns (uint256, uint256) {\n if (address(comptroller) != address(0)) {\n accrueVAIInterest();\n\n /* Fail if liquidate not allowed */\n uint256 allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify vTokenCollateral market's block number equals current block number */\n //if (vTokenCollateral.accrualBlockNumber() != accrualBlockNumber) {\n if (vTokenCollateral.accrualBlockNumber() != getBlockNumber()) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == uint256(-1)) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayVAI fails */\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayVAIFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.VAI_LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateVAICalculateSeizeTokens(\n address(vTokenCollateral),\n actualRepayAmount\n );\n require(\n amountSeizeError == uint256(Error.NO_ERROR),\n \"VAI_LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\"\n );\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(vTokenCollateral.balanceOf(borrower) >= seizeTokens, \"VAI_LIQUIDATE_SEIZE_TOO_MUCH\");\n\n uint256 seizeError;\n seizeError = vTokenCollateral.seize(liquidator, borrower, seizeTokens);\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint256(Error.NO_ERROR), \"token seizure failed\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateVAI(liquidator, borrower, actualRepayAmount, address(vTokenCollateral), seizeTokens);\n\n /* We call the defense hook */\n comptroller.liquidateBorrowVerify(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n actualRepayAmount,\n seizeTokens\n );\n\n return (uint256(Error.NO_ERROR), actualRepayAmount);\n }\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Sets a new comptroller\n * @dev Admin function to set a new comptroller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptroller(ComptrollerInterface comptroller_) external returns (uint256) {\n // Check caller is admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK);\n }\n\n ComptrollerInterface oldComptroller = comptroller;\n comptroller = comptroller_;\n emit NewComptroller(oldComptroller, comptroller_);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the prime token contract address\n * @param prime_ The new address of the prime token contract\n */\n function setPrimeToken(address prime_) external onlyAdmin {\n emit NewPrime(prime, prime_);\n prime = prime_;\n }\n\n /**\n * @notice Set the VAI token contract address\n * @param vai_ The new address of the VAI token contract\n */\n function setVAIToken(address vai_) external onlyAdmin {\n emit NewVaiToken(vai, vai_);\n vai = vai_;\n }\n\n /**\n * @notice Toggle mint only for prime holder\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function toggleOnlyPrimeHolderMint() external returns (uint256) {\n _ensureAllowed(\"toggleOnlyPrimeHolderMint()\");\n\n if (!mintEnabledOnlyForPrimeHolder && prime == address(0)) {\n return uint256(Error.REJECTION);\n }\n\n emit MintOnlyForPrimeHolder(mintEnabledOnlyForPrimeHolder, !mintEnabledOnlyForPrimeHolder);\n mintEnabledOnlyForPrimeHolder = !mintEnabledOnlyForPrimeHolder;\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account total supply balance.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountAmountLocalVars {\n uint256 oErr;\n MathError mErr;\n uint256 sumSupply;\n uint256 marketSupply;\n uint256 sumBorrowPlusEffects;\n uint256 vTokenBalance;\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n uint256 oraclePriceMantissa;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n }\n\n /**\n * @notice Function that returns the amount of VAI a user can mint based on their account liquidy and the VAI mint rate\n * If mintEnabledOnlyForPrimeHolder is true, only Prime holders are able to mint VAI\n * @param minter The account to check mintable VAI\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol for details)\n * @return Mintable amount (with 18 decimals)\n */\n // solhint-disable-next-line code-complexity\n function getMintableVAI(address minter) public view returns (uint256, uint256) {\n if (mintEnabledOnlyForPrimeHolder && !IPrime(prime).isUserPrimeHolder(minter)) {\n return (uint256(Error.REJECTION), 0);\n }\n\n PriceOracle oracle = comptroller.oracle();\n VToken[] memory enteredMarkets = comptroller.getAssetsIn(minter);\n\n AccountAmountLocalVars memory vars; // Holds all our calculation results\n\n uint256 accountMintableVAI;\n uint256 i;\n\n /**\n * We use this formula to calculate mintable VAI amount.\n * totalSupplyAmount * VAIMintRate - (totalBorrowAmount + mintedVAIOf)\n */\n uint256 marketsCount = enteredMarkets.length;\n for (i = 0; i < marketsCount; i++) {\n (vars.oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = enteredMarkets[i]\n .getAccountSnapshot(minter);\n if (vars.oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (uint256(Error.SNAPSHOT_ERROR), 0);\n }\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(enteredMarkets[i]);\n if (vars.oraclePriceMantissa == 0) {\n return (uint256(Error.PRICE_ERROR), 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n (vars.mErr, vars.tokensToDenom) = mulExp(vars.exchangeRate, vars.oraclePrice);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n // marketSupply = tokensToDenom * vTokenBalance\n (vars.mErr, vars.marketSupply) = mulScalarTruncate(vars.tokensToDenom, vars.vTokenBalance);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (, uint256 collateralFactorMantissa) = comptroller.markets(address(enteredMarkets[i]));\n (vars.mErr, vars.marketSupply) = mulUInt(vars.marketSupply, collateralFactorMantissa);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, vars.marketSupply) = divUInt(vars.marketSupply, 1e18);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, vars.sumSupply) = addUInt(vars.sumSupply, vars.marketSupply);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n (vars.mErr, vars.sumBorrowPlusEffects) = mulScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n }\n\n uint256 totalMintedVAI = comptroller.mintedVAIs(minter);\n uint256 repayAmount = 0;\n\n if (totalMintedVAI > 0) {\n repayAmount = getVAIRepayAmount(minter);\n }\n\n (vars.mErr, vars.sumBorrowPlusEffects) = addUInt(vars.sumBorrowPlusEffects, repayAmount);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, accountMintableVAI) = mulUInt(vars.sumSupply, comptroller.vaiMintRate());\n require(vars.mErr == MathError.NO_ERROR, \"VAI_MINT_AMOUNT_CALCULATION_FAILED\");\n\n (vars.mErr, accountMintableVAI) = divUInt(accountMintableVAI, 10000);\n require(vars.mErr == MathError.NO_ERROR, \"VAI_MINT_AMOUNT_CALCULATION_FAILED\");\n\n (vars.mErr, accountMintableVAI) = subUInt(accountMintableVAI, vars.sumBorrowPlusEffects);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.REJECTION), 0);\n }\n\n return (uint256(Error.NO_ERROR), accountMintableVAI);\n }\n\n /**\n * @notice Update treasury data\n * @param newTreasuryGuardian New Treasury Guardian address\n * @param newTreasuryAddress New Treasury Address\n * @param newTreasuryPercent New fee percentage for minting VAI that is sent to the treasury\n */\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256) {\n // Check caller is admin\n if (!(msg.sender == admin || msg.sender == treasuryGuardian)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_TREASURY_OWNER_CHECK);\n }\n\n require(newTreasuryPercent < 1e18, \"treasury percent cap overflow\");\n\n address oldTreasuryGuardian = treasuryGuardian;\n address oldTreasuryAddress = treasuryAddress;\n uint256 oldTreasuryPercent = treasuryPercent;\n\n treasuryGuardian = newTreasuryGuardian;\n treasuryAddress = newTreasuryAddress;\n treasuryPercent = newTreasuryPercent;\n\n emit NewTreasuryGuardian(oldTreasuryGuardian, newTreasuryGuardian);\n emit NewTreasuryAddress(oldTreasuryAddress, newTreasuryAddress);\n emit NewTreasuryPercent(oldTreasuryPercent, newTreasuryPercent);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Gets yearly VAI interest rate based on the VAI price\n * @return uint256 Yearly VAI interest rate\n */\n function getVAIRepayRate() public view returns (uint256) {\n PriceOracle oracle = comptroller.oracle();\n MathError mErr;\n\n if (baseRateMantissa > 0) {\n if (floatRateMantissa > 0) {\n uint256 oraclePrice = oracle.getUnderlyingPrice(VToken(getVAIAddress()));\n if (1e18 > oraclePrice) {\n uint256 delta;\n uint256 rate;\n\n (mErr, delta) = subUInt(1e18, oraclePrice);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, delta) = mulUInt(delta, floatRateMantissa);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, delta) = divUInt(delta, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, rate) = addUInt(delta, baseRateMantissa);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n return rate;\n } else {\n return baseRateMantissa;\n }\n } else {\n return baseRateMantissa;\n }\n } else {\n return 0;\n }\n }\n\n /**\n * @notice Get interest rate per block\n * @return uint256 Interest rate per bock\n */\n function getVAIRepayRatePerBlock() public view returns (uint256) {\n uint256 yearlyRate = getVAIRepayRate();\n\n MathError mErr;\n uint256 rate;\n\n (mErr, rate) = divUInt(yearlyRate, getBlocksPerYear());\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n return rate;\n }\n\n /**\n * @notice Get the last updated interest index for a VAI Minter\n * @param minter Address of VAI minter\n * @return uint256 Returns the interest rate index for a minter\n */\n function getVAIMinterInterestIndex(address minter) public view returns (uint256) {\n uint256 storedIndex = vaiMinterInterestIndex[minter];\n // If the user minted VAI before the stability fee was introduced, accrue\n // starting from stability fee launch\n if (storedIndex == 0) {\n return INITIAL_VAI_MINT_INDEX;\n }\n return storedIndex;\n }\n\n /**\n * @notice Get the current total VAI a user needs to repay\n * @param account The address of the VAI borrower\n * @return (uint256) The total amount of VAI the user needs to repay\n */\n function getVAIRepayAmount(address account) public view returns (uint256) {\n MathError mErr;\n uint256 delta;\n\n uint256 amount = comptroller.mintedVAIs(account);\n uint256 interest = pastVAIInterest[account];\n uint256 totalMintedVAI;\n uint256 newInterest;\n\n (mErr, totalMintedVAI) = subUInt(amount, interest);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, delta) = subUInt(vaiMintIndex, getVAIMinterInterestIndex(account));\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, newInterest) = mulUInt(delta, totalMintedVAI);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, newInterest) = divUInt(newInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, amount) = addUInt(amount, newInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n return amount;\n }\n\n /**\n * @notice Calculate how much VAI the user needs to repay\n * @param borrower The address of the VAI borrower\n * @param repayAmount The amount of VAI being returned\n * @return Amount of VAI to be burned\n * @return Amount of VAI the user needs to pay in current interest\n * @return Amount of VAI the user needs to pay in past interest\n */\n function getVAICalculateRepayAmount(\n address borrower,\n uint256 repayAmount\n ) public view returns (uint256, uint256, uint256) {\n MathError mErr;\n uint256 totalRepayAmount = getVAIRepayAmount(borrower);\n uint256 currentInterest;\n\n (mErr, currentInterest) = subUInt(totalRepayAmount, comptroller.mintedVAIs(borrower));\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, currentInterest) = addUInt(pastVAIInterest[borrower], currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n uint256 burn;\n uint256 partOfCurrentInterest = currentInterest;\n uint256 partOfPastInterest = pastVAIInterest[borrower];\n\n if (repayAmount >= totalRepayAmount) {\n (mErr, burn) = subUInt(totalRepayAmount, currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n } else {\n uint256 delta;\n\n (mErr, delta) = mulUInt(repayAmount, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_PART_CALCULATION_FAILED\");\n\n (mErr, delta) = divUInt(delta, totalRepayAmount);\n require(mErr == MathError.NO_ERROR, \"VAI_PART_CALCULATION_FAILED\");\n\n uint256 totalMintedAmount;\n (mErr, totalMintedAmount) = subUInt(totalRepayAmount, currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_MINTED_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, burn) = mulUInt(totalMintedAmount, delta);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, burn) = divUInt(burn, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfCurrentInterest) = mulUInt(currentInterest, delta);\n require(mErr == MathError.NO_ERROR, \"VAI_CURRENT_INTEREST_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfCurrentInterest) = divUInt(partOfCurrentInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_CURRENT_INTEREST_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfPastInterest) = mulUInt(pastVAIInterest[borrower], delta);\n require(mErr == MathError.NO_ERROR, \"VAI_PAST_INTEREST_CALCULATION_FAILED\");\n\n (mErr, partOfPastInterest) = divUInt(partOfPastInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_PAST_INTEREST_CALCULATION_FAILED\");\n }\n\n return (burn, partOfCurrentInterest, partOfPastInterest);\n }\n\n /**\n * @notice Accrue interest on outstanding minted VAI\n */\n function accrueVAIInterest() public {\n MathError mErr;\n uint256 delta;\n\n (mErr, delta) = mulUInt(getVAIRepayRatePerBlock(), getBlockNumber() - accrualBlockNumber);\n require(mErr == MathError.NO_ERROR, \"VAI_INTEREST_ACCRUE_FAILED\");\n\n (mErr, delta) = addUInt(delta, vaiMintIndex);\n require(mErr == MathError.NO_ERROR, \"VAI_INTEREST_ACCRUE_FAILED\");\n\n vaiMintIndex = delta;\n accrualBlockNumber = getBlockNumber();\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _ensureNonzeroAddress(newAccessControlAddress);\n\n address oldAccessControlAddress = accessControl;\n accessControl = newAccessControlAddress;\n emit NewAccessControl(oldAccessControlAddress, accessControl);\n }\n\n /**\n * @notice Set VAI borrow base rate\n * @param newBaseRateMantissa the base rate multiplied by 10**18\n */\n function setBaseRate(uint256 newBaseRateMantissa) external {\n _ensureAllowed(\"setBaseRate(uint256)\");\n\n uint256 old = baseRateMantissa;\n baseRateMantissa = newBaseRateMantissa;\n emit NewVAIBaseRate(old, baseRateMantissa);\n }\n\n /**\n * @notice Set VAI borrow float rate\n * @param newFloatRateMantissa the VAI float rate multiplied by 10**18\n */\n function setFloatRate(uint256 newFloatRateMantissa) external {\n _ensureAllowed(\"setFloatRate(uint256)\");\n\n uint256 old = floatRateMantissa;\n floatRateMantissa = newFloatRateMantissa;\n emit NewVAIFloatRate(old, floatRateMantissa);\n }\n\n /**\n * @notice Set VAI stability fee receiver address\n * @param newReceiver the address of the VAI fee receiver\n */\n function setReceiver(address newReceiver) external onlyAdmin {\n _ensureNonzeroAddress(newReceiver);\n\n address old = receiver;\n receiver = newReceiver;\n emit NewVAIReceiver(old, newReceiver);\n }\n\n /**\n * @notice Set VAI mint cap\n * @param _mintCap the amount of VAI that can be minted\n */\n function setMintCap(uint256 _mintCap) external {\n _ensureAllowed(\"setMintCap(uint256)\");\n\n uint256 old = mintCap;\n mintCap = _mintCap;\n emit NewVAIMintCap(old, _mintCap);\n }\n\n function getBlockNumber() internal view returns (uint256) {\n return block.number;\n }\n\n function getBlocksPerYear() public view returns (uint256) {\n return 10512000; //(24 * 60 * 60 * 365) / 3;\n }\n\n /**\n * @notice Return the address of the VAI token\n * @return The address of VAI\n */\n function getVAIAddress() public view returns (address) {\n return vai;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n function _ensureAllowed(string memory functionSig) private view {\n require(IAccessControlManagerV5(accessControl).isAllowedToCall(msg.sender, functionSig), \"access denied\");\n }\n\n /// @dev Reverts if the protocol is paused\n function _ensureNotPaused() private view {\n require(!comptroller.protocolPaused(), \"protocol is paused\");\n }\n\n /// @dev Reverts if the passed address is zero\n function _ensureNonzeroAddress(address someone) private pure {\n require(someone != address(0), \"can't be zero address\");\n }\n\n /// @dev Reverts if the passed amount is zero\n function _ensureNonzeroAmount(uint256 amount) private pure {\n require(amount > 0, \"amount can't be zero\");\n }\n}\n" + }, + "contracts/Tokens/VAI/VAIControllerInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VTokenInterface } from \"../VTokens/VTokenInterfaces.sol\";\n\ncontract VAIControllerInterface {\n function mintVAI(uint256 mintVAIAmount) external returns (uint256);\n\n function repayVAI(uint256 amount) external returns (uint256, uint256);\n\n function repayVAIBehalf(address borrower, uint256 amount) external returns (uint256, uint256);\n\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint256, uint256);\n\n function getMintableVAI(address minter) external view returns (uint256, uint256);\n\n function getVAIAddress() external view returns (address);\n\n function getVAIRepayAmount(address account) external view returns (uint256);\n}\n" + }, + "contracts/Tokens/VAI/VAIControllerStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { ComptrollerInterface } from \"../../Comptroller/ComptrollerInterface.sol\";\n\ncontract VAIUnitrollerAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of Unitroller\n */\n address public vaiControllerImplementation;\n\n /**\n * @notice Pending brains of Unitroller\n */\n address public pendingVAIControllerImplementation;\n}\n\ncontract VAIControllerStorageG1 is VAIUnitrollerAdminStorage {\n ComptrollerInterface public comptroller;\n\n struct VenusVAIState {\n /// @notice The last updated venusVAIMintIndex\n uint224 index;\n /// @notice The block number the index was last updated at\n uint32 block;\n }\n\n /// @notice The Venus VAI state\n VenusVAIState public venusVAIState;\n\n /// @notice The Venus VAI state initialized\n bool public isVenusVAIInitialized;\n\n /// @notice The Venus VAI minter index as of the last time they accrued XVS\n mapping(address => uint256) public venusVAIMinterIndex;\n}\n\ncontract VAIControllerStorageG2 is VAIControllerStorageG1 {\n /// @notice Treasury Guardian address\n address public treasuryGuardian;\n\n /// @notice Treasury address\n address public treasuryAddress;\n\n /// @notice Fee percent of accrued interest with decimal 18\n uint256 public treasuryPercent;\n\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice The base rate for stability fee\n uint256 public baseRateMantissa;\n\n /// @notice The float rate for stability fee\n uint256 public floatRateMantissa;\n\n /// @notice The address for VAI interest receiver\n address public receiver;\n\n /// @notice Accumulator of the total earned interest rate since the opening of the market. For example: 0.6 (60%)\n uint256 public vaiMintIndex;\n\n /// @notice Block number that interest was last accrued at\n uint256 internal accrualBlockNumber;\n\n /// @notice Global vaiMintIndex as of the most recent balance-changing action for user\n mapping(address => uint256) internal vaiMinterInterestIndex;\n\n /// @notice Tracks the amount of mintedVAI of a user that represents the accrued interest\n mapping(address => uint256) public pastVAIInterest;\n\n /// @notice VAI mint cap\n uint256 public mintCap;\n\n /// @notice Access control manager address\n address public accessControl;\n}\n\ncontract VAIControllerStorageG3 is VAIControllerStorageG2 {\n /// @notice The address of the prime contract. It can be a ZERO address\n address public prime;\n\n /// @notice Tracks if minting is enabled only for prime token holders. Only used if prime is set\n bool public mintEnabledOnlyForPrimeHolder;\n}\n\ncontract VAIControllerStorageG4 is VAIControllerStorageG3 {\n /// @notice The address of the VAI token\n address internal vai;\n}\n" + }, + "contracts/Tokens/VAI/VAIUnitroller.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/ErrorReporter.sol\";\nimport \"./VAIControllerStorage.sol\";\n\n/**\n * @title VAI Unitroller\n * @author Venus\n * @notice This is the proxy contract for the VAIComptroller\n */\ncontract VAIUnitroller is VAIUnitrollerAdminStorage, VAIControllerErrorReporter {\n /**\n * @notice Emitted when pendingVAIControllerImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingVAIControllerImplementation is accepted, which means comptroller implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint256) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingVAIControllerImplementation;\n\n pendingVAIControllerImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIControllerImplementation);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint256) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingVAIControllerImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = vaiControllerImplementation;\n address oldPendingImplementation = pendingVAIControllerImplementation;\n\n vaiControllerImplementation = pendingVAIControllerImplementation;\n\n pendingVAIControllerImplementation = address(0);\n\n emit NewImplementation(oldImplementation, vaiControllerImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIControllerImplementation);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint256) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = vaiControllerImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/VRT/VRT.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/Tokenlock.sol\";\n\ncontract VRT is Tokenlock {\n /// @notice BEP-20 token name for this token\n string public constant name = \"Venus Reward Token\";\n\n /// @notice BEP-20 token symbol for this token\n string public constant symbol = \"VRT\";\n\n /// @notice BEP-20 token decimals for this token\n uint8 public constant decimals = 18;\n\n /// @notice Total number of tokens in circulation\n uint public constant totalSupply = 30000000000e18; // 30 billion VRT\n\n /// @notice Allowance amounts on behalf of others\n mapping(address => mapping(address => uint96)) internal allowances;\n\n /// @notice Official record of token balances for each account\n mapping(address => uint96) internal balances;\n\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A checkpoint for marking number of votes from a given block\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice The standard BEP-20 transfer event\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /// @notice The standard BEP-20 approval event\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Construct a new VRT token\n * @param account The initial account to grant all the tokens\n */\n constructor(address account) public {\n balances[account] = uint96(totalSupply);\n emit Transfer(address(0), account, totalSupply);\n }\n\n /**\n * @notice Get the number of tokens `spender` is approved to spend on behalf of `account`\n * @param account The address of the account holding the funds\n * @param spender The address of the account spending the funds\n * @return The number of tokens approved\n */\n function allowance(address account, address spender) external view returns (uint) {\n return allowances[account][spender];\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param rawAmount The number of tokens that are approved (2^256-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint rawAmount) external validLock returns (bool) {\n uint96 amount;\n if (rawAmount == uint(-1)) {\n amount = uint96(-1);\n } else {\n amount = safe96(rawAmount, \"VRT::approve: amount exceeds 96 bits\");\n }\n\n allowances[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the number of tokens held by the `account`\n * @param account The address of the account to get the balance of\n * @return The number of tokens held\n */\n function balanceOf(address account) external view returns (uint) {\n return balances[account];\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint rawAmount) external validLock returns (bool) {\n uint96 amount = safe96(rawAmount, \"VRT::transfer: amount exceeds 96 bits\");\n _transferTokens(msg.sender, dst, amount);\n return true;\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint rawAmount) external validLock returns (bool) {\n address spender = msg.sender;\n uint96 spenderAllowance = allowances[src][spender];\n uint96 amount = safe96(rawAmount, \"VRT::approve: amount exceeds 96 bits\");\n\n if (spender != src && spenderAllowance != uint96(-1)) {\n uint96 newAllowance = sub96(\n spenderAllowance,\n amount,\n \"VRT::transferFrom: transfer amount exceeds spender allowance\"\n );\n allowances[src][spender] = newAllowance;\n\n emit Approval(src, spender, newAllowance);\n }\n\n _transferTokens(src, dst, amount);\n return true;\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) public validLock {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public validLock {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"VRT::delegateBySig: invalid signature\");\n require(nonce == nonces[signatory]++, \"VRT::delegateBySig: invalid nonce\");\n require(now <= expiry, \"VRT::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n /**\n * @notice Determine the prior number of votes for an account as of a block number\n * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n * @param account The address of the account to check\n * @param blockNumber The block number to get the vote balance at\n * @return The number of votes the account had as of the given block\n */\n function getPriorVotes(address account, uint blockNumber) public view returns (uint96) {\n require(blockNumber < block.number, \"VRT::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlock > blockNumber) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlock == blockNumber) {\n return cp.votes;\n } else if (cp.fromBlock < blockNumber) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = balances[delegator];\n delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _transferTokens(address src, address dst, uint96 amount) internal {\n require(src != address(0), \"VRT::_transferTokens: cannot transfer from the zero address\");\n require(dst != address(0), \"VRT::_transferTokens: cannot transfer to the zero address\");\n\n balances[src] = sub96(balances[src], amount, \"VRT::_transferTokens: transfer amount exceeds balance\");\n balances[dst] = add96(balances[dst], amount, \"VRT::_transferTokens: transfer amount overflows\");\n emit Transfer(src, dst, amount);\n\n _moveDelegates(delegates[src], delegates[dst], amount);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"VRT::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"VRT::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumber = safe32(block.number, \"VRT::_writeCheckpoint: block number exceeds 32 bits\");\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChanged(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverter.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/IBEP20.sol\";\nimport \"../../Utils/SafeBEP20.sol\";\nimport \"../XVS/IXVSVesting.sol\";\nimport \"./VRTConverterStorage.sol\";\nimport \"./VRTConverterProxy.sol\";\n\n/**\n * @title Venus's VRTConversion Contract\n * @author Venus\n */\ncontract VRTConverter is VRTConverterStorage {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n address public constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;\n\n /// @notice decimal precision for VRT\n uint256 public constant vrtDecimalsMultiplier = 1e18;\n\n /// @notice decimal precision for XVS\n uint256 public constant xvsDecimalsMultiplier = 1e18;\n\n /// @notice Emitted when an admin set conversion info\n event ConversionInfoSet(\n uint256 conversionRatio,\n uint256 conversionStartTime,\n uint256 conversionPeriod,\n uint256 conversionEndTime\n );\n\n /// @notice Emitted when token conversion is done\n event TokenConverted(\n address reedeemer,\n address vrtAddress,\n uint256 vrtAmount,\n address xvsAddress,\n uint256 xvsAmount\n );\n\n /// @notice Emitted when an admin withdraw converted token\n event TokenWithdraw(address token, address to, uint256 amount);\n\n /// @notice Emitted when XVSVestingAddress is set\n event XVSVestingSet(address xvsVestingAddress);\n\n constructor() public {}\n\n function initialize(\n address _vrtAddress,\n address _xvsAddress,\n uint256 _conversionRatio,\n uint256 _conversionStartTime,\n uint256 _conversionPeriod\n ) public {\n require(msg.sender == admin, \"only admin may initialize the VRTConverter\");\n require(initialized == false, \"VRTConverter is already initialized\");\n\n require(_vrtAddress != address(0), \"vrtAddress cannot be Zero\");\n vrt = IBEP20(_vrtAddress);\n\n require(_xvsAddress != address(0), \"xvsAddress cannot be Zero\");\n xvs = IBEP20(_xvsAddress);\n\n require(_conversionRatio > 0, \"conversionRatio cannot be Zero\");\n conversionRatio = _conversionRatio;\n\n require(_conversionStartTime >= block.timestamp, \"conversionStartTime must be time in the future\");\n require(_conversionPeriod > 0, \"_conversionPeriod is invalid\");\n\n conversionStartTime = _conversionStartTime;\n conversionPeriod = _conversionPeriod;\n conversionEndTime = conversionStartTime.add(conversionPeriod);\n emit ConversionInfoSet(conversionRatio, conversionStartTime, conversionPeriod, conversionEndTime);\n\n totalVrtConverted = 0;\n _notEntered = true;\n initialized = true;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @notice sets XVSVestingProxy Address\n * @dev Note: If XVSVestingProxy is not set, then Conversion is not allowed\n * @param _xvsVestingAddress The XVSVestingProxy Address\n */\n function setXVSVesting(address _xvsVestingAddress) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_xvsVestingAddress != address(0), \"xvsVestingAddress cannot be Zero\");\n xvsVesting = IXVSVesting(_xvsVestingAddress);\n emit XVSVestingSet(_xvsVestingAddress);\n }\n\n modifier isInitialized() {\n require(initialized == true, \"VRTConverter is not initialized\");\n _;\n }\n\n function isConversionActive() public view returns (bool) {\n uint256 currentTime = block.timestamp;\n if (currentTime >= conversionStartTime && currentTime <= conversionEndTime) {\n return true;\n }\n return false;\n }\n\n modifier checkForActiveConversionPeriod() {\n uint256 currentTime = block.timestamp;\n require(currentTime >= conversionStartTime, \"Conversion did not start yet\");\n require(currentTime <= conversionEndTime, \"Conversion Period Ended\");\n _;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Transfer VRT and redeem XVS\n * @dev Note: If there is not enough XVS, we do not perform the conversion.\n * @param vrtAmount The amount of VRT\n */\n function convert(uint256 vrtAmount) external isInitialized checkForActiveConversionPeriod nonReentrant {\n require(\n address(xvsVesting) != address(0) && address(xvsVesting) != DEAD_ADDRESS,\n \"XVS-Vesting Address is not set\"\n );\n require(vrtAmount > 0, \"VRT amount must be non-zero\");\n totalVrtConverted = totalVrtConverted.add(vrtAmount);\n\n uint256 redeemAmount = vrtAmount.mul(conversionRatio).mul(xvsDecimalsMultiplier).div(1e18).div(\n vrtDecimalsMultiplier\n );\n\n emit TokenConverted(msg.sender, address(vrt), vrtAmount, address(xvs), redeemAmount);\n vrt.safeTransferFrom(msg.sender, DEAD_ADDRESS, vrtAmount);\n xvsVesting.deposit(msg.sender, redeemAmount);\n }\n\n /*** Admin Functions ***/\n function _become(VRTConverterProxy vrtConverterProxy) public {\n require(msg.sender == vrtConverterProxy.admin(), \"only proxy admin can change brains\");\n vrtConverterProxy._acceptImplementation();\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverterProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VRTConverterStorage.sol\";\n\ncontract VRTConverterProxy is VRTConverterAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means VRTConverter implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(\n address implementation_,\n address _vrtAddress,\n address _xvsAddress,\n uint256 _conversionRatio,\n uint256 _conversionStartTime,\n uint256 _conversionPeriod\n ) public nonZeroAddress(implementation_) nonZeroAddress(_vrtAddress) nonZeroAddress(_xvsAddress) {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,uint256,uint256,uint256)\",\n _vrtAddress,\n _xvsAddress,\n _conversionRatio,\n _conversionStartTime,\n _conversionPeriod\n )\n );\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"VRTConverterProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"VRTConverterProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal nonZeroAddress(callee) returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(\n address newPendingImplementation\n ) public nonZeroAddress(newPendingImplementation) {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRTConverter. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public nonZeroAddress(newPendingAdmin) {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n require(newPendingAdmin != pendingAdmin, \"New pendingAdmin can not be same as the previous one\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverterStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/SafeMath.sol\";\nimport \"../../Utils/IBEP20.sol\";\nimport \"../XVS/IXVSVesting.sol\";\n\ncontract VRTConverterAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VRTConverter\n */\n address public implementation;\n\n /**\n * @notice Pending brains of VRTConverter\n */\n address public pendingImplementation;\n}\n\ncontract VRTConverterStorage is VRTConverterAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice indicator to check if the contract is initialized\n bool public initialized;\n\n /// @notice The VRT TOKEN!\n IBEP20 public vrt;\n\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice XVSVesting Contract reference\n IXVSVesting public xvsVesting;\n\n /// @notice Conversion ratio from VRT to XVS with decimal 18\n uint256 public conversionRatio;\n\n /// @notice total VRT converted to XVS\n uint256 public totalVrtConverted;\n\n /// @notice Conversion Start time in EpochSeconds\n uint256 public conversionStartTime;\n\n /// @notice ConversionPeriod in Seconds\n uint256 public conversionPeriod;\n\n /// @notice Conversion End time in EpochSeconds\n uint256 public conversionEndTime;\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VBep20DelegateR1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../VTokenInterfaces.sol\";\nimport { VBep20R1 } from \"./VBep20R1.sol\";\nimport { VDelegateInterface } from \"./VTokenInterfaceR1.sol\";\n\n/**\n * @title Venus's VBep20Delegate Contract\n * @notice VTokens which wrap an EIP-20 underlying and are delegated to\n * @author Venus\n */\ncontract VBep20DelegateR1 is VBep20R1, VDelegateInterface {\n /**\n * @notice Construct an empty delegate\n */\n constructor() public {}\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public {\n // Shh -- currently unused\n data;\n\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _becomeImplementation\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public {\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _resignImplementation\");\n }\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VBep20DelegatorR1.sol": { + "content": "pragma solidity ^0.5.16;\nimport \"../VTokenInterfaces.sol\";\nimport \"./VTokenInterfaceR1.sol\";\n\n/**\n * @title Venus's VBep20Delegator Contract\n * @notice vTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Venus\n */\ncontract VBep20DelegatorR1 is VTokenInterfaceR1, VBep20Interface, VDelegatorInterface {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n * @param implementation_ The address of the implementation the contract delegates to\n * @param becomeImplementationData The encoded args for becomeImplementation\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,address,uint256,string,string,uint8)\",\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n )\n );\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_, false, becomeImplementationData);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n */\n function() external payable {\n require(msg.value == 0, \"VBep20Delegator:fallback: cannot send value to fallback\");\n\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mint(uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"mint(uint256)\", mintAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"mintBehalf(address,uint256)\", receiver, mintAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying asset\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeem(uint redeemTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"redeem(uint256)\", redeemTokens));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"redeemUnderlying(uint256)\", redeemAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrow(uint borrowAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrow(uint256)\", borrowAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrow(uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"repayBorrow(uint256)\", repayAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrower\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"repayBorrowBehalf(address,uint256)\", borrower, repayAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"liquidateBorrow(address,uint256,address)\", borrower, repayAmount, vTokenCollateral)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint amount) external returns (bool) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"transfer(address,uint256)\", dst, amount));\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", src, dst, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"approve(address,uint256)\", spender, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"balanceOfUnderlying(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"totalBorrowsCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrowBalanceCurrent(address)\", account));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * It's absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"seize(address,address,uint256)\", liquidator, borrower, seizeTokens)\n );\n return abi.decode(data, (uint));\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setPendingAdmin(address)\", newPendingAdmin)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setReserveFactor(uint256)\", newReserveFactorMantissa)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accepts transfer of admin rights. `msg.sender` must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _acceptAdmin() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_acceptAdmin()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from admin\n * @param addAmount Amount of reserves to add\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReserves(uint addAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_addReserves(uint256)\", addAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReserves(uint reduceAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_reduceReserves(uint256)\", reduceAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"getCash()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"allowance(address,address)\", owner, spender)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"balanceOf(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get a snapshot of the account's balances and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"getAccountSnapshot(address)\", account)\n );\n return abi.decode(data, (uint, uint, uint, uint));\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"borrowRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"supplyRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n // @custom:access Only callable by admin\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public {\n require(msg.sender == admin, \"VBep20Delegator::_setImplementation: Caller must be admin\");\n\n if (allowResign) {\n delegateToImplementation(abi.encodeWithSignature(\"_resignImplementation()\"));\n }\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n delegateToImplementation(abi.encodeWithSignature(\"_becomeImplementation(bytes)\", becomeImplementationData));\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"exchangeRateCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves.\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"accrueInterest()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setComptroller(address)\", newComptroller)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using `_setInterestRateModelFresh`\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setInterestRateModel(address)\", newInterestRateModel)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Delegates execution to the implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToImplementation(bytes memory data) public returns (bytes memory) {\n return delegateTo(implementation, data);\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {\n (bool success, bytes memory returnData) = address(this).staticcall(\n abi.encodeWithSignature(\"delegateToImplementation(bytes)\", data)\n );\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return abi.decode(returnData, (bytes));\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"borrowBalanceStored(address)\", account)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"exchangeRateStored()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VBep20R1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VTokenR1, VBep20Interface, ComptrollerInterface, InterestRateModel, VTokenInterface } from \"./VTokenR1.sol\";\nimport { EIP20Interface } from \"../../EIP20Interface.sol\";\nimport { EIP20NonStandardInterface } from \"../../EIP20NonStandardInterface.sol\";\n\n/**\n * @title Venus's VBep20 Contract\n * @notice vTokens which wrap an EIP-20 underlying\n * @author Venus\n */\ncontract VBep20R1 is VTokenR1, VBep20Interface {\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint(uint mintAmount) external returns (uint) {\n (uint err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits MintBehalf event\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n (uint err, ) = mintBehalfInternal(receiver, mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The user on behalf of whom to redeem\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemBehalf(address redeemer, uint redeemTokens) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemInternal(redeemer, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer, on behalf of whom to redeem\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlyingBehalf(address redeemer, uint redeemAmount) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemUnderlyingInternal(redeemer, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender borrows assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the borrower using `comptroller.updateDelegate`\n * @param borrower The borrower, on behalf of whom to borrow.\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrowBehalf(address borrower, uint borrowAmount) external returns (uint) {\n require(comptroller.approvedDelegates(borrower, msg.sender), \"not an approved delegate\");\n return borrowInternal(borrower, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow(uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n (uint err, ) = liquidateBorrowInternal(borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n /**\n * @notice The sender adds to reserves.\n * @param addAmount The amount of underlying tokens to add as reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesAdded event\n function _addReserves(uint addAmount) external returns (uint) {\n return _addReservesInternal(addAmount);\n }\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n */\n function initialize(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n // VToken initialize does the bulk of the work\n super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n EIP20NonStandardInterface(underlying).transferFrom(from, address(this), amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_IN_FAILED\");\n\n // Calculate the amount that was *actually* transferred\n uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address payable to, uint amount) internal {\n EIP20NonStandardInterface(underlying).transfer(to, amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_OUT_FAILED\");\n }\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VTokenInterfaceR1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../../InterestRateModels/InterestRateModel.sol\";\nimport \"../VTokenInterfaces.sol\";\n\ncontract VTokenInterfaceR1 is VTokenStorage {\n /**\n * @notice Indicator that this is a vToken contract (for inspection)\n */\n bool public constant isVToken = true;\n\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows);\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint mintAmount, uint mintTokens);\n\n /**\n * @notice Event emitted when tokens are minted behalf by payer to receiver\n */\n event MintBehalf(address payer, address receiver, uint mintAmount, uint mintTokens);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint redeemAmount, uint redeemTokens);\n\n /**\n * @notice Event emitted when tokens are redeemed and fee is transferred\n */\n event RedeemFee(address redeemer, uint feeAmount, uint redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint repayAmount,\n address vTokenCollateral,\n uint seizeTokens\n );\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Event emitted when pendingAdmin is accepted, which means admin has been updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @notice Event emitted when comptroller is changed\n */\n event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address protocolShareReserve, uint reduceAmount, uint newTotalReserves);\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint amount);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint amount);\n\n /**\n * @notice Event emitted when block delta for reduce reserves get updated\n */\n event NewReduceReservesBlockDelta(uint256 oldReduceReservesBlockDelta, uint256 newReduceReservesBlockDelta);\n\n /**\n * @notice Event emitted when address of ProtocolShareReserve contract get updated\n */\n event NewProtocolShareReserve(address indexed oldProtocolShareReserve, address indexed newProtocolShareReserve);\n\n /**\n * @notice Failure event\n */\n event Failure(uint error, uint info, uint detail);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControlManager(address oldAccessControlAddress, address newAccessControlAddress);\n\n /*** User Interface ***/\n\n function transfer(address dst, uint amount) external returns (bool);\n\n function transferFrom(address src, address dst, uint amount) external returns (bool);\n\n function approve(address spender, uint amount) external returns (bool);\n\n function balanceOfUnderlying(address owner) external returns (uint);\n\n function totalBorrowsCurrent() external returns (uint);\n\n function borrowBalanceCurrent(address account) external returns (uint);\n\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint);\n\n /*** Admin Function ***/\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint);\n\n /*** Admin Function ***/\n function _acceptAdmin() external returns (uint);\n\n /*** Admin Function ***/\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint);\n\n /*** Admin Function ***/\n function _reduceReserves(uint reduceAmount) external returns (uint);\n\n function balanceOf(address owner) external view returns (uint);\n\n function allowance(address owner, address spender) external view returns (uint);\n\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint);\n\n function borrowRatePerBlock() external view returns (uint);\n\n function supplyRatePerBlock() external view returns (uint);\n\n function getCash() external view returns (uint);\n\n function exchangeRateCurrent() public returns (uint);\n\n function accrueInterest() public returns (uint);\n\n /*** Admin Function ***/\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint);\n\n /*** Admin Function ***/\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint);\n\n function borrowBalanceStored(address account) public view returns (uint);\n\n function exchangeRateStored() public view returns (uint);\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VTokenR1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../../Utils/ErrorReporter.sol\";\nimport \"../../../Utils/Exponential.sol\";\nimport \"../../../Tokens/EIP20Interface.sol\";\nimport \"../../../Tokens/EIP20NonStandardInterface.sol\";\nimport \"../../../InterestRateModels/InterestRateModel.sol\";\nimport \"../VTokenInterfaces.sol\";\nimport { VTokenInterfaceR1 } from \"./VTokenInterfaceR1.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\n\n/**\n * @title Venus's vToken Contract\n * @notice Abstract base for vTokens\n * @author Venus\n */\ncontract VTokenR1 is VTokenInterfaceR1, Exponential, TokenErrorReporter {\n struct MintLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint mintTokens;\n uint totalSupplyNew;\n uint accountTokensNew;\n uint actualMintAmount;\n }\n\n struct RedeemLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint redeemTokens;\n uint redeemAmount;\n uint totalSupplyNew;\n uint accountTokensNew;\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint repayAmount;\n uint borrowerIndex;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n uint actualRepayAmount;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transfer(address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transferFrom(address src, address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n // @custom:event Emits Approval event on successful approve\n function approve(address spender, uint256 amount) external returns (bool) {\n transferAllowances[msg.sender][spender] = amount;\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n ensureNoMathError(mErr);\n return balance;\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return totalBorrows;\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return borrowBalanceStored(account);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewPendingAdmin event with old and new admin addresses\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n // Check caller = admin\n ensureAdmin(msg.sender);\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewAdmin event on successful acceptance\n // @custom:event Emits NewPendingAdmin event with null new pending admin\n function _acceptAdmin() external returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using `_setReserveFactorFresh`\n * @dev Governor function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewReserveFactor event\n function _setReserveFactor(uint newReserveFactorMantissa_) external nonReentrant returns (uint) {\n ensureAllowed(\"_setReserveFactor(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed.\n return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);\n }\n // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to.\n return _setReserveFactorFresh(newReserveFactorMantissa_);\n }\n\n /**\n * @notice Sets the address of the access control manager of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlManagerAddress New address for the access control\n * @return uint 0=success, otherwise will revert\n */\n function setAccessControlManager(address newAccessControlManagerAddress) external returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ensureNonZeroAddress(newAccessControlManagerAddress);\n\n emit NewAccessControlManager(accessControlManager, newAccessControlManagerAddress);\n accessControlManager = newAccessControlManagerAddress;\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to protocol share reserve\n * @param reduceAmount_ Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesReduced event\n function _reduceReserves(uint reduceAmount_) external nonReentrant returns (uint) {\n ensureAllowed(\"_reduceReserves(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // If reserves were reduced in accrueInterest\n if (reduceReservesBlockNumber == block.number) return (uint(Error.NO_ERROR));\n // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.\n return _reduceReservesFresh(reduceAmount_);\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint256) {\n return accountTokens[owner];\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n uint vTokenBalance = accountTokens[account];\n uint borrowBalance;\n uint exchangeRateMantissa;\n\n MathError mErr;\n\n (mErr, borrowBalance) = borrowBalanceStoredInternal(account);\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n (mErr, exchangeRateMantissa) = exchangeRateStoredInternal();\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n return (uint(Error.NO_ERROR), vTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves);\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n return getCashPrior();\n }\n\n /**\n * @notice Governance function to set new threshold of block difference after which funds will be sent to the protocol share reserve\n * @param newReduceReservesBlockDelta_ block difference value\n */\n function setReduceReservesBlockDelta(uint256 newReduceReservesBlockDelta_) external {\n require(newReduceReservesBlockDelta_ > 0, \"Invalid Input\");\n ensureAllowed(\"setReduceReservesBlockDelta(uint256)\");\n emit NewReduceReservesBlockDelta(reduceReservesBlockDelta, newReduceReservesBlockDelta_);\n reduceReservesBlockDelta = newReduceReservesBlockDelta_;\n }\n\n /**\n * @notice Sets protocol share reserve contract address\n * @param protcolShareReserve_ The address of protocol share reserve contract\n */\n function setProtocolShareReserve(address payable protcolShareReserve_) external {\n // Check caller is admin\n ensureAdmin(msg.sender);\n ensureNonZeroAddress(protcolShareReserve_);\n emit NewProtocolShareReserve(protocolShareReserve, protcolShareReserve_);\n protocolShareReserve = protcolShareReserve_;\n }\n\n /**\n * @notice Initialize the money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ EIP-20 name of this token\n * @param symbol_ EIP-20 symbol of this token\n * @param decimals_ EIP-20 decimal precision of this token\n */\n function initialize(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n ensureAdmin(msg.sender);\n require(accrualBlockNumber == 0 && borrowIndex == 0, \"market may only be initialized once\");\n\n // Set initial exchange rate\n initialExchangeRateMantissa = initialExchangeRateMantissa_;\n require(initialExchangeRateMantissa > 0, \"initial exchange rate must be greater than zero.\");\n\n // Set the comptroller\n uint err = _setComptroller(comptroller_);\n require(err == uint(Error.NO_ERROR), \"setting comptroller failed\");\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = mantissaOne;\n\n // Set the interest rate model (depends on block number / borrow index)\n err = _setInterestRateModelFresh(interestRateModel_);\n require(err == uint(Error.NO_ERROR), \"setting interest rate model failed\");\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return exchangeRateStored();\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage and\n * reduce spread reserves to protocol share reserve\n * if currentBlock - reduceReservesBlockNumber >= blockDelta\n */\n // @custom:event Emits AccrueInterest event\n function accrueInterest() public returns (uint) {\n /* Remember the initial block number */\n uint currentBlockNumber = block.number;\n uint accrualBlockNumberPrior = accrualBlockNumber;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumberPrior == currentBlockNumber) {\n return uint(Error.NO_ERROR);\n }\n\n /* Read the previous values out of storage */\n uint cashPrior = getCashPrior();\n uint borrowsPrior = totalBorrows;\n uint reservesPrior = totalReserves;\n uint borrowIndexPrior = borrowIndex;\n\n /* Calculate the current borrow interest rate */\n uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior);\n require(borrowRateMantissa <= borrowRateMaxMantissa, \"borrow rate is absurdly high\");\n\n /* Calculate the number of blocks elapsed since the last accrual */\n (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);\n ensureNoMathError(mathErr);\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n Exp memory simpleInterestFactor;\n uint interestAccumulated;\n uint totalBorrowsNew;\n uint totalReservesNew;\n uint borrowIndexNew;\n\n (mathErr, simpleInterestFactor) = mulScalar(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n interestAccumulated,\n reservesPrior\n );\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = borrowIndexNew;\n totalBorrows = totalBorrowsNew;\n totalReserves = totalReservesNew;\n\n (mathErr, blockDelta) = subUInt(currentBlockNumber, reduceReservesBlockNumber);\n ensureNoMathError(mathErr);\n if (blockDelta >= reduceReservesBlockDelta) {\n reduceReservesBlockNumber = currentBlockNumber;\n if (cashPrior < totalReservesNew) {\n _reduceReservesFresh(cashPrior);\n } else {\n _reduceReservesFresh(totalReservesNew);\n }\n }\n\n /* We emit an AccrueInterest event */\n emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewComptroller event\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ComptrollerInterface oldComptroller = comptroller;\n // Ensure invoke comptroller.isComptroller() returns true\n require(newComptroller.isComptroller(), \"marker method returned false\");\n\n // Set market's comptroller to newComptroller\n comptroller = newComptroller;\n\n // Emit NewComptroller(oldComptroller, newComptroller)\n emit NewComptroller(oldComptroller, newComptroller);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Governance function to accrue interest and update the interest rate model\n * @param newInterestRateModel_ The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel_) public returns (uint) {\n ensureAllowed(\"_setInterestRateModel(address)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed\n return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);\n }\n // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.\n return _setInterestRateModelFresh(newInterestRateModel_);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n (MathError err, uint result) = exchangeRateStoredInternal();\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n (MathError err, uint result) = borrowBalanceStoredInternal(account);\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Transfers `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) {\n /* Fail if transfer not allowed */\n uint allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint startingAllowance = 0;\n if (spender == src) {\n startingAllowance = uint(-1);\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint allowanceNew;\n uint srvTokensNew;\n uint dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srvTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srvTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != uint(-1)) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mint failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n /**\n * @notice User supplies assets into the market and receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) {\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The address of the account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfInternal(address receiver, uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mintBehalf failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintBelahfFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintBehalfFresh(msg.sender, receiver, mintAmount);\n }\n\n /**\n * @notice Payer supplies assets into the market and receiver receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param payer The address of the account which is paying the underlying token\n * @param receiver The address of the account which is receiving vToken\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfFresh(address payer, address receiver, uint mintAmount) internal returns (uint, uint) {\n ensureNonZeroAddress(receiver);\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), receiver, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the payer and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(payer, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and receiver token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[receiver] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[receiver], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[receiver] = vars.accountTokensNew;\n\n /* We emit a MintBehalf event, and a Transfer event */\n emit MintBehalf(payer, receiver, vars.actualMintAmount, vars.mintTokens);\n emit Transfer(address(this), receiver, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), receiver, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemInternal(\n address redeemer,\n address payable receiver,\n uint redeemTokens\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens, if called by a delegate\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlyingInternal(\n address redeemer,\n address payable receiver,\n uint redeemAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, 0, redeemAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokensIn The number of vTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming vTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // solhint-disable-next-line code-complexity\n function redeemFresh(\n address redeemer,\n address payable receiver,\n uint redeemTokensIn,\n uint redeemAmountIn\n ) internal returns (uint) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"one of redeemTokensIn or redeemAmountIn must be zero\");\n\n RedeemLocalVars memory vars;\n\n /* exchangeRate = invoke Exchange Rate Stored() */\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n ensureNoMathError(vars.mathErr);\n\n /* If redeemTokensIn > 0: */\n if (redeemTokensIn > 0) {\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n ensureNoMathError(vars.mathErr);\n } else {\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(\n redeemAmountIn,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashPrior() < vars.redeemAmount) {\n revert(\"math error\");\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the receiver and the redeemAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n\n uint feeAmount;\n uint remainedAmount;\n if (IComptroller(address(comptroller)).treasuryPercent() != 0) {\n (vars.mathErr, feeAmount) = mulUInt(\n vars.redeemAmount,\n IComptroller(address(comptroller)).treasuryPercent()\n );\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, feeAmount) = divUInt(feeAmount, 1e18);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, remainedAmount) = subUInt(vars.redeemAmount, feeAmount);\n ensureNoMathError(vars.mathErr);\n\n doTransferOut(address(uint160(IComptroller(address(comptroller)).treasuryAddress())), feeAmount);\n\n emit RedeemFee(redeemer, feeAmount, vars.redeemTokens);\n } else {\n remainedAmount = vars.redeemAmount;\n }\n\n doTransferOut(receiver, remainedAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, remainedAmount, vars.redeemTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrowInternal(\n address borrower,\n address payable receiver,\n uint borrowAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED);\n }\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(borrower, receiver, borrowAmount);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @dev Before calling this function, ensure that the interest has been accrued\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise revert (see ErrorReporter.sol for details).\n */\n function borrowFresh(address borrower, address payable receiver, uint borrowAmount) internal returns (uint) {\n /* Revert if borrow not allowed */\n uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /* Revert if protocol has insufficient underlying cash */\n if (getCashPrior() < borrowAmount) {\n revert(\"math error\");\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the receiver and the borrowAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(receiver, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer The account paying off the borrow\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) {\n /* Fail if repayBorrow not allowed */\n uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (\n failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed),\n 0\n );\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n if (vars.mathErr != MathError.NO_ERROR) {\n return (\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n uint(vars.mathErr)\n ),\n 0\n );\n }\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == uint(-1)) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0);\n }\n\n error = vTokenCollateral.accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0);\n }\n\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, vTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n // solhint-disable-next-line code-complexity\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal returns (uint, uint) {\n /* Fail if liquidate not allowed */\n uint allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify vTokenCollateral market's block number equals current block number */\n if (vTokenCollateral.accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == uint(-1)) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n address(vTokenCollateral),\n actualRepayAmount\n );\n require(amountSeizeError == uint(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(vTokenCollateral.balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint seizeError;\n if (address(vTokenCollateral) == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = vTokenCollateral.seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint(Error.NO_ERROR), \"token seizure failed\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(vTokenCollateral), seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.liquidateBorrowVerify(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n actualRepayAmount,\n seizeTokens\n );\n\n return (uint(Error.NO_ERROR), actualRepayAmount);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another vToken.\n * Its absolutely critical to use msg.sender as the seizer vToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed vToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) internal returns (uint) {\n /* Fail if seize not allowed */\n uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n MathError mathErr;\n uint borrowerTokensNew;\n uint liquidatorTokensNew;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr));\n }\n\n (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountTokens[borrower] = borrowerTokensNew;\n accountTokens[liquidator] = liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new reserve factor for the protocol (requires fresh interest accrual)\n * @dev Governance function to set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) {\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa > reserveFactorMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from `msg.sender`\n * @param addAmount Amount of addition to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to.\n (error, ) = _addReservesFresh(addAmount);\n return error;\n }\n\n /**\n * @notice Add reserves by transferring from caller\n * @dev Requires fresh interest accrual\n * @param addAmount Amount of addition to reserves\n * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees\n */\n function _addReservesFresh(uint addAmount) internal returns (uint, uint) {\n // totalReserves + actualAddAmount\n uint totalReservesNew;\n uint actualAddAmount;\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the caller and the addAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional addAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n\n actualAddAmount = doTransferIn(msg.sender, addAmount);\n\n totalReservesNew = totalReserves + actualAddAmount;\n\n /* Revert on overflow */\n require(totalReservesNew >= totalReserves, \"add reserves unexpected overflow\");\n\n // Store reserves[n+1] = reserves[n] + actualAddAmount\n totalReserves = totalReservesNew;\n\n /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */\n emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew);\n\n /* Return (NO_ERROR, actualAddAmount) */\n return (uint(Error.NO_ERROR), actualAddAmount);\n }\n\n /**\n * @notice Reduces reserves by transferring to protocol share reserve contract\n * @dev Requires fresh interest accrual\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReservesFresh(uint reduceAmount) internal returns (uint) {\n if (reduceAmount == 0) {\n return uint(Error.NO_ERROR);\n }\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashPrior() < reduceAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);\n }\n\n // Check reduceAmount ≤ reserves[n] (totalReserves)\n if (reduceAmount > totalReserves) {\n return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n // totalReserves - reduceAmount\n uint totalReservesNew = totalReserves - reduceAmount;\n\n // Store reserves[n+1] = reserves[n] - reduceAmount\n totalReserves = totalReservesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(protocolShareReserve, reduceAmount);\n\n IProtocolShareReserveV5(protocolShareReserve).updateAssetsState(\n address(comptroller),\n underlying,\n IProtocolShareReserveV5.IncomeType.SPREAD\n );\n\n emit ReservesReduced(protocolShareReserve, reduceAmount, totalReservesNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice updates the interest rate model (requires fresh interest accrual)\n * @dev Governance function to update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) {\n // Used to store old model for use in the event that is emitted on success\n InterestRateModel oldInterestRateModel;\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n // Track the market's current interest rate model\n oldInterestRateModel = interestRateModel;\n\n // Ensure invoke newInterestRateModel.isInterestRateModel() returns true\n require(newInterestRateModel.isInterestRateModel(), \"marker method returned false\");\n\n // Set the interest rate model to newInterestRateModel\n interestRateModel = newInterestRateModel;\n\n // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel)\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee.\n * This may revert due to insufficient balance or insufficient allowance.\n */\n function doTransferIn(address from, uint amount) internal returns (uint);\n\n /**\n * @dev Performs a transfer out, ideally returning an explanatory error code upon failure rather than reverting.\n * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract.\n * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions.\n */\n function doTransferOut(address payable to, uint amount) internal;\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return Tuple of error code and the calculated balance or 0 if error code is non-zero\n */\n function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint) {\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint principalTimesIndex;\n uint result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, borrowIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, result);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the vToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Tuple of error code and calculated exchange rate scaled by 1e18\n */\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n uint _totalSupply = totalSupply;\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return (MathError.NO_ERROR, initialExchangeRateMantissa);\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply\n */\n uint totalCash = getCashPrior();\n uint cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(totalCash, totalBorrows, totalReserves);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, exchangeRate.mantissa);\n }\n }\n\n function ensureAllowed(string memory functionSig) private view {\n require(\n IAccessControlManagerV5(accessControlManager).isAllowedToCall(msg.sender, functionSig),\n \"access denied\"\n );\n }\n\n function ensureAdmin(address caller_) private view {\n require(caller_ == admin, \"Unauthorized\");\n }\n\n function ensureNoMathError(MathError mErr) private pure {\n require(mErr == MathError.NO_ERROR, \"math error\");\n }\n\n function ensureNonZeroAddress(address address_) private pure {\n require(address_ != address(0), \"zero address\");\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying owned by this contract\n */\n function getCashPrior() internal view returns (uint);\n}\n" + }, + "contracts/Tokens/VTokens/VBep20.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VToken, VBep20Interface, ComptrollerInterface, InterestRateModel, VTokenInterface } from \"./VToken.sol\";\nimport { EIP20Interface } from \"../EIP20Interface.sol\";\nimport { EIP20NonStandardInterface } from \"../EIP20NonStandardInterface.sol\";\n\n/**\n * @title Venus's VBep20 Contract\n * @notice vTokens which wrap an EIP-20 underlying\n * @author Venus\n */\ncontract VBep20 is VToken, VBep20Interface {\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint(uint mintAmount) external returns (uint) {\n (uint err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits MintBehalf event\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n (uint err, ) = mintBehalfInternal(receiver, mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The user on behalf of whom to redeem\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemBehalf(address redeemer, uint redeemTokens) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemInternal(redeemer, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer, on behalf of whom to redeem\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlyingBehalf(address redeemer, uint redeemAmount) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemUnderlyingInternal(redeemer, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender borrows assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the borrower using `comptroller.updateDelegate`\n * @param borrower The borrower, on behalf of whom to borrow.\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrowBehalf(address borrower, uint borrowAmount) external returns (uint) {\n require(comptroller.approvedDelegates(borrower, msg.sender), \"not an approved delegate\");\n return borrowInternal(borrower, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow(uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n (uint err, ) = liquidateBorrowInternal(borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n /**\n * @notice The sender adds to reserves.\n * @param addAmount The amount of underlying tokens to add as reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesAdded event\n function _addReserves(uint addAmount) external returns (uint) {\n return _addReservesInternal(addAmount);\n }\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n */\n function initialize(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n // VToken initialize does the bulk of the work\n super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n EIP20NonStandardInterface(underlying).transferFrom(from, address(this), amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_IN_FAILED\");\n\n // Calculate the amount that was *actually* transferred\n uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address payable to, uint amount) internal {\n EIP20NonStandardInterface(underlying).transfer(to, amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_OUT_FAILED\");\n }\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Delegate.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VBep20 } from \"./VBep20.sol\";\nimport { VDelegateInterface } from \"./VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegate Contract\n * @notice VTokens which wrap an EIP-20 underlying and are delegated to\n * @author Venus\n */\ncontract VBep20Delegate is VBep20, VDelegateInterface {\n /**\n * @notice Construct an empty delegate\n */\n constructor() public {}\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public {\n // Shh -- currently unused\n data;\n\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _becomeImplementation\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public {\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _resignImplementation\");\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Delegator.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegator Contract\n * @notice vTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Venus\n */\ncontract VBep20Delegator is VTokenInterface, VBep20Interface, VDelegatorInterface {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n * @param implementation_ The address of the implementation the contract delegates to\n * @param becomeImplementationData The encoded args for becomeImplementation\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,address,uint256,string,string,uint8)\",\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n )\n );\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_, false, becomeImplementationData);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n */\n function() external payable {\n require(msg.value == 0, \"VBep20Delegator:fallback: cannot send value to fallback\");\n\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mint(uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"mint(uint256)\", mintAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"mintBehalf(address,uint256)\", receiver, mintAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying asset\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeem(uint redeemTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"redeem(uint256)\", redeemTokens));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"redeemUnderlying(uint256)\", redeemAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrow(uint borrowAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrow(uint256)\", borrowAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrow(uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"repayBorrow(uint256)\", repayAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrower\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"repayBorrowBehalf(address,uint256)\", borrower, repayAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"liquidateBorrow(address,uint256,address)\", borrower, repayAmount, vTokenCollateral)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint amount) external returns (bool) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"transfer(address,uint256)\", dst, amount));\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", src, dst, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"approve(address,uint256)\", spender, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"balanceOfUnderlying(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"totalBorrowsCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrowBalanceCurrent(address)\", account));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * It's absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"seize(address,address,uint256)\", liquidator, borrower, seizeTokens)\n );\n return abi.decode(data, (uint));\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setPendingAdmin(address)\", newPendingAdmin)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setReserveFactor(uint256)\", newReserveFactorMantissa)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accepts transfer of admin rights. `msg.sender` must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _acceptAdmin() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_acceptAdmin()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from admin\n * @param addAmount Amount of reserves to add\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReserves(uint addAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_addReserves(uint256)\", addAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReserves(uint reduceAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_reduceReserves(uint256)\", reduceAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"getCash()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"allowance(address,address)\", owner, spender)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"balanceOf(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get a snapshot of the account's balances and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"getAccountSnapshot(address)\", account)\n );\n return abi.decode(data, (uint, uint, uint, uint));\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"borrowRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"supplyRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n // @custom:access Only callable by admin\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public {\n require(msg.sender == admin, \"VBep20Delegator::_setImplementation: Caller must be admin\");\n\n if (allowResign) {\n delegateToImplementation(abi.encodeWithSignature(\"_resignImplementation()\"));\n }\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n delegateToImplementation(abi.encodeWithSignature(\"_becomeImplementation(bytes)\", becomeImplementationData));\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"exchangeRateCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves.\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"accrueInterest()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setComptroller(address)\", newComptroller)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using `_setInterestRateModelFresh`\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setInterestRateModel(address)\", newInterestRateModel)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Delegates execution to the implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToImplementation(bytes memory data) public returns (bytes memory) {\n return delegateTo(implementation, data);\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {\n (bool success, bytes memory returnData) = address(this).staticcall(\n abi.encodeWithSignature(\"delegateToImplementation(bytes)\", data)\n );\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return abi.decode(returnData, (bytes));\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"borrowBalanceStored(address)\", account)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"exchangeRateStored()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Immutable.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VBep20.sol\";\n\n/**\n * @title Venus's VBep20Immutable Contract\n * @notice VTokens which wrap an EIP-20 underlying and are immutable\n * @author Venus\n */\ncontract VBep20Immutable is VBep20 {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // Initialize the market\n initialize(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n );\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBNB.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VToken.sol\";\n\n/**\n * @title Venus's vBNB Contract\n * @notice vToken which wraps BNB\n * @author Venus\n */\ncontract VBNB is VToken {\n /**\n * @notice Construct a new vBNB money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Send BNB to VBNB to mint\n */\n function() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Reverts upon any failure\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @dev Reverts upon any failure\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow() external payable {\n (uint err, ) = repayBorrowInternal(msg.value);\n requireNoError(err, \"repayBorrow failed\");\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @dev Reverts upon any failure\n * @param borrower The account with the debt being payed off\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower) external payable {\n (uint err, ) = repayBorrowBehalfInternal(borrower, msg.value);\n requireNoError(err, \"repayBorrowBehalf failed\");\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @dev Reverts upon any failure\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(address borrower, VToken vTokenCollateral) external payable {\n (uint err, ) = liquidateBorrowInternal(borrower, msg.value, vTokenCollateral);\n requireNoError(err, \"liquidateBorrow failed\");\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Perform the actual transfer in, which is a no-op\n * @param from Address sending the BNB\n * @param amount Amount of BNB being sent\n * @return The actual amount of BNB transferred\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n // Sanity checks\n require(msg.sender == from, \"sender mismatch\");\n require(msg.value == amount, \"value mismatch\");\n return amount;\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n /* Send the BNB, with minimal gas and revert on failure */\n to.transfer(amount);\n }\n\n /**\n * @notice Gets balance of this contract in terms of BNB, before this message\n * @dev This excludes the value of the current message, if any\n * @return The quantity of BNB owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n (MathError err, uint startingBalance) = subUInt(address(this).balance, msg.value);\n require(err == MathError.NO_ERROR, \"cash prior math error\");\n return startingBalance;\n }\n\n function requireNoError(uint errCode, string memory message) internal pure {\n if (errCode == uint(Error.NO_ERROR)) {\n return;\n }\n\n bytes memory fullMessage = new bytes(bytes(message).length + 5);\n uint i;\n\n for (i = 0; i < bytes(message).length; i++) {\n fullMessage[i] = bytes(message)[i];\n }\n\n fullMessage[i + 0] = bytes1(uint8(32));\n fullMessage[i + 1] = bytes1(uint8(40));\n fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10)));\n fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10)));\n fullMessage[i + 4] = bytes1(uint8(41));\n\n require(errCode == uint(Error.NO_ERROR), string(fullMessage));\n }\n}\n" + }, + "contracts/Tokens/VTokens/VToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../Utils/ErrorReporter.sol\";\nimport \"../../Utils/Exponential.sol\";\nimport \"../../Tokens/EIP20Interface.sol\";\nimport \"../../Tokens/EIP20NonStandardInterface.sol\";\nimport \"../../InterestRateModels/InterestRateModel.sol\";\nimport \"./VTokenInterfaces.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\n\n/**\n * @title Venus's vToken Contract\n * @notice Abstract base for vTokens\n * @author Venus\n */\ncontract VToken is VTokenInterface, Exponential, TokenErrorReporter {\n struct MintLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint mintTokens;\n uint totalSupplyNew;\n uint accountTokensNew;\n uint actualMintAmount;\n }\n\n struct RedeemLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint redeemTokens;\n uint redeemAmount;\n uint totalSupplyNew;\n uint accountTokensNew;\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint repayAmount;\n uint borrowerIndex;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n uint actualRepayAmount;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transfer(address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transferFrom(address src, address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n // @custom:event Emits Approval event on successful approve\n function approve(address spender, uint256 amount) external returns (bool) {\n transferAllowances[msg.sender][spender] = amount;\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n ensureNoMathError(mErr);\n return balance;\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return totalBorrows;\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return borrowBalanceStored(account);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewPendingAdmin event with old and new admin addresses\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n // Check caller = admin\n ensureAdmin(msg.sender);\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewAdmin event on successful acceptance\n // @custom:event Emits NewPendingAdmin event with null new pending admin\n function _acceptAdmin() external returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using `_setReserveFactorFresh`\n * @dev Governor function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewReserveFactor event\n function _setReserveFactor(uint newReserveFactorMantissa_) external nonReentrant returns (uint) {\n ensureAllowed(\"_setReserveFactor(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed.\n return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);\n }\n // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to.\n return _setReserveFactorFresh(newReserveFactorMantissa_);\n }\n\n /**\n * @notice Sets the address of the access control manager of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlManagerAddress New address for the access control\n * @return uint 0=success, otherwise will revert\n */\n function setAccessControlManager(address newAccessControlManagerAddress) external returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ensureNonZeroAddress(newAccessControlManagerAddress);\n\n emit NewAccessControlManager(accessControlManager, newAccessControlManagerAddress);\n accessControlManager = newAccessControlManagerAddress;\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to protocol share reserve\n * @param reduceAmount_ Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesReduced event\n function _reduceReserves(uint reduceAmount_) external nonReentrant returns (uint) {\n ensureAllowed(\"_reduceReserves(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // If reserves were reduced in accrueInterest\n if (reduceReservesBlockNumber == block.number) return (uint(Error.NO_ERROR));\n // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.\n return _reduceReservesFresh(reduceAmount_);\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint256) {\n return accountTokens[owner];\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n uint vTokenBalance = accountTokens[account];\n uint borrowBalance;\n uint exchangeRateMantissa;\n\n MathError mErr;\n\n (mErr, borrowBalance) = borrowBalanceStoredInternal(account);\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n (mErr, exchangeRateMantissa) = exchangeRateStoredInternal();\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n return (uint(Error.NO_ERROR), vTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves);\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n return getCashPrior();\n }\n\n /**\n * @notice Governance function to set new threshold of block difference after which funds will be sent to the protocol share reserve\n * @param newReduceReservesBlockDelta_ block difference value\n */\n function setReduceReservesBlockDelta(uint256 newReduceReservesBlockDelta_) external {\n require(newReduceReservesBlockDelta_ > 0, \"Invalid Input\");\n ensureAllowed(\"setReduceReservesBlockDelta(uint256)\");\n emit NewReduceReservesBlockDelta(reduceReservesBlockDelta, newReduceReservesBlockDelta_);\n reduceReservesBlockDelta = newReduceReservesBlockDelta_;\n }\n\n /**\n * @notice Sets protocol share reserve contract address\n * @param protcolShareReserve_ The address of protocol share reserve contract\n */\n function setProtocolShareReserve(address payable protcolShareReserve_) external {\n // Check caller is admin\n ensureAdmin(msg.sender);\n ensureNonZeroAddress(protcolShareReserve_);\n emit NewProtocolShareReserve(protocolShareReserve, protcolShareReserve_);\n protocolShareReserve = protcolShareReserve_;\n }\n\n /**\n * @notice Initialize the money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ EIP-20 name of this token\n * @param symbol_ EIP-20 symbol of this token\n * @param decimals_ EIP-20 decimal precision of this token\n */\n function initialize(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n ensureAdmin(msg.sender);\n require(accrualBlockNumber == 0 && borrowIndex == 0, \"market may only be initialized once\");\n\n // Set initial exchange rate\n initialExchangeRateMantissa = initialExchangeRateMantissa_;\n require(initialExchangeRateMantissa > 0, \"initial exchange rate must be greater than zero.\");\n\n // Set the comptroller\n uint err = _setComptroller(comptroller_);\n require(err == uint(Error.NO_ERROR), \"setting comptroller failed\");\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = mantissaOne;\n\n // Set the interest rate model (depends on block number / borrow index)\n err = _setInterestRateModelFresh(interestRateModel_);\n require(err == uint(Error.NO_ERROR), \"setting interest rate model failed\");\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return exchangeRateStored();\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage and\n * reduce spread reserves to protocol share reserve\n * if currentBlock - reduceReservesBlockNumber >= blockDelta\n */\n // @custom:event Emits AccrueInterest event\n function accrueInterest() public returns (uint) {\n /* Remember the initial block number */\n uint currentBlockNumber = block.number;\n uint accrualBlockNumberPrior = accrualBlockNumber;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumberPrior == currentBlockNumber) {\n return uint(Error.NO_ERROR);\n }\n\n /* Read the previous values out of storage */\n uint cashPrior = getCashPrior();\n uint borrowsPrior = totalBorrows;\n uint reservesPrior = totalReserves;\n uint borrowIndexPrior = borrowIndex;\n\n /* Calculate the current borrow interest rate */\n uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior);\n require(borrowRateMantissa <= borrowRateMaxMantissa, \"borrow rate is absurdly high\");\n\n /* Calculate the number of blocks elapsed since the last accrual */\n (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);\n ensureNoMathError(mathErr);\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n Exp memory simpleInterestFactor;\n uint interestAccumulated;\n uint totalBorrowsNew;\n uint totalReservesNew;\n uint borrowIndexNew;\n\n (mathErr, simpleInterestFactor) = mulScalar(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n interestAccumulated,\n reservesPrior\n );\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = borrowIndexNew;\n totalBorrows = totalBorrowsNew;\n totalReserves = totalReservesNew;\n\n (mathErr, blockDelta) = subUInt(currentBlockNumber, reduceReservesBlockNumber);\n ensureNoMathError(mathErr);\n if (blockDelta >= reduceReservesBlockDelta) {\n reduceReservesBlockNumber = currentBlockNumber;\n if (cashPrior < totalReservesNew) {\n _reduceReservesFresh(cashPrior);\n } else {\n _reduceReservesFresh(totalReservesNew);\n }\n }\n\n /* We emit an AccrueInterest event */\n emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewComptroller event\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ComptrollerInterface oldComptroller = comptroller;\n // Ensure invoke comptroller.isComptroller() returns true\n require(newComptroller.isComptroller(), \"marker method returned false\");\n\n // Set market's comptroller to newComptroller\n comptroller = newComptroller;\n\n // Emit NewComptroller(oldComptroller, newComptroller)\n emit NewComptroller(oldComptroller, newComptroller);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Governance function to accrue interest and update the interest rate model\n * @param newInterestRateModel_ The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel_) public returns (uint) {\n ensureAllowed(\"_setInterestRateModel(address)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed\n return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);\n }\n // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.\n return _setInterestRateModelFresh(newInterestRateModel_);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n (MathError err, uint result) = exchangeRateStoredInternal();\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n (MathError err, uint result) = borrowBalanceStoredInternal(account);\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Transfers `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) {\n /* Fail if transfer not allowed */\n uint allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint startingAllowance = 0;\n if (spender == src) {\n startingAllowance = uint(-1);\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint allowanceNew;\n uint srvTokensNew;\n uint dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srvTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srvTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != uint(-1)) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mint failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n /**\n * @notice User supplies assets into the market and receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) {\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens, vars.accountTokensNew);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The address of the account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfInternal(address receiver, uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mintBehalf failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintBelahfFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintBehalfFresh(msg.sender, receiver, mintAmount);\n }\n\n /**\n * @notice Payer supplies assets into the market and receiver receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param payer The address of the account which is paying the underlying token\n * @param receiver The address of the account which is receiving vToken\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfFresh(address payer, address receiver, uint mintAmount) internal returns (uint, uint) {\n ensureNonZeroAddress(receiver);\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), receiver, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the payer and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(payer, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and receiver token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[receiver] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[receiver], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[receiver] = vars.accountTokensNew;\n\n /* We emit a MintBehalf event, and a Transfer event */\n emit MintBehalf(payer, receiver, vars.actualMintAmount, vars.mintTokens, vars.accountTokensNew);\n emit Transfer(address(this), receiver, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), receiver, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemInternal(\n address redeemer,\n address payable receiver,\n uint redeemTokens\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens, if called by a delegate\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlyingInternal(\n address redeemer,\n address payable receiver,\n uint redeemAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, 0, redeemAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokensIn The number of vTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming vTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // solhint-disable-next-line code-complexity\n function redeemFresh(\n address redeemer,\n address payable receiver,\n uint redeemTokensIn,\n uint redeemAmountIn\n ) internal returns (uint) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"one of redeemTokensIn or redeemAmountIn must be zero\");\n\n RedeemLocalVars memory vars;\n\n /* exchangeRate = invoke Exchange Rate Stored() */\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n ensureNoMathError(vars.mathErr);\n\n /* If redeemTokensIn > 0: */\n if (redeemTokensIn > 0) {\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n ensureNoMathError(vars.mathErr);\n } else {\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(\n redeemAmountIn,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashPrior() < vars.redeemAmount) {\n revert(\"math error\");\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the receiver and the redeemAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n\n uint feeAmount;\n uint remainedAmount;\n if (IComptroller(address(comptroller)).treasuryPercent() != 0) {\n (vars.mathErr, feeAmount) = mulUInt(\n vars.redeemAmount,\n IComptroller(address(comptroller)).treasuryPercent()\n );\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, feeAmount) = divUInt(feeAmount, 1e18);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, remainedAmount) = subUInt(vars.redeemAmount, feeAmount);\n ensureNoMathError(vars.mathErr);\n\n doTransferOut(address(uint160(IComptroller(address(comptroller)).treasuryAddress())), feeAmount);\n\n emit RedeemFee(redeemer, feeAmount, vars.redeemTokens);\n } else {\n remainedAmount = vars.redeemAmount;\n }\n\n doTransferOut(receiver, remainedAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, remainedAmount, vars.redeemTokens, vars.accountTokensNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrowInternal(\n address borrower,\n address payable receiver,\n uint borrowAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED);\n }\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(borrower, receiver, borrowAmount);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @dev Before calling this function, ensure that the interest has been accrued\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise revert (see ErrorReporter.sol for details).\n */\n function borrowFresh(address borrower, address payable receiver, uint borrowAmount) internal returns (uint) {\n /* Revert if borrow not allowed */\n uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /* Revert if protocol has insufficient underlying cash */\n if (getCashPrior() < borrowAmount) {\n revert(\"math error\");\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the receiver and the borrowAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(receiver, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer The account paying off the borrow\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) {\n /* Fail if repayBorrow not allowed */\n uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (\n failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed),\n 0\n );\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n if (vars.mathErr != MathError.NO_ERROR) {\n return (\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n uint(vars.mathErr)\n ),\n 0\n );\n }\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == uint(-1)) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0);\n }\n\n error = vTokenCollateral.accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0);\n }\n\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, vTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n // solhint-disable-next-line code-complexity\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal returns (uint, uint) {\n /* Fail if liquidate not allowed */\n uint allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify vTokenCollateral market's block number equals current block number */\n if (vTokenCollateral.accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == uint(-1)) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n address(vTokenCollateral),\n actualRepayAmount\n );\n require(amountSeizeError == uint(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(vTokenCollateral.balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint seizeError;\n if (address(vTokenCollateral) == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = vTokenCollateral.seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint(Error.NO_ERROR), \"token seizure failed\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(vTokenCollateral), seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.liquidateBorrowVerify(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n actualRepayAmount,\n seizeTokens\n );\n\n return (uint(Error.NO_ERROR), actualRepayAmount);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another vToken.\n * Its absolutely critical to use msg.sender as the seizer vToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed vToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) internal returns (uint) {\n /* Fail if seize not allowed */\n uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n MathError mathErr;\n uint borrowerTokensNew;\n uint liquidatorTokensNew;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr));\n }\n\n (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountTokens[borrower] = borrowerTokensNew;\n accountTokens[liquidator] = liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new reserve factor for the protocol (requires fresh interest accrual)\n * @dev Governance function to set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) {\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa > reserveFactorMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from `msg.sender`\n * @param addAmount Amount of addition to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to.\n (error, ) = _addReservesFresh(addAmount);\n return error;\n }\n\n /**\n * @notice Add reserves by transferring from caller\n * @dev Requires fresh interest accrual\n * @param addAmount Amount of addition to reserves\n * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees\n */\n function _addReservesFresh(uint addAmount) internal returns (uint, uint) {\n // totalReserves + actualAddAmount\n uint totalReservesNew;\n uint actualAddAmount;\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the caller and the addAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional addAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n\n actualAddAmount = doTransferIn(msg.sender, addAmount);\n\n totalReservesNew = totalReserves + actualAddAmount;\n\n /* Revert on overflow */\n require(totalReservesNew >= totalReserves, \"add reserves unexpected overflow\");\n\n // Store reserves[n+1] = reserves[n] + actualAddAmount\n totalReserves = totalReservesNew;\n\n /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */\n emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew);\n\n /* Return (NO_ERROR, actualAddAmount) */\n return (uint(Error.NO_ERROR), actualAddAmount);\n }\n\n /**\n * @notice Reduces reserves by transferring to protocol share reserve contract\n * @dev Requires fresh interest accrual\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReservesFresh(uint reduceAmount) internal returns (uint) {\n if (reduceAmount == 0) {\n return uint(Error.NO_ERROR);\n }\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashPrior() < reduceAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);\n }\n\n // Check reduceAmount ≤ reserves[n] (totalReserves)\n if (reduceAmount > totalReserves) {\n return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n // totalReserves - reduceAmount\n uint totalReservesNew = totalReserves - reduceAmount;\n\n // Store reserves[n+1] = reserves[n] - reduceAmount\n totalReserves = totalReservesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(protocolShareReserve, reduceAmount);\n\n IProtocolShareReserveV5(protocolShareReserve).updateAssetsState(\n address(comptroller),\n underlying,\n IProtocolShareReserveV5.IncomeType.SPREAD\n );\n\n emit ReservesReduced(protocolShareReserve, reduceAmount, totalReservesNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice updates the interest rate model (requires fresh interest accrual)\n * @dev Governance function to update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) {\n // Used to store old model for use in the event that is emitted on success\n InterestRateModel oldInterestRateModel;\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n // Track the market's current interest rate model\n oldInterestRateModel = interestRateModel;\n\n // Ensure invoke newInterestRateModel.isInterestRateModel() returns true\n require(newInterestRateModel.isInterestRateModel(), \"marker method returned false\");\n\n // Set the interest rate model to newInterestRateModel\n interestRateModel = newInterestRateModel;\n\n // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel)\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee.\n * This may revert due to insufficient balance or insufficient allowance.\n */\n function doTransferIn(address from, uint amount) internal returns (uint);\n\n /**\n * @dev Performs a transfer out, ideally returning an explanatory error code upon failure rather than reverting.\n * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract.\n * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions.\n */\n function doTransferOut(address payable to, uint amount) internal;\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return Tuple of error code and the calculated balance or 0 if error code is non-zero\n */\n function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint) {\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint principalTimesIndex;\n uint result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, borrowIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, result);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the vToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Tuple of error code and calculated exchange rate scaled by 1e18\n */\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n uint _totalSupply = totalSupply;\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return (MathError.NO_ERROR, initialExchangeRateMantissa);\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply\n */\n uint totalCash = getCashPrior();\n uint cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(totalCash, totalBorrows, totalReserves);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, exchangeRate.mantissa);\n }\n }\n\n function ensureAllowed(string memory functionSig) private view {\n require(\n IAccessControlManagerV5(accessControlManager).isAllowedToCall(msg.sender, functionSig),\n \"access denied\"\n );\n }\n\n function ensureAdmin(address caller_) private view {\n require(caller_ == admin, \"Unauthorized\");\n }\n\n function ensureNoMathError(MathError mErr) private pure {\n require(mErr == MathError.NO_ERROR, \"math error\");\n }\n\n function ensureNonZeroAddress(address address_) private pure {\n require(address_ != address(0), \"zero address\");\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying owned by this contract\n */\n function getCashPrior() internal view returns (uint);\n}\n" + }, + "contracts/Tokens/VTokens/VTokenInterfaces.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../InterestRateModels/InterestRateModel.sol\";\n\ninterface IProtocolShareReserveV5 {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType kind) external;\n}\n\ncontract VTokenStorageBase {\n /**\n * @notice Container for borrow balance information\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\n */\n struct BorrowSnapshot {\n uint principal;\n uint interestIndex;\n }\n\n /**\n * @dev Guard variable for re-entrancy checks\n */\n bool internal _notEntered;\n\n /**\n * @notice EIP-20 token name for this token\n */\n string public name;\n\n /**\n * @notice EIP-20 token symbol for this token\n */\n string public symbol;\n\n /**\n * @notice EIP-20 token decimals for this token\n */\n uint8 public decimals;\n\n /**\n * @notice Maximum borrow rate that can ever be applied (.0005% / block)\n */\n\n uint internal constant borrowRateMaxMantissa = 0.0005e16;\n\n /**\n * @notice Maximum fraction of interest that can be set aside for reserves\n */\n uint internal constant reserveFactorMaxMantissa = 1e18;\n\n /**\n * @notice Administrator for this contract\n */\n address payable public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address payable public pendingAdmin;\n\n /**\n * @notice Contract which oversees inter-vToken operations\n */\n ComptrollerInterface public comptroller;\n\n /**\n * @notice Model which tells what the current interest rate should be\n */\n InterestRateModel public interestRateModel;\n\n /**\n * @notice Initial exchange rate used when minting the first VTokens (used when totalSupply = 0)\n */\n uint internal initialExchangeRateMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for reserves\n */\n uint public reserveFactorMantissa;\n\n /**\n * @notice Block number that interest was last accrued at\n */\n uint public accrualBlockNumber;\n\n /**\n * @notice Accumulator of the total earned interest rate since the opening of the market\n */\n uint public borrowIndex;\n\n /**\n * @notice Total amount of outstanding borrows of the underlying in this market\n */\n uint public totalBorrows;\n\n /**\n * @notice Total amount of reserves of the underlying held in this market\n */\n uint public totalReserves;\n\n /**\n * @notice Total number of tokens in circulation\n */\n uint public totalSupply;\n\n /**\n * @notice Official record of token balances for each account\n */\n mapping(address => uint) internal accountTokens;\n\n /**\n * @notice Approved token transfer amounts on behalf of others\n */\n mapping(address => mapping(address => uint)) internal transferAllowances;\n\n /**\n * @notice Mapping of account addresses to outstanding borrow balances\n */\n mapping(address => BorrowSnapshot) internal accountBorrows;\n\n /**\n * @notice Underlying asset for this VToken\n */\n address public underlying;\n\n /**\n * @notice Implementation address for this contract\n */\n address public implementation;\n\n /**\n * @notice delta block after which reserves will be reduced\n */\n uint public reduceReservesBlockDelta;\n\n /**\n * @notice last block number at which reserves were reduced\n */\n uint public reduceReservesBlockNumber;\n\n /**\n * @notice address of protocol share reserve contract\n */\n address payable public protocolShareReserve;\n\n /**\n * @notice address of accessControlManager\n */\n\n address public accessControlManager;\n}\n\ncontract VTokenStorage is VTokenStorageBase {\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\ncontract VTokenInterface is VTokenStorage {\n /**\n * @notice Indicator that this is a vToken contract (for inspection)\n */\n bool public constant isVToken = true;\n\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows);\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint mintAmount, uint mintTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are minted behalf by payer to receiver\n */\n event MintBehalf(address payer, address receiver, uint mintAmount, uint mintTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint redeemAmount, uint redeemTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are redeemed and fee is transferred\n */\n event RedeemFee(address redeemer, uint feeAmount, uint redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint repayAmount,\n address vTokenCollateral,\n uint seizeTokens\n );\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Event emitted when pendingAdmin is accepted, which means admin has been updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @notice Event emitted when comptroller is changed\n */\n event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address protocolShareReserve, uint reduceAmount, uint newTotalReserves);\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint amount);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint amount);\n\n /**\n * @notice Event emitted when block delta for reduce reserves get updated\n */\n event NewReduceReservesBlockDelta(uint256 oldReduceReservesBlockDelta, uint256 newReduceReservesBlockDelta);\n\n /**\n * @notice Event emitted when address of ProtocolShareReserve contract get updated\n */\n event NewProtocolShareReserve(address indexed oldProtocolShareReserve, address indexed newProtocolShareReserve);\n\n /**\n * @notice Failure event\n */\n event Failure(uint error, uint info, uint detail);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControlManager(address oldAccessControlAddress, address newAccessControlAddress);\n\n /*** User Interface ***/\n\n function transfer(address dst, uint amount) external returns (bool);\n\n function transferFrom(address src, address dst, uint amount) external returns (bool);\n\n function approve(address spender, uint amount) external returns (bool);\n\n function balanceOfUnderlying(address owner) external returns (uint);\n\n function totalBorrowsCurrent() external returns (uint);\n\n function borrowBalanceCurrent(address account) external returns (uint);\n\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint);\n\n /*** Admin Function ***/\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint);\n\n /*** Admin Function ***/\n function _acceptAdmin() external returns (uint);\n\n /*** Admin Function ***/\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint);\n\n /*** Admin Function ***/\n function _reduceReserves(uint reduceAmount) external returns (uint);\n\n function balanceOf(address owner) external view returns (uint);\n\n function allowance(address owner, address spender) external view returns (uint);\n\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint);\n\n function borrowRatePerBlock() external view returns (uint);\n\n function supplyRatePerBlock() external view returns (uint);\n\n function getCash() external view returns (uint);\n\n function exchangeRateCurrent() public returns (uint);\n\n function accrueInterest() public returns (uint);\n\n /*** Admin Function ***/\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint);\n\n /*** Admin Function ***/\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint);\n\n function borrowBalanceStored(address account) public view returns (uint);\n\n function exchangeRateStored() public view returns (uint);\n}\n\ncontract VBep20Interface {\n /*** User Interface ***/\n\n function mint(uint mintAmount) external returns (uint);\n\n function mintBehalf(address receiver, uint mintAmount) external returns (uint);\n\n function redeem(uint redeemTokens) external returns (uint);\n\n function redeemUnderlying(uint redeemAmount) external returns (uint);\n\n function borrow(uint borrowAmount) external returns (uint);\n\n function repayBorrow(uint repayAmount) external returns (uint);\n\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);\n\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint);\n\n /*** Admin Functions ***/\n\n function _addReserves(uint addAmount) external returns (uint);\n}\n\ncontract VDelegatorInterface {\n /**\n * @notice Emitted when implementation is changed\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public;\n}\n\ncontract VDelegateInterface {\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @dev Should revert if any issues arise which make it unfit for delegation\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public;\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public;\n}\n" + }, + "contracts/Tokens/XVS/IXVSVesting.sol": { + "content": "pragma solidity ^0.5.16;\n\ninterface IXVSVesting {\n /// @param _recipient Address of the Vesting. recipient entitled to claim the vested funds\n /// @param _amount Total number of tokens Vested\n function deposit(address _recipient, uint256 _amount) external;\n}\n" + }, + "contracts/Tokens/XVS/XVS.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/Tokenlock.sol\";\n\ncontract XVS is Tokenlock {\n /// @notice BEP-20 token name for this token\n string public constant name = \"Venus\";\n\n /// @notice BEP-20 token symbol for this token\n string public constant symbol = \"XVS\";\n\n /// @notice BEP-20 token decimals for this token\n uint8 public constant decimals = 18;\n\n /// @notice Total number of tokens in circulation\n uint public constant totalSupply = 30000000e18; // 30 million XVS\n\n /// @notice Allowance amounts on behalf of others\n mapping(address => mapping(address => uint96)) internal allowances;\n\n /// @notice Official record of token balances for each account\n mapping(address => uint96) internal balances;\n\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A checkpoint for marking number of votes from a given block\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice The standard BEP-20 transfer event\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /// @notice The standard BEP-20 approval event\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Construct a new XVS token\n * @param account The initial account to grant all the tokens\n */\n constructor(address account) public {\n balances[account] = uint96(totalSupply);\n emit Transfer(address(0), account, totalSupply);\n }\n\n /**\n * @notice Get the number of tokens `spender` is approved to spend on behalf of `account`\n * @param account The address of the account holding the funds\n * @param spender The address of the account spending the funds\n * @return The number of tokens approved\n */\n function allowance(address account, address spender) external view returns (uint) {\n return allowances[account][spender];\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param rawAmount The number of tokens that are approved (2^256-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint rawAmount) external validLock returns (bool) {\n uint96 amount;\n if (rawAmount == uint(-1)) {\n amount = uint96(-1);\n } else {\n amount = safe96(rawAmount, \"XVS::approve: amount exceeds 96 bits\");\n }\n\n allowances[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the number of tokens held by the `account`\n * @param account The address of the account to get the balance of\n * @return The number of tokens held\n */\n function balanceOf(address account) external view returns (uint) {\n return balances[account];\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint rawAmount) external validLock returns (bool) {\n uint96 amount = safe96(rawAmount, \"XVS::transfer: amount exceeds 96 bits\");\n _transferTokens(msg.sender, dst, amount);\n return true;\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint rawAmount) external validLock returns (bool) {\n address spender = msg.sender;\n uint96 spenderAllowance = allowances[src][spender];\n uint96 amount = safe96(rawAmount, \"XVS::approve: amount exceeds 96 bits\");\n\n if (spender != src && spenderAllowance != uint96(-1)) {\n uint96 newAllowance = sub96(\n spenderAllowance,\n amount,\n \"XVS::transferFrom: transfer amount exceeds spender allowance\"\n );\n allowances[src][spender] = newAllowance;\n\n emit Approval(src, spender, newAllowance);\n }\n\n _transferTokens(src, dst, amount);\n return true;\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) public validLock {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public validLock {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"XVS::delegateBySig: invalid signature\");\n require(nonce == nonces[signatory]++, \"XVS::delegateBySig: invalid nonce\");\n require(now <= expiry, \"XVS::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n /**\n * @notice Determine the prior number of votes for an account as of a block number\n * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n * @param account The address of the account to check\n * @param blockNumber The block number to get the vote balance at\n * @return The number of votes the account had as of the given block\n */\n function getPriorVotes(address account, uint blockNumber) public view returns (uint96) {\n require(blockNumber < block.number, \"XVS::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlock > blockNumber) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlock == blockNumber) {\n return cp.votes;\n } else if (cp.fromBlock < blockNumber) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = balances[delegator];\n delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _transferTokens(address src, address dst, uint96 amount) internal {\n require(src != address(0), \"XVS::_transferTokens: cannot transfer from the zero address\");\n require(dst != address(0), \"XVS::_transferTokens: cannot transfer to the zero address\");\n\n balances[src] = sub96(balances[src], amount, \"XVS::_transferTokens: transfer amount exceeds balance\");\n balances[dst] = add96(balances[dst], amount, \"XVS::_transferTokens: transfer amount overflows\");\n emit Transfer(src, dst, amount);\n\n _moveDelegates(delegates[src], delegates[dst], amount);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"XVS::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"XVS::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumber = safe32(block.number, \"XVS::_writeCheckpoint: block number exceeds 32 bits\");\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChanged(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVesting.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/IBEP20.sol\";\nimport \"../../Utils/SafeBEP20.sol\";\nimport \"./XVSVestingStorage.sol\";\nimport \"./XVSVestingProxy.sol\";\n\n/**\n * @title Venus's XVSVesting Contract\n * @author Venus\n */\ncontract XVSVesting is XVSVestingStorage {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice total vesting period for 1 year in seconds\n uint256 public constant TOTAL_VESTING_TIME = 365 * 24 * 60 * 60;\n\n /// @notice decimal precision for XVS\n uint256 public constant xvsDecimalsMultiplier = 1e18;\n\n /// @notice Emitted when XVSVested is claimed by recipient\n event VestedTokensClaimed(address recipient, uint256 amountClaimed);\n\n /// @notice Emitted when vrtConversionAddress is set\n event VRTConversionSet(address vrtConversionAddress);\n\n /// @notice Emitted when XVS is deposited for vesting\n event XVSVested(address indexed recipient, uint256 startTime, uint256 amount, uint256 withdrawnAmount);\n\n /// @notice Emitted when XVS is withdrawn by recipient\n event XVSWithdrawn(address recipient, uint256 amount);\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n constructor() public {}\n\n /**\n * @notice initialize XVSVestingStorage\n * @param _xvsAddress The XVSToken address\n */\n function initialize(address _xvsAddress) public {\n require(msg.sender == admin, \"only admin may initialize the XVSVesting\");\n require(initialized == false, \"XVSVesting is already initialized\");\n require(_xvsAddress != address(0), \"_xvsAddress cannot be Zero\");\n xvs = IBEP20(_xvsAddress);\n\n _notEntered = true;\n initialized = true;\n }\n\n modifier isInitialized() {\n require(initialized == true, \"XVSVesting is not initialized\");\n _;\n }\n\n /**\n * @notice sets VRTConverter Address\n * @dev Note: If VRTConverter is not set, then Vesting is not allowed\n * @param _vrtConversionAddress The VRTConverterProxy Address\n */\n function setVRTConverter(address _vrtConversionAddress) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_vrtConversionAddress != address(0), \"vrtConversionAddress cannot be Zero\");\n vrtConversionAddress = _vrtConversionAddress;\n emit VRTConversionSet(_vrtConversionAddress);\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier onlyVrtConverter() {\n require(msg.sender == vrtConversionAddress, \"only VRTConversion Address can call the function\");\n _;\n }\n\n modifier vestingExistCheck(address recipient) {\n require(vestings[recipient].length > 0, \"recipient doesnot have any vestingRecord\");\n _;\n }\n\n /**\n * @notice Deposit XVS for Vesting\n * @param recipient The vesting recipient\n * @param depositAmount XVS amount for deposit\n */\n function deposit(\n address recipient,\n uint depositAmount\n ) external isInitialized onlyVrtConverter nonZeroAddress(recipient) {\n require(depositAmount > 0, \"Deposit amount must be non-zero\");\n\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n\n VestingRecord memory vesting = VestingRecord({\n recipient: recipient,\n startTime: getCurrentTime(),\n amount: depositAmount,\n withdrawnAmount: 0\n });\n\n vestingsOfRecipient.push(vesting);\n\n emit XVSVested(recipient, vesting.startTime, vesting.amount, vesting.withdrawnAmount);\n }\n\n /**\n * @notice Withdraw Vested XVS of recipient\n */\n function withdraw() external isInitialized vestingExistCheck(msg.sender) {\n address recipient = msg.sender;\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n uint256 totalWithdrawableAmount = 0;\n\n for (uint i = 0; i < vestingCount; ++i) {\n VestingRecord storage vesting = vestingsOfRecipient[i];\n (, uint256 toWithdraw) = calculateWithdrawableAmount(\n vesting.amount,\n vesting.startTime,\n vesting.withdrawnAmount\n );\n if (toWithdraw > 0) {\n totalWithdrawableAmount = totalWithdrawableAmount.add(toWithdraw);\n vesting.withdrawnAmount = vesting.withdrawnAmount.add(toWithdraw);\n }\n }\n\n if (totalWithdrawableAmount > 0) {\n uint256 xvsBalance = xvs.balanceOf(address(this));\n require(xvsBalance >= totalWithdrawableAmount, \"Insufficient XVS for withdrawal\");\n emit XVSWithdrawn(recipient, totalWithdrawableAmount);\n xvs.safeTransfer(recipient, totalWithdrawableAmount);\n }\n }\n\n /**\n * @notice get Withdrawable XVS Amount\n * @param recipient The vesting recipient\n * @dev returns A tuple with totalWithdrawableAmount , totalVestedAmount and totalWithdrawnAmount\n */\n function getWithdrawableAmount(\n address recipient\n )\n public\n view\n isInitialized\n nonZeroAddress(recipient)\n vestingExistCheck(recipient)\n returns (uint256 totalWithdrawableAmount, uint256 totalVestedAmount, uint256 totalWithdrawnAmount)\n {\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n\n for (uint i = 0; i < vestingCount; i++) {\n VestingRecord storage vesting = vestingsOfRecipient[i];\n (uint256 vestedAmount, uint256 toWithdraw) = calculateWithdrawableAmount(\n vesting.amount,\n vesting.startTime,\n vesting.withdrawnAmount\n );\n totalVestedAmount = totalVestedAmount.add(vestedAmount);\n totalWithdrawableAmount = totalWithdrawableAmount.add(toWithdraw);\n totalWithdrawnAmount = totalWithdrawnAmount.add(vesting.withdrawnAmount);\n }\n\n return (totalWithdrawableAmount, totalVestedAmount, totalWithdrawnAmount);\n }\n\n /**\n * @notice get Withdrawable XVS Amount\n * @param amount Amount deposited for vesting\n * @param vestingStartTime time in epochSeconds at the time of vestingDeposit\n * @param withdrawnAmount XVSAmount withdrawn from VestedAmount\n * @dev returns A tuple with vestedAmount and withdrawableAmount\n */\n function calculateWithdrawableAmount(\n uint256 amount,\n uint256 vestingStartTime,\n uint256 withdrawnAmount\n ) internal view returns (uint256, uint256) {\n uint256 vestedAmount = calculateVestedAmount(amount, vestingStartTime, getCurrentTime());\n uint toWithdraw = vestedAmount.sub(withdrawnAmount);\n return (vestedAmount, toWithdraw);\n }\n\n /**\n * @notice calculate total vested amount\n * @param vestingAmount Amount deposited for vesting\n * @param vestingStartTime time in epochSeconds at the time of vestingDeposit\n * @param currentTime currentTime in epochSeconds\n * @return Total XVS amount vested\n */\n function calculateVestedAmount(\n uint256 vestingAmount,\n uint256 vestingStartTime,\n uint256 currentTime\n ) internal view returns (uint256) {\n if (currentTime < vestingStartTime) {\n return 0;\n } else if (currentTime > vestingStartTime.add(TOTAL_VESTING_TIME)) {\n return vestingAmount;\n } else {\n return (vestingAmount.mul(currentTime.sub(vestingStartTime))).div(TOTAL_VESTING_TIME);\n }\n }\n\n /**\n * @notice current block timestamp\n * @return blocktimestamp\n */\n function getCurrentTime() public view returns (uint256) {\n return block.timestamp;\n }\n\n /*** Admin Functions ***/\n function _become(XVSVestingProxy xvsVestingProxy) public {\n require(msg.sender == xvsVestingProxy.admin(), \"only proxy admin can change brains\");\n xvsVestingProxy._acceptImplementation();\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVestingProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./XVSVestingStorage.sol\";\n\ncontract XVSVestingProxy is XVSVestingAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means XVSVesting implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(\n address implementation_,\n address _xvsAddress\n ) public nonZeroAddress(implementation_) nonZeroAddress(_xvsAddress) {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(implementation_, abi.encodeWithSignature(\"initialize(address)\", _xvsAddress));\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"XVSVestingProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"XVSVestingProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal nonZeroAddress(callee) returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(\n address newPendingImplementation\n ) public nonZeroAddress(newPendingImplementation) {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRT Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) public nonZeroAddress(newPendingAdmin) {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n require(newPendingAdmin != pendingAdmin, \"New pendingAdmin can not be same as the previous one\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVestingStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/SafeMath.sol\";\nimport \"../../Utils/IBEP20.sol\";\n\ncontract XVSVestingAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of XVSVesting\n */\n address public implementation;\n\n /**\n * @notice Pending brains of XVSVesting\n */\n address public pendingImplementation;\n}\n\ncontract XVSVestingStorage is XVSVestingAdminStorage {\n struct VestingRecord {\n address recipient;\n uint256 startTime;\n uint256 amount;\n uint256 withdrawnAmount;\n }\n\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice indicator to check if the contract is initialized\n bool public initialized;\n\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice VRTConversion Contract Address\n address public vrtConversionAddress;\n\n /// @notice mapping of VestingRecord(s) for user(s)\n mapping(address => VestingRecord[]) public vestings;\n}\n" + }, + "contracts/Utils/Address.sol": { + "content": "pragma solidity ^0.5.5;\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 function isContract(address account) internal view returns (bool) {\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n // for accounts without code, i.e. `keccak256('')`\n bytes32 codehash;\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n codehash := extcodehash(account)\n }\n return (codehash != accountHash && codehash != 0x0);\n }\n\n /**\n * @dev Converts an `address` into `address payable`. Note that this is\n * simply a type cast: the actual underlying value is not changed.\n *\n * _Available since v2.4.0._\n */\n function toPayable(address account) internal pure returns (address payable) {\n return address(uint160(account));\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 * _Available since v2.4.0._\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-call-value\n // solium-disable-next-line security/no-call-value\n (bool success, ) = recipient.call.value(amount)(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n}\n" + }, + "contracts/Utils/CarefulMath.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Careful Math\n * @author Venus\n * @notice Derived from OpenZeppelin's SafeMath library\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\n */\ncontract CarefulMath {\n /**\n * @dev Possible error codes that we can return\n */\n enum MathError {\n NO_ERROR,\n DIVISION_BY_ZERO,\n INTEGER_OVERFLOW,\n INTEGER_UNDERFLOW\n }\n\n /**\n * @dev Multiplies two numbers, returns an error on overflow.\n */\n function mulUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (a == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n uint c = a * b;\n\n if (c / a != b) {\n return (MathError.INTEGER_OVERFLOW, 0);\n } else {\n return (MathError.NO_ERROR, c);\n }\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function divUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (b == 0) {\n return (MathError.DIVISION_BY_ZERO, 0);\n }\n\n return (MathError.NO_ERROR, a / b);\n }\n\n /**\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\n */\n function subUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (b <= a) {\n return (MathError.NO_ERROR, a - b);\n } else {\n return (MathError.INTEGER_UNDERFLOW, 0);\n }\n }\n\n /**\n * @dev Adds two numbers, returns an error on overflow.\n */\n function addUInt(uint a, uint b) internal pure returns (MathError, uint) {\n uint c = a + b;\n\n if (c >= a) {\n return (MathError.NO_ERROR, c);\n } else {\n return (MathError.INTEGER_OVERFLOW, 0);\n }\n }\n\n /**\n * @dev add a and b and then subtract c\n */\n function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) {\n (MathError err0, uint sum) = addUInt(a, b);\n\n if (err0 != MathError.NO_ERROR) {\n return (err0, 0);\n }\n\n return subUInt(sum, c);\n }\n}\n" + }, + "contracts/Utils/Context.sol": { + "content": "pragma solidity ^0.5.16;\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 GSN 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 */\ncontract Context {\n // Empty internal constructor, to prevent people from mistakenly deploying\n // an instance of this contract, which should be used via inheritance.\n constructor() internal {}\n\n function _msgSender() internal view returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n" + }, + "contracts/Utils/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// Adapted from OpenZeppelin Contracts v4.3.2 (utils/cryptography/ECDSA.sol)\n\n// SPDX-Copyright-Text: OpenZeppelin, 2021\n// SPDX-Copyright-Text: Venus, 2021\n\npragma solidity ^0.5.16;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\ncontract ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n}\n" + }, + "contracts/Utils/ErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract ComptrollerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n COMPTROLLER_MISMATCH,\n INSUFFICIENT_SHORTFALL,\n INSUFFICIENT_LIQUIDITY,\n INVALID_CLOSE_FACTOR,\n INVALID_COLLATERAL_FACTOR,\n INVALID_LIQUIDATION_INCENTIVE,\n MARKET_NOT_ENTERED, // no longer possible\n MARKET_NOT_LISTED,\n MARKET_ALREADY_LISTED,\n MATH_ERROR,\n NONZERO_BORROW_BALANCE,\n PRICE_ERROR,\n REJECTION,\n SNAPSHOT_ERROR,\n TOO_MANY_ASSETS,\n TOO_MUCH_REPAY,\n INSUFFICIENT_BALANCE_FOR_VAI,\n MARKET_NOT_COLLATERAL\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n EXIT_MARKET_BALANCE_OWED,\n EXIT_MARKET_REJECTION,\n SET_CLOSE_FACTOR_OWNER_CHECK,\n SET_CLOSE_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_NO_EXISTS,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\n SET_IMPLEMENTATION_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\n SET_MAX_ASSETS_OWNER_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_PRICE_ORACLE_OWNER_CHECK,\n SUPPORT_MARKET_EXISTS,\n SUPPORT_MARKET_OWNER_CHECK,\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\n SET_VAI_MINT_RATE_CHECK,\n SET_VAICONTROLLER_OWNER_CHECK,\n SET_MINTED_VAI_REJECTION,\n SET_TREASURY_OWNER_CHECK,\n UNLIST_MARKET_NOT_LISTED\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n\ncontract TokenErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n BAD_INPUT,\n COMPTROLLER_REJECTION,\n COMPTROLLER_CALCULATION_ERROR,\n INTEREST_RATE_MODEL_ERROR,\n INVALID_ACCOUNT_PAIR,\n INVALID_CLOSE_AMOUNT_REQUESTED,\n INVALID_COLLATERAL_FACTOR,\n MATH_ERROR,\n MARKET_NOT_FRESH,\n MARKET_NOT_LISTED,\n TOKEN_INSUFFICIENT_ALLOWANCE,\n TOKEN_INSUFFICIENT_BALANCE,\n TOKEN_INSUFFICIENT_CASH,\n TOKEN_TRANSFER_IN_FAILED,\n TOKEN_TRANSFER_OUT_FAILED,\n TOKEN_PRICE_ERROR\n }\n\n /*\n * Note: FailureInfo (but not Error) is kept in alphabetical order\n * This is because FailureInfo grows significantly faster, and\n * the order of Error has some meaning, while the order of FailureInfo\n * is entirely arbitrary.\n */\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n BORROW_ACCRUE_INTEREST_FAILED,\n BORROW_CASH_NOT_AVAILABLE,\n BORROW_FRESHNESS_CHECK,\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n BORROW_MARKET_NOT_LISTED,\n BORROW_COMPTROLLER_REJECTION,\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n LIQUIDATE_COMPTROLLER_REJECTION,\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n LIQUIDATE_FRESHNESS_CHECK,\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_ACCRUE_INTEREST_FAILED,\n MINT_COMPTROLLER_REJECTION,\n MINT_EXCHANGE_CALCULATION_FAILED,\n MINT_EXCHANGE_RATE_READ_FAILED,\n MINT_FRESHNESS_CHECK,\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n MINT_TRANSFER_IN_FAILED,\n MINT_TRANSFER_IN_NOT_POSSIBLE,\n REDEEM_ACCRUE_INTEREST_FAILED,\n REDEEM_COMPTROLLER_REJECTION,\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\n REDEEM_EXCHANGE_RATE_READ_FAILED,\n REDEEM_FRESHNESS_CHECK,\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\n REDUCE_RESERVES_ADMIN_CHECK,\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\n REDUCE_RESERVES_FRESH_CHECK,\n REDUCE_RESERVES_VALIDATION,\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_COMPTROLLER_REJECTION,\n REPAY_BORROW_FRESHNESS_CHECK,\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COMPTROLLER_OWNER_CHECK,\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\n SET_MAX_ASSETS_OWNER_CHECK,\n SET_ORACLE_MARKET_NOT_LISTED,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\n SET_RESERVE_FACTOR_ADMIN_CHECK,\n SET_RESERVE_FACTOR_FRESH_CHECK,\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\n TRANSFER_COMPTROLLER_REJECTION,\n TRANSFER_NOT_ALLOWED,\n TRANSFER_NOT_ENOUGH,\n TRANSFER_TOO_MUCH,\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\n ADD_RESERVES_FRESH_CHECK,\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE,\n TOKEN_GET_UNDERLYING_PRICE_ERROR,\n REPAY_VAI_COMPTROLLER_REJECTION,\n REPAY_VAI_FRESHNESS_CHECK,\n VAI_MINT_EXCHANGE_CALCULATION_FAILED,\n SFT_MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n\ncontract VAIControllerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED, // The sender is not authorized to perform this action.\n REJECTION, // The action would violate the comptroller, vaicontroller policy.\n SNAPSHOT_ERROR, // The comptroller could not get the account borrows and exchange rate from the market.\n PRICE_ERROR, // The comptroller could not obtain a required price of an asset.\n MATH_ERROR, // A math calculation error occurred.\n INSUFFICIENT_BALANCE_FOR_VAI // Caller does not have sufficient balance to mint VAI.\n }\n\n enum FailureInfo {\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_COMPTROLLER_OWNER_CHECK,\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n VAI_MINT_REJECTION,\n VAI_BURN_REJECTION,\n VAI_LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n VAI_LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n VAI_LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n VAI_LIQUIDATE_COMPTROLLER_REJECTION,\n VAI_LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n VAI_LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n VAI_LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n VAI_LIQUIDATE_FRESHNESS_CHECK,\n VAI_LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n VAI_LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n VAI_LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n VAI_LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n VAI_LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n VAI_LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n VAI_LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_FEE_CALCULATION_FAILED,\n SET_TREASURY_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/Utils/Exponential.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./CarefulMath.sol\";\nimport \"./ExponentialNoError.sol\";\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Venus\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract Exponential is CarefulMath, ExponentialNoError {\n /**\n * @dev Creates an exponential from numerator and denominator values.\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\n * or if `denom` is zero.\n */\n function getExp(uint num, uint denom) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint scaledNumerator) = mulUInt(num, expScale);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n (MathError err1, uint rational) = divUInt(scaledNumerator, denom);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\n }\n\n /**\n * @dev Adds two exponentials, returning a new exponential.\n */\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint result) = addUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Subtracts two exponentials, returning a new exponential.\n */\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint result) = subUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, returning a new Exp.\n */\n function mulScalar(Exp memory a, uint scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mulScalarTruncate(Exp memory a, uint scalar) internal pure returns (MathError, uint) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(product));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) internal pure returns (MathError, uint) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return addUInt(truncate(product), addend);\n }\n\n /**\n * @dev Divide an Exp by a scalar, returning a new Exp.\n */\n function divScalar(Exp memory a, uint scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\n }\n\n /**\n * @dev Divide a scalar by an Exp, returning a new Exp.\n */\n function divScalarByExp(uint scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\n /*\n We are doing this as:\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\n\n How it works:\n Exp = a / b;\n Scalar = s;\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\n */\n (MathError err0, uint numerator) = mulUInt(expScale, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n return getExp(numerator, divisor.mantissa);\n }\n\n /**\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\n */\n function divScalarByExpTruncate(uint scalar, Exp memory divisor) internal pure returns (MathError, uint) {\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(fraction));\n }\n\n /**\n * @dev Multiplies two exponentials, returning a new exponential.\n */\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n // We add half the scale before dividing so that we get rounding instead of truncation.\n // See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\n (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale);\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\n assert(err2 == MathError.NO_ERROR);\n\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\n }\n\n /**\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\n */\n function mulExp(uint a, uint b) internal pure returns (MathError, Exp memory) {\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\n }\n\n /**\n * @dev Multiplies three exponentials, returning a new exponential.\n */\n function mulExp3(Exp memory a, Exp memory b, Exp memory c) internal pure returns (MathError, Exp memory) {\n (MathError err, Exp memory ab) = mulExp(a, b);\n if (err != MathError.NO_ERROR) {\n return (err, ab);\n }\n return mulExp(ab, c);\n }\n\n /**\n * @dev Divides two exponentials, returning a new exponential.\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\n */\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n return getExp(a.mantissa, b.mantissa);\n }\n}\n" + }, + "contracts/Utils/ExponentialNoError.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract ExponentialNoError {\n uint internal constant expScale = 1e18;\n uint internal constant doubleScale = 1e36;\n uint internal constant halfExpScale = expScale / 2;\n uint internal constant mantissaOne = expScale;\n\n struct Exp {\n uint mantissa;\n }\n\n struct Double {\n uint mantissa;\n }\n\n /**\n * @dev Truncates the given exp to a whole number value.\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\n */\n function truncate(Exp memory exp) internal pure returns (uint) {\n // Note: We are not using careful math here as we're performing a division that cannot fail\n return exp.mantissa / expScale;\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mul_ScalarTruncate(Exp memory a, uint scalar) internal pure returns (uint) {\n Exp memory product = mul_(a, scalar);\n return truncate(product);\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mul_ScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) internal pure returns (uint) {\n Exp memory product = mul_(a, scalar);\n return add_(truncate(product), addend);\n }\n\n /**\n * @dev Checks if first Exp is less than second Exp.\n */\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa < right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp <= right Exp.\n */\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa <= right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp > right Exp.\n */\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa > right.mantissa;\n }\n\n /**\n * @dev returns true if Exp is exactly zero\n */\n function isZeroExp(Exp memory value) internal pure returns (bool) {\n return value.mantissa == 0;\n }\n\n function safe224(uint n, string memory errorMessage) internal pure returns (uint224) {\n require(n < 2 ** 224, errorMessage);\n return uint224(n);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(uint a, uint b) internal pure returns (uint) {\n return add_(a, b, \"addition overflow\");\n }\n\n function add_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n uint c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(uint a, uint b) internal pure returns (uint) {\n return sub_(a, b, \"subtraction underflow\");\n }\n\n function sub_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\n }\n\n function mul_(Exp memory a, uint b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint a, Exp memory b) internal pure returns (uint) {\n return mul_(a, b.mantissa) / expScale;\n }\n\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\n }\n\n function mul_(Double memory a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint a, Double memory b) internal pure returns (uint) {\n return mul_(a, b.mantissa) / doubleScale;\n }\n\n function mul_(uint a, uint b) internal pure returns (uint) {\n return mul_(a, b, \"multiplication overflow\");\n }\n\n function mul_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n if (a == 0 || b == 0) {\n return 0;\n }\n uint c = a * b;\n require(c / a == b, errorMessage);\n return c;\n }\n\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\n }\n\n function div_(Exp memory a, uint b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint a, Exp memory b) internal pure returns (uint) {\n return div_(mul_(a, expScale), b.mantissa);\n }\n\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\n }\n\n function div_(Double memory a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint a, Double memory b) internal pure returns (uint) {\n return div_(mul_(a, doubleScale), b.mantissa);\n }\n\n function div_(uint a, uint b) internal pure returns (uint) {\n return div_(a, b, \"divide by zero\");\n }\n\n function div_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n function fraction(uint a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\n }\n}\n" + }, + "contracts/Utils/IBEP20.sol": { + "content": "pragma solidity ^0.5.0;\n\n/**\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\n * the optional functions; to access them see {BEP20Detailed}.\n */\ninterface IBEP20 {\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 `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\n\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" + }, + "contracts/Utils/Ownable.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\ncontract 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() internal {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view 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 onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = 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 onlyOwner {\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n */\n function _transferOwnership(address newOwner) internal {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n}\n" + }, + "contracts/Utils/Owned.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract Owned {\n address public owner;\n\n event OwnershipTransferred(address indexed _from, address indexed _to);\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Should be owner\");\n _;\n }\n\n function transferOwnership(address newOwner) public onlyOwner {\n owner = newOwner;\n emit OwnershipTransferred(owner, newOwner);\n }\n}\n" + }, + "contracts/Utils/SafeBEP20.sol": { + "content": "pragma solidity ^0.5.0;\n\nimport \"./SafeMath.sol\";\nimport \"./IBEP20.sol\";\nimport \"./Address.sol\";\n\n/**\n * @title SafeBEP20\n * @dev Wrappers around BEP20 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 SafeBEP20 for BEP20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeBEP20 {\n using SafeMath for uint256;\n using Address for address;\n\n function safeTransfer(IBEP20 token, address to, uint256 value) internal {\n callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(IBEP20 token, address from, address to, uint256 value) internal {\n callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n function safeApprove(IBEP20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeBEP20: approve from non-zero to non-zero allowance\"\n );\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).sub(\n value,\n \"SafeBEP20: decreased allowance below zero\"\n );\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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(IBEP20 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.\n\n // A Solidity high level call has three parts:\n // 1. The target address is checked to verify it contains contract code\n // 2. The call itself is made, and success asserted\n // 3. The return value is decoded, which in turn checks the size of the returned data.\n // solhint-disable-next-line max-line-length\n require(address(token).isContract(), \"SafeBEP20: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = address(token).call(data);\n require(success, \"SafeBEP20: low-level call failed\");\n\n if (returndata.length > 0) {\n // Return data is optional\n // solhint-disable-next-line max-line-length\n require(abi.decode(returndata, (bool)), \"SafeBEP20: BEP20 operation did not succeed\");\n }\n }\n}\n" + }, + "contracts/Utils/SafeCast.sol": { + "content": "pragma solidity ^0.5.16;\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 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 < 2 ** 128, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(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 < 2 ** 64, \"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 < 2 ** 32, \"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 < 2 ** 16, \"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 < 2 ** 8, \"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 >= -2 ** 127 && value < 2 ** 127, \"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 >= -2 ** 63 && value < 2 ** 63, \"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 >= -2 ** 31 && value < 2 ** 31, \"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 >= -2 ** 15 && value < 2 ** 15, \"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 >= -2 ** 7 && value < 2 ** 7, \"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 require(value < 2 ** 255, \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "contracts/Utils/SafeMath.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return add(a, b, \"SafeMath: addition overflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, errorMessage);\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0, errorMessage);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return mod(a, b, \"SafeMath: modulo by zero\");\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts with custom message when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b != 0, errorMessage);\n return a % b;\n }\n}\n" + }, + "contracts/Utils/Tokenlock.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./Owned.sol\";\n\ncontract Tokenlock is Owned {\n /// @notice Indicates if token is locked\n uint8 internal isLocked = 0;\n\n event Freezed();\n event UnFreezed();\n\n modifier validLock() {\n require(isLocked == 0, \"Token is locked\");\n _;\n }\n\n function freeze() public onlyOwner {\n isLocked = 1;\n\n emit Freezed();\n }\n\n function unfreeze() public onlyOwner {\n isLocked = 0;\n\n emit UnFreezed();\n }\n}\n" + }, + "contracts/VAIVault/VAIVault.sol": { + "content": "pragma solidity 0.5.16;\n\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./VAIVaultStorage.sol\";\nimport \"./VAIVaultErrorReporter.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\nimport { VAIVaultProxy } from \"./VAIVaultProxy.sol\";\n\n/**\n * @title VAI Vault\n * @author Venus\n * @notice The VAI Vault is configured for users to stake VAI And receive XVS as a reward.\n */\ncontract VAIVault is VAIVaultStorage, AccessControlledV5 {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice Event emitted when VAI deposit\n event Deposit(address indexed user, uint256 amount);\n\n /// @notice Event emitted when VAI withrawal\n event Withdraw(address indexed user, uint256 amount);\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @dev Prevents functions to execute when vault is paused.\n */\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @notice Pause vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Deposit VAI to VAIVault for XVS allocation\n * @param _amount The amount to deposit to vault\n */\n function deposit(uint256 _amount) external nonReentrant isActive {\n UserInfo storage user = userInfo[msg.sender];\n\n updateVault();\n\n // Transfer pending tokens to user\n updateAndPayOutPending(msg.sender);\n\n // Transfer in the amounts from user\n if (_amount > 0) {\n vai.safeTransferFrom(address(msg.sender), address(this), _amount);\n user.amount = user.amount.add(_amount);\n }\n\n user.rewardDebt = user.amount.mul(accXVSPerShare).div(1e18);\n emit Deposit(msg.sender, _amount);\n }\n\n /**\n * @notice Withdraw VAI from VAIVault\n * @param _amount The amount to withdraw from vault\n */\n function withdraw(uint256 _amount) external nonReentrant isActive {\n _withdraw(msg.sender, _amount);\n }\n\n /**\n * @notice Claim XVS from VAIVault\n */\n function claim() external nonReentrant isActive {\n _withdraw(msg.sender, 0);\n }\n\n /**\n * @notice Claim XVS from VAIVault\n * @param account The account for which to claim XVS\n */\n function claim(address account) external nonReentrant isActive {\n _withdraw(account, 0);\n }\n\n /**\n * @notice Low level withdraw function\n * @param account The account to withdraw from vault\n * @param _amount The amount to withdraw from vault\n */\n function _withdraw(address account, uint256 _amount) internal {\n UserInfo storage user = userInfo[account];\n require(user.amount >= _amount, \"withdraw: not good\");\n\n updateVault();\n updateAndPayOutPending(account); // Update balances of account this is not withdrawal but claiming XVS farmed\n\n if (_amount > 0) {\n user.amount = user.amount.sub(_amount);\n vai.safeTransfer(address(account), _amount);\n }\n user.rewardDebt = user.amount.mul(accXVSPerShare).div(1e18);\n\n emit Withdraw(account, _amount);\n }\n\n /**\n * @notice View function to see pending XVS on frontend\n * @param _user The user to see pending XVS\n * @return Amount of XVS the user can claim\n */\n function pendingXVS(address _user) public view returns (uint256) {\n UserInfo storage user = userInfo[_user];\n\n return user.amount.mul(accXVSPerShare).div(1e18).sub(user.rewardDebt);\n }\n\n /**\n * @notice Update and pay out pending XVS to user\n * @param account The user to pay out\n */\n function updateAndPayOutPending(address account) internal {\n uint256 pending = pendingXVS(account);\n\n if (pending > 0) {\n safeXVSTransfer(account, pending);\n }\n }\n\n /**\n * @notice Safe XVS transfer function, just in case if rounding error causes pool to not have enough XVS\n * @param _to The address that XVS to be transfered\n * @param _amount The amount that XVS to be transfered\n */\n function safeXVSTransfer(address _to, uint256 _amount) internal {\n uint256 xvsBal = xvs.balanceOf(address(this));\n\n if (_amount > xvsBal) {\n xvs.transfer(_to, xvsBal);\n xvsBalance = xvs.balanceOf(address(this));\n } else {\n xvs.transfer(_to, _amount);\n xvsBalance = xvs.balanceOf(address(this));\n }\n }\n\n /**\n * @notice Function that updates pending rewards\n */\n function updatePendingRewards() public isActive {\n uint256 newRewards = xvs.balanceOf(address(this)).sub(xvsBalance);\n\n if (newRewards > 0) {\n xvsBalance = xvs.balanceOf(address(this)); // If there is no change the balance didn't change\n pendingRewards = pendingRewards.add(newRewards);\n }\n }\n\n /**\n * @notice Update reward variables to be up-to-date\n */\n function updateVault() internal {\n updatePendingRewards();\n\n uint256 vaiBalance = vai.balanceOf(address(this));\n if (vaiBalance == 0) {\n // avoids division by 0 errors\n return;\n }\n\n accXVSPerShare = accXVSPerShare.add(pendingRewards.mul(1e18).div(vaiBalance));\n pendingRewards = 0;\n }\n\n /*** Admin Functions ***/\n\n function _become(VAIVaultProxy vaiVaultProxy) external {\n require(msg.sender == vaiVaultProxy.admin(), \"only proxy admin can change brains\");\n require(vaiVaultProxy._acceptImplementation() == 0, \"change not authorized\");\n }\n\n function setVenusInfo(address _xvs, address _vai) external onlyAdmin {\n require(_xvs != address(0) && _vai != address(0), \"addresses must not be zero\");\n require(address(xvs) == address(0) && address(vai) == address(0), \"addresses already set\");\n xvs = IBEP20(_xvs);\n vai = IBEP20(_vai);\n\n _notEntered = true;\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract VAIVaultErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VAIVaultStorage.sol\";\nimport \"./VAIVaultErrorReporter.sol\";\n\n/**\n * @title VAI Vault Proxy\n * @author Venus\n * @notice Proxy contract for the VAI Vault\n */\ncontract VAIVaultProxy is VAIVaultAdminStorage, VAIVaultErrorReporter {\n /**\n * @notice Emitted when pendingVAIVaultImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingVAIVaultImplementation is accepted, which means VAI Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingVAIVaultImplementation;\n\n pendingVAIVaultImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of VAI Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingVAIVaultImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = vaiVaultImplementation;\n address oldPendingImplementation = pendingVAIVaultImplementation;\n\n vaiVaultImplementation = pendingVAIVaultImplementation;\n\n pendingVAIVaultImplementation = address(0);\n\n emit NewImplementation(oldImplementation, vaiVaultImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = vaiVaultImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\n\ncontract VAIVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VAI Vault\n */\n address public vaiVaultImplementation;\n\n /**\n * @notice Pending brains of VAI Vault\n */\n address public pendingVAIVaultImplementation;\n}\n\ncontract VAIVaultStorage is VAIVaultAdminStorage {\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice The VAI TOKEN!\n IBEP20 public vai;\n\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice XVS balance of vault\n uint256 public xvsBalance;\n\n /// @notice Accumulated XVS per share\n uint256 public accXVSPerShare;\n\n //// pending rewards awaiting anyone to update\n uint256 public pendingRewards;\n\n /// @notice Info of each user.\n struct UserInfo {\n uint256 amount;\n uint256 rewardDebt;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => UserInfo) public userInfo;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "contracts/VRTVault/VRTVault.sol": { + "content": "pragma solidity 0.5.16;\n\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./VRTVaultStorage.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\n\ninterface IVRTVaultProxy {\n function _acceptImplementation() external;\n\n function admin() external returns (address);\n}\n\ncontract VRTVault is VRTVaultStorage, AccessControlledV5 {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The upper bound for lastAccruingBlock. Close to year 3,000, considering 3 seconds per block. Used to avoid a value absurdly high\n uint256 public constant MAX_LAST_ACCRUING_BLOCK = 9999999999;\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n /// @notice Event emitted on VRT deposit\n event Deposit(address indexed user, uint256 amount);\n\n /// @notice Event emitted when accruedInterest and VRT PrincipalAmount is withrawn\n event Withdraw(\n address indexed user,\n uint256 withdrawnAmount,\n uint256 totalPrincipalAmount,\n uint256 accruedInterest\n );\n\n /// @notice Event emitted when Admin withdraw BEP20 token from contract\n event WithdrawToken(address indexed tokenAddress, address indexed receiver, uint256 amount);\n\n /// @notice Event emitted when accruedInterest is claimed\n event Claim(address indexed user, uint256 interestAmount);\n\n /// @notice Event emitted when lastAccruingBlock state variable changes\n event LastAccruingBlockChanged(uint256 oldLastAccruingBlock, uint256 newLastAccruingBlock);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin allowed\");\n _;\n }\n\n function initialize(address _vrtAddress, uint256 _interestRatePerBlock) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_vrtAddress != address(0), \"vrtAddress cannot be Zero\");\n require(interestRatePerBlock == 0, \"Vault may only be initialized once\");\n\n // Set initial exchange rate\n interestRatePerBlock = _interestRatePerBlock;\n require(interestRatePerBlock > 0, \"interestRate Per Block must be greater than zero.\");\n\n // Set the VRT\n vrt = IBEP20(_vrtAddress);\n _notEntered = true;\n }\n\n modifier isInitialized() {\n require(interestRatePerBlock > 0, \"Vault is not initialized\");\n _;\n }\n\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n modifier userHasPosition(address userAddress) {\n UserInfo storage user = userInfo[userAddress];\n require(user.userAddress != address(0), \"User does not have any position in the Vault.\");\n _;\n }\n\n /**\n * @notice Pause vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Deposit VRT to VRTVault for a fixed-interest-rate\n * @param depositAmount The amount to deposit to vault\n */\n function deposit(uint256 depositAmount) external nonReentrant isInitialized isActive {\n require(depositAmount > 0, \"Deposit amount must be non-zero\");\n\n address userAddress = msg.sender;\n UserInfo storage user = userInfo[userAddress];\n\n if (user.userAddress == address(0)) {\n user.userAddress = userAddress;\n user.totalPrincipalAmount = depositAmount;\n } else {\n // accrue Interest and transfer to the user\n uint256 accruedInterest = computeAccruedInterest(user.totalPrincipalAmount, user.accrualStartBlockNumber);\n\n user.totalPrincipalAmount = user.totalPrincipalAmount.add(depositAmount);\n\n if (accruedInterest > 0) {\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(\n vrtBalance >= accruedInterest,\n \"Failed to transfer accruedInterest, Insufficient VRT in Vault.\"\n );\n emit Claim(userAddress, accruedInterest);\n vrt.safeTransfer(user.userAddress, accruedInterest);\n }\n }\n\n uint256 currentBlock_ = getBlockNumber();\n if (lastAccruingBlock > currentBlock_) {\n user.accrualStartBlockNumber = currentBlock_;\n } else {\n user.accrualStartBlockNumber = lastAccruingBlock;\n }\n emit Deposit(userAddress, depositAmount);\n vrt.safeTransferFrom(userAddress, address(this), depositAmount);\n }\n\n /**\n * @notice get accruedInterest of the user's VRTDeposits in the Vault\n * @param userAddress Address of User in the the Vault\n * @return The interest accrued, in VRT\n */\n function getAccruedInterest(\n address userAddress\n ) public view nonZeroAddress(userAddress) isInitialized returns (uint256) {\n UserInfo storage user = userInfo[userAddress];\n if (user.accrualStartBlockNumber == 0) {\n return 0;\n }\n\n return computeAccruedInterest(user.totalPrincipalAmount, user.accrualStartBlockNumber);\n }\n\n /**\n * @notice get accruedInterest of the user's VRTDeposits in the Vault\n * @param totalPrincipalAmount of the User\n * @param accrualStartBlockNumber of the User\n * @return The interest accrued, in VRT\n */\n function computeAccruedInterest(\n uint256 totalPrincipalAmount,\n uint256 accrualStartBlockNumber\n ) internal view isInitialized returns (uint256) {\n uint256 blockNumber = getBlockNumber();\n uint256 _lastAccruingBlock = lastAccruingBlock;\n\n if (blockNumber > _lastAccruingBlock) {\n blockNumber = _lastAccruingBlock;\n }\n\n if (accrualStartBlockNumber == 0 || accrualStartBlockNumber >= blockNumber) {\n return 0;\n }\n\n // Number of blocks since deposit\n uint256 blockDelta = blockNumber.sub(accrualStartBlockNumber);\n uint256 accruedInterest = (totalPrincipalAmount.mul(interestRatePerBlock).mul(blockDelta)).div(1e18);\n return accruedInterest;\n }\n\n /**\n * @notice claim the accruedInterest of the user's VRTDeposits in the Vault\n */\n function claim() external nonReentrant isInitialized userHasPosition(msg.sender) isActive {\n _claim(msg.sender);\n }\n\n /**\n * @notice claim the accruedInterest of the user's VRTDeposits in the Vault\n * @param account The account for which to claim rewards\n */\n function claim(address account) external nonReentrant isInitialized userHasPosition(account) isActive {\n _claim(account);\n }\n\n /**\n * @notice Low level claim function\n * @param account The account for which to claim rewards\n */\n function _claim(address account) internal {\n uint256 accruedInterest = getAccruedInterest(account);\n if (accruedInterest > 0) {\n UserInfo storage user = userInfo[account];\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(vrtBalance >= accruedInterest, \"Failed to transfer VRT, Insufficient VRT in Vault.\");\n emit Claim(account, accruedInterest);\n uint256 currentBlock_ = getBlockNumber();\n if (lastAccruingBlock > currentBlock_) {\n user.accrualStartBlockNumber = currentBlock_;\n } else {\n user.accrualStartBlockNumber = lastAccruingBlock;\n }\n vrt.safeTransfer(user.userAddress, accruedInterest);\n }\n }\n\n /**\n * @notice withdraw accruedInterest and totalPrincipalAmount of the user's VRTDeposit in the Vault\n */\n function withdraw() external nonReentrant isInitialized userHasPosition(msg.sender) isActive {\n address userAddress = msg.sender;\n uint256 accruedInterest = getAccruedInterest(userAddress);\n\n UserInfo storage user = userInfo[userAddress];\n\n uint256 totalPrincipalAmount = user.totalPrincipalAmount;\n uint256 vrtForWithdrawal = accruedInterest.add(totalPrincipalAmount);\n user.totalPrincipalAmount = 0;\n user.accrualStartBlockNumber = getBlockNumber();\n\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(vrtBalance >= vrtForWithdrawal, \"Failed to transfer VRT, Insufficient VRT in Vault.\");\n\n emit Withdraw(userAddress, vrtForWithdrawal, totalPrincipalAmount, accruedInterest);\n vrt.safeTransfer(user.userAddress, vrtForWithdrawal);\n }\n\n /**\n * @notice withdraw BEP20 tokens from the contract to a recipient address.\n * @param tokenAddress address of the BEP20 token\n * @param receiver recipient of the BEP20 token\n * @param amount tokenAmount\n */\n function withdrawBep20(\n address tokenAddress,\n address receiver,\n uint256 amount\n ) external isInitialized nonZeroAddress(tokenAddress) nonZeroAddress(receiver) {\n _checkAccessAllowed(\"withdrawBep20(address,address,uint256)\");\n require(amount > 0, \"amount is invalid\");\n IBEP20 token = IBEP20(tokenAddress);\n require(amount <= token.balanceOf(address(this)), \"Insufficient amount in Vault\");\n emit WithdrawToken(tokenAddress, receiver, amount);\n token.safeTransfer(receiver, amount);\n }\n\n function setLastAccruingBlock(uint256 _lastAccruingBlock) external {\n _checkAccessAllowed(\"setLastAccruingBlock(uint256)\");\n require(_lastAccruingBlock < MAX_LAST_ACCRUING_BLOCK, \"_lastAccruingBlock is absurdly high\");\n\n uint256 oldLastAccruingBlock = lastAccruingBlock;\n uint256 currentBlock = getBlockNumber();\n if (oldLastAccruingBlock != 0) {\n require(currentBlock < oldLastAccruingBlock, \"Cannot change at this point\");\n }\n if (oldLastAccruingBlock == 0 || _lastAccruingBlock < oldLastAccruingBlock) {\n // Must be in future\n require(currentBlock < _lastAccruingBlock, \"Invalid _lastAccruingBlock interest have been accumulated\");\n }\n lastAccruingBlock = _lastAccruingBlock;\n emit LastAccruingBlockChanged(oldLastAccruingBlock, _lastAccruingBlock);\n }\n\n function getBlockNumber() public view returns (uint256) {\n return block.number;\n }\n\n /*** Admin Functions ***/\n\n function _become(IVRTVaultProxy vrtVaultProxy) external {\n require(msg.sender == vrtVaultProxy.admin(), \"only proxy admin can change brains\");\n vrtVaultProxy._acceptImplementation();\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n}\n" + }, + "contracts/VRTVault/VRTVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VRTVaultStorage.sol\";\n\ncontract VRTVaultProxy is VRTVaultAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means VRT Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(address implementation_, address vrtAddress_, uint256 interestRatePerBlock_) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\"initialize(address,uint256)\", vrtAddress_, interestRatePerBlock_)\n );\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"VRTVaultProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"VRTVaultProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRT Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) public {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/VRTVault/VRTVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\n\ncontract VRTVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VRT Vault\n */\n address public implementation;\n\n /**\n * @notice Pending brains of VAI Vault\n */\n address public pendingImplementation;\n}\n\ncontract VRTVaultStorage is VRTVaultAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /// @notice The VRT TOKEN!\n IBEP20 public vrt;\n\n /// @notice interestRate for accrual - per Block\n uint256 public interestRatePerBlock;\n\n /// @notice Info of each user.\n struct UserInfo {\n address userAddress;\n uint256 accrualStartBlockNumber;\n uint256 totalPrincipalAmount;\n uint256 lastWithdrawnBlockNumber;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => UserInfo) public userInfo;\n\n /// @notice block number after which no interest will be accrued\n uint256 public lastAccruingBlock;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "contracts/XVSVault/XVSStore.sol": { + "content": "pragma solidity 0.5.16;\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\n\n/**\n * @title XVS Store\n * @author Venus\n * @notice XVS Store responsible for distributing XVS rewards\n */\ncontract XVSStore {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The Admin Address\n address public admin;\n\n /// @notice The pending admin address\n address public pendingAdmin;\n\n /// @notice The Owner Address\n address public owner;\n\n /// @notice The reward tokens\n mapping(address => bool) public rewardTokens;\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Event emitted when admin changed\n event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);\n\n /// @notice Event emitted when owner changed\n event OwnerTransferred(address indexed oldOwner, address indexed newOwner);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"only owner can\");\n _;\n }\n\n /**\n * @notice Safely transfer rewards. Only active reward tokens can be sent using this function.\n * Only callable by owner\n * @dev Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\n * @param token Reward token to transfer\n * @param _to Destination address of the reward\n * @param _amount Amount to transfer\n */\n function safeRewardTransfer(address token, address _to, uint256 _amount) external onlyOwner {\n require(rewardTokens[token] == true, \"only reward token can\");\n\n if (address(token) != address(0)) {\n uint256 tokenBalance = IBEP20(token).balanceOf(address(this));\n if (_amount > tokenBalance) {\n IBEP20(token).safeTransfer(_to, tokenBalance);\n } else {\n IBEP20(token).safeTransfer(_to, _amount);\n }\n }\n }\n\n /**\n * @notice Allows the admin to propose a new admin\n * Only callable admin\n * @param _admin Propose an account as admin of the XVS store\n */\n function setPendingAdmin(address _admin) external onlyAdmin {\n address oldPendingAdmin = pendingAdmin;\n pendingAdmin = _admin;\n emit NewPendingAdmin(oldPendingAdmin, _admin);\n }\n\n /**\n * @notice Allows an account that is pending as admin to accept the role\n * nly calllable by the pending admin\n */\n function acceptAdmin() external {\n require(msg.sender == pendingAdmin, \"only pending admin\");\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n admin = pendingAdmin;\n pendingAdmin = address(0);\n\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n emit AdminTransferred(oldAdmin, admin);\n }\n\n /**\n * @notice Set the contract owner\n * @param _owner The address of the owner to set\n * Only callable admin\n */\n function setNewOwner(address _owner) external onlyAdmin {\n require(_owner != address(0), \"new owner is the zero address\");\n address oldOwner = owner;\n owner = _owner;\n emit OwnerTransferred(oldOwner, _owner);\n }\n\n /**\n * @notice Set or disable a reward token\n * @param _tokenAddress The address of a token to set as active or inactive\n * @param status Set whether a reward token is active or not\n */\n function setRewardToken(address _tokenAddress, bool status) external {\n require(msg.sender == admin || msg.sender == owner, \"only admin or owner can\");\n rewardTokens[_tokenAddress] = status;\n }\n\n /**\n * @notice Security function to allow the owner of the contract to withdraw from the contract\n * @param _tokenAddress Reward token address to withdraw\n * @param _amount Amount of token to withdraw\n */\n function emergencyRewardWithdraw(address _tokenAddress, uint256 _amount) external onlyOwner {\n IBEP20(_tokenAddress).safeTransfer(address(msg.sender), _amount);\n }\n}\n" + }, + "contracts/XVSVault/XVSVault.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Utils/ECDSA.sol\";\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./XVSVaultStorage.sol\";\nimport \"../Tokens/Prime/IPrime.sol\";\nimport \"../Utils/SafeCast.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\nimport \"@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol\";\n\nimport { XVSStore } from \"./XVSStore.sol\";\nimport { XVSVaultProxy } from \"./XVSVaultProxy.sol\";\n\n/**\n * @title XVS Vault\n * @author Venus\n * @notice The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS.\n */\ncontract XVSVault is XVSVaultStorage, ECDSA, AccessControlledV5, TimeManagerV5 {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The upper bound for the lock period in a pool, 10 years\n uint256 public constant MAX_LOCK_PERIOD = 60 * 60 * 24 * 365 * 10;\n\n /// @notice Event emitted when deposit\n event Deposit(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when execute withrawal\n event ExecutedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when request withrawal\n event RequestedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChangedV2(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChangedV2(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice An event emitted when the reward store address is updated\n event StoreUpdated(address oldXvs, address oldStore, address newXvs, address newStore);\n\n /// @notice An event emitted when the withdrawal locking period is updated for a pool\n event WithdrawalLockingPeriodUpdated(address indexed rewardToken, uint indexed pid, uint oldPeriod, uint newPeriod);\n\n /// @notice An event emitted when the reward amount per block or second is modified for a pool\n event RewardAmountUpdated(address indexed rewardToken, uint oldReward, uint newReward);\n\n /// @notice An event emitted when a new pool is added\n event PoolAdded(\n address indexed rewardToken,\n uint indexed pid,\n address indexed token,\n uint allocPoints,\n uint rewardPerBlockOrSecond,\n uint lockPeriod\n );\n\n /// @notice An event emitted when a pool allocation points are updated\n event PoolUpdated(address indexed rewardToken, uint indexed pid, uint oldAllocPoints, uint newAllocPoints);\n\n /// @notice Event emitted when reward claimed\n event Claim(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n /// @notice Event emitted when protocol logs a debt to a user due to insufficient funds for pending reward distribution\n event VaultDebtUpdated(\n address indexed rewardToken,\n address indexed userAddress,\n uint256 oldOwedAmount,\n uint256 newOwedAmount\n );\n\n /// @notice Emitted when prime token contract address is changed\n event NewPrimeToken(\n IPrime indexed oldPrimeToken,\n IPrime indexed newPrimeToken,\n address oldPrimeRewardToken,\n address newPrimeRewardToken,\n uint256 oldPrimePoolId,\n uint256 newPrimePoolId\n );\n\n /**\n * @notice XVSVault constructor\n */\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @dev Prevents functions to execute when vault is paused.\n */\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @notice Pauses vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Returns the number of pools with the specified reward token\n * @param rewardToken Reward token address\n * @return Number of pools that distribute the specified token as a reward\n */\n function poolLength(address rewardToken) external view returns (uint256) {\n return poolInfos[rewardToken].length;\n }\n\n /**\n * @notice Returns the number of reward tokens created per block or second\n * @param _rewardToken Reward token address\n * @return Number of reward tokens created per block or second\n */\n function rewardTokenAmountsPerBlock(address _rewardToken) external view returns (uint256) {\n return rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n }\n\n /**\n * @notice Add a new token pool\n * @dev This vault DOES NOT support deflationary tokens — it expects that\n * the amount of transferred tokens would equal the actually deposited\n * amount. In practice this means that this vault DOES NOT support USDT\n * and similar tokens (that do not provide these guarantees).\n * @param _rewardToken Reward token address\n * @param _allocPoint Number of allocation points assigned to this pool\n * @param _token Staked token\n * @param _rewardPerBlockOrSecond Initial reward per block or second, in terms of _rewardToken\n * @param _lockPeriod A period between withdrawal request and a moment when it's executable\n */\n function add(\n address _rewardToken,\n uint256 _allocPoint,\n IBEP20 _token,\n uint256 _rewardPerBlockOrSecond,\n uint256 _lockPeriod\n ) external {\n _checkAccessAllowed(\"add(address,uint256,address,uint256,uint256)\");\n _ensureNonzeroAddress(_rewardToken);\n _ensureNonzeroAddress(address(_token));\n require(address(xvsStore) != address(0), \"Store contract address is empty\");\n require(_allocPoint > 0, \"Alloc points must not be zero\");\n\n massUpdatePools(_rewardToken);\n\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\n\n uint256 length = poolInfo.length;\n for (uint256 pid = 0; pid < length; ++pid) {\n require(poolInfo[pid].token != _token, \"Pool already added\");\n }\n\n // We use balanceOf to get the supply amount, so shouldn't be possible to\n // configure pools with different reward token but the same staked token\n require(!isStakedToken[address(_token)], \"Token exists in other pool\");\n\n totalAllocPoints[_rewardToken] = totalAllocPoints[_rewardToken].add(_allocPoint);\n\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardPerBlockOrSecond;\n\n poolInfo.push(\n PoolInfo({\n token: _token,\n allocPoint: _allocPoint,\n lastRewardBlockOrSecond: getBlockNumberOrTimestamp(),\n accRewardPerShare: 0,\n lockPeriod: _lockPeriod\n })\n );\n isStakedToken[address(_token)] = true;\n\n XVSStore(xvsStore).setRewardToken(_rewardToken, true);\n\n emit PoolAdded(\n _rewardToken,\n poolInfo.length - 1,\n address(_token),\n _allocPoint,\n _rewardPerBlockOrSecond,\n _lockPeriod\n );\n }\n\n /**\n * @notice Update the given pool's reward allocation point\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _allocPoint Number of allocation points assigned to this pool\n */\n function set(address _rewardToken, uint256 _pid, uint256 _allocPoint) external {\n _checkAccessAllowed(\"set(address,uint256,uint256)\");\n _ensureValidPool(_rewardToken, _pid);\n\n massUpdatePools(_rewardToken);\n\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\n uint256 newTotalAllocPoints = totalAllocPoints[_rewardToken].sub(poolInfo[_pid].allocPoint).add(_allocPoint);\n require(newTotalAllocPoints > 0, \"Alloc points per reward token must not be zero\");\n\n uint256 oldAllocPoints = poolInfo[_pid].allocPoint;\n poolInfo[_pid].allocPoint = _allocPoint;\n totalAllocPoints[_rewardToken] = newTotalAllocPoints;\n\n emit PoolUpdated(_rewardToken, _pid, oldAllocPoints, _allocPoint);\n }\n\n /**\n * @notice Update the given reward token's amount per block or second\n * @param _rewardToken Reward token address\n * @param _rewardAmount Number of allocation points assigned to this pool\n */\n function setRewardAmountPerBlockOrSecond(address _rewardToken, uint256 _rewardAmount) external {\n _checkAccessAllowed(\"setRewardAmountPerBlockOrSecond(address,uint256)\");\n require(XVSStore(xvsStore).rewardTokens(_rewardToken), \"Invalid reward token\");\n massUpdatePools(_rewardToken);\n uint256 oldReward = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardAmount;\n\n emit RewardAmountUpdated(_rewardToken, oldReward, _rewardAmount);\n }\n\n /**\n * @notice Update the lock period after which a requested withdrawal can be executed\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _newPeriod New lock period\n */\n function setWithdrawalLockingPeriod(address _rewardToken, uint256 _pid, uint256 _newPeriod) external {\n _checkAccessAllowed(\"setWithdrawalLockingPeriod(address,uint256,uint256)\");\n _ensureValidPool(_rewardToken, _pid);\n require(_newPeriod > 0 && _newPeriod < MAX_LOCK_PERIOD, \"Invalid new locking period\");\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n uint256 oldPeriod = pool.lockPeriod;\n pool.lockPeriod = _newPeriod;\n\n emit WithdrawalLockingPeriodUpdated(_rewardToken, _pid, oldPeriod, _newPeriod);\n }\n\n /**\n * @notice Deposit XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _amount The amount to deposit to vault\n */\n function deposit(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n _updatePool(_rewardToken, _pid);\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, msg.sender) == 0, \"execute pending withdrawal\");\n\n if (user.amount > 0) {\n uint256 pending = _computeReward(user, pool);\n if (pending > 0) {\n _transferReward(_rewardToken, msg.sender, pending);\n emit Claim(msg.sender, _rewardToken, _pid, pending);\n }\n }\n pool.token.safeTransferFrom(msg.sender, address(this), _amount);\n user.amount = user.amount.add(_amount);\n user.rewardDebt = _cumulativeReward(user, pool);\n\n // Update Delegate Amount\n if (address(pool.token) == xvsAddress) {\n _moveDelegates(address(0), delegates[msg.sender], safe96(_amount, \"XVSVault::deposit: votes overflow\"));\n }\n\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\n primeToken.xvsUpdated(msg.sender);\n }\n\n emit Deposit(msg.sender, _rewardToken, _pid, _amount);\n }\n\n /**\n * @notice Claim rewards for pool\n * @param _account The account for which to claim rewards\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n */\n function claim(address _account, address _rewardToken, uint256 _pid) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][_account];\n _updatePool(_rewardToken, _pid);\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, _account) == 0, \"execute pending withdrawal\");\n\n if (user.amount > 0) {\n uint256 pending = _computeReward(user, pool);\n\n if (pending > 0) {\n user.rewardDebt = _cumulativeReward(user, pool);\n\n _transferReward(_rewardToken, _account, pending);\n emit Claim(_account, _rewardToken, _pid, pending);\n }\n }\n }\n\n /**\n * @notice Pushes withdrawal request to the requests array and updates\n * the pending withdrawals amount. The requests are always sorted\n * by unlock time (descending) so that the earliest to execute requests\n * are always at the end of the array.\n * @param _user The user struct storage pointer\n * @param _requests The user's requests array storage pointer\n * @param _amount The amount being requested\n */\n function pushWithdrawalRequest(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests,\n uint _amount,\n uint _lockedUntil\n ) internal {\n uint i = _requests.length;\n _requests.push(WithdrawalRequest(0, 0, 1));\n // Keep it sorted so that the first to get unlocked request is always at the end\n for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) {\n _requests[i] = _requests[i - 1];\n }\n _requests[i] = WithdrawalRequest(_amount, _lockedUntil.toUint128(), 1);\n _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount);\n }\n\n /**\n * @notice Pops the requests with unlock time < now from the requests\n * array and deducts the computed amount from the user's pending\n * withdrawals counter. Assumes that the requests array is sorted\n * by unclock time (descending).\n * @dev This function **removes** the eligible requests from the requests\n * array. If this function is called, the withdrawal should actually\n * happen (or the transaction should be reverted).\n * @param _user The user struct storage pointer\n * @param _requests The user's requests array storage pointer\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade (this amount should be\n * sent to the user, otherwise the state would be inconsistent).\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade (this amount should be\n * sent to the user, otherwise the state would be inconsistent).\n */\n function popEligibleWithdrawalRequests(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests\n ) internal returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\n // Since the requests are sorted by their unlock time, we can just\n // pop them from the array and stop at the first not-yet-eligible one\n for (uint i = _requests.length; i > 0 && isUnlocked(_requests[i - 1]); --i) {\n if (_requests[i - 1].afterUpgrade == 1) {\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n } else {\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n }\n\n _requests.pop();\n }\n _user.pendingWithdrawals = _user.pendingWithdrawals.sub(\n afterUpgradeWithdrawalAmount.add(beforeUpgradeWithdrawalAmount)\n );\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\n }\n\n /**\n * @notice Checks if the request is eligible for withdrawal.\n * @param _request The request struct storage pointer\n * @return True if the request is eligible for withdrawal, false otherwise\n */\n function isUnlocked(WithdrawalRequest storage _request) private view returns (bool) {\n return _request.lockedUntil <= block.timestamp;\n }\n\n /**\n * @notice Execute withdrawal to XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n */\n function executeWithdrawal(address _rewardToken, uint256 _pid) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n\n uint256 beforeUpgradeWithdrawalAmount;\n uint256 afterUpgradeWithdrawalAmount;\n\n (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount) = popEligibleWithdrawalRequests(user, requests);\n require(beforeUpgradeWithdrawalAmount > 0 || afterUpgradeWithdrawalAmount > 0, \"nothing to withdraw\");\n\n // Having both old-style and new-style requests is not allowed and shouldn't be possible\n require(beforeUpgradeWithdrawalAmount == 0 || afterUpgradeWithdrawalAmount == 0, \"inconsistent state\");\n\n if (beforeUpgradeWithdrawalAmount > 0) {\n _updatePool(_rewardToken, _pid);\n uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub(user.rewardDebt);\n XVSStore(xvsStore).safeRewardTransfer(_rewardToken, msg.sender, pending);\n user.amount = user.amount.sub(beforeUpgradeWithdrawalAmount);\n user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);\n pool.token.safeTransfer(address(msg.sender), beforeUpgradeWithdrawalAmount);\n } else {\n user.amount = user.amount.sub(afterUpgradeWithdrawalAmount);\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].sub(\n afterUpgradeWithdrawalAmount\n );\n pool.token.safeTransfer(address(msg.sender), afterUpgradeWithdrawalAmount);\n }\n\n emit ExecutedWithdrawal(\n msg.sender,\n _rewardToken,\n _pid,\n beforeUpgradeWithdrawalAmount.add(afterUpgradeWithdrawalAmount)\n );\n }\n\n /**\n * @notice Returns before and after upgrade pending withdrawal amount\n * @param _requests The user's requests array storage pointer\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade\n */\n function getRequestedWithdrawalAmount(\n WithdrawalRequest[] storage _requests\n ) internal view returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\n for (uint i = _requests.length; i > 0; --i) {\n if (_requests[i - 1].afterUpgrade == 1) {\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n } else {\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n }\n }\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\n }\n\n /**\n * @notice Request withdrawal to XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _amount The amount to withdraw from the vault\n */\n function requestWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n require(_amount > 0, \"requested amount cannot be zero\");\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n require(user.amount >= user.pendingWithdrawals.add(_amount), \"requested amount is invalid\");\n\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n\n uint beforeUpgradeWithdrawalAmount;\n\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\n require(beforeUpgradeWithdrawalAmount == 0, \"execute pending withdrawal\");\n\n _updatePool(_rewardToken, _pid);\n uint256 pending = _computeReward(user, pool);\n _transferReward(_rewardToken, msg.sender, pending);\n\n uint lockedUntil = pool.lockPeriod.add(block.timestamp);\n\n pushWithdrawalRequest(user, requests, _amount, lockedUntil);\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].add(_amount);\n user.rewardDebt = _cumulativeReward(user, pool);\n\n // Update Delegate Amount\n if (address(pool.token) == xvsAddress) {\n _moveDelegates(\n delegates[msg.sender],\n address(0),\n safe96(_amount, \"XVSVault::requestWithdrawal: votes overflow\")\n );\n }\n\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\n primeToken.xvsUpdated(msg.sender);\n }\n\n emit Claim(msg.sender, _rewardToken, _pid, pending);\n emit RequestedWithdrawal(msg.sender, _rewardToken, _pid, _amount);\n }\n\n /**\n * @notice Get unlocked withdrawal amount\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return withdrawalAmount Amount that the user can withdraw\n */\n function getEligibleWithdrawalAmount(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (uint withdrawalAmount) {\n _ensureValidPool(_rewardToken, _pid);\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n // Since the requests are sorted by their unlock time, we can take\n // the entries from the end of the array and stop at the first\n // not-yet-eligible one\n for (uint i = requests.length; i > 0 && isUnlocked(requests[i - 1]); --i) {\n withdrawalAmount = withdrawalAmount.add(requests[i - 1].amount);\n }\n return withdrawalAmount;\n }\n\n /**\n * @notice Get requested amount\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return Total amount of requested but not yet executed withdrawals (including both executable and locked ones)\n */\n function getRequestedAmount(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\n _ensureValidPool(_rewardToken, _pid);\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n return user.pendingWithdrawals;\n }\n\n /**\n * @notice Returns the array of withdrawal requests that have not been executed yet\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return An array of withdrawal requests\n */\n function getWithdrawalRequests(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (WithdrawalRequest[] memory) {\n _ensureValidPool(_rewardToken, _pid);\n return withdrawalRequests[_rewardToken][_pid][_user];\n }\n\n /**\n * @notice View function to see pending XVSs on frontend\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _user User address\n * @return Reward the user is eligible for in this pool, in terms of _rewardToken\n */\n function pendingReward(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n uint256 accRewardPerShare = pool.accRewardPerShare;\n uint256 supply = pool.token.balanceOf(address(this)).sub(totalPendingWithdrawals[_rewardToken][_pid]);\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\n uint256 rewardTokenPerBlockOrSecond = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n if (curBlockNumberOrSecond > pool.lastRewardBlockOrSecond && supply != 0) {\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\n uint256 reward = multiplier.mul(rewardTokenPerBlockOrSecond).mul(pool.allocPoint).div(\n totalAllocPoints[_rewardToken]\n );\n accRewardPerShare = accRewardPerShare.add(reward.mul(1e12).div(supply));\n }\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n (, uint256 afterUpgradeWithdrawalAmount) = getRequestedWithdrawalAmount(requests);\n return user.amount.sub(afterUpgradeWithdrawalAmount).mul(accRewardPerShare).div(1e12).sub(user.rewardDebt);\n }\n\n // Update reward variables for all pools. Be careful of gas spending!\n function massUpdatePools(address _rewardToken) internal {\n uint256 length = poolInfos[_rewardToken].length;\n for (uint256 pid = 0; pid < length; ++pid) {\n _updatePool(_rewardToken, pid);\n }\n }\n\n /**\n * @notice Update reward variables of the given pool to be up-to-date\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n */\n function updatePool(address _rewardToken, uint256 _pid) external isActive {\n _ensureValidPool(_rewardToken, _pid);\n _updatePool(_rewardToken, _pid);\n }\n\n // Update reward variables of the given pool to be up-to-date.\n function _updatePool(address _rewardToken, uint256 _pid) internal {\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n if (getBlockNumberOrTimestamp() <= pool.lastRewardBlockOrSecond) {\n return;\n }\n uint256 supply = pool.token.balanceOf(address(this));\n supply = supply.sub(totalPendingWithdrawals[_rewardToken][_pid]);\n if (supply == 0) {\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\n return;\n }\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\n uint256 reward = multiplier.mul(rewardTokenAmountsPerBlockOrSecond[_rewardToken]).mul(pool.allocPoint).div(\n totalAllocPoints[_rewardToken]\n );\n pool.accRewardPerShare = pool.accRewardPerShare.add(reward.mul(1e12).div(supply));\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\n }\n\n function _ensureValidPool(address rewardToken, uint256 pid) internal view {\n require(pid < poolInfos[rewardToken].length, \"vault: pool exists?\");\n }\n\n /**\n * @notice Get user info with reward token address and pid\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _user User address\n * @return amount Deposited amount\n * @return rewardDebt Reward debt (technical value used to track past payouts)\n * @return pendingWithdrawals Requested but not yet executed withdrawals\n */\n function getUserInfo(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals) {\n _ensureValidPool(_rewardToken, _pid);\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n amount = user.amount;\n rewardDebt = user.rewardDebt;\n pendingWithdrawals = user.pendingWithdrawals;\n }\n\n /**\n * @notice Gets the total pending withdrawal amount of a user before upgrade\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The address of the user\n * @return beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade\n */\n function pendingWithdrawalsBeforeUpgrade(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) public view returns (uint256 beforeUpgradeWithdrawalAmount) {\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\n return beforeUpgradeWithdrawalAmount;\n }\n\n /**\n * @notice Get the XVS stake balance of an account (excluding the pending withdrawals)\n * @param account The address of the account to check\n * @return The balance that user staked\n */\n function getStakeAmount(address account) internal view returns (uint96) {\n require(xvsAddress != address(0), \"XVSVault::getStakeAmount: xvs address is not set\");\n\n PoolInfo[] storage poolInfo = poolInfos[xvsAddress];\n\n uint256 length = poolInfo.length;\n for (uint256 pid = 0; pid < length; ++pid) {\n if (address(poolInfo[pid].token) == address(xvsAddress)) {\n UserInfo storage user = userInfos[xvsAddress][pid][account];\n return safe96(user.amount.sub(user.pendingWithdrawals), \"XVSVault::getStakeAmount: votes overflow\");\n }\n }\n return uint96(0);\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) external isActive {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(\n address delegatee,\n uint nonce,\n uint expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external isActive {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(\"XVSVault\")), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ECDSA.recover(digest, v, r, s);\n require(nonce == nonces[signatory]++, \"XVSVault::delegateBySig: invalid nonce\");\n require(block.timestamp <= expiry, \"XVSVault::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = getStakeAmount(delegator);\n delegates[delegator] = delegatee;\n\n emit DelegateChangedV2(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"XVSVault::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"XVSVault::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumberOrSecond = safe32(\n getBlockNumberOrTimestamp(),\n \"XVSVault::_writeCheckpoint: block number or second exceeds 32 bits\"\n );\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlockOrSecond == blockNumberOrSecond) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumberOrSecond, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChangedV2(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n\n /**\n * @notice Determine the xvs stake balance for an account\n * @param account The address of the account to check\n * @param blockNumberOrSecond The block number or second to get the vote balance at\n * @return The balance that user staked\n */\n function getPriorVotes(address account, uint256 blockNumberOrSecond) external view returns (uint96) {\n require(blockNumberOrSecond < getBlockNumberOrTimestamp(), \"XVSVault::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlockOrSecond <= blockNumberOrSecond) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlockOrSecond > blockNumberOrSecond) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlockOrSecond == blockNumberOrSecond) {\n return cp.votes;\n } else if (cp.fromBlockOrSecond < blockNumberOrSecond) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n /*** Admin Functions ***/\n\n function _become(XVSVaultProxy xvsVaultProxy) external {\n require(msg.sender == xvsVaultProxy.admin(), \"only proxy admin can change brains\");\n require(xvsVaultProxy._acceptImplementation() == 0, \"change not authorized\");\n }\n\n function setXvsStore(address _xvs, address _xvsStore) external onlyAdmin {\n _ensureNonzeroAddress(_xvs);\n _ensureNonzeroAddress(_xvsStore);\n\n address oldXvsContract = xvsAddress;\n address oldStore = xvsStore;\n require(oldXvsContract == address(0), \"already initialized\");\n\n xvsAddress = _xvs;\n xvsStore = _xvsStore;\n\n _notEntered = true;\n\n emit StoreUpdated(oldXvsContract, oldStore, _xvs, _xvsStore);\n }\n\n /**\n * @notice Sets the address of the prime token contract\n * @param _primeToken address of the prime token contract\n * @param _primeRewardToken address of reward token\n * @param _primePoolId pool id for reward\n */\n function setPrimeToken(IPrime _primeToken, address _primeRewardToken, uint256 _primePoolId) external onlyAdmin {\n require(address(_primeToken) != address(0), \"prime token cannot be zero address\");\n require(_primeRewardToken != address(0), \"reward cannot be zero address\");\n\n _ensureValidPool(_primeRewardToken, _primePoolId);\n\n emit NewPrimeToken(primeToken, _primeToken, primeRewardToken, _primeRewardToken, primePoolId, _primePoolId);\n\n primeToken = _primeToken;\n primeRewardToken = _primeRewardToken;\n primePoolId = _primePoolId;\n }\n\n /**\n * @dev Initializes the contract to use either blocks or seconds\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\n * @param blocksPerYear_ The number of blocks per year\n */\n function initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) external onlyAdmin {\n _initializeTimeManager(timeBased_, blocksPerYear_);\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n\n /**\n * @dev Reverts if the provided address is a zero address\n * @param address_ Address to check\n */\n function _ensureNonzeroAddress(address address_) internal pure {\n require(address_ != address(0), \"zero address not allowed\");\n }\n\n /**\n * @dev Transfers the reward to the user, taking into account the rewards store\n * balance and the previous debt. If there are not enough rewards in the store,\n * transfers the available funds and records the debt amount in pendingRewardTransfers.\n * @param rewardToken Reward token address\n * @param userAddress User address\n * @param amount Reward amount, in reward tokens\n */\n function _transferReward(address rewardToken, address userAddress, uint256 amount) internal {\n address xvsStore_ = xvsStore;\n uint256 storeBalance = IBEP20(rewardToken).balanceOf(xvsStore_);\n uint256 debtDueToFailedTransfers = pendingRewardTransfers[rewardToken][userAddress];\n uint256 fullAmount = amount.add(debtDueToFailedTransfers);\n\n if (fullAmount <= storeBalance) {\n if (debtDueToFailedTransfers != 0) {\n pendingRewardTransfers[rewardToken][userAddress] = 0;\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, 0);\n }\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, fullAmount);\n return;\n }\n // Overflow isn't possible due to the check above\n uint256 newOwedAmount = fullAmount - storeBalance;\n pendingRewardTransfers[rewardToken][userAddress] = newOwedAmount;\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, newOwedAmount);\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, storeBalance);\n }\n\n /**\n * @dev Computes cumulative reward for all user's shares\n * @param user UserInfo storage struct\n * @param pool PoolInfo storage struct\n */\n function _cumulativeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\n return user.amount.sub(user.pendingWithdrawals).mul(pool.accRewardPerShare).div(1e12);\n }\n\n /**\n * @dev Computes the reward for all user's shares\n * @param user UserInfo storage struct\n * @param pool PoolInfo storage struct\n */\n function _computeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\n return _cumulativeReward(user, pool).sub(user.rewardDebt);\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract XVSVaultErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./XVSVaultStorage.sol\";\nimport \"./XVSVaultErrorReporter.sol\";\n\n/**\n * @title XVS Vault Proxy\n * @author Venus\n * @notice XVS Vault Proxy contract\n */\ncontract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter {\n /**\n * @notice Emitted when pendingXVSVaultImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingXVSVaultImplementation is accepted, which means XVS Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingXVSVaultImplementation;\n\n pendingXVSVaultImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingXVSVaultImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingXVSVaultImplementation;\n\n implementation = pendingXVSVaultImplementation;\n\n pendingXVSVaultImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"../Tokens/Prime/IPrime.sol\";\n\ncontract XVSVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of XVS Vault\n */\n address public implementation;\n\n /**\n * @notice Pending brains of XVS Vault\n */\n address public pendingXVSVaultImplementation;\n}\n\ncontract XVSVaultStorageV1 is XVSVaultAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice The reward token store\n address public xvsStore;\n\n /// @notice The xvs token address\n address public xvsAddress;\n\n // Reward tokens created per block or second indentified by reward token address.\n mapping(address => uint256) public rewardTokenAmountsPerBlockOrSecond;\n\n /// @notice Info of each user.\n struct UserInfo {\n uint256 amount;\n uint256 rewardDebt;\n uint256 pendingWithdrawals;\n }\n\n // Info of each pool.\n struct PoolInfo {\n IBEP20 token; // Address of token contract to stake.\n uint256 allocPoint; // How many allocation points assigned to this pool.\n uint256 lastRewardBlockOrSecond; // Last block number or second that reward tokens distribution occurs.\n uint256 accRewardPerShare; // Accumulated per share, times 1e12. See below.\n uint256 lockPeriod; // Min time between withdrawal request and its execution.\n }\n\n // Infomation about a withdrawal request\n struct WithdrawalRequest {\n uint256 amount;\n uint128 lockedUntil;\n uint128 afterUpgrade;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => mapping(uint256 => mapping(address => UserInfo))) internal userInfos;\n\n // Info of each pool.\n mapping(address => PoolInfo[]) public poolInfos;\n\n // Total allocation points. Must be the sum of all allocation points in all pools.\n mapping(address => uint256) public totalAllocPoints;\n\n // Info of requested but not yet executed withdrawals\n mapping(address => mapping(uint256 => mapping(address => WithdrawalRequest[]))) internal withdrawalRequests;\n\n /// @notice DEPRECATED A record of each accounts delegate (before the voting power fix)\n mapping(address => address) private __oldDelegatesSlot;\n\n /// @notice A checkpoint for marking number of votes from a given block or second\n struct Checkpoint {\n uint32 fromBlockOrSecond;\n uint96 votes;\n }\n\n /// @notice DEPRECATED A record of votes checkpoints for each account, by index (before the voting power fix)\n mapping(address => mapping(uint32 => Checkpoint)) private __oldCheckpointsSlot;\n\n /// @notice DEPRECATED The number of checkpoints for each account (before the voting power fix)\n mapping(address => uint32) private __oldNumCheckpointsSlot;\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n}\n\ncontract XVSVaultStorage is XVSVaultStorageV1 {\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice Tracks pending withdrawals for all users for a particular reward token and pool id\n mapping(address => mapping(uint256 => uint256)) public totalPendingWithdrawals;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /// @notice if the token is added to any of the pools\n mapping(address => bool) public isStakedToken;\n\n /// @notice Amount we owe to users because of failed transfer attempts\n mapping(address => mapping(address => uint256)) public pendingRewardTransfers;\n\n /// @notice Prime token contract address\n IPrime public primeToken;\n\n /// @notice Reward token for which prime token is issued for staking\n address public primeRewardToken;\n\n /// @notice Pool ID for which prime token is issued for staking\n uint256 public primePoolId;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[46] private __gap;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "storageLayout", + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/deployments/bscmainnet_addresses.json b/deployments/bscmainnet_addresses.json index a8b7e55e6..f15eb5137 100644 --- a/deployments/bscmainnet_addresses.json +++ b/deployments/bscmainnet_addresses.json @@ -16,7 +16,7 @@ "DefaultProxyAdmin": "0x6beb6D2695B67FEb73ad4f172E8E2975497187e4", "ETH": "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", "FIL": "0x0D8Ce2A99Bb6e3B7Db580eD848240e4a0F9aE153", - "InterestRateModelVBNB": "0xe5be8D9f4697dD264e488efD4b29c8CC31616fa5", + "InterestRateModelVBNB": "0xDb8347b96c94Be24B9c077A4CDDAAD074F6480cf", "JumpRateModel_base0bps_slope10000bps_jump25000bps_kink8000bps": "0x9e8fbACBfbD811Fc561af3Af7df8e38dEd4c52F3", "JumpRateModel_base0bps_slope10000bps_jump50000bps_kink8000bps": "0x958F4C84d3ad523Fa9936Dc465A123C7AD43D69B", "JumpRateModel_base0bps_slope1000bps_jump25000bps_kink8000bps": "0x62A8919C4C413fd4F9aef7348540Bc4B1b5CC805", diff --git a/deployments/opmainnet.json b/deployments/opmainnet.json index 58d00eb23..01f3c3821 100644 --- a/deployments/opmainnet.json +++ b/deployments/opmainnet.json @@ -1,5 +1,8303 @@ { "name": "opmainnet", "chainId": "10", - "contracts": {} + "contracts": { + "DefaultProxyAdmin": { + "address": "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialOwner", + "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" + }, + { + "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" + } + ] + }, + "Prime": { + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "abi": [ + { + "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": [], + "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" + }, + { + "inputs": [], + "name": "AssetAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "ExpTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "IneligibleToClaim", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAlphaArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidComptroller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFixedPoint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "d", + "type": "uint256" + } + ], + "name": "InvalidFraction", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLimit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimestamp", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVToken", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnNonRealResult", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "MarketAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MarketNotSupported", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NoScoreUpdatesRequired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "UserHasNoPrimeToken", + "type": "error" + }, + { + "inputs": [], + "name": "WaitMoreTime", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "oldNumerator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "newNumerator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "AlphaUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InterestClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "oldIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldRevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "newIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRevocableLimit", + "type": "uint256" + } + ], + "name": "MintLimitsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldBorrowMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowMultiplier", + "type": "uint256" + } + ], + "name": "MultiplierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "StakedAtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "TokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "UserScoreUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAXIMUM_XVS_CAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_STAKED_XVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_MARKET", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WRAPPED_NATIVE_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "accrueInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + } + ], + "name": "accrueInterestAndUpdateScore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "addMarket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alphaDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alphaNumerator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "calculateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimTimeRemaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsStaked", + "type": "uint256" + } + ], + "name": "estimateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getInterestAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct PrimeStorageV1.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "incomeDistributionYearly", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "xvsVault_", + "type": "address" + }, + { + "internalType": "address", + "name": "xvsVaultRewardToken_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "xvsVaultPoolId_", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "alphaNumerator_", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "alphaDenominator_", + "type": "uint128" + }, + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "primeLiquidityProvider_", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolRegistry_", + "type": "address" + } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "interests", + "outputs": [ + { + "internalType": "uint256", + "name": "accrued", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "irrevocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isScoreUpdated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserPrimeHolder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "issue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sumOfMembersScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextScoreUpdateRoundId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "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": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingScoreUpdates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primeLiquidityProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_irrevocableLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_revocableLimit", + "type": "uint256" + } + ], + "name": "setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "timestamps", + "type": "uint256[]" + } + ], + "name": "setStakedAt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "stakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIrrevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalScoreUpdatesRequired", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unreleasedPLPIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_alphaNumerator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_alphaDenominator", + "type": "uint128" + } + ], + "name": "updateAlpha", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "updateMultipliers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "updateScores", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "vTokenForAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "xvsUpdated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "PrimeLiquidityProvider": { + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "abi": [ + { + "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": [], + "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" + }, + { + "inputs": [], + "name": "AddressesMustDiffer", + "type": "error" + }, + { + "inputs": [], + "name": "FundsTransferIsPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "speed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSpeed", + "type": "uint256" + } + ], + "name": "InvalidDistributionSpeed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "TokenNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "MaxTokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPrimeToken", + "type": "address" + } + ], + "name": "PrimeTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + } + ], + "name": "SweepToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenDistributionInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "TokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenTransferredToPrime", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensAccrued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_DISTRIBUTION_SPEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "accrueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "getEffectiveDistributionSpeed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + } + ], + "name": "initializeTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "lastAccruedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastAccruedBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxTokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prime", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "releaseFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resumeFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setMaxTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "prime_", + "type": "address" + } + ], + "name": "setPrimeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token_", + "type": "address" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount_", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "tokenAmountAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "PrimeLiquidityProvider_Implementation": { + "address": "0xF3B8d6b1778548F975D6eBebD8a8e515832Cfb0a", + "abi": [ + { + "inputs": [ + { + "internalType": "bool", + "name": "_timeBased", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AddressesMustDiffer", + "type": "error" + }, + { + "inputs": [], + "name": "FundsTransferIsPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "speed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSpeed", + "type": "uint256" + } + ], + "name": "InvalidDistributionSpeed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "TokenNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "MaxTokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPrimeToken", + "type": "address" + } + ], + "name": "PrimeTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + } + ], + "name": "SweepToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenDistributionInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "TokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenTransferredToPrime", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensAccrued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_DISTRIBUTION_SPEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "accrueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "getEffectiveDistributionSpeed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + } + ], + "name": "initializeTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "lastAccruedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastAccruedBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxTokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prime", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "releaseFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resumeFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setMaxTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "prime_", + "type": "address" + } + ], + "name": "setPrimeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token_", + "type": "address" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount_", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "tokenAmountAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "PrimeLiquidityProvider_Proxy": { + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "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": [], + "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" + } + ] + }, + "Prime_Implementation": { + "address": "0x7DCF81746fFA44C4469eBA2F6Db86AE3d5f92b10", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_wrappedNativeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_nativeMarket", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_stakingPeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_minimumStakedXVS", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maximumXVSCap", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_timeBased", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AssetAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "ExpTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "IneligibleToClaim", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAlphaArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidComptroller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFixedPoint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "d", + "type": "uint256" + } + ], + "name": "InvalidFraction", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLimit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimestamp", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVToken", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnNonRealResult", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "MarketAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MarketNotSupported", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NoScoreUpdatesRequired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "UserHasNoPrimeToken", + "type": "error" + }, + { + "inputs": [], + "name": "WaitMoreTime", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "oldNumerator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "newNumerator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "AlphaUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InterestClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "oldIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldRevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "newIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRevocableLimit", + "type": "uint256" + } + ], + "name": "MintLimitsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldBorrowMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowMultiplier", + "type": "uint256" + } + ], + "name": "MultiplierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "StakedAtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "TokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "UserScoreUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAXIMUM_XVS_CAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_STAKED_XVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_MARKET", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WRAPPED_NATIVE_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "accrueInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + } + ], + "name": "accrueInterestAndUpdateScore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "addMarket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alphaDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alphaNumerator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "calculateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimTimeRemaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsStaked", + "type": "uint256" + } + ], + "name": "estimateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getInterestAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct PrimeStorageV1.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "incomeDistributionYearly", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "xvsVault_", + "type": "address" + }, + { + "internalType": "address", + "name": "xvsVaultRewardToken_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "xvsVaultPoolId_", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "alphaNumerator_", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "alphaDenominator_", + "type": "uint128" + }, + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "primeLiquidityProvider_", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolRegistry_", + "type": "address" + } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "interests", + "outputs": [ + { + "internalType": "uint256", + "name": "accrued", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "irrevocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isScoreUpdated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserPrimeHolder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "issue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sumOfMembersScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextScoreUpdateRoundId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "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": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingScoreUpdates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primeLiquidityProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_irrevocableLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_revocableLimit", + "type": "uint256" + } + ], + "name": "setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "timestamps", + "type": "uint256[]" + } + ], + "name": "setStakedAt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "stakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIrrevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalScoreUpdatesRequired", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unreleasedPLPIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_alphaNumerator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_alphaDenominator", + "type": "uint128" + } + ], + "name": "updateAlpha", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "updateMultipliers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "updateScores", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "vTokenForAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "xvsUpdated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "Prime_Proxy": { + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "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": [], + "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" + } + ] + }, + "VTreasuryV8": { + "address": "0x104c01EB7b4664551BE6A9bdB26a8C5c6Be7d3da", + "abi": [ + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "withdrawAddress", + "type": "address" + } + ], + "name": "WithdrawTreasuryNative", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "withdrawAddress", + "type": "address" + } + ], + "name": "WithdrawTreasuryToken", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "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": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "withdrawAddress", + "type": "address" + } + ], + "name": "withdrawTreasuryNative", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "withdrawAddress", + "type": "address" + } + ], + "name": "withdrawTreasuryToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] + }, + "XVSStore": { + "address": "0xFE548630954129923f63113923eF5373E10589d3", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerTransferred", + "type": "event" + }, + { + "constant": false, + "inputs": [], + "name": "acceptAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "emergencyRewardWithdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardTokens", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "safeRewardTransfer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "setNewOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_admin", + "type": "address" + } + ], + "name": "setPendingAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "setRewardToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "XVSVaultProxy": { + "address": "0x133120607C018c949E91AE333785519F6d947e01", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "NewImplementation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "NewPendingImplementation", + "type": "event" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptImplementation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "_setPendingAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "_setPendingImplementation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ] + }, + "XVSVaultProxy_Implementation": { + "address": "0x8B8651EEB002a7991F2287500B17a395E8cfe7d9", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Claim", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ExecutedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IPrime", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IPrime", + "name": "newPrimeToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldPrimeRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPrimeRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldPrimePoolId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPrimePoolId", + "type": "uint256" + } + ], + "name": "NewPrimeToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "allocPoints", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardPerBlockOrSecond", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lockPeriod", + "type": "uint256" + } + ], + "name": "PoolAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldAllocPoints", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newAllocPoints", + "type": "uint256" + } + ], + "name": "PoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RequestedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldReward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReward", + "type": "uint256" + } + ], + "name": "RewardAmountUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldXvs", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldStore", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newXvs", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newStore", + "type": "address" + } + ], + "name": "StoreUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "userAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldOwedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newOwedAmount", + "type": "uint256" + } + ], + "name": "VaultDebtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "VaultPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "VaultResumed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldPeriod", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPeriod", + "type": "uint256" + } + ], + "name": "WithdrawalLockingPeriodUpdated", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_LOCK_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SECONDS_PER_YEAR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract XVSVaultProxy", + "name": "xvsVaultProxy", + "type": "address" + } + ], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV5", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_allocPoint", + "type": "uint256" + }, + { + "internalType": "contract IBEP20", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rewardPerBlockOrSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_lockPeriod", + "type": "uint256" + } + ], + "name": "add", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "fromBlockOrSecond", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "claim", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "delegateBySig", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "executeWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCurrentVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getEligibleWithdrawalAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "withdrawalAmount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumberOrSecond", + "type": "uint256" + } + ], + "name": "getPriorVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getRequestedAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getUserInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pendingWithdrawals", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getWithdrawalRequests", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "lockedUntil", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "afterUpgrade", + "type": "uint128" + } + ], + "internalType": "struct XVSVaultStorageV1.WithdrawalRequest[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "timeBased_", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "blocksPerYear_", + "type": "uint256" + } + ], + "name": "initializeTimeManager", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isStakedToken", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "pause", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "pendingReward", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pendingRewardTransfers", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "pendingWithdrawalsBeforeUpgrade", + "outputs": [ + { + "internalType": "uint256", + "name": "beforeUpgradeWithdrawalAmount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "poolInfos", + "outputs": [ + { + "internalType": "contract IBEP20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allocPoint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastRewardBlockOrSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "accRewardPerShare", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lockPeriod", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + } + ], + "name": "poolLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primePoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primeRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primeToken", + "outputs": [ + { + "internalType": "contract IPrime", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "requestWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "resume", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + } + ], + "name": "rewardTokenAmountsPerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardTokenAmountsPerBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_allocPoint", + "type": "uint256" + } + ], + "name": "set", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newAccessControlAddress", + "type": "address" + } + ], + "name": "setAccessControl", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract IPrime", + "name": "_primeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_primeRewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_primePoolId", + "type": "uint256" + } + ], + "name": "setPrimeToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rewardAmount", + "type": "uint256" + } + ], + "name": "setRewardAmountPerBlockOrSecond", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newPeriod", + "type": "uint256" + } + ], + "name": "setWithdrawalLockingPeriod", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_xvs", + "type": "address" + }, + { + "internalType": "address", + "name": "_xvsStore", + "type": "address" + } + ], + "name": "setXvsStore", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "totalAllocPoints", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "totalPendingWithdrawals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "updatePool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaultPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsStore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ] + } + } } diff --git a/deployments/opmainnet/.chainId b/deployments/opmainnet/.chainId new file mode 100644 index 000000000..9a037142a --- /dev/null +++ b/deployments/opmainnet/.chainId @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/deployments/opmainnet/DefaultProxyAdmin.json b/deployments/opmainnet/DefaultProxyAdmin.json new file mode 100644 index 000000000..bec4f70b2 --- /dev/null +++ b/deployments/opmainnet/DefaultProxyAdmin.json @@ -0,0 +1,200 @@ +{ + "address": "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialOwner", + "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" + }, + { + "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": "0xf64357fc579316df77269ea8d1cf109e7b709d4b7bb0a2fd4e2355c41599694a", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "transactionIndex": 11, + "gasUsed": "473314", + "logsBloom": "0x00000000000000000020000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000801000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000020000000000000000000000000080000000000000000000000000000000000000000", + "blockHash": "0xb187274d850f55a40c74142867d093c26f35fbd0278e81e660aa199472c93a0f", + "transactionHash": "0xf64357fc579316df77269ea8d1cf109e7b709d4b7bb0a2fd4e2355c41599694a", + "logs": [ + { + "transactionIndex": 11, + "blockNumber": 125522713, + "transactionHash": "0xf64357fc579316df77269ea8d1cf109e7b709d4b7bb0a2fd4e2355c41599694a", + "address": "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000002e94dd14e81999cdbf5dede31938bed7308354b3" + ], + "data": "0x", + "logIndex": 60, + "blockHash": "0xb187274d850f55a40c74142867d093c26f35fbd0278e81e660aa199472c93a0f" + } + ], + "blockNumber": 125522713, + "cumulativeGasUsed": "2956674", + "status": 1, + "byzantium": true + }, + "args": ["0x2e94dd14E81999CdBF5deDE31938beD7308354b3"], + "numDeployments": 1, + "bytecode": "0x6080604052348015600f57600080fd5b506040516107e43803806107e4833981016040819052602c91608a565b80603481603a565b505060b8565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215609b57600080fd5b81516001600160a01b038116811460b157600080fd5b9392505050565b61071d806100c76000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461011157806399a88ec414610124578063f2fde38b14610144578063f3b7dead1461016457600080fd5b8063204e1c7a14610080578063715018a6146100bc5780637eff275e146100d35780638da5cb5b146100f3575b600080fd5b34801561008c57600080fd5b506100a061009b3660046104ed565b610184565b6040516001600160a01b03909116815260200160405180910390f35b3480156100c857600080fd5b506100d1610215565b005b3480156100df57600080fd5b506100d16100ee366004610511565b610254565b3480156100ff57600080fd5b506000546001600160a01b03166100a0565b6100d161011f366004610560565b6102de565b34801561013057600080fd5b506100d161013f366004610511565b61036f565b34801561015057600080fd5b506100d161015f3660046104ed565b6103c7565b34801561017057600080fd5b506100a061017f3660046104ed565b610462565b6000806000836001600160a01b03166040516101aa90635c60da1b60e01b815260040190565b600060405180830381855afa9150503d80600081146101e5576040519150601f19603f3d011682016040523d82523d6000602084013e6101ea565b606091505b5091509150816101f957600080fd5b8080602001905181019061020d9190610636565b949350505050565b6000546001600160a01b031633146102485760405162461bcd60e51b815260040161023f90610653565b60405180910390fd5b6102526000610488565b565b6000546001600160a01b0316331461027e5760405162461bcd60e51b815260040161023f90610653565b6040516308f2839760e41b81526001600160a01b038281166004830152831690638f283970906024015b600060405180830381600087803b1580156102c257600080fd5b505af11580156102d6573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146103085760405162461bcd60e51b815260040161023f90610653565b60405163278f794360e11b81526001600160a01b03841690634f1ef2869034906103389086908690600401610688565b6000604051808303818588803b15801561035157600080fd5b505af1158015610365573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146103995760405162461bcd60e51b815260040161023f90610653565b604051631b2ce7f360e11b81526001600160a01b038281166004830152831690633659cfe6906024016102a8565b6000546001600160a01b031633146103f15760405162461bcd60e51b815260040161023f90610653565b6001600160a01b0381166104565760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161023f565b61045f81610488565b50565b6000806000836001600160a01b03166040516101aa906303e1469160e61b815260040190565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038116811461045f57600080fd5b6000602082840312156104ff57600080fd5b813561050a816104d8565b9392505050565b6000806040838503121561052457600080fd5b823561052f816104d8565b9150602083013561053f816104d8565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561057557600080fd5b8335610580816104d8565b92506020840135610590816104d8565b9150604084013567ffffffffffffffff808211156105ad57600080fd5b818601915086601f8301126105c157600080fd5b8135818111156105d3576105d361054a565b604051601f8201601f19908116603f011681019083821181831017156105fb576105fb61054a565b8160405282815289602084870101111561061457600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561064857600080fd5b815161050a816104d8565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60018060a01b03831681526000602060406020840152835180604085015260005b818110156106c5578581018301518582016060015282016106a9565b506000606082860101526060601f19601f83011685010192505050939250505056fea264697066735822122030f52ef7e16587f148a9f5ca0dbcadc434f9288a9162f8ab87307aa33db8fc4364736f6c63430008190033", + "deployedBytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461011157806399a88ec414610124578063f2fde38b14610144578063f3b7dead1461016457600080fd5b8063204e1c7a14610080578063715018a6146100bc5780637eff275e146100d35780638da5cb5b146100f3575b600080fd5b34801561008c57600080fd5b506100a061009b3660046104ed565b610184565b6040516001600160a01b03909116815260200160405180910390f35b3480156100c857600080fd5b506100d1610215565b005b3480156100df57600080fd5b506100d16100ee366004610511565b610254565b3480156100ff57600080fd5b506000546001600160a01b03166100a0565b6100d161011f366004610560565b6102de565b34801561013057600080fd5b506100d161013f366004610511565b61036f565b34801561015057600080fd5b506100d161015f3660046104ed565b6103c7565b34801561017057600080fd5b506100a061017f3660046104ed565b610462565b6000806000836001600160a01b03166040516101aa90635c60da1b60e01b815260040190565b600060405180830381855afa9150503d80600081146101e5576040519150601f19603f3d011682016040523d82523d6000602084013e6101ea565b606091505b5091509150816101f957600080fd5b8080602001905181019061020d9190610636565b949350505050565b6000546001600160a01b031633146102485760405162461bcd60e51b815260040161023f90610653565b60405180910390fd5b6102526000610488565b565b6000546001600160a01b0316331461027e5760405162461bcd60e51b815260040161023f90610653565b6040516308f2839760e41b81526001600160a01b038281166004830152831690638f283970906024015b600060405180830381600087803b1580156102c257600080fd5b505af11580156102d6573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146103085760405162461bcd60e51b815260040161023f90610653565b60405163278f794360e11b81526001600160a01b03841690634f1ef2869034906103389086908690600401610688565b6000604051808303818588803b15801561035157600080fd5b505af1158015610365573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146103995760405162461bcd60e51b815260040161023f90610653565b604051631b2ce7f360e11b81526001600160a01b038281166004830152831690633659cfe6906024016102a8565b6000546001600160a01b031633146103f15760405162461bcd60e51b815260040161023f90610653565b6001600160a01b0381166104565760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161023f565b61045f81610488565b50565b6000806000836001600160a01b03166040516101aa906303e1469160e61b815260040190565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038116811461045f57600080fd5b6000602082840312156104ff57600080fd5b813561050a816104d8565b9392505050565b6000806040838503121561052457600080fd5b823561052f816104d8565b9150602083013561053f816104d8565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561057557600080fd5b8335610580816104d8565b92506020840135610590816104d8565b9150604084013567ffffffffffffffff808211156105ad57600080fd5b818601915086601f8301126105c157600080fd5b8135818111156105d3576105d361054a565b604051601f8201601f19908116603f011681019083821181831017156105fb576105fb61054a565b8160405282815289602084870101111561061457600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561064857600080fd5b815161050a816104d8565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60018060a01b03831681526000602060406020840152835180604085015260005b818110156106c5578581018301518582016060015282016106a9565b506000606082860101526060601f19601f83011685010192505050939250505056fea264697066735822122030f52ef7e16587f148a9f5ca0dbcadc434f9288a9162f8ab87307aa33db8fc4364736f6c63430008190033" +} diff --git a/deployments/opmainnet/Prime.json b/deployments/opmainnet/Prime.json new file mode 100644 index 000000000..ffcdc9cc8 --- /dev/null +++ b/deployments/opmainnet/Prime.json @@ -0,0 +1,2042 @@ +{ + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "abi": [ + { + "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": [], + "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" + }, + { + "inputs": [], + "name": "AssetAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "ExpTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "IneligibleToClaim", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAlphaArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidComptroller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFixedPoint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "d", + "type": "uint256" + } + ], + "name": "InvalidFraction", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLimit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimestamp", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVToken", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnNonRealResult", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "MarketAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MarketNotSupported", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NoScoreUpdatesRequired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "UserHasNoPrimeToken", + "type": "error" + }, + { + "inputs": [], + "name": "WaitMoreTime", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "oldNumerator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "newNumerator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "AlphaUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InterestClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "oldIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldRevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "newIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRevocableLimit", + "type": "uint256" + } + ], + "name": "MintLimitsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldBorrowMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowMultiplier", + "type": "uint256" + } + ], + "name": "MultiplierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "StakedAtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "TokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "UserScoreUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAXIMUM_XVS_CAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_STAKED_XVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_MARKET", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WRAPPED_NATIVE_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "accrueInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + } + ], + "name": "accrueInterestAndUpdateScore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "addMarket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alphaDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alphaNumerator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "calculateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimTimeRemaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsStaked", + "type": "uint256" + } + ], + "name": "estimateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getInterestAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct PrimeStorageV1.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "incomeDistributionYearly", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "xvsVault_", + "type": "address" + }, + { + "internalType": "address", + "name": "xvsVaultRewardToken_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "xvsVaultPoolId_", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "alphaNumerator_", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "alphaDenominator_", + "type": "uint128" + }, + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "primeLiquidityProvider_", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolRegistry_", + "type": "address" + } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "interests", + "outputs": [ + { + "internalType": "uint256", + "name": "accrued", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "irrevocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isScoreUpdated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserPrimeHolder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "issue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sumOfMembersScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextScoreUpdateRoundId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "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": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingScoreUpdates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primeLiquidityProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_irrevocableLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_revocableLimit", + "type": "uint256" + } + ], + "name": "setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "timestamps", + "type": "uint256[]" + } + ], + "name": "setStakedAt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "stakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIrrevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalScoreUpdatesRequired", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unreleasedPLPIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_alphaNumerator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_alphaDenominator", + "type": "uint128" + } + ], + "name": "updateAlpha", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "updateMultipliers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "updateScores", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "vTokenForAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "xvsUpdated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "transactionIndex": 10, + "gasUsed": "774848", + "logsBloom": "0x00000000000000000000000000080000400000000000000004800000000000000000000000000000000000000000000000020000000000000000000000008000000000000000000000000000000002000001000000000400000000000000000000000000020000000000000000000800000000810800000000000080000000400000100000000000040008000000000000000000000081000000000000800000000000000000000000002000000400000000000000800000000000000000000000000020000000000000000001040000000040000400000000000000000020000000000200000000000000000000000000000800000000000000000000000000", + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b", + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "logs": [ + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000007dcf81746ffa44c4469eba2f6db86ae3d5f92b10" + ], + "data": "0x", + "logIndex": 16, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000c76363b887031e79e6a2954c5515f5e5507a6387" + ], + "data": "0x", + "logIndex": 17, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d71b1f33f6b0259683f11174ee4ddc2bb9ce4ed6", + "logIndex": 18, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0xc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014", + "logIndex": 19, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0x62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258"], + "data": "0x000000000000000000000000c76363b887031e79e6a2954c5515f5e5507a6387", + "logIndex": 20, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 21, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eaf9490cbea6ff9ba1d23671c39a799ced0dced2", + "logIndex": 22, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + } + ], + "blockNumber": 126396250, + "cumulativeGasUsed": "3174172", + "status": 1, + "byzantium": true + }, + "args": [ + "0x7DCF81746fFA44C4469eBA2F6Db86AE3d5f92b10", + "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "0xb1a250f2000000000000000000000000133120607c018c949e91ae333785519f6d947e010000000000000000000000004a971e87ad1f61f7f3081645f52a99277ae917cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d71b1f33f6b0259683f11174ee4ddc2bb9ce4ed60000000000000000000000006412f6cd58d0182ae150b90b5a99e285b91c1a12000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021fc48569bd3a6623281f55fc1f8b48b9386907b0000000000000000000000000000000000000000000000000000000000000014" + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"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\":[],\"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.\",\"events\":{\"AdminChanged(address,address)\":{\"details\":\"Emitted when the admin account has changed.\"},\"BeaconUpgraded(address)\":{\"details\":\"Emitted when the beacon is upgraded.\"},\"Upgraded(address)\":{\"details\":\"Emitted when the implementation is upgraded.\"}},\"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`\"},\"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\":{\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\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 _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a0604052604051610d1a380380610d1a833981016040819052610022916103d2565b828161004f60017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6104a2565b600080516020610cd38339815191521461006b5761006b6104c3565b61007782826000610128565b506100a5905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046104a2565b600080516020610cb3833981519152146100c1576100c16104c3565b6001600160a01b0382166080819052600080516020610cb38339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050610528565b61013183610154565b60008251118061013e5750805b1561014f5761014d8383610194565b505b505050565b61015d816101c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606101b98383604051806060016040528060278152602001610cf360279139610263565b90505b92915050565b6001600160a01b0381163b6102345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b600080516020610cd383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6102cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161022b565b600080856001600160a01b0316856040516102e691906104d9565b600060405180830381855af49150503d8060008114610321576040519150601f19603f3d011682016040523d82523d6000602084013e610326565b606091505b509092509050610337828286610343565b925050505b9392505050565b6060831561035257508161033c565b8251156103625782518084602001fd5b8160405162461bcd60e51b815260040161022b91906104f5565b80516001600160a01b038116811461039357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103c95781810151838201526020016103b1565b50506000910152565b6000806000606084860312156103e757600080fd5b6103f08461037c565b92506103fe6020850161037c565b60408501519092506001600160401b038082111561041b57600080fd5b818601915086601f83011261042f57600080fd5b81518181111561044157610441610398565b604051601f8201601f19908116603f0116810190838211818310171561046957610469610398565b8160405282815289602084870101111561048257600080fd5b6104938360208301602088016103ae565b80955050505050509250925092565b818103818111156101bc57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600082516104eb8184602087016103ae565b9190910192915050565b60208152600082518060208401526105148160408501602087016103ae565b601f01601f19169190910160400192915050565b60805161074e6105656000396000818160ef01528181610145015281816101c701528181610211015281816102420152610266015261074e6000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033", + "execute": { + "methodName": "initialize", + "args": [ + "0x133120607C018c949E91AE333785519F6d947e01", + "0x4a971e87ad1F61f7f3081645f52a99277AE917cF", + 0, + 1, + 2, + "0xD71b1F33f6B0259683f11174EE4Ddc2bb9cE4eD6", + "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "0x0000000000000000000000000000000000000000", + "0x21FC48569bd3a6623281f55FC1F8B48B9386907b", + 20 + ] + }, + "implementation": "0x7DCF81746fFA44C4469eBA2F6Db86AE3d5f92b10", + "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.", + "events": { + "AdminChanged(address,address)": { + "details": "Emitted when the admin account has changed." + }, + "BeaconUpgraded(address)": { + "details": "Emitted when the beacon is upgraded." + }, + "Upgraded(address)": { + "details": "Emitted when the implementation is upgraded." + } + }, + "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`" + }, + "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/deployments/opmainnet/PrimeLiquidityProvider.json b/deployments/opmainnet/PrimeLiquidityProvider.json new file mode 100644 index 000000000..a77d91804 --- /dev/null +++ b/deployments/opmainnet/PrimeLiquidityProvider.json @@ -0,0 +1,1113 @@ +{ + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "abi": [ + { + "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": [], + "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" + }, + { + "inputs": [], + "name": "AddressesMustDiffer", + "type": "error" + }, + { + "inputs": [], + "name": "FundsTransferIsPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "speed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSpeed", + "type": "uint256" + } + ], + "name": "InvalidDistributionSpeed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "TokenNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "MaxTokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPrimeToken", + "type": "address" + } + ], + "name": "PrimeTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + } + ], + "name": "SweepToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenDistributionInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "TokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenTransferredToPrime", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensAccrued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_DISTRIBUTION_SPEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "accrueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "getEffectiveDistributionSpeed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + } + ], + "name": "initializeTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "lastAccruedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastAccruedBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxTokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prime", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "releaseFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resumeFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setMaxTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "prime_", + "type": "address" + } + ], + "name": "setPrimeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token_", + "type": "address" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount_", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "tokenAmountAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "transactionIndex": 22, + "gasUsed": "634674", + "logsBloom": "0x00000400000000000000000000000000400000000000000004800000000000000000000000000000000000000000000100020000000000000000000000008000040000000000000000000000000002000001000000000000000000000000000000000000020000000000000000000800000000800000000000000080000000400020000000000000000000000000000000000000000080000000000000800000000000000000000000002000000400000000000000800004000000000000000000000020000000000000000001040000000000000400000000000000000020000000000200000000000000000000000000000800000800000000000000000000", + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21", + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "logs": [ + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000f3b8d6b1778548f975d6ebebd8a8e515832cfb0a" + ], + "data": "0x", + "logIndex": 136, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000c76363b887031e79e6a2954c5515f5e5507a6387" + ], + "data": "0x", + "logIndex": 137, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d71b1f33f6b0259683f11174ee4ddc2bb9ce4ed6", + "logIndex": 138, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": ["0xc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014", + "logIndex": 139, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 140, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eaf9490cbea6ff9ba1d23671c39a799ced0dced2", + "logIndex": 141, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + } + ], + "blockNumber": 126396240, + "cumulativeGasUsed": "6810714", + "status": 1, + "byzantium": true + }, + "args": [ + "0xF3B8d6b1778548F975D6eBebD8a8e515832Cfb0a", + "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "0xe458a65d000000000000000000000000d71b1f33f6b0259683f11174ee4ddc2bb9ce4ed600000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"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\":[],\"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.\",\"events\":{\"AdminChanged(address,address)\":{\"details\":\"Emitted when the admin account has changed.\"},\"BeaconUpgraded(address)\":{\"details\":\"Emitted when the beacon is upgraded.\"},\"Upgraded(address)\":{\"details\":\"Emitted when the implementation is upgraded.\"}},\"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`\"},\"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\":{\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\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 _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a0604052604051610d1a380380610d1a833981016040819052610022916103d2565b828161004f60017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6104a2565b600080516020610cd38339815191521461006b5761006b6104c3565b61007782826000610128565b506100a5905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046104a2565b600080516020610cb3833981519152146100c1576100c16104c3565b6001600160a01b0382166080819052600080516020610cb38339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050610528565b61013183610154565b60008251118061013e5750805b1561014f5761014d8383610194565b505b505050565b61015d816101c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606101b98383604051806060016040528060278152602001610cf360279139610263565b90505b92915050565b6001600160a01b0381163b6102345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b600080516020610cd383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6102cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161022b565b600080856001600160a01b0316856040516102e691906104d9565b600060405180830381855af49150503d8060008114610321576040519150601f19603f3d011682016040523d82523d6000602084013e610326565b606091505b509092509050610337828286610343565b925050505b9392505050565b6060831561035257508161033c565b8251156103625782518084602001fd5b8160405162461bcd60e51b815260040161022b91906104f5565b80516001600160a01b038116811461039357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103c95781810151838201526020016103b1565b50506000910152565b6000806000606084860312156103e757600080fd5b6103f08461037c565b92506103fe6020850161037c565b60408501519092506001600160401b038082111561041b57600080fd5b818601915086601f83011261042f57600080fd5b81518181111561044157610441610398565b604051601f8201601f19908116603f0116810190838211818310171561046957610469610398565b8160405282815289602084870101111561048257600080fd5b6104938360208301602088016103ae565b80955050505050509250925092565b818103818111156101bc57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600082516104eb8184602087016103ae565b9190910192915050565b60208152600082518060208401526105148160408501602087016103ae565b601f01601f19169190910160400192915050565b60805161074e6105656000396000818160ef01528181610145015281816101c701528181610211015281816102420152610266015261074e6000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033", + "execute": { + "methodName": "initialize", + "args": ["0xD71b1F33f6B0259683f11174EE4Ddc2bb9cE4eD6", [], [], [], 20] + }, + "implementation": "0xF3B8d6b1778548F975D6eBebD8a8e515832Cfb0a", + "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.", + "events": { + "AdminChanged(address,address)": { + "details": "Emitted when the admin account has changed." + }, + "BeaconUpgraded(address)": { + "details": "Emitted when the beacon is upgraded." + }, + "Upgraded(address)": { + "details": "Emitted when the implementation is upgraded." + } + }, + "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`" + }, + "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/deployments/opmainnet/PrimeLiquidityProvider_Implementation.json b/deployments/opmainnet/PrimeLiquidityProvider_Implementation.json new file mode 100644 index 000000000..e5cc21dd9 --- /dev/null +++ b/deployments/opmainnet/PrimeLiquidityProvider_Implementation.json @@ -0,0 +1,1432 @@ +{ + "address": "0xF3B8d6b1778548F975D6eBebD8a8e515832Cfb0a", + "abi": [ + { + "inputs": [ + { + "internalType": "bool", + "name": "_timeBased", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AddressesMustDiffer", + "type": "error" + }, + { + "inputs": [], + "name": "FundsTransferIsPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "speed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSpeed", + "type": "uint256" + } + ], + "name": "InvalidDistributionSpeed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "TokenNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "MaxTokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPrimeToken", + "type": "address" + } + ], + "name": "PrimeTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + } + ], + "name": "SweepToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenDistributionInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "TokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenTransferredToPrime", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensAccrued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_DISTRIBUTION_SPEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "accrueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "getEffectiveDistributionSpeed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + } + ], + "name": "initializeTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "lastAccruedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastAccruedBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxTokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prime", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "releaseFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resumeFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setMaxTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "prime_", + "type": "address" + } + ], + "name": "setPrimeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token_", + "type": "address" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount_", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "tokenAmountAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x6c8a15cd221b2189bfd293197becbb0b42adadda30755cb83a4aec7c6ac7c91a", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0xF3B8d6b1778548F975D6eBebD8a8e515832Cfb0a", + "transactionIndex": 27, + "gasUsed": "1768450", + "logsBloom": "0x00000000000000000002000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x9702a8520375534724752550e7931b24d2090d58aa3fbc9eed358bba1996fc33", + "transactionHash": "0x6c8a15cd221b2189bfd293197becbb0b42adadda30755cb83a4aec7c6ac7c91a", + "logs": [ + { + "transactionIndex": 27, + "blockNumber": 126396236, + "transactionHash": "0x6c8a15cd221b2189bfd293197becbb0b42adadda30755cb83a4aec7c6ac7c91a", + "address": "0xF3B8d6b1778548F975D6eBebD8a8e515832Cfb0a", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 75, + "blockHash": "0x9702a8520375534724752550e7931b24d2090d58aa3fbc9eed358bba1996fc33" + } + ], + "blockNumber": 126396236, + "cumulativeGasUsed": "5552795", + "status": 1, + "byzantium": true + }, + "args": [true, 0], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_timeBased\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"_blocksPerYear\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AddressesMustDiffer\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FundsTransferIsPaused\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"sweepAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"name\":\"InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidArguments\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidBlocksPerYear\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidCaller\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"speed\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSpeed\",\"type\":\"uint256\"}],\"name\":\"InvalidDistributionSpeed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTimeBasedConfiguration\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"loopsLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredLoops\",\"type\":\"uint256\"}],\"name\":\"MaxLoopsLimitExceeded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"TokenAlreadyInitialized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"TokenNotInitialized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"calledContract\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"methodSignature\",\"type\":\"string\"}],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldMaxLoopsLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newmaxLoopsLimit\",\"type\":\"uint256\"}],\"name\":\"MaxLoopsLimitUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldSpeed\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSpeed\",\"type\":\"uint256\"}],\"name\":\"MaxTokenDistributionSpeedUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldPrimeToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newPrimeToken\",\"type\":\"address\"}],\"name\":\"PrimeTokenUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"sweepAmount\",\"type\":\"uint256\"}],\"name\":\"SweepToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"TokenDistributionInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldSpeed\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSpeed\",\"type\":\"uint256\"}],\"name\":\"TokenDistributionSpeedUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokenTransferredToPrime\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokensAccrued\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_MAX_DISTRIBUTION_SPEED\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV8\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"accrueTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blocksOrSecondsPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumberOrTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"getEffectiveDistributionSpeed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"tokens_\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"distributionSpeeds_\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"maxDistributionSpeeds_\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"loopsLimit_\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"tokens_\",\"type\":\"address[]\"}],\"name\":\"initializeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isTimeBased\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"lastAccruedBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastAccruedBlockOrSecond\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxLoopsLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"maxTokenDistributionSpeeds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseFundsTransfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"prime\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"releaseFunds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"resumeFundsTransfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"setAccessControlManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"loopsLimit\",\"type\":\"uint256\"}],\"name\":\"setMaxLoopsLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"tokens_\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"maxDistributionSpeeds_\",\"type\":\"uint256[]\"}],\"name\":\"setMaxTokensDistributionSpeed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"prime_\",\"type\":\"address\"}],\"name\":\"setPrimeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"tokens_\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"distributionSpeeds_\",\"type\":\"uint256[]\"}],\"name\":\"setTokensDistributionSpeed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"token_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount_\",\"type\":\"uint256\"}],\"name\":\"sweepToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"tokenAmountAccrued\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"tokenDistributionSpeeds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"Paused(address)\":{\"details\":\"Emitted when the pause is triggered by `account`.\"},\"Unpaused(address)\":{\"details\":\"Emitted when the pause is lifted by `account`.\"}},\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"accrueTokens(address)\":{\"custom:event\":\"Emits TokensAccrued event\",\"params\":{\"token_\":\"Address of the token\"}},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"getBlockNumberOrTimestamp()\":{\"details\":\"Function to simply retrieve block number or block timestamp\",\"returns\":{\"_0\":\"Current block number or block timestamp\"}},\"getEffectiveDistributionSpeed(address)\":{\"params\":{\"token_\":\"Address of the token\"},\"returns\":{\"_0\":\"speed returns the per block or second reward\"}},\"initialize(address,address[],uint256[],uint256[],uint256)\":{\"custom:error\":\"Throw InvalidArguments on different length of tokens and speeds array\",\"details\":\"Initializes the deployer to owner\",\"params\":{\"accessControlManager_\":\"AccessControlManager contract address\",\"distributionSpeeds_\":\"New distribution speeds for tokens\",\"loopsLimit_\":\"Maximum number of loops allowed in a single transaction\",\"tokens_\":\"Array of addresses of the tokens\"}},\"initializeTokens(address[])\":{\"custom:access\":\"Only Governance\",\"params\":{\"tokens_\":\"Array of addresses of the tokens to be intialized\"}},\"lastAccruedBlock(address)\":{\"params\":{\"token_\":\"Address of the token\"},\"returns\":{\"_0\":\"blockNumberOrSecond returns the last accrued block or second\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pauseFundsTransfer()\":{\"custom:access\":\"Controlled by ACM\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"releaseFunds(address)\":{\"custom:error\":\"Throw InvalidArguments on Zero address(token)Throw FundsTransferIsPaused is pausedThrow InvalidCaller if the sender is not the Prime contract\",\"custom:event\":\"Emits TokenTransferredToPrime event\",\"params\":{\"token_\":\"The token to release to the Prime contract\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"resumeFundsTransfer()\":{\"custom:access\":\"Controlled by ACM\"},\"setAccessControlManager(address)\":{\"custom:access\":\"Only Governance\",\"custom:event\":\"Emits NewAccessControlManager event\",\"details\":\"Admin function to set address of AccessControlManager\",\"params\":{\"accessControlManager_\":\"The new address of the AccessControlManager\"}},\"setMaxLoopsLimit(uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:event\":\"Emits MaxLoopsLimitUpdated event on success\",\"params\":{\"loopsLimit\":\"Limit for the max loops can execute at a time\"}},\"setMaxTokensDistributionSpeed(address[],uint256[])\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw InvalidArguments on different length of tokens and speeds array\",\"params\":{\"maxDistributionSpeeds_\":\"New distribution speeds for tokens\",\"tokens_\":\"Array of addresses of the tokens\"}},\"setPrimeToken(address)\":{\"custom:access\":\"Only owner\",\"custom:event\":\"Emits PrimeTokenUpdated event\",\"params\":{\"prime_\":\"The new address of the prime token contract\"}},\"setTokensDistributionSpeed(address[],uint256[])\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw InvalidArguments on different length of tokens and speeds array\",\"params\":{\"distributionSpeeds_\":\"New distribution speeds for tokens\",\"tokens_\":\"Array of addresses of the tokens\"}},\"sweepToken(address,address,uint256)\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract\",\"custom:event\":\"Emits SweepToken event\",\"params\":{\"amount_\":\"The amount of tokens needs to transfer\",\"to_\":\"The address of the recipient\",\"token_\":\"The address of the ERC-20 token to sweep\"}},\"tokenAmountAccrued(address)\":{\"params\":{\"token_\":\"Address of the token\"},\"returns\":{\"_0\":\"returns the amount of accrued tokens for the token provided\"}},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"title\":\"PrimeLiquidityProvider\",\"version\":1},\"userdoc\":{\"errors\":{\"AddressesMustDiffer()\":[{\"notice\":\"Error thrown when argument value in setter is same as previous value\"}],\"FundsTransferIsPaused()\":[{\"notice\":\"Error thrown when funds transfer is paused\"}],\"InsufficientBalance(uint256,uint256)\":[{\"notice\":\"Error thrown when PrimeLiquidityProvider's balance is less than sweep amount\"}],\"InvalidArguments()\":[{\"notice\":\"Thrown when arguments are passed are invalid\"}],\"InvalidBlocksPerYear()\":[{\"notice\":\"Thrown when blocks per year is invalid\"}],\"InvalidCaller()\":[{\"notice\":\"Thrown when caller is not the desired caller\"}],\"InvalidDistributionSpeed(uint256,uint256)\":[{\"notice\":\"Thrown when distribution speed is greater than maxTokenDistributionSpeeds[tokenAddress]\"}],\"InvalidTimeBasedConfiguration()\":[{\"notice\":\"Thrown when time based but blocks per year is provided\"}],\"MaxLoopsLimitExceeded(uint256,uint256)\":[{\"notice\":\"Thrown an error on maxLoopsLimit exceeds for any loop\"}],\"TokenAlreadyInitialized(address)\":[{\"notice\":\"Thrown when token is initialized\"}],\"TokenNotInitialized(address)\":[{\"notice\":\"Error thrown when accrueTokens is called for an uninitialized token\"}],\"Unauthorized(address,address,string)\":[{\"notice\":\"Thrown when the action is prohibited by AccessControlManager\"}]},\"events\":{\"MaxLoopsLimitUpdated(uint256,uint256)\":{\"notice\":\"Emitted when max loops limit is set\"},\"MaxTokenDistributionSpeedUpdated(address,uint256,uint256)\":{\"notice\":\"Emitted when a new max distribution speed for token is set\"},\"NewAccessControlManager(address,address)\":{\"notice\":\"Emitted when access control manager contract address is changed\"},\"PrimeTokenUpdated(address,address)\":{\"notice\":\"Emitted when prime token contract address is changed\"},\"SweepToken(address,address,uint256)\":{\"notice\":\"Emitted on sweep token success\"},\"TokenDistributionInitialized(address)\":{\"notice\":\"Emitted when a token distribution is initialized\"},\"TokenDistributionSpeedUpdated(address,uint256,uint256)\":{\"notice\":\"Emitted when a new token distribution speed is set\"},\"TokenTransferredToPrime(address,uint256)\":{\"notice\":\"Emitted when token is transferred to the prime contract\"},\"TokensAccrued(address,uint256)\":{\"notice\":\"Emitted when distribution state(Index and block or second) is updated\"}},\"kind\":\"user\",\"methods\":{\"DEFAULT_MAX_DISTRIBUTION_SPEED()\":{\"notice\":\"The default max token distribution speed\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"accrueTokens(address)\":{\"notice\":\"Accrue token by updating the distribution state\"},\"blocksOrSecondsPerYear()\":{\"notice\":\"Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\"},\"getEffectiveDistributionSpeed(address)\":{\"notice\":\"Get rewards per block or second for token\"},\"initialize(address,address[],uint256[],uint256[],uint256)\":{\"notice\":\"PrimeLiquidityProvider initializer\"},\"initializeTokens(address[])\":{\"notice\":\"Initialize the distribution of the token\"},\"isTimeBased()\":{\"notice\":\"Acknowledges if a contract is time based or not\"},\"lastAccruedBlock(address)\":{\"notice\":\"Get the last accrued block or second for token\"},\"lastAccruedBlockOrSecond(address)\":{\"notice\":\"The block or second till which rewards are distributed for an asset\"},\"maxTokenDistributionSpeeds(address)\":{\"notice\":\"The max token distribution speed for token\"},\"pauseFundsTransfer()\":{\"notice\":\"Pause fund transfer of tokens to Prime contract\"},\"prime()\":{\"notice\":\"Address of the Prime contract\"},\"releaseFunds(address)\":{\"notice\":\"Claim all the token accrued till last block or second\"},\"resumeFundsTransfer()\":{\"notice\":\"Resume fund transfer of tokens to Prime contract\"},\"setAccessControlManager(address)\":{\"notice\":\"Sets the address of AccessControlManager\"},\"setMaxLoopsLimit(uint256)\":{\"notice\":\"Set the limit for the loops can iterate to avoid the DOS\"},\"setMaxTokensDistributionSpeed(address[],uint256[])\":{\"notice\":\"Set max distribution speed for token (amount of maximum token distribute per block or second)\"},\"setPrimeToken(address)\":{\"notice\":\"Set the prime token contract address\"},\"setTokensDistributionSpeed(address[],uint256[])\":{\"notice\":\"Set distribution speed (amount of token distribute per block or second)\"},\"sweepToken(address,address,uint256)\":{\"notice\":\"A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\"},\"tokenAmountAccrued(address)\":{\"notice\":\"Get the tokens accrued\"},\"tokenDistributionSpeeds(address)\":{\"notice\":\"The rate at which token is distributed (per block or second)\"}},\"notice\":\"PrimeLiquidityProvider is used to fund Prime\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Tokens/Prime/PrimeLiquidityProvider.sol\":\"PrimeLiquidityProvider\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./OwnableUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n function __Ownable2Step_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable2Step_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x9140dabc466abab21b48b72dbda26736b1183a310d0e677d3719d201df026510\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling 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 /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x359a1ab89b46b9aba7bcad3fb651924baf4893d15153049b9976b0fc9be1358e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\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 _requireNotPaused();\\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 _requirePaused();\\n _;\\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 Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\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 /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xad32f6821f860555f9530902a65b54203a4f5db2117f4384ae47a124958078db\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.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 IERC20Upgradeable {\\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(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x0e1f0f5f62f67a881cd1a9597acbc0a5e4071f3c2c10449a183b922ae7272e3f\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x07e881de3b9f6d2c07909f193f24b96c7fe4ea60013260f3f25aecd8bab3c2f8\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) 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(IERC20Upgradeable token, address spender, uint256 value) 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 /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\\n * Revert on invalid signature.\\n */\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\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(IERC20Upgradeable 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 require(returndata.length == 0 || abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\\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 cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return\\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));\\n }\\n}\\n\",\"keccak256\":\"0x23b997be73d3dd46885262704f0f8cfc7273fdadfe303d37969a9561373972b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\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 * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(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 (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport {Initializable} from \\\"../proxy/utils/Initializable.sol\\\";\\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 ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n function _contextSuffixLength() internal view virtual returns (uint256) {\\n return 0;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x75097e35253e7fb282ee4d7f27a80eaacfa759923185bf17302a89cbc059c5ef\",\"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\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title AccessControlledV8\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0dcf283925f4dddc23ca0ee71d2cb96a9dd6e4cf08061b69fde1697ea39dc514\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\n/**\\n * @title IAccessControlManagerV8\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\\n */\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xaa29b098440d0b3a131c5ecdf25ce548790c1b5ac7bf9b5c0264b6af6f7a1e0b\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\n/**\\n * @title MaxLoopsLimitHelper\\n * @author Venus\\n * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.\\n */\\nabstract contract MaxLoopsLimitHelper {\\n // Limit for the loops to avoid the DOS\\n uint256 public maxLoopsLimit;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when max loops limit is set\\n event MaxLoopsLimitUpdated(uint256 oldMaxLoopsLimit, uint256 newmaxLoopsLimit);\\n\\n /// @notice Thrown an error on maxLoopsLimit exceeds for any loop\\n error MaxLoopsLimitExceeded(uint256 loopsLimit, uint256 requiredLoops);\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param limit Limit for the max loops can execute at a time\\n */\\n function _setMaxLoopsLimit(uint256 limit) internal {\\n require(limit > maxLoopsLimit, \\\"Comptroller: Invalid maxLoopsLimit\\\");\\n\\n uint256 oldMaxLoopsLimit = maxLoopsLimit;\\n maxLoopsLimit = limit;\\n\\n emit MaxLoopsLimitUpdated(oldMaxLoopsLimit, limit);\\n }\\n\\n /**\\n * @notice Compare the maxLoopsLimit with number of the times loop iterate\\n * @param len Length of the loops iterate\\n * @custom:error MaxLoopsLimitExceeded error is thrown when loops length exceeds maxLoopsLimit\\n */\\n function _ensureMaxLoops(uint256 len) internal view {\\n if (len > maxLoopsLimit) {\\n revert MaxLoopsLimitExceeded(maxLoopsLimit, len);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4c25e30635485d162177effa384eee51768b0141a567a0da16ff6ad673274166\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { SECONDS_PER_YEAR } from \\\"./constants.sol\\\";\\n\\nabstract contract TimeManagerV8 {\\n /// @notice Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable blocksOrSecondsPerYear;\\n\\n /// @notice Acknowledges if a contract is time based or not\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n bool public immutable isTimeBased;\\n\\n /// @notice Stores the current block timestamp or block number depending on isTimeBased\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n function() view returns (uint256) private immutable _getCurrentSlot;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[48] private __gap;\\n\\n /// @notice Thrown when blocks per year is invalid\\n error InvalidBlocksPerYear();\\n\\n /// @notice Thrown when time based but blocks per year is provided\\n error InvalidTimeBasedConfiguration();\\n\\n /**\\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\\n * @param blocksPerYear_ The number of blocks per year\\n * @custom:error InvalidBlocksPerYear is thrown if blocksPerYear entered is zero and timeBased is false\\n * @custom:error InvalidTimeBasedConfiguration is thrown if blocksPerYear entered is non zero and timeBased is true\\n * @custom:oz-upgrades-unsafe-allow constructor\\n */\\n constructor(bool timeBased_, uint256 blocksPerYear_) {\\n if (!timeBased_ && blocksPerYear_ == 0) {\\n revert InvalidBlocksPerYear();\\n }\\n\\n if (timeBased_ && blocksPerYear_ != 0) {\\n revert InvalidTimeBasedConfiguration();\\n }\\n\\n isTimeBased = timeBased_;\\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\\n _getCurrentSlot = timeBased_ ? _getBlockTimestamp : _getBlockNumber;\\n }\\n\\n /**\\n * @dev Function to simply retrieve block number or block timestamp\\n * @return Current block number or block timestamp\\n */\\n function getBlockNumberOrTimestamp() public view virtual returns (uint256) {\\n return _getCurrentSlot();\\n }\\n\\n /**\\n * @dev Returns the current timestamp in seconds\\n * @return The current timestamp\\n */\\n function _getBlockTimestamp() private view returns (uint256) {\\n return block.timestamp;\\n }\\n\\n /**\\n * @dev Returns the current block number\\n * @return The current block number\\n */\\n function _getBlockNumber() private view returns (uint256) {\\n return block.number;\\n }\\n}\\n\",\"keccak256\":\"0x57a2bbb9b8e02b1c0a5c0e305fef1328a22db56c3d4b148c362010a6e767243c\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/constants.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\\nuint256 constant EXP_SCALE = 1e18;\\n\\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\\nuint256 constant MANTISSA_ONE = EXP_SCALE;\\n\\n/// @dev The approximate number of seconds per year\\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\\n\",\"keccak256\":\"0x14de93ead464da249af31bea0e3bcfb62ec693bea3475fb4d90f055ac81dc5eb\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IPrimeLiquidityProvider.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport { IERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IPrimeLiquidityProvider\\n * @author Venus\\n * @notice Interface for PrimeLiquidityProvider\\n */\\ninterface IPrimeLiquidityProvider {\\n /**\\n * @notice Initialize the distribution of the token\\n * @param tokens_ Array of addresses of the tokens to be intialized\\n */\\n function initializeTokens(address[] calldata tokens_) external;\\n\\n /**\\n * @notice Pause fund transfer of tokens to Prime contract\\n */\\n function pauseFundsTransfer() external;\\n\\n /**\\n * @notice Resume fund transfer of tokens to Prime contract\\n */\\n function resumeFundsTransfer() external;\\n\\n /**\\n * @notice Set distribution speed (amount of token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param distributionSpeeds_ New distribution speeds for tokens\\n */\\n function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external;\\n\\n /**\\n * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param maxDistributionSpeeds_ New distribution speeds for tokens\\n */\\n function setMaxTokensDistributionSpeed(\\n address[] calldata tokens_,\\n uint256[] calldata maxDistributionSpeeds_\\n ) external;\\n\\n /**\\n * @notice Set the prime token contract address\\n * @param prime_ The new address of the prime token contract\\n */\\n function setPrimeToken(address prime_) external;\\n\\n /**\\n * @notice Claim all the token accrued till last block or second\\n * @param token_ The token to release to the Prime contract\\n */\\n function releaseFunds(address token_) external;\\n\\n /**\\n * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\\n * @param token_ The address of the ERC-20 token to sweep\\n * @param to_ The address of the recipient\\n * @param amount_ The amount of tokens needs to transfer\\n */\\n function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external;\\n\\n /**\\n * @notice Accrue token by updating the distribution state\\n * @param token_ Address of the token\\n */\\n function accrueTokens(address token_) external;\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Limit for the max loops can execute at a time\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external;\\n\\n /**\\n * @notice Get rewards per block or second for token\\n * @param token_ Address of the token\\n * @return speed returns the per block or second reward\\n */\\n function getEffectiveDistributionSpeed(address token_) external view returns (uint256);\\n\\n /**\\n * @notice Get the amount of tokens accrued\\n * @param token_ Address of the token\\n * @return Amount of tokens that are accrued\\n */\\n function tokenAmountAccrued(address token_) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x4dca0341931008bcd81de18e627c2d0cd4f9d0be67db4d8f0d678d11ba0d330f\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/PrimeLiquidityProvider.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { PrimeLiquidityProviderStorageV1 } from \\\"./PrimeLiquidityProviderStorage.sol\\\";\\nimport { SafeERC20Upgradeable, IERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport { AccessControlledV8 } from \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\nimport { PausableUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport { IPrimeLiquidityProvider } from \\\"./Interfaces/IPrimeLiquidityProvider.sol\\\";\\nimport { MaxLoopsLimitHelper } from \\\"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\\\";\\nimport { TimeManagerV8 } from \\\"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\\\";\\n\\n/**\\n * @title PrimeLiquidityProvider\\n * @author Venus\\n * @notice PrimeLiquidityProvider is used to fund Prime\\n */\\ncontract PrimeLiquidityProvider is\\n IPrimeLiquidityProvider,\\n AccessControlledV8,\\n PausableUpgradeable,\\n MaxLoopsLimitHelper,\\n PrimeLiquidityProviderStorageV1,\\n TimeManagerV8\\n{\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n /// @notice The default max token distribution speed\\n uint256 public constant DEFAULT_MAX_DISTRIBUTION_SPEED = 1e18;\\n\\n /// @notice Emitted when a token distribution is initialized\\n event TokenDistributionInitialized(address indexed token);\\n\\n /// @notice Emitted when a new token distribution speed is set\\n event TokenDistributionSpeedUpdated(address indexed token, uint256 oldSpeed, uint256 newSpeed);\\n\\n /// @notice Emitted when a new max distribution speed for token is set\\n event MaxTokenDistributionSpeedUpdated(address indexed token, uint256 oldSpeed, uint256 newSpeed);\\n\\n /// @notice Emitted when prime token contract address is changed\\n event PrimeTokenUpdated(address indexed oldPrimeToken, address indexed newPrimeToken);\\n\\n /// @notice Emitted when distribution state(Index and block or second) is updated\\n event TokensAccrued(address indexed token, uint256 amount);\\n\\n /// @notice Emitted when token is transferred to the prime contract\\n event TokenTransferredToPrime(address indexed token, uint256 amount);\\n\\n /// @notice Emitted on sweep token success\\n event SweepToken(address indexed token, address indexed to, uint256 sweepAmount);\\n\\n /// @notice Thrown when arguments are passed are invalid\\n error InvalidArguments();\\n\\n /// @notice Thrown when distribution speed is greater than maxTokenDistributionSpeeds[tokenAddress]\\n error InvalidDistributionSpeed(uint256 speed, uint256 maxSpeed);\\n\\n /// @notice Thrown when caller is not the desired caller\\n error InvalidCaller();\\n\\n /// @notice Thrown when token is initialized\\n error TokenAlreadyInitialized(address token);\\n\\n ///@notice Error thrown when PrimeLiquidityProvider's balance is less than sweep amount\\n error InsufficientBalance(uint256 sweepAmount, uint256 balance);\\n\\n /// @notice Error thrown when funds transfer is paused\\n error FundsTransferIsPaused();\\n\\n /// @notice Error thrown when accrueTokens is called for an uninitialized token\\n error TokenNotInitialized(address token_);\\n\\n /// @notice Error thrown when argument value in setter is same as previous value\\n error AddressesMustDiffer();\\n\\n /**\\n * @notice Compares two addresses to ensure they are different\\n * @param oldAddress The original address to compare\\n * @param newAddress The new address to compare\\n */\\n modifier compareAddress(address oldAddress, address newAddress) {\\n if (newAddress == oldAddress) {\\n revert AddressesMustDiffer();\\n }\\n _;\\n }\\n\\n /**\\n * @notice Prime Liquidity Provider constructor\\n * @param _timeBased A boolean indicating whether the contract is based on time or block.\\n * @param _blocksPerYear total blocks per year\\n */\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(bool _timeBased, uint256 _blocksPerYear) TimeManagerV8(_timeBased, _blocksPerYear) {\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice PrimeLiquidityProvider initializer\\n * @dev Initializes the deployer to owner\\n * @param accessControlManager_ AccessControlManager contract address\\n * @param tokens_ Array of addresses of the tokens\\n * @param distributionSpeeds_ New distribution speeds for tokens\\n * @param loopsLimit_ Maximum number of loops allowed in a single transaction\\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\\n */\\n function initialize(\\n address accessControlManager_,\\n address[] calldata tokens_,\\n uint256[] calldata distributionSpeeds_,\\n uint256[] calldata maxDistributionSpeeds_,\\n uint256 loopsLimit_\\n ) external initializer {\\n _ensureZeroAddress(accessControlManager_);\\n\\n __AccessControlled_init(accessControlManager_);\\n __Pausable_init();\\n _setMaxLoopsLimit(loopsLimit_);\\n\\n uint256 numTokens = tokens_.length;\\n _ensureMaxLoops(numTokens);\\n\\n if ((numTokens != distributionSpeeds_.length) || (numTokens != maxDistributionSpeeds_.length)) {\\n revert InvalidArguments();\\n }\\n\\n for (uint256 i; i < numTokens; ) {\\n _initializeToken(tokens_[i]);\\n _setMaxTokenDistributionSpeed(tokens_[i], maxDistributionSpeeds_[i]);\\n _setTokenDistributionSpeed(tokens_[i], distributionSpeeds_[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Initialize the distribution of the token\\n * @param tokens_ Array of addresses of the tokens to be intialized\\n * @custom:access Only Governance\\n */\\n function initializeTokens(address[] calldata tokens_) external onlyOwner {\\n uint256 tokensLength = tokens_.length;\\n _ensureMaxLoops(tokensLength);\\n\\n for (uint256 i; i < tokensLength; ) {\\n _initializeToken(tokens_[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Pause fund transfer of tokens to Prime contract\\n * @custom:access Controlled by ACM\\n */\\n function pauseFundsTransfer() external {\\n _checkAccessAllowed(\\\"pauseFundsTransfer()\\\");\\n _pause();\\n }\\n\\n /**\\n * @notice Resume fund transfer of tokens to Prime contract\\n * @custom:access Controlled by ACM\\n */\\n function resumeFundsTransfer() external {\\n _checkAccessAllowed(\\\"resumeFundsTransfer()\\\");\\n _unpause();\\n }\\n\\n /**\\n * @notice Set distribution speed (amount of token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param distributionSpeeds_ New distribution speeds for tokens\\n * @custom:access Controlled by ACM\\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\\n */\\n function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external {\\n _checkAccessAllowed(\\\"setTokensDistributionSpeed(address[],uint256[])\\\");\\n uint256 numTokens = tokens_.length;\\n _ensureMaxLoops(numTokens);\\n\\n if (numTokens != distributionSpeeds_.length) {\\n revert InvalidArguments();\\n }\\n\\n for (uint256 i; i < numTokens; ) {\\n _ensureTokenInitialized(tokens_[i]);\\n _setTokenDistributionSpeed(tokens_[i], distributionSpeeds_[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param maxDistributionSpeeds_ New distribution speeds for tokens\\n * @custom:access Controlled by ACM\\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\\n */\\n function setMaxTokensDistributionSpeed(\\n address[] calldata tokens_,\\n uint256[] calldata maxDistributionSpeeds_\\n ) external {\\n _checkAccessAllowed(\\\"setMaxTokensDistributionSpeed(address[],uint256[])\\\");\\n uint256 numTokens = tokens_.length;\\n _ensureMaxLoops(numTokens);\\n\\n if (numTokens != maxDistributionSpeeds_.length) {\\n revert InvalidArguments();\\n }\\n\\n for (uint256 i; i < numTokens; ) {\\n _setMaxTokenDistributionSpeed(tokens_[i], maxDistributionSpeeds_[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Set the prime token contract address\\n * @param prime_ The new address of the prime token contract\\n * @custom:event Emits PrimeTokenUpdated event\\n * @custom:access Only owner\\n */\\n function setPrimeToken(address prime_) external onlyOwner compareAddress(prime, prime_) {\\n _ensureZeroAddress(prime_);\\n\\n emit PrimeTokenUpdated(prime, prime_);\\n prime = prime_;\\n }\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Limit for the max loops can execute at a time\\n * @custom:event Emits MaxLoopsLimitUpdated event on success\\n * @custom:access Controlled by ACM\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external {\\n _checkAccessAllowed(\\\"setMaxLoopsLimit(uint256)\\\");\\n _setMaxLoopsLimit(loopsLimit);\\n }\\n\\n /**\\n * @notice Claim all the token accrued till last block or second\\n * @param token_ The token to release to the Prime contract\\n * @custom:event Emits TokenTransferredToPrime event\\n * @custom:error Throw InvalidArguments on Zero address(token)\\n * @custom:error Throw FundsTransferIsPaused is paused\\n * @custom:error Throw InvalidCaller if the sender is not the Prime contract\\n */\\n function releaseFunds(address token_) external {\\n address _prime = prime;\\n if (msg.sender != _prime) revert InvalidCaller();\\n if (paused()) {\\n revert FundsTransferIsPaused();\\n }\\n\\n accrueTokens(token_);\\n uint256 accruedAmount = _tokenAmountAccrued[token_];\\n delete _tokenAmountAccrued[token_];\\n\\n emit TokenTransferredToPrime(token_, accruedAmount);\\n\\n IERC20Upgradeable(token_).safeTransfer(_prime, accruedAmount);\\n }\\n\\n /**\\n * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\\n * @param token_ The address of the ERC-20 token to sweep\\n * @param to_ The address of the recipient\\n * @param amount_ The amount of tokens needs to transfer\\n * @custom:event Emits SweepToken event\\n * @custom:error Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract\\n * @custom:access Only Governance\\n */\\n function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external onlyOwner {\\n uint256 balance = token_.balanceOf(address(this));\\n if (amount_ > balance) {\\n revert InsufficientBalance(amount_, balance);\\n }\\n\\n emit SweepToken(address(token_), to_, amount_);\\n\\n token_.safeTransfer(to_, amount_);\\n }\\n\\n /**\\n * @notice Get rewards per block or second for token\\n * @param token_ Address of the token\\n * @return speed returns the per block or second reward\\n */\\n function getEffectiveDistributionSpeed(address token_) external view returns (uint256) {\\n uint256 distributionSpeed = tokenDistributionSpeeds[token_];\\n uint256 balance = IERC20Upgradeable(token_).balanceOf(address(this));\\n uint256 accrued = _tokenAmountAccrued[token_];\\n\\n if (balance > accrued) {\\n return distributionSpeed;\\n }\\n\\n return 0;\\n }\\n\\n /**\\n * @notice Accrue token by updating the distribution state\\n * @param token_ Address of the token\\n * @custom:event Emits TokensAccrued event\\n */\\n function accrueTokens(address token_) public {\\n _ensureZeroAddress(token_);\\n\\n _ensureTokenInitialized(token_);\\n\\n uint256 blockNumberOrSecond = getBlockNumberOrTimestamp();\\n uint256 deltaBlocksOrSeconds;\\n unchecked {\\n deltaBlocksOrSeconds = blockNumberOrSecond - lastAccruedBlockOrSecond[token_];\\n }\\n\\n if (deltaBlocksOrSeconds != 0) {\\n uint256 distributionSpeed = tokenDistributionSpeeds[token_];\\n uint256 balance = IERC20Upgradeable(token_).balanceOf(address(this));\\n\\n uint256 balanceDiff = balance - _tokenAmountAccrued[token_];\\n if (distributionSpeed != 0 && balanceDiff != 0) {\\n uint256 accruedSinceUpdate = deltaBlocksOrSeconds * distributionSpeed;\\n uint256 tokenAccrued = (balanceDiff <= accruedSinceUpdate ? balanceDiff : accruedSinceUpdate);\\n\\n _tokenAmountAccrued[token_] += tokenAccrued;\\n emit TokensAccrued(token_, tokenAccrued);\\n }\\n\\n lastAccruedBlockOrSecond[token_] = blockNumberOrSecond;\\n }\\n }\\n\\n /**\\n * @notice Get the last accrued block or second for token\\n * @param token_ Address of the token\\n * @return blockNumberOrSecond returns the last accrued block or second\\n */\\n function lastAccruedBlock(address token_) external view returns (uint256) {\\n return lastAccruedBlockOrSecond[token_];\\n }\\n\\n /**\\n * @notice Get the tokens accrued\\n * @param token_ Address of the token\\n * @return returns the amount of accrued tokens for the token provided\\n */\\n function tokenAmountAccrued(address token_) external view returns (uint256) {\\n return _tokenAmountAccrued[token_];\\n }\\n\\n /**\\n * @notice Initialize the distribution of the token\\n * @param token_ Address of the token to be intialized\\n * @custom:event Emits TokenDistributionInitialized event\\n * @custom:error Throw TokenAlreadyInitialized if token is already initialized\\n */\\n function _initializeToken(address token_) internal {\\n _ensureZeroAddress(token_);\\n uint256 blockNumberOrSecond = getBlockNumberOrTimestamp();\\n uint256 initializedBlockOrSecond = lastAccruedBlockOrSecond[token_];\\n\\n if (initializedBlockOrSecond != 0) {\\n revert TokenAlreadyInitialized(token_);\\n }\\n\\n /*\\n * Update token state block number or second\\n */\\n lastAccruedBlockOrSecond[token_] = blockNumberOrSecond;\\n\\n emit TokenDistributionInitialized(token_);\\n }\\n\\n /**\\n * @notice Set distribution speed (amount of token distribute per block or second)\\n * @param token_ Address of the token\\n * @param distributionSpeed_ New distribution speed for token\\n * @custom:event Emits TokenDistributionSpeedUpdated event\\n * @custom:error Throw InvalidDistributionSpeed if speed is greater than max speed\\n */\\n function _setTokenDistributionSpeed(address token_, uint256 distributionSpeed_) internal {\\n uint256 maxDistributionSpeed = maxTokenDistributionSpeeds[token_];\\n if (maxDistributionSpeed == 0) {\\n maxTokenDistributionSpeeds[token_] = maxDistributionSpeed = DEFAULT_MAX_DISTRIBUTION_SPEED;\\n }\\n\\n if (distributionSpeed_ > maxDistributionSpeed) {\\n revert InvalidDistributionSpeed(distributionSpeed_, maxDistributionSpeed);\\n }\\n\\n uint256 oldDistributionSpeed = tokenDistributionSpeeds[token_];\\n if (oldDistributionSpeed != distributionSpeed_) {\\n // Distribution speed updated so let's update distribution state to ensure that\\n // 1. Token accrued properly for the old speed, and\\n // 2. Token accrued at the new speed starts after this block or second.\\n accrueTokens(token_);\\n\\n // Update speed\\n tokenDistributionSpeeds[token_] = distributionSpeed_;\\n\\n emit TokenDistributionSpeedUpdated(token_, oldDistributionSpeed, distributionSpeed_);\\n }\\n }\\n\\n /**\\n * @notice Set max distribution speed (amount of maximum token distribute per block or second)\\n * @param token_ Address of the token\\n * @param maxDistributionSpeed_ New max distribution speed for token\\n * @custom:event Emits MaxTokenDistributionSpeedUpdated event\\n */\\n function _setMaxTokenDistributionSpeed(address token_, uint256 maxDistributionSpeed_) internal {\\n emit MaxTokenDistributionSpeedUpdated(token_, tokenDistributionSpeeds[token_], maxDistributionSpeed_);\\n maxTokenDistributionSpeeds[token_] = maxDistributionSpeed_;\\n }\\n\\n /**\\n * @notice Revert on non initialized token\\n * @param token_ Token Address to be verified for\\n */\\n function _ensureTokenInitialized(address token_) internal view {\\n uint256 lastBlockOrSecondAccrued = lastAccruedBlockOrSecond[token_];\\n\\n if (lastBlockOrSecondAccrued == 0) {\\n revert TokenNotInitialized(token_);\\n }\\n }\\n\\n /**\\n * @notice Revert on zero address\\n * @param address_ Address to be verified\\n */\\n function _ensureZeroAddress(address address_) internal pure {\\n if (address_ == address(0)) {\\n revert InvalidArguments();\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8fa6826d33694827d2007991f36311a5c1e3a1bc9809e8e704e0de0ce26c83ff\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/PrimeLiquidityProviderStorage.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\n/**\\n * @title PrimeLiquidityProviderStorageV1\\n * @author Venus\\n * @notice Storage for Prime Liquidity Provider\\n */\\ncontract PrimeLiquidityProviderStorageV1 {\\n /// @notice Address of the Prime contract\\n address public prime;\\n\\n /// @notice The rate at which token is distributed (per block or second)\\n mapping(address => uint256) public tokenDistributionSpeeds;\\n\\n /// @notice The max token distribution speed for token\\n mapping(address => uint256) public maxTokenDistributionSpeeds;\\n\\n /// @notice The block or second till which rewards are distributed for an asset\\n mapping(address => uint256) public lastAccruedBlockOrSecond;\\n\\n /// @notice The token accrued but not yet transferred to prime contract\\n mapping(address => uint256) internal _tokenAmountAccrued;\\n\\n /// @dev This empty reserved space is put in place to allow future versions to add new\\n /// variables without shifting down storage in the inheritance chain.\\n uint256[45] private __gap;\\n}\\n\",\"keccak256\":\"0x697e43e039edbec0f14857b1d118fa55f5ca87b2b284dad0a363013d885e7c29\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", + "bytecode": "0x60e060405234801561001057600080fd5b5060405161207a38038061207a83398101604081905261002f916101a3565b81818115801561003d575080155b1561005b576040516302723dfb60e21b815260040160405180910390fd5b81801561006757508015155b156100855760405163ae0fcab360e01b815260040160405180910390fd5b81151560a05281610096578061009c565b6301e133805b608052816100b3576100dc60201b610f61176100be565b6100e060201b610f65175b6001600160401b031660c052506100d590506100e4565b50506101d6565b4390565b4290565b600054610100900460ff16156101505760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146101a1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b600080604083850312156101b657600080fd5b825180151581146101c657600080fd5b6020939093015192949293505050565b60805160a05160c051611e756102056000396000610cb7015260006103e8015260006102db0152611e756000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c806393920bf81161010f578063c7ad0895116100a2578063e30c397811610071578063e30c397814610439578063e458a65d1461044a578063f2fde38b1461045d578063fa7781ff1461047057600080fd5b8063c7ad0895146103e3578063c7ee005e1461040a578063ce82e8411461041e578063e1d146fb1461043157600080fd5b8063b4a0bdf3116100de578063b4a0bdf3146103ae578063bc2f7dc3146103bf578063be26317e146103c7578063c32094c7146103d057600080fd5b806393920bf8146103585780639d3cc5431461036b5780639dd5428e1461038c578063a666642b1461039b57600080fd5b8063637c9b4e1161018757806379ba50971161015657806379ba50971461030557806380d45a2d1461030d5780638aadf799146103205780638da5cb5b1461033357600080fd5b8063637c9b4e146102a257806364aff9ec146102c35780636857249c146102d6578063715018a6146102fd57600080fd5b80633131b065116101c35780633131b0651461024657806343bf7283146102595780635a38f84d146102835780635c975abb1461028b57600080fd5b80630e32cb86146101ea578063192e7a7b146101ff578063231f82bb14610212575b600080fd5b6101fd6101f83660046119e5565b61049a565b005b6101fd61020d3660046119e5565b6104ae565b6102336102203660046119e5565b61012e6020526000908152604090205481565b6040519081526020015b60405180910390f35b6101fd610254366004611a55565b610574565b6102336102673660046119e5565b6001600160a01b03166000908152610130602052604090205490565b6101fd6105ce565b60c95460ff165b604051901515815260200161023d565b6102336102b03660046119e5565b61012f6020526000908152604090205481565b6101fd6102d1366004611a97565b61060d565b6102337f000000000000000000000000000000000000000000000000000000000000000081565b6101fd610713565b6101fd610725565b6101fd61031b366004611ad8565b61079c565b6101fd61032e3660046119e5565b6107e3565b6033546001600160a01b03165b6040516001600160a01b03909116815260200161023d565b6101fd610366366004611af1565b610993565b6102336103793660046119e5565b6101306020526000908152604090205481565b610233670de0b6b3a764000081565b6102336103a93660046119e5565b610a41565b6097546001600160a01b0316610340565b6101fd610af8565b61023360fb5481565b6101fd6103de3660046119e5565b610b36565b6102927f000000000000000000000000000000000000000000000000000000000000000081565b61012d54610340906001600160a01b031681565b6101fd61042c366004611af1565b610bdb565b610233610cb0565b6065546001600160a01b0316610340565b6101fd610458366004611b5d565b610ce3565b6101fd61046b3660046119e5565b610ef0565b61023361047e3660046119e5565b6001600160a01b03166000908152610131602052604090205490565b6104a2610f69565b6104ab81610fc3565b50565b61012d546001600160a01b03163381146104db576040516348f5c3ed60e01b815260040160405180910390fd5b60c95460ff16156104ff5760405163f4eaf50160e01b815260040160405180910390fd5b610508826107e3565b6001600160a01b0382166000818152610131602090815260408083208054939055518281529192917fa80c25cc8959419d41ee66f93961c567b272badc10e0e117261a0ee31b55c312910160405180910390a261056f6001600160a01b0384168383611089565b505050565b61057c610f69565b80610586816110db565b60005b818110156105c8576105c08484838181106105a6576105a6611c11565b90506020020160208101906105bb91906119e5565b61110c565b600101610589565b50505050565b61060360405180604001604052806014815260200173706175736546756e64735472616e73666572282960601b8152506111ad565b61060b61124b565b565b610615610f69565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106809190611c27565b9050808211156106b25760405163cf47918160e01b815260048101839052602481018290526044015b60405180910390fd5b826001600160a01b0316846001600160a01b03167f6d25be279134f4ecaa4770aff0c3d916d9e7c5ef37b65ed95dbdba411f5d54d5846040516106f791815260200190565b60405180910390a36105c86001600160a01b0385168484611089565b61071b610f69565b61060b60006112a5565b60655433906001600160a01b031681146107935760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016106a9565b6104ab816112a5565b6107da6040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e7432353629000000000000008152506111ad565b6104ab816112be565b6107ec81611358565b6107f58161137f565b60006107ff610cb0565b6001600160a01b0383166000908152610130602052604090205490915080820390821461056f576001600160a01b038316600081815261012e60205260408082205490516370a0823160e01b81523060048201529092906370a0823190602401602060405180830381865afa15801561087c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a09190611c27565b6001600160a01b03861660009081526101316020526040812054919250906108c89083611c56565b905082158015906108d857508015155b156109715760006108e98486611c6f565b90506000818311156108fb57816108fd565b825b6001600160a01b0389166000908152610131602052604081208054929350839290919061092b908490611c86565b90915550506040518181526001600160a01b038916907ffe854c4c4e633d5bb31aec1f39f01d9f8f01ad2e0212a0e576825ac986af05899060200160405180910390a250505b505050506001600160a01b039190911660009081526101306020526040902055565b6109b4604051806060016040528060328152602001611ddf603291396111ad565b826109be816110db565b8082146109de576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610a3957610a318686838181106109fe576109fe611c11565b9050602002016020810190610a1391906119e5565b858584818110610a2557610a25611c11565b905060200201356113c5565b6001016109e1565b505050505050565b6001600160a01b038116600081815261012e60205260408082205490516370a0823160e01b8152306004820152919290918391906370a0823190602401602060405180830381865afa158015610a9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abf9190611c27565b6001600160a01b0385166000908152610131602052604090205490915080821115610aed5750909392505050565b506000949350505050565b610b2e60405180604001604052806015815260200174726573756d6546756e64735472616e73666572282960581b8152506111ad565b61060b611436565b610b3e610f69565b61012d546001600160a01b039081169082908116829003610b72576040516380ae98f560e01b815260040160405180910390fd5b610b7b83611358565b61012d546040516001600160a01b038086169216907fcf4d0ac7a2f943727f0189dd1f26ba0cde29a1b14f222163ac866d4f5167db9490600090a3505061012d80546001600160a01b0319166001600160a01b0392909216919091179055565b610bfc6040518060600160405280602f8152602001611e11602f91396111ad565b82610c06816110db565b808214610c26576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610a3957610c60868683818110610c4657610c46611c11565b9050602002016020810190610c5b91906119e5565b61137f565b610ca8868683818110610c7557610c75611c11565b9050602002016020810190610c8a91906119e5565b858584818110610c9c57610c9c611c11565b9050602002013561146f565b600101610c29565b6000610cde7f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b600054610100900460ff1615808015610d035750600054600160ff909116105b80610d1d5750303b158015610d1d575060005460ff166001145b610d805760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106a9565b6000805460ff191660011790558015610da3576000805461ff0019166101001790555b610dac89611358565b610db58961156a565b610dbd6115a2565b610dc6826112be565b86610dd0816110db565b8086141580610ddf5750808414155b15610dfd576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610e9d57610e1d8a8a838181106105a6576105a6611c11565b610e598a8a83818110610e3257610e32611c11565b9050602002016020810190610e4791906119e5565b878784818110610a2557610a25611c11565b610e958a8a83818110610e6e57610e6e611c11565b9050602002016020810190610e8391906119e5565b898984818110610c9c57610c9c611c11565b600101610e00565b50508015610ee5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b610ef8610f69565b606580546001600160a01b0383166001600160a01b03199091168117909155610f296033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b4390565b4290565b6033546001600160a01b0316331461060b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106a9565b6001600160a01b0381166110275760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b60648201526084016106a9565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091015b60405180910390a15050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261056f9084906115d1565b60fb548111156104ab5760fb5460405163792bfb1b60e11b81526004810191909152602481018290526044016106a9565b61111581611358565b600061111f610cb0565b6001600160a01b038316600090815261013060205260409020549091508015611166576040516303b51ceb60e11b81526001600160a01b03841660048201526024016106a9565b6001600160a01b03831660008181526101306020526040808220859055517fcf6e06116a82c1b468912f23d8bb1d126edbb21bc0864d6d5169e3be39b1a8189190a2505050565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906111e09033908690600401611ce9565b602060405180830381865afa1580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112219190611d0d565b90508061124757333083604051634a3fa29360e01b81526004016106a993929190611d2f565b5050565b6112536116a6565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586112883390565b6040516001600160a01b03909116815260200160405180910390a1565b606580546001600160a01b03191690556104ab816116ec565b60fb54811161131a5760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b60648201526084016106a9565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa910161107d565b6001600160a01b0381166104ab576040516317dbc4cb60e21b815260040160405180910390fd5b6001600160a01b0381166000908152610130602052604081205490819003611247576040516341ea4b5960e01b81526001600160a01b03831660048201526024016106a9565b6001600160a01b038216600081815261012e60209081526040918290205482519081529081018490527f2351eb1e51f0d96d3d2dc08e3c9bddbdb2153580843330b57433c3bf5031be01910160405180910390a26001600160a01b03909116600090815261012f6020526040902055565b61143e61173e565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611288565b6001600160a01b038216600090815261012f6020526040812054908190036114b957506001600160a01b038216600090815261012f60205260409020670de0b6b3a7640000908190555b808211156114e457604051631cf8f4dd60e11b815260048101839052602481018290526044016106a9565b6001600160a01b038316600090815261012e60205260409020548281146105c85761150e846107e3565b6001600160a01b038416600081815261012e602090815260409182902086905581518481529081018690527f2a139b40b9bf8c89ae5053746323912620b9d8ea3b076b098b1bc57702abf3a5910160405180910390a250505050565b600054610100900460ff166115915760405162461bcd60e51b81526004016106a990611d64565b611599611787565b6104ab816117b6565b600054610100900460ff166115c95760405162461bcd60e51b81526004016106a990611d64565b61060b6117dd565b6000611626826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118109092919063ffffffff16565b90508051600014806116475750808060200190518101906116479190611d0d565b61056f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106a9565b60c95460ff161561060b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106a9565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60c95460ff1661060b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016106a9565b600054610100900460ff166117ae5760405162461bcd60e51b81526004016106a990611d64565b61060b611827565b600054610100900460ff166104a25760405162461bcd60e51b81526004016106a990611d64565b600054610100900460ff166118045760405162461bcd60e51b81526004016106a990611d64565b60c9805460ff19169055565b606061181f8484600085611857565b949350505050565b600054610100900460ff1661184e5760405162461bcd60e51b81526004016106a990611d64565b61060b336112a5565b6060824710156118b85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106a9565b600080866001600160a01b031685876040516118d49190611daf565b60006040518083038185875af1925050503d8060008114611911576040519150601f19603f3d011682016040523d82523d6000602084013e611916565b606091505b509150915061192787838387611932565b979650505050505050565b606083156119a157825160000361199a576001600160a01b0385163b61199a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106a9565b508161181f565b61181f83838151156119b65781518083602001fd5b8060405162461bcd60e51b81526004016106a99190611dcb565b6001600160a01b03811681146104ab57600080fd5b6000602082840312156119f757600080fd5b8135611a02816119d0565b9392505050565b60008083601f840112611a1b57600080fd5b50813567ffffffffffffffff811115611a3357600080fd5b6020830191508360208260051b8501011115611a4e57600080fd5b9250929050565b60008060208385031215611a6857600080fd5b823567ffffffffffffffff811115611a7f57600080fd5b611a8b85828601611a09565b90969095509350505050565b600080600060608486031215611aac57600080fd5b8335611ab7816119d0565b92506020840135611ac7816119d0565b929592945050506040919091013590565b600060208284031215611aea57600080fd5b5035919050565b60008060008060408587031215611b0757600080fd5b843567ffffffffffffffff80821115611b1f57600080fd5b611b2b88838901611a09565b90965094506020870135915080821115611b4457600080fd5b50611b5187828801611a09565b95989497509550505050565b60008060008060008060008060a0898b031215611b7957600080fd5b8835611b84816119d0565b9750602089013567ffffffffffffffff80821115611ba157600080fd5b611bad8c838d01611a09565b909950975060408b0135915080821115611bc657600080fd5b611bd28c838d01611a09565b909750955060608b0135915080821115611beb57600080fd5b50611bf88b828c01611a09565b999c989b50969995989497949560800135949350505050565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611c3957600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611c6957611c69611c40565b92915050565b8082028115828204841417611c6957611c69611c40565b80820180821115611c6957611c69611c40565b60005b83811015611cb4578181015183820152602001611c9c565b50506000910152565b60008151808452611cd5816020860160208601611c99565b601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009061181f90830184611cbd565b600060208284031215611d1f57600080fd5b81518015158114611a0257600080fd5b6001600160a01b03848116825283166020820152606060408201819052600090611d5b90830184611cbd565b95945050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251611dc1818460208701611c99565b9190910192915050565b602081526000611a026020830184611cbd56fe7365744d6178546f6b656e73446973747269627574696f6e537065656428616464726573735b5d2c75696e743235365b5d29736574546f6b656e73446973747269627574696f6e537065656428616464726573735b5d2c75696e743235365b5d29a26469706673582212200c9d46a058dbf3a96c4cd4ce25d3f05a6a88096bf609a1ae8de1fb215c20c2b864736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101e55760003560e01c806393920bf81161010f578063c7ad0895116100a2578063e30c397811610071578063e30c397814610439578063e458a65d1461044a578063f2fde38b1461045d578063fa7781ff1461047057600080fd5b8063c7ad0895146103e3578063c7ee005e1461040a578063ce82e8411461041e578063e1d146fb1461043157600080fd5b8063b4a0bdf3116100de578063b4a0bdf3146103ae578063bc2f7dc3146103bf578063be26317e146103c7578063c32094c7146103d057600080fd5b806393920bf8146103585780639d3cc5431461036b5780639dd5428e1461038c578063a666642b1461039b57600080fd5b8063637c9b4e1161018757806379ba50971161015657806379ba50971461030557806380d45a2d1461030d5780638aadf799146103205780638da5cb5b1461033357600080fd5b8063637c9b4e146102a257806364aff9ec146102c35780636857249c146102d6578063715018a6146102fd57600080fd5b80633131b065116101c35780633131b0651461024657806343bf7283146102595780635a38f84d146102835780635c975abb1461028b57600080fd5b80630e32cb86146101ea578063192e7a7b146101ff578063231f82bb14610212575b600080fd5b6101fd6101f83660046119e5565b61049a565b005b6101fd61020d3660046119e5565b6104ae565b6102336102203660046119e5565b61012e6020526000908152604090205481565b6040519081526020015b60405180910390f35b6101fd610254366004611a55565b610574565b6102336102673660046119e5565b6001600160a01b03166000908152610130602052604090205490565b6101fd6105ce565b60c95460ff165b604051901515815260200161023d565b6102336102b03660046119e5565b61012f6020526000908152604090205481565b6101fd6102d1366004611a97565b61060d565b6102337f000000000000000000000000000000000000000000000000000000000000000081565b6101fd610713565b6101fd610725565b6101fd61031b366004611ad8565b61079c565b6101fd61032e3660046119e5565b6107e3565b6033546001600160a01b03165b6040516001600160a01b03909116815260200161023d565b6101fd610366366004611af1565b610993565b6102336103793660046119e5565b6101306020526000908152604090205481565b610233670de0b6b3a764000081565b6102336103a93660046119e5565b610a41565b6097546001600160a01b0316610340565b6101fd610af8565b61023360fb5481565b6101fd6103de3660046119e5565b610b36565b6102927f000000000000000000000000000000000000000000000000000000000000000081565b61012d54610340906001600160a01b031681565b6101fd61042c366004611af1565b610bdb565b610233610cb0565b6065546001600160a01b0316610340565b6101fd610458366004611b5d565b610ce3565b6101fd61046b3660046119e5565b610ef0565b61023361047e3660046119e5565b6001600160a01b03166000908152610131602052604090205490565b6104a2610f69565b6104ab81610fc3565b50565b61012d546001600160a01b03163381146104db576040516348f5c3ed60e01b815260040160405180910390fd5b60c95460ff16156104ff5760405163f4eaf50160e01b815260040160405180910390fd5b610508826107e3565b6001600160a01b0382166000818152610131602090815260408083208054939055518281529192917fa80c25cc8959419d41ee66f93961c567b272badc10e0e117261a0ee31b55c312910160405180910390a261056f6001600160a01b0384168383611089565b505050565b61057c610f69565b80610586816110db565b60005b818110156105c8576105c08484838181106105a6576105a6611c11565b90506020020160208101906105bb91906119e5565b61110c565b600101610589565b50505050565b61060360405180604001604052806014815260200173706175736546756e64735472616e73666572282960601b8152506111ad565b61060b61124b565b565b610615610f69565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106809190611c27565b9050808211156106b25760405163cf47918160e01b815260048101839052602481018290526044015b60405180910390fd5b826001600160a01b0316846001600160a01b03167f6d25be279134f4ecaa4770aff0c3d916d9e7c5ef37b65ed95dbdba411f5d54d5846040516106f791815260200190565b60405180910390a36105c86001600160a01b0385168484611089565b61071b610f69565b61060b60006112a5565b60655433906001600160a01b031681146107935760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016106a9565b6104ab816112a5565b6107da6040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e7432353629000000000000008152506111ad565b6104ab816112be565b6107ec81611358565b6107f58161137f565b60006107ff610cb0565b6001600160a01b0383166000908152610130602052604090205490915080820390821461056f576001600160a01b038316600081815261012e60205260408082205490516370a0823160e01b81523060048201529092906370a0823190602401602060405180830381865afa15801561087c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a09190611c27565b6001600160a01b03861660009081526101316020526040812054919250906108c89083611c56565b905082158015906108d857508015155b156109715760006108e98486611c6f565b90506000818311156108fb57816108fd565b825b6001600160a01b0389166000908152610131602052604081208054929350839290919061092b908490611c86565b90915550506040518181526001600160a01b038916907ffe854c4c4e633d5bb31aec1f39f01d9f8f01ad2e0212a0e576825ac986af05899060200160405180910390a250505b505050506001600160a01b039190911660009081526101306020526040902055565b6109b4604051806060016040528060328152602001611ddf603291396111ad565b826109be816110db565b8082146109de576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610a3957610a318686838181106109fe576109fe611c11565b9050602002016020810190610a1391906119e5565b858584818110610a2557610a25611c11565b905060200201356113c5565b6001016109e1565b505050505050565b6001600160a01b038116600081815261012e60205260408082205490516370a0823160e01b8152306004820152919290918391906370a0823190602401602060405180830381865afa158015610a9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abf9190611c27565b6001600160a01b0385166000908152610131602052604090205490915080821115610aed5750909392505050565b506000949350505050565b610b2e60405180604001604052806015815260200174726573756d6546756e64735472616e73666572282960581b8152506111ad565b61060b611436565b610b3e610f69565b61012d546001600160a01b039081169082908116829003610b72576040516380ae98f560e01b815260040160405180910390fd5b610b7b83611358565b61012d546040516001600160a01b038086169216907fcf4d0ac7a2f943727f0189dd1f26ba0cde29a1b14f222163ac866d4f5167db9490600090a3505061012d80546001600160a01b0319166001600160a01b0392909216919091179055565b610bfc6040518060600160405280602f8152602001611e11602f91396111ad565b82610c06816110db565b808214610c26576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610a3957610c60868683818110610c4657610c46611c11565b9050602002016020810190610c5b91906119e5565b61137f565b610ca8868683818110610c7557610c75611c11565b9050602002016020810190610c8a91906119e5565b858584818110610c9c57610c9c611c11565b9050602002013561146f565b600101610c29565b6000610cde7f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b600054610100900460ff1615808015610d035750600054600160ff909116105b80610d1d5750303b158015610d1d575060005460ff166001145b610d805760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106a9565b6000805460ff191660011790558015610da3576000805461ff0019166101001790555b610dac89611358565b610db58961156a565b610dbd6115a2565b610dc6826112be565b86610dd0816110db565b8086141580610ddf5750808414155b15610dfd576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610e9d57610e1d8a8a838181106105a6576105a6611c11565b610e598a8a83818110610e3257610e32611c11565b9050602002016020810190610e4791906119e5565b878784818110610a2557610a25611c11565b610e958a8a83818110610e6e57610e6e611c11565b9050602002016020810190610e8391906119e5565b898984818110610c9c57610c9c611c11565b600101610e00565b50508015610ee5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b610ef8610f69565b606580546001600160a01b0383166001600160a01b03199091168117909155610f296033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b4390565b4290565b6033546001600160a01b0316331461060b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106a9565b6001600160a01b0381166110275760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b60648201526084016106a9565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091015b60405180910390a15050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261056f9084906115d1565b60fb548111156104ab5760fb5460405163792bfb1b60e11b81526004810191909152602481018290526044016106a9565b61111581611358565b600061111f610cb0565b6001600160a01b038316600090815261013060205260409020549091508015611166576040516303b51ceb60e11b81526001600160a01b03841660048201526024016106a9565b6001600160a01b03831660008181526101306020526040808220859055517fcf6e06116a82c1b468912f23d8bb1d126edbb21bc0864d6d5169e3be39b1a8189190a2505050565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906111e09033908690600401611ce9565b602060405180830381865afa1580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112219190611d0d565b90508061124757333083604051634a3fa29360e01b81526004016106a993929190611d2f565b5050565b6112536116a6565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586112883390565b6040516001600160a01b03909116815260200160405180910390a1565b606580546001600160a01b03191690556104ab816116ec565b60fb54811161131a5760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b60648201526084016106a9565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa910161107d565b6001600160a01b0381166104ab576040516317dbc4cb60e21b815260040160405180910390fd5b6001600160a01b0381166000908152610130602052604081205490819003611247576040516341ea4b5960e01b81526001600160a01b03831660048201526024016106a9565b6001600160a01b038216600081815261012e60209081526040918290205482519081529081018490527f2351eb1e51f0d96d3d2dc08e3c9bddbdb2153580843330b57433c3bf5031be01910160405180910390a26001600160a01b03909116600090815261012f6020526040902055565b61143e61173e565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611288565b6001600160a01b038216600090815261012f6020526040812054908190036114b957506001600160a01b038216600090815261012f60205260409020670de0b6b3a7640000908190555b808211156114e457604051631cf8f4dd60e11b815260048101839052602481018290526044016106a9565b6001600160a01b038316600090815261012e60205260409020548281146105c85761150e846107e3565b6001600160a01b038416600081815261012e602090815260409182902086905581518481529081018690527f2a139b40b9bf8c89ae5053746323912620b9d8ea3b076b098b1bc57702abf3a5910160405180910390a250505050565b600054610100900460ff166115915760405162461bcd60e51b81526004016106a990611d64565b611599611787565b6104ab816117b6565b600054610100900460ff166115c95760405162461bcd60e51b81526004016106a990611d64565b61060b6117dd565b6000611626826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118109092919063ffffffff16565b90508051600014806116475750808060200190518101906116479190611d0d565b61056f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106a9565b60c95460ff161561060b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106a9565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60c95460ff1661060b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016106a9565b600054610100900460ff166117ae5760405162461bcd60e51b81526004016106a990611d64565b61060b611827565b600054610100900460ff166104a25760405162461bcd60e51b81526004016106a990611d64565b600054610100900460ff166118045760405162461bcd60e51b81526004016106a990611d64565b60c9805460ff19169055565b606061181f8484600085611857565b949350505050565b600054610100900460ff1661184e5760405162461bcd60e51b81526004016106a990611d64565b61060b336112a5565b6060824710156118b85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106a9565b600080866001600160a01b031685876040516118d49190611daf565b60006040518083038185875af1925050503d8060008114611911576040519150601f19603f3d011682016040523d82523d6000602084013e611916565b606091505b509150915061192787838387611932565b979650505050505050565b606083156119a157825160000361199a576001600160a01b0385163b61199a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106a9565b508161181f565b61181f83838151156119b65781518083602001fd5b8060405162461bcd60e51b81526004016106a99190611dcb565b6001600160a01b03811681146104ab57600080fd5b6000602082840312156119f757600080fd5b8135611a02816119d0565b9392505050565b60008083601f840112611a1b57600080fd5b50813567ffffffffffffffff811115611a3357600080fd5b6020830191508360208260051b8501011115611a4e57600080fd5b9250929050565b60008060208385031215611a6857600080fd5b823567ffffffffffffffff811115611a7f57600080fd5b611a8b85828601611a09565b90969095509350505050565b600080600060608486031215611aac57600080fd5b8335611ab7816119d0565b92506020840135611ac7816119d0565b929592945050506040919091013590565b600060208284031215611aea57600080fd5b5035919050565b60008060008060408587031215611b0757600080fd5b843567ffffffffffffffff80821115611b1f57600080fd5b611b2b88838901611a09565b90965094506020870135915080821115611b4457600080fd5b50611b5187828801611a09565b95989497509550505050565b60008060008060008060008060a0898b031215611b7957600080fd5b8835611b84816119d0565b9750602089013567ffffffffffffffff80821115611ba157600080fd5b611bad8c838d01611a09565b909950975060408b0135915080821115611bc657600080fd5b611bd28c838d01611a09565b909750955060608b0135915080821115611beb57600080fd5b50611bf88b828c01611a09565b999c989b50969995989497949560800135949350505050565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611c3957600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611c6957611c69611c40565b92915050565b8082028115828204841417611c6957611c69611c40565b80820180821115611c6957611c69611c40565b60005b83811015611cb4578181015183820152602001611c9c565b50506000910152565b60008151808452611cd5816020860160208601611c99565b601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009061181f90830184611cbd565b600060208284031215611d1f57600080fd5b81518015158114611a0257600080fd5b6001600160a01b03848116825283166020820152606060408201819052600090611d5b90830184611cbd565b95945050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251611dc1818460208701611c99565b9190910192915050565b602081526000611a026020830184611cbd56fe7365744d6178546f6b656e73446973747269627574696f6e537065656428616464726573735b5d2c75696e743235365b5d29736574546f6b656e73446973747269627574696f6e537065656428616464726573735b5d2c75696e743235365b5d29a26469706673582212200c9d46a058dbf3a96c4cd4ce25d3f05a6a88096bf609a1ae8de1fb215c20c2b864736f6c63430008190033", + "devdoc": { + "author": "Venus", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + }, + "Paused(address)": { + "details": "Emitted when the pause is triggered by `account`." + }, + "Unpaused(address)": { + "details": "Emitted when the pause is lifted by `account`." + } + }, + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "accrueTokens(address)": { + "custom:event": "Emits TokensAccrued event", + "params": { + "token_": "Address of the token" + } + }, + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor" + }, + "getBlockNumberOrTimestamp()": { + "details": "Function to simply retrieve block number or block timestamp", + "returns": { + "_0": "Current block number or block timestamp" + } + }, + "getEffectiveDistributionSpeed(address)": { + "params": { + "token_": "Address of the token" + }, + "returns": { + "_0": "speed returns the per block or second reward" + } + }, + "initialize(address,address[],uint256[],uint256[],uint256)": { + "custom:error": "Throw InvalidArguments on different length of tokens and speeds array", + "details": "Initializes the deployer to owner", + "params": { + "accessControlManager_": "AccessControlManager contract address", + "distributionSpeeds_": "New distribution speeds for tokens", + "loopsLimit_": "Maximum number of loops allowed in a single transaction", + "tokens_": "Array of addresses of the tokens" + } + }, + "initializeTokens(address[])": { + "custom:access": "Only Governance", + "params": { + "tokens_": "Array of addresses of the tokens to be intialized" + } + }, + "lastAccruedBlock(address)": { + "params": { + "token_": "Address of the token" + }, + "returns": { + "_0": "blockNumberOrSecond returns the last accrued block or second" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pauseFundsTransfer()": { + "custom:access": "Controlled by ACM" + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "releaseFunds(address)": { + "custom:error": "Throw InvalidArguments on Zero address(token)Throw FundsTransferIsPaused is pausedThrow InvalidCaller if the sender is not the Prime contract", + "custom:event": "Emits TokenTransferredToPrime event", + "params": { + "token_": "The token to release to the Prime contract" + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." + }, + "resumeFundsTransfer()": { + "custom:access": "Controlled by ACM" + }, + "setAccessControlManager(address)": { + "custom:access": "Only Governance", + "custom:event": "Emits NewAccessControlManager event", + "details": "Admin function to set address of AccessControlManager", + "params": { + "accessControlManager_": "The new address of the AccessControlManager" + } + }, + "setMaxLoopsLimit(uint256)": { + "custom:access": "Controlled by ACM", + "custom:event": "Emits MaxLoopsLimitUpdated event on success", + "params": { + "loopsLimit": "Limit for the max loops can execute at a time" + } + }, + "setMaxTokensDistributionSpeed(address[],uint256[])": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw InvalidArguments on different length of tokens and speeds array", + "params": { + "maxDistributionSpeeds_": "New distribution speeds for tokens", + "tokens_": "Array of addresses of the tokens" + } + }, + "setPrimeToken(address)": { + "custom:access": "Only owner", + "custom:event": "Emits PrimeTokenUpdated event", + "params": { + "prime_": "The new address of the prime token contract" + } + }, + "setTokensDistributionSpeed(address[],uint256[])": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw InvalidArguments on different length of tokens and speeds array", + "params": { + "distributionSpeeds_": "New distribution speeds for tokens", + "tokens_": "Array of addresses of the tokens" + } + }, + "sweepToken(address,address,uint256)": { + "custom:access": "Only Governance", + "custom:error": "Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract", + "custom:event": "Emits SweepToken event", + "params": { + "amount_": "The amount of tokens needs to transfer", + "to_": "The address of the recipient", + "token_": "The address of the ERC-20 token to sweep" + } + }, + "tokenAmountAccrued(address)": { + "params": { + "token_": "Address of the token" + }, + "returns": { + "_0": "returns the amount of accrued tokens for the token provided" + } + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "title": "PrimeLiquidityProvider", + "version": 1 + }, + "userdoc": { + "errors": { + "AddressesMustDiffer()": [ + { + "notice": "Error thrown when argument value in setter is same as previous value" + } + ], + "FundsTransferIsPaused()": [ + { + "notice": "Error thrown when funds transfer is paused" + } + ], + "InsufficientBalance(uint256,uint256)": [ + { + "notice": "Error thrown when PrimeLiquidityProvider's balance is less than sweep amount" + } + ], + "InvalidArguments()": [ + { + "notice": "Thrown when arguments are passed are invalid" + } + ], + "InvalidBlocksPerYear()": [ + { + "notice": "Thrown when blocks per year is invalid" + } + ], + "InvalidCaller()": [ + { + "notice": "Thrown when caller is not the desired caller" + } + ], + "InvalidDistributionSpeed(uint256,uint256)": [ + { + "notice": "Thrown when distribution speed is greater than maxTokenDistributionSpeeds[tokenAddress]" + } + ], + "InvalidTimeBasedConfiguration()": [ + { + "notice": "Thrown when time based but blocks per year is provided" + } + ], + "MaxLoopsLimitExceeded(uint256,uint256)": [ + { + "notice": "Thrown an error on maxLoopsLimit exceeds for any loop" + } + ], + "TokenAlreadyInitialized(address)": [ + { + "notice": "Thrown when token is initialized" + } + ], + "TokenNotInitialized(address)": [ + { + "notice": "Error thrown when accrueTokens is called for an uninitialized token" + } + ], + "Unauthorized(address,address,string)": [ + { + "notice": "Thrown when the action is prohibited by AccessControlManager" + } + ] + }, + "events": { + "MaxLoopsLimitUpdated(uint256,uint256)": { + "notice": "Emitted when max loops limit is set" + }, + "MaxTokenDistributionSpeedUpdated(address,uint256,uint256)": { + "notice": "Emitted when a new max distribution speed for token is set" + }, + "NewAccessControlManager(address,address)": { + "notice": "Emitted when access control manager contract address is changed" + }, + "PrimeTokenUpdated(address,address)": { + "notice": "Emitted when prime token contract address is changed" + }, + "SweepToken(address,address,uint256)": { + "notice": "Emitted on sweep token success" + }, + "TokenDistributionInitialized(address)": { + "notice": "Emitted when a token distribution is initialized" + }, + "TokenDistributionSpeedUpdated(address,uint256,uint256)": { + "notice": "Emitted when a new token distribution speed is set" + }, + "TokenTransferredToPrime(address,uint256)": { + "notice": "Emitted when token is transferred to the prime contract" + }, + "TokensAccrued(address,uint256)": { + "notice": "Emitted when distribution state(Index and block or second) is updated" + } + }, + "kind": "user", + "methods": { + "DEFAULT_MAX_DISTRIBUTION_SPEED()": { + "notice": "The default max token distribution speed" + }, + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "accrueTokens(address)": { + "notice": "Accrue token by updating the distribution state" + }, + "blocksOrSecondsPerYear()": { + "notice": "Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored" + }, + "getEffectiveDistributionSpeed(address)": { + "notice": "Get rewards per block or second for token" + }, + "initialize(address,address[],uint256[],uint256[],uint256)": { + "notice": "PrimeLiquidityProvider initializer" + }, + "initializeTokens(address[])": { + "notice": "Initialize the distribution of the token" + }, + "isTimeBased()": { + "notice": "Acknowledges if a contract is time based or not" + }, + "lastAccruedBlock(address)": { + "notice": "Get the last accrued block or second for token" + }, + "lastAccruedBlockOrSecond(address)": { + "notice": "The block or second till which rewards are distributed for an asset" + }, + "maxTokenDistributionSpeeds(address)": { + "notice": "The max token distribution speed for token" + }, + "pauseFundsTransfer()": { + "notice": "Pause fund transfer of tokens to Prime contract" + }, + "prime()": { + "notice": "Address of the Prime contract" + }, + "releaseFunds(address)": { + "notice": "Claim all the token accrued till last block or second" + }, + "resumeFundsTransfer()": { + "notice": "Resume fund transfer of tokens to Prime contract" + }, + "setAccessControlManager(address)": { + "notice": "Sets the address of AccessControlManager" + }, + "setMaxLoopsLimit(uint256)": { + "notice": "Set the limit for the loops can iterate to avoid the DOS" + }, + "setMaxTokensDistributionSpeed(address[],uint256[])": { + "notice": "Set max distribution speed for token (amount of maximum token distribute per block or second)" + }, + "setPrimeToken(address)": { + "notice": "Set the prime token contract address" + }, + "setTokensDistributionSpeed(address[],uint256[])": { + "notice": "Set distribution speed (amount of token distribute per block or second)" + }, + "sweepToken(address,address,uint256)": { + "notice": "A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user" + }, + "tokenAmountAccrued(address)": { + "notice": "Get the tokens accrued" + }, + "tokenDistributionSpeeds(address)": { + "notice": "The rate at which token is distributed (per block or second)" + } + }, + "notice": "PrimeLiquidityProvider is used to fund Prime", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 246, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 249, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1516, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 118, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 238, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 11, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 105, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 5863, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_accessControlManager", + "offset": 0, + "slot": "151", + "type": "t_contract(IAccessControlManagerV8)6048" + }, + { + "astId": 5868, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 430, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_paused", + "offset": 0, + "slot": "201", + "type": "t_bool" + }, + { + "astId": 535, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "202", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 6105, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "maxLoopsLimit", + "offset": 0, + "slot": "251", + "type": "t_uint256" + }, + { + "astId": 6110, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "252", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 22562, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "prime", + "offset": 0, + "slot": "301", + "type": "t_address" + }, + { + "astId": 22567, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "tokenDistributionSpeeds", + "offset": 0, + "slot": "302", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22572, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "maxTokenDistributionSpeeds", + "offset": 0, + "slot": "303", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22577, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "lastAccruedBlockOrSecond", + "offset": 0, + "slot": "304", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22582, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_tokenAmountAccrued", + "offset": 0, + "slot": "305", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22587, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "306", + "type": "t_array(t_uint256)45_storage" + }, + { + "astId": 6191, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "351", + "type": "t_array(t_uint256)48_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)45_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[45]", + "numberOfBytes": "1440" + }, + "t_array(t_uint256)48_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IAccessControlManagerV8)6048": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV8", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/opmainnet/PrimeLiquidityProvider_Proxy.json b/deployments/opmainnet/PrimeLiquidityProvider_Proxy.json new file mode 100644 index 000000000..102e5aa4a --- /dev/null +++ b/deployments/opmainnet/PrimeLiquidityProvider_Proxy.json @@ -0,0 +1,272 @@ +{ + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "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": [], + "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": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "transactionIndex": 22, + "gasUsed": "634674", + "logsBloom": "0x00000400000000000000000000000000400000000000000004800000000000000000000000000000000000000000000100020000000000000000000000008000040000000000000000000000000002000001000000000000000000000000000000000000020000000000000000000800000000800000000000000080000000400020000000000000000000000000000000000000000080000000000000800000000000000000000000002000000400000000000000800004000000000000000000000020000000000000000001040000000000000400000000000000000020000000000200000000000000000000000000000800000800000000000000000000", + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21", + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "logs": [ + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000f3b8d6b1778548f975d6ebebd8a8e515832cfb0a" + ], + "data": "0x", + "logIndex": 136, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000c76363b887031e79e6a2954c5515f5e5507a6387" + ], + "data": "0x", + "logIndex": 137, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d71b1f33f6b0259683f11174ee4ddc2bb9ce4ed6", + "logIndex": 138, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": ["0xc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014", + "logIndex": 139, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 140, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + }, + { + "transactionIndex": 22, + "blockNumber": 126396240, + "transactionHash": "0x20f911a6cba3ccae315b381257abb588a52be7fd2f055473ec020322c19de39b", + "address": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eaf9490cbea6ff9ba1d23671c39a799ced0dced2", + "logIndex": 141, + "blockHash": "0xe2d67cef350e673dc909642f7a5420050e62177383f98b59bf6a3504ac040b21" + } + ], + "blockNumber": 126396240, + "cumulativeGasUsed": "6810714", + "status": 1, + "byzantium": true + }, + "args": [ + "0xF3B8d6b1778548F975D6eBebD8a8e515832Cfb0a", + "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "0xe458a65d000000000000000000000000d71b1f33f6b0259683f11174ee4ddc2bb9ce4ed600000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"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\":[],\"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.\",\"events\":{\"AdminChanged(address,address)\":{\"details\":\"Emitted when the admin account has changed.\"},\"BeaconUpgraded(address)\":{\"details\":\"Emitted when the beacon is upgraded.\"},\"Upgraded(address)\":{\"details\":\"Emitted when the implementation is upgraded.\"}},\"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`\"},\"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\":{\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\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 _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a0604052604051610d1a380380610d1a833981016040819052610022916103d2565b828161004f60017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6104a2565b600080516020610cd38339815191521461006b5761006b6104c3565b61007782826000610128565b506100a5905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046104a2565b600080516020610cb3833981519152146100c1576100c16104c3565b6001600160a01b0382166080819052600080516020610cb38339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050610528565b61013183610154565b60008251118061013e5750805b1561014f5761014d8383610194565b505b505050565b61015d816101c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606101b98383604051806060016040528060278152602001610cf360279139610263565b90505b92915050565b6001600160a01b0381163b6102345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b600080516020610cd383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6102cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161022b565b600080856001600160a01b0316856040516102e691906104d9565b600060405180830381855af49150503d8060008114610321576040519150601f19603f3d011682016040523d82523d6000602084013e610326565b606091505b509092509050610337828286610343565b925050505b9392505050565b6060831561035257508161033c565b8251156103625782518084602001fd5b8160405162461bcd60e51b815260040161022b91906104f5565b80516001600160a01b038116811461039357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103c95781810151838201526020016103b1565b50506000910152565b6000806000606084860312156103e757600080fd5b6103f08461037c565b92506103fe6020850161037c565b60408501519092506001600160401b038082111561041b57600080fd5b818601915086601f83011261042f57600080fd5b81518181111561044157610441610398565b604051601f8201601f19908116603f0116810190838211818310171561046957610469610398565b8160405282815289602084870101111561048257600080fd5b6104938360208301602088016103ae565b80955050505050509250925092565b818103818111156101bc57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600082516104eb8184602087016103ae565b9190910192915050565b60208152600082518060208401526105148160408501602087016103ae565b601f01601f19169190910160400192915050565b60805161074e6105656000396000818160ef01528181610145015281816101c701528181610211015281816102420152610266015261074e6000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033", + "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.", + "events": { + "AdminChanged(address,address)": { + "details": "Emitted when the admin account has changed." + }, + "BeaconUpgraded(address)": { + "details": "Emitted when the beacon is upgraded." + }, + "Upgraded(address)": { + "details": "Emitted when the implementation is upgraded." + } + }, + "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`" + }, + "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/deployments/opmainnet/Prime_Implementation.json b/deployments/opmainnet/Prime_Implementation.json new file mode 100644 index 000000000..f12d5a3d1 --- /dev/null +++ b/deployments/opmainnet/Prime_Implementation.json @@ -0,0 +1,2966 @@ +{ + "address": "0x7DCF81746fFA44C4469eBA2F6Db86AE3d5f92b10", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_wrappedNativeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_nativeMarket", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_stakingPeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_minimumStakedXVS", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maximumXVSCap", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_timeBased", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AssetAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "ExpTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "IneligibleToClaim", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAlphaArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidComptroller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFixedPoint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "d", + "type": "uint256" + } + ], + "name": "InvalidFraction", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLimit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimestamp", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVToken", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnNonRealResult", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "MarketAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MarketNotSupported", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NoScoreUpdatesRequired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "UserHasNoPrimeToken", + "type": "error" + }, + { + "inputs": [], + "name": "WaitMoreTime", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "oldNumerator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "newNumerator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "AlphaUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InterestClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "oldIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldRevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "newIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRevocableLimit", + "type": "uint256" + } + ], + "name": "MintLimitsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldBorrowMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowMultiplier", + "type": "uint256" + } + ], + "name": "MultiplierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "StakedAtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "TokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "UserScoreUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAXIMUM_XVS_CAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_STAKED_XVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_MARKET", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WRAPPED_NATIVE_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "accrueInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + } + ], + "name": "accrueInterestAndUpdateScore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "addMarket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alphaDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alphaNumerator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "calculateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimTimeRemaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsStaked", + "type": "uint256" + } + ], + "name": "estimateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getInterestAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct PrimeStorageV1.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "incomeDistributionYearly", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "xvsVault_", + "type": "address" + }, + { + "internalType": "address", + "name": "xvsVaultRewardToken_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "xvsVaultPoolId_", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "alphaNumerator_", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "alphaDenominator_", + "type": "uint128" + }, + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "primeLiquidityProvider_", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolRegistry_", + "type": "address" + } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "interests", + "outputs": [ + { + "internalType": "uint256", + "name": "accrued", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "irrevocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isScoreUpdated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserPrimeHolder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "issue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sumOfMembersScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextScoreUpdateRoundId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "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": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingScoreUpdates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primeLiquidityProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_irrevocableLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_revocableLimit", + "type": "uint256" + } + ], + "name": "setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "timestamps", + "type": "uint256[]" + } + ], + "name": "setStakedAt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "stakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIrrevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalScoreUpdatesRequired", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unreleasedPLPIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_alphaNumerator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_alphaDenominator", + "type": "uint128" + } + ], + "name": "updateAlpha", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "updateMultipliers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "updateScores", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "vTokenForAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "xvsUpdated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xa7217e6a7a6fb74fc47ebd6b3d81d7fcc7ca463ec9ac7dc8f184d62a83e135a0", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0x7DCF81746fFA44C4469eBA2F6Db86AE3d5f92b10", + "transactionIndex": 11, + "gasUsed": "5170093", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040400000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000", + "blockHash": "0x5f1ef67478bc7717b2f40b5c7b0197b44560a9da0fa94677dbfe59aa9138ef13", + "transactionHash": "0xa7217e6a7a6fb74fc47ebd6b3d81d7fcc7ca463ec9ac7dc8f184d62a83e135a0", + "logs": [ + { + "transactionIndex": 11, + "blockNumber": 126396246, + "transactionHash": "0xa7217e6a7a6fb74fc47ebd6b3d81d7fcc7ca463ec9ac7dc8f184d62a83e135a0", + "address": "0x7DCF81746fFA44C4469eBA2F6Db86AE3d5f92b10", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 7, + "blockHash": "0x5f1ef67478bc7717b2f40b5c7b0197b44560a9da0fa94677dbfe59aa9138ef13" + } + ], + "blockNumber": 126396246, + "cumulativeGasUsed": "5612574", + "status": 1, + "byzantium": true + }, + "args": [ + "0x0000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000", + 0, + 7776000, + "1000000000000000000000", + "100000000000000000000000", + true + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wrappedNativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_nativeMarket\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_blocksPerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_stakingPeriod\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_minimumStakedXVS\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maximumXVSCap\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_timeBased\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AssetAlreadyExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"x\",\"type\":\"int256\"}],\"name\":\"ExpTooLarge\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IneligibleToClaim\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAlphaArguments\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidBlocksPerYear\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidComptroller\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidFixedPoint\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"n\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"d\",\"type\":\"uint256\"}],\"name\":\"InvalidFraction\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidLength\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidLimit\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTimeBasedConfiguration\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTimestamp\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidVToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"x\",\"type\":\"int256\"}],\"name\":\"LnNonRealResult\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"x\",\"type\":\"int256\"}],\"name\":\"LnTooLarge\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MarketAlreadyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MarketNotSupported\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"loopsLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredLoops\",\"type\":\"uint256\"}],\"name\":\"MaxLoopsLimitExceeded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NoScoreUpdatesRequired\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"calledContract\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"methodSignature\",\"type\":\"string\"}],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UserHasNoPrimeToken\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WaitMoreTime\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"oldNumerator\",\"type\":\"uint128\"},{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"oldDenominator\",\"type\":\"uint128\"},{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"newNumerator\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"newDenominator\",\"type\":\"uint128\"}],\"name\":\"AlphaUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"Burn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"InterestClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"supplyMultiplier\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowMultiplier\",\"type\":\"uint256\"}],\"name\":\"MarketAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldMaxLoopsLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newmaxLoopsLimit\",\"type\":\"uint256\"}],\"name\":\"MaxLoopsLimitUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isIrrevocable\",\"type\":\"bool\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldIrrevocableLimit\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldRevocableLimit\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newIrrevocableLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newRevocableLimit\",\"type\":\"uint256\"}],\"name\":\"MintLimitsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldSupplyMultiplier\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldBorrowMultiplier\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSupplyMultiplier\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBorrowMultiplier\",\"type\":\"uint256\"}],\"name\":\"MultiplierUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"StakedAtUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"TokenUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"UserScoreUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAXIMUM_XVS_CAP\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINIMUM_STAKED_XVS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NATIVE_MARKET\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"STAKING_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WRAPPED_NATIVE_TOKEN\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV8\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"accrueInterest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"}],\"name\":\"accrueInterestAndUpdateScore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"supplyMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMultiplier\",\"type\":\"uint256\"}],\"name\":\"addMarket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"alphaDenominator\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"alphaNumerator\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blocksOrSecondsPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"calculateAPR\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"supplyAPR\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowAPR\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"userScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"xvsBalanceForScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"capital\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cappedSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cappedBorrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplyCapUSD\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowCapUSD\",\"type\":\"uint256\"}],\"internalType\":\"struct IPrime.APRInfo\",\"name\":\"aprInfo\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"claimInterest\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"claimInterest\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"claimTimeRemaining\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"comptroller\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"xvsStaked\",\"type\":\"uint256\"}],\"name\":\"estimateAPR\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"supplyAPR\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowAPR\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"userScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"xvsBalanceForScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"capital\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cappedSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cappedBorrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplyCapUSD\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowCapUSD\",\"type\":\"uint256\"}],\"internalType\":\"struct IPrime.APRInfo\",\"name\":\"aprInfo\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllMarkets\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumberOrTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getInterestAccrued\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getPendingRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"struct PrimeStorageV1.PendingReward[]\",\"name\":\"pendingRewards\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"incomeDistributionYearly\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"xvsVault_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"xvsVaultRewardToken_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"xvsVaultPoolId_\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"alphaNumerator_\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"alphaDenominator_\",\"type\":\"uint128\"},{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"primeLiquidityProvider_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"oracle_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"loopsLimit_\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolRegistry_\",\"type\":\"address\"}],\"name\":\"initializeV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"interests\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"accrued\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"score\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardIndex\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"irrevocableLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isScoreUpdated\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isTimeBased\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"isUserPrimeHolder\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"isIrrevocable\",\"type\":\"bool\"},{\"internalType\":\"address[]\",\"name\":\"users\",\"type\":\"address[]\"}],\"name\":\"issue\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"markets\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"supplyMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"sumOfMembersScore\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"exists\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxLoopsLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextScoreUpdateRoundId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"outputs\":[{\"internalType\":\"contract ResilientOracleInterface\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"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\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingScoreUpdates\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"poolRegistry\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"primeLiquidityProvider\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"revocableLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"setAccessControlManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_irrevocableLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_revocableLimit\",\"type\":\"uint256\"}],\"name\":\"setLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"loopsLimit\",\"type\":\"uint256\"}],\"name\":\"setMaxLoopsLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"users\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"timestamps\",\"type\":\"uint256[]\"}],\"name\":\"setStakedAt\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"stakedAt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"togglePause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"tokens\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"exists\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isIrrevocable\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalIrrevocable\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalRevocable\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalScoreUpdatesRequired\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"unreleasedPLPIncome\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"_alphaNumerator\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"_alphaDenominator\",\"type\":\"uint128\"}],\"name\":\"updateAlpha\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"supplyMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMultiplier\",\"type\":\"uint256\"}],\"name\":\"updateMultipliers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"users\",\"type\":\"address[]\"}],\"name\":\"updateScores\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"vTokenForAsset\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"xvsUpdated\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"xvsVault\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"xvsVaultPoolId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"xvsVaultRewardToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"custom:security-contact\":\"https://github.com/VenusProtocol/venus-protocol\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"Paused(address)\":{\"details\":\"Emitted when the pause is triggered by `account`.\"},\"Unpaused(address)\":{\"details\":\"Emitted when the pause is lifted by `account`.\"}},\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"accrueInterest(address)\":{\"custom:error\":\"Throw MarketNotSupported if market is not supported\",\"params\":{\"vToken\":\"the market for which to distribute the income\"}},\"accrueInterestAndUpdateScore(address,address)\":{\"params\":{\"market\":\"the market for which to accrue interest and update score\",\"user\":\"the account address for which to accrue interest and update score\"}},\"addMarket(address,address,uint256,uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw MarketAlreadyExists if market already existsThrow InvalidVToken if market is not valid\",\"custom:event\":\"Emits MarketAdded event\",\"params\":{\"borrowMultiplier\":\"the multiplier for borrow cap. It should be converted to 1e18\",\"comptroller\":\"address of the comptroller\",\"market\":\"address of the market vToken\",\"supplyMultiplier\":\"the multiplier for supply cap. It should be converted to 1e18\"}},\"burn(address)\":{\"custom:access\":\"Controlled by ACM\",\"params\":{\"user\":\"the account address for which the prime token will be burned\"}},\"calculateAPR(address,address)\":{\"params\":{\"market\":\"the market for which to fetch the APR\",\"user\":\"the account for which to get the APR\"},\"returns\":{\"aprInfo\":\"APR information for the user for the given market\"}},\"claimInterest(address)\":{\"params\":{\"vToken\":\"the market for which claim the accrued interest\"},\"returns\":{\"_0\":\"amount the amount of tokens transferred to the msg.sender\"}},\"claimInterest(address,address)\":{\"params\":{\"user\":\"the user for which to claim the accrued interest\",\"vToken\":\"the market for which claim the accrued interest\"},\"returns\":{\"_0\":\"amount the amount of tokens transferred to the user\"}},\"claimTimeRemaining(address)\":{\"params\":{\"user\":\"the account address for which we are checking the remaining time\"},\"returns\":{\"_0\":\"timeRemaining the number of seconds the user needs to wait to claim prime token\"}},\"comptroller()\":{\"returns\":{\"_0\":\"the core pool comptroller address\"}},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"estimateAPR(address,address,uint256,uint256,uint256)\":{\"params\":{\"market\":\"the market for which to fetch the APR\",\"user\":\"the account for which to get the APR\"},\"returns\":{\"aprInfo\":\"APR information for the user for the given market\"}},\"getAllMarkets()\":{\"returns\":{\"_0\":\"an array of addresses representing all available markets\"}},\"getBlockNumberOrTimestamp()\":{\"details\":\"Function to simply retrieve block number or block timestamp\",\"returns\":{\"_0\":\"Current block number or block timestamp\"}},\"getInterestAccrued(address,address)\":{\"params\":{\"user\":\"the account for which to get the accrued interest\",\"vToken\":\"the market for which to fetch the accrued interest\"},\"returns\":{\"_0\":\"interestAccrued the number of underlying tokens accrued by the user since the last accrual\"}},\"getPendingRewards(address)\":{\"params\":{\"user\":\"the account for which to get the accrued interests\"},\"returns\":{\"pendingRewards\":\"the number of underlying tokens accrued by the user for all markets\"}},\"incomeDistributionYearly(address)\":{\"params\":{\"vToken\":\"the market for which to fetch the total income that's going to distributed in a year\"},\"returns\":{\"amount\":\"the total income\"}},\"initialize(address,address,uint256,uint128,uint128,address,address,address,address,uint256)\":{\"custom:error\":\"Throw InvalidAddress if any of the address is invalid\",\"params\":{\"accessControlManager_\":\"Address of AccessControlManager\",\"alphaDenominator_\":\"denominator of alpha. If alpha is 0.5 then denominator is 2. alpha is alphaNumerator_/alphaDenominator_. So, 0 < alpha < 1\",\"alphaNumerator_\":\"numerator of alpha. If alpha is 0.5 then numerator is 1. alphaDenominator_ must be greater than alphaNumerator_, alphaDenominator_ cannot be zero and alphaNumerator_ cannot be zero\",\"comptroller_\":\"Address of core pool comptroller\",\"loopsLimit_\":\"Maximum number of loops allowed in a single transaction\",\"oracle_\":\"Address of Oracle\",\"primeLiquidityProvider_\":\"Address of PrimeLiquidityProvider\",\"xvsVaultPoolId_\":\"Pool id of XVSVault\",\"xvsVaultRewardToken_\":\"Address of XVSVault reward token\",\"xvsVault_\":\"Address of XVSVault\"}},\"initializeV2(address)\":{\"params\":{\"poolRegistry_\":\"Address of IL pool registry\"}},\"isUserPrimeHolder(address)\":{\"returns\":{\"_0\":\"isPrimeHolder true if user is a prime holder\"}},\"issue(bool,address[])\":{\"custom:access\":\"Controlled by ACM\",\"params\":{\"isIrrevocable\":\"are the tokens being issued\",\"users\":\"list of address to issue tokens to\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"setAccessControlManager(address)\":{\"custom:access\":\"Only Governance\",\"custom:event\":\"Emits NewAccessControlManager event\",\"details\":\"Admin function to set address of AccessControlManager\",\"params\":{\"accessControlManager_\":\"The new address of the AccessControlManager\"}},\"setLimit(uint256,uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw InvalidLimit if any of the limit is less than total tokens minted\",\"custom:event\":\"Emits MintLimitsUpdated event\",\"params\":{\"_irrevocableLimit\":\"total number of irrevocable tokens that can be minted\",\"_revocableLimit\":\"total number of revocable tokens that can be minted\"}},\"setMaxLoopsLimit(uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:event\":\"Emits MaxLoopsLimitUpdated event on success\",\"params\":{\"loopsLimit\":\"Number of loops limit\"}},\"setStakedAt(address[],uint256[])\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw InvalidLength if users and timestamps length are not equal\",\"custom:event\":\"Emits StakedAtUpdated event for each user\",\"params\":{\"timestamps\":\"new staked at timestamp for the users\",\"users\":\"accounts for which we need to update staked at timestamp\"}},\"togglePause()\":{\"custom:access\":\"Controlled by ACM\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"},\"updateAlpha(uint128,uint128)\":{\"custom:access\":\"Controlled by ACM\",\"custom:event\":\"Emits AlphaUpdated event\",\"params\":{\"_alphaDenominator\":\"denominator of alpha. If alpha is 0.5 then denominator is 2\",\"_alphaNumerator\":\"numerator of alpha. If alpha is 0.5 then numerator is 1\"}},\"updateMultipliers(address,uint256,uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw MarketNotSupported if market is not supported\",\"custom:event\":\"Emits MultiplierUpdated event\",\"params\":{\"borrowMultiplier\":\"new borrow multiplier for the market, scaled by 1e18\",\"market\":\"address of the market vToken\",\"supplyMultiplier\":\"new supply multiplier for the market, scaled by 1e18\"}},\"updateScores(address[])\":{\"custom:error\":\"Throw NoScoreUpdatesRequired if no score updates are requiredThrow UserHasNoPrimeToken if user has no prime token\",\"custom:event\":\"Emits UserScoreUpdated event\",\"params\":{\"users\":\"accounts for which we need to update score\"}},\"xvsUpdated(address)\":{\"params\":{\"user\":\"the account address whose balance was updated\"}}},\"stateVariables\":{\"MAXIMUM_XVS_CAP\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"MINIMUM_STAKED_XVS\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"NATIVE_MARKET\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"STAKING_PERIOD\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"WRAPPED_NATIVE_TOKEN\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"Prime\",\"version\":1},\"userdoc\":{\"errors\":{\"AssetAlreadyExists()\":[{\"notice\":\"Error thrown when asset already exists\"}],\"ExpTooLarge(int256)\":[{\"notice\":\"Thrown when exp is given too large of an argument\"}],\"IneligibleToClaim()\":[{\"notice\":\"Error thrown when user is not eligible to claim prime token\"}],\"InvalidAddress()\":[{\"notice\":\"Error thrown when invalid address is passed\"}],\"InvalidAlphaArguments()\":[{\"notice\":\"Error thrown when invalid alpha arguments are passed\"}],\"InvalidBlocksPerYear()\":[{\"notice\":\"Thrown when blocks per year is invalid\"}],\"InvalidComptroller()\":[{\"notice\":\"Error thrown when invalid comptroller is passed\"}],\"InvalidLength()\":[{\"notice\":\"Error thrown when invalid length is passed\"}],\"InvalidLimit()\":[{\"notice\":\"Error thrown when mint limit is reached\"}],\"InvalidTimeBasedConfiguration()\":[{\"notice\":\"Thrown when time based but blocks per year is provided\"}],\"InvalidTimestamp()\":[{\"notice\":\"Error thrown when timestamp is invalid\"}],\"InvalidVToken()\":[{\"notice\":\"Error thrown when invalid vToken is passed\"}],\"LnNonRealResult(int256)\":[{\"notice\":\"Thrown when the natural log would have returned a number outside of \\u211d\"}],\"LnTooLarge(int256)\":[{\"notice\":\"Thrown when the natural log function is given too large of an argument\"}],\"MarketAlreadyExists()\":[{\"notice\":\"Error thrown when market already exists\"}],\"MarketNotSupported()\":[{\"notice\":\"Error thrown when market is not supported\"}],\"MaxLoopsLimitExceeded(uint256,uint256)\":[{\"notice\":\"Thrown an error on maxLoopsLimit exceeds for any loop\"}],\"NoScoreUpdatesRequired()\":[{\"notice\":\"Error thrown when no score updates are required\"}],\"Unauthorized(address,address,string)\":[{\"notice\":\"Thrown when the action is prohibited by AccessControlManager\"}],\"UserHasNoPrimeToken()\":[{\"notice\":\"Error thrown when user has no prime token\"}],\"WaitMoreTime()\":[{\"notice\":\"Error thrown when user needs to wait more time to claim prime token\"}]},\"events\":{\"AlphaUpdated(uint128,uint128,uint128,uint128)\":{\"notice\":\"Emitted when alpha is updated\"},\"Burn(address)\":{\"notice\":\"Emitted when prime token is burned\"},\"InterestClaimed(address,address,uint256)\":{\"notice\":\"Emitted when interest is claimed\"},\"MarketAdded(address,address,uint256,uint256)\":{\"notice\":\"Emitted when a market is added to prime program\"},\"MaxLoopsLimitUpdated(uint256,uint256)\":{\"notice\":\"Emitted when max loops limit is set\"},\"Mint(address,bool)\":{\"notice\":\"Emitted when prime token is minted\"},\"MintLimitsUpdated(uint256,uint256,uint256,uint256)\":{\"notice\":\"Emitted when mint limits are updated\"},\"MultiplierUpdated(address,uint256,uint256,uint256,uint256)\":{\"notice\":\"Emitted when multiplier is updated\"},\"NewAccessControlManager(address,address)\":{\"notice\":\"Emitted when access control manager contract address is changed\"},\"StakedAtUpdated(address,uint256)\":{\"notice\":\"Emitted when stakedAt is updated\"},\"TokenUpgraded(address)\":{\"notice\":\"Emitted when revocable token is upgraded to irrevocable token\"},\"UserScoreUpdated(address)\":{\"notice\":\"Emitted when user score is updated\"}},\"kind\":\"user\",\"methods\":{\"MAXIMUM_XVS_CAP()\":{\"notice\":\"maximum XVS taken in account when calculating user score\"},\"MINIMUM_STAKED_XVS()\":{\"notice\":\"minimum amount of XVS user needs to stake to become a prime member\"},\"NATIVE_MARKET()\":{\"notice\":\"address of native market contract\"},\"STAKING_PERIOD()\":{\"notice\":\"number of days user need to stake to claim prime token\"},\"WRAPPED_NATIVE_TOKEN()\":{\"notice\":\"address of wrapped native token contract\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"accrueInterest(address)\":{\"notice\":\"Distributes income from market since last distribution\"},\"accrueInterestAndUpdateScore(address,address)\":{\"notice\":\"accrues interes and updates score for an user for a specific market\"},\"addMarket(address,address,uint256,uint256)\":{\"notice\":\"Add a market to prime program\"},\"alphaDenominator()\":{\"notice\":\"denominator of alpha. Ex: if alpha is 0.5 then this will be 2\"},\"alphaNumerator()\":{\"notice\":\"numerator of alpha. Ex: if alpha is 0.5 then this will be 1\"},\"blocksOrSecondsPerYear()\":{\"notice\":\"Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\"},\"burn(address)\":{\"notice\":\"For burning any prime token\"},\"calculateAPR(address,address)\":{\"notice\":\"Returns supply and borrow APR for user for a given market\"},\"claim()\":{\"notice\":\"For claiming prime token when staking period is completed\"},\"claimInterest(address)\":{\"notice\":\"For user to claim boosted yield\"},\"claimInterest(address,address)\":{\"notice\":\"For user to claim boosted yield\"},\"claimTimeRemaining(address)\":{\"notice\":\"fetch the numbers of seconds remaining for staking period to complete\"},\"comptroller()\":{\"notice\":\"Retrieves the core pool comptroller address\"},\"estimateAPR(address,address,uint256,uint256,uint256)\":{\"notice\":\"Returns supply and borrow APR for estimated supply, borrow and XVS staked\"},\"getAllMarkets()\":{\"notice\":\"Retrieves an array of all available markets\"},\"getInterestAccrued(address,address)\":{\"notice\":\"Returns boosted interest accrued for a user\"},\"getPendingRewards(address)\":{\"notice\":\"Returns boosted pending interest accrued for a user for all markets\"},\"incomeDistributionYearly(address)\":{\"notice\":\"the total income that's going to be distributed in a year to prime token holders\"},\"initialize(address,address,uint256,uint128,uint128,address,address,address,address,uint256)\":{\"notice\":\"Prime initializer\"},\"initializeV2(address)\":{\"notice\":\"Prime initializer V2 for initializing pool registry\"},\"interests(address,address)\":{\"notice\":\"vToken to user to user index\"},\"irrevocableLimit()\":{\"notice\":\"Indicates maximum irrevocable tokens that can be minted\"},\"isScoreUpdated(uint256,address)\":{\"notice\":\"mapping to check if a account's score was updated in the round\"},\"isTimeBased()\":{\"notice\":\"Acknowledges if a contract is time based or not\"},\"isUserPrimeHolder(address)\":{\"notice\":\"Returns if user is a prime holder\"},\"issue(bool,address[])\":{\"notice\":\"Directly issue prime tokens to users\"},\"markets(address)\":{\"notice\":\"vToken to market configuration\"},\"nextScoreUpdateRoundId()\":{\"notice\":\"unique id for next round\"},\"oracle()\":{\"notice\":\"The address of ResilientOracle contract\"},\"pendingScoreUpdates()\":{\"notice\":\"total number of accounts whose score is yet to be updated\"},\"poolRegistry()\":{\"notice\":\"The address of PoolRegistry contract\"},\"primeLiquidityProvider()\":{\"notice\":\"The address of PLP contract\"},\"revocableLimit()\":{\"notice\":\"Indicates maximum revocable tokens that can be minted\"},\"setAccessControlManager(address)\":{\"notice\":\"Sets the address of AccessControlManager\"},\"setLimit(uint256,uint256)\":{\"notice\":\"Set limits for total tokens that can be minted\"},\"setMaxLoopsLimit(uint256)\":{\"notice\":\"Set the limit for the loops can iterate to avoid the DOS\"},\"setStakedAt(address[],uint256[])\":{\"notice\":\"Update staked at timestamp for multiple users\"},\"stakedAt(address)\":{\"notice\":\"Tracks when prime token eligible users started staking for claiming prime token\"},\"togglePause()\":{\"notice\":\"To pause or unpause claiming of interest\"},\"tokens(address)\":{\"notice\":\"Mapping to get prime token's metadata\"},\"totalIrrevocable()\":{\"notice\":\"Tracks total irrevocable tokens minted\"},\"totalRevocable()\":{\"notice\":\"Tracks total revocable tokens minted\"},\"totalScoreUpdatesRequired()\":{\"notice\":\"total number of accounts whose score needs to be updated\"},\"unreleasedPLPIncome(address)\":{\"notice\":\"unreleased income from PLP that's already distributed to prime holders\"},\"updateAlpha(uint128,uint128)\":{\"notice\":\"Update value of alpha\"},\"updateMultipliers(address,uint256,uint256)\":{\"notice\":\"Update multipliers for a market\"},\"updateScores(address[])\":{\"notice\":\"Update total score of multiple users and market\"},\"vTokenForAsset(address)\":{\"notice\":\"mapping used to find if an asset is part of prime markets\"},\"xvsUpdated(address)\":{\"notice\":\"Executed by XVSVault whenever user's XVSVault balance changes\"},\"xvsVault()\":{\"notice\":\"address of XVS vault\"},\"xvsVaultPoolId()\":{\"notice\":\"address of XVS vault pool id\"},\"xvsVaultRewardToken()\":{\"notice\":\"address of XVS vault reward token\"}},\"notice\":\"Prime Token is used to provide extra rewards to the users who have staked a minimum of `MINIMUM_STAKED_XVS` XVS in the XVSVault for `STAKING_PERIOD` days\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Tokens/Prime/Prime.sol\":\"Prime\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./OwnableUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n function __Ownable2Step_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable2Step_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x9140dabc466abab21b48b72dbda26736b1183a310d0e677d3719d201df026510\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling 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 /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x359a1ab89b46b9aba7bcad3fb651924baf4893d15153049b9976b0fc9be1358e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\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 _requireNotPaused();\\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 _requirePaused();\\n _;\\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 Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\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 /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xad32f6821f860555f9530902a65b54203a4f5db2117f4384ae47a124958078db\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.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 IERC20Upgradeable {\\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(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x0e1f0f5f62f67a881cd1a9597acbc0a5e4071f3c2c10449a183b922ae7272e3f\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\\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\":\"0x605434219ebbe4653f703640f06969faa5a1d78f0bfef878e5ddbb1ca369ceeb\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x07e881de3b9f6d2c07909f193f24b96c7fe4ea60013260f3f25aecd8bab3c2f8\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) 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(IERC20Upgradeable token, address spender, uint256 value) 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 /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\\n * Revert on invalid signature.\\n */\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\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(IERC20Upgradeable 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 require(returndata.length == 0 || abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\\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 cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return\\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));\\n }\\n}\\n\",\"keccak256\":\"0x23b997be73d3dd46885262704f0f8cfc7273fdadfe303d37969a9561373972b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\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 * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(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 (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport {Initializable} from \\\"../proxy/utils/Initializable.sol\\\";\\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 ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n function _contextSuffixLength() internal view virtual returns (uint256) {\\n return 0;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x75097e35253e7fb282ee4d7f27a80eaacfa759923185bf17302a89cbc059c5ef\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcef50f95b43b038aa40aed25b62fc45906c681a5c1d504a4fdcf3bc6330a8d4b\",\"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\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title AccessControlledV8\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0dcf283925f4dddc23ca0ee71d2cb96a9dd6e4cf08061b69fde1697ea39dc514\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\n/**\\n * @title IAccessControlManagerV8\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\\n */\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xaa29b098440d0b3a131c5ecdf25ce548790c1b5ac7bf9b5c0264b6af6f7a1e0b\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\ninterface OracleInterface {\\n function getPrice(address asset) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n\\n function updateAssetPrice(address asset) external;\\n\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address asset) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address asset,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2432799b0d824fc701beb4c30146e912b9aeecf77b5c1635dde6c5fbe6bfc3a7\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\n/**\\n * @title MaxLoopsLimitHelper\\n * @author Venus\\n * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.\\n */\\nabstract contract MaxLoopsLimitHelper {\\n // Limit for the loops to avoid the DOS\\n uint256 public maxLoopsLimit;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when max loops limit is set\\n event MaxLoopsLimitUpdated(uint256 oldMaxLoopsLimit, uint256 newmaxLoopsLimit);\\n\\n /// @notice Thrown an error on maxLoopsLimit exceeds for any loop\\n error MaxLoopsLimitExceeded(uint256 loopsLimit, uint256 requiredLoops);\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param limit Limit for the max loops can execute at a time\\n */\\n function _setMaxLoopsLimit(uint256 limit) internal {\\n require(limit > maxLoopsLimit, \\\"Comptroller: Invalid maxLoopsLimit\\\");\\n\\n uint256 oldMaxLoopsLimit = maxLoopsLimit;\\n maxLoopsLimit = limit;\\n\\n emit MaxLoopsLimitUpdated(oldMaxLoopsLimit, limit);\\n }\\n\\n /**\\n * @notice Compare the maxLoopsLimit with number of the times loop iterate\\n * @param len Length of the loops iterate\\n * @custom:error MaxLoopsLimitExceeded error is thrown when loops length exceeds maxLoopsLimit\\n */\\n function _ensureMaxLoops(uint256 len) internal view {\\n if (len > maxLoopsLimit) {\\n revert MaxLoopsLimitExceeded(maxLoopsLimit, len);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4c25e30635485d162177effa384eee51768b0141a567a0da16ff6ad673274166\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { SECONDS_PER_YEAR } from \\\"./constants.sol\\\";\\n\\nabstract contract TimeManagerV8 {\\n /// @notice Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable blocksOrSecondsPerYear;\\n\\n /// @notice Acknowledges if a contract is time based or not\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n bool public immutable isTimeBased;\\n\\n /// @notice Stores the current block timestamp or block number depending on isTimeBased\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n function() view returns (uint256) private immutable _getCurrentSlot;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[48] private __gap;\\n\\n /// @notice Thrown when blocks per year is invalid\\n error InvalidBlocksPerYear();\\n\\n /// @notice Thrown when time based but blocks per year is provided\\n error InvalidTimeBasedConfiguration();\\n\\n /**\\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\\n * @param blocksPerYear_ The number of blocks per year\\n * @custom:error InvalidBlocksPerYear is thrown if blocksPerYear entered is zero and timeBased is false\\n * @custom:error InvalidTimeBasedConfiguration is thrown if blocksPerYear entered is non zero and timeBased is true\\n * @custom:oz-upgrades-unsafe-allow constructor\\n */\\n constructor(bool timeBased_, uint256 blocksPerYear_) {\\n if (!timeBased_ && blocksPerYear_ == 0) {\\n revert InvalidBlocksPerYear();\\n }\\n\\n if (timeBased_ && blocksPerYear_ != 0) {\\n revert InvalidTimeBasedConfiguration();\\n }\\n\\n isTimeBased = timeBased_;\\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\\n _getCurrentSlot = timeBased_ ? _getBlockTimestamp : _getBlockNumber;\\n }\\n\\n /**\\n * @dev Function to simply retrieve block number or block timestamp\\n * @return Current block number or block timestamp\\n */\\n function getBlockNumberOrTimestamp() public view virtual returns (uint256) {\\n return _getCurrentSlot();\\n }\\n\\n /**\\n * @dev Returns the current timestamp in seconds\\n * @return The current timestamp\\n */\\n function _getBlockTimestamp() private view returns (uint256) {\\n return block.timestamp;\\n }\\n\\n /**\\n * @dev Returns the current block number\\n * @return The current block number\\n */\\n function _getBlockNumber() private view returns (uint256) {\\n return block.number;\\n }\\n}\\n\",\"keccak256\":\"0x57a2bbb9b8e02b1c0a5c0e305fef1328a22db56c3d4b148c362010a6e767243c\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/constants.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\\nuint256 constant EXP_SCALE = 1e18;\\n\\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\\nuint256 constant MANTISSA_ONE = EXP_SCALE;\\n\\n/// @dev The approximate number of seconds per year\\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\\n\",\"keccak256\":\"0x14de93ead464da249af31bea0e3bcfb62ec693bea3475fb4d90f055ac81dc5eb\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IPoolRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\n/**\\n * @title PoolRegistryInterface\\n * @author Venus\\n * @notice Interface implemented by `PoolRegistry`.\\n */\\ninterface PoolRegistryInterface {\\n /**\\n * @notice Struct for a Venus interest rate pool.\\n */\\n struct VenusPool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /// @notice Get a pool by comptroller address\\n function getPoolByComptroller(address comptroller) external view returns (VenusPool memory);\\n}\\n\",\"keccak256\":\"0x3977ed49a7eaccbdbd674cfbabff12e59e2476301810aad30a4e991c63b8e9ee\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IPrime.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport { PrimeStorageV1 } from \\\"../PrimeStorage.sol\\\";\\n\\n/**\\n * @title IPrime\\n * @author Venus\\n * @notice Interface for Prime Token\\n */\\ninterface IPrime {\\n struct APRInfo {\\n // supply APR of the user in BPS\\n uint256 supplyAPR;\\n // borrow APR of the user in BPS\\n uint256 borrowAPR;\\n // total score of the market\\n uint256 totalScore;\\n // score of the user\\n uint256 userScore;\\n // capped XVS balance of the user\\n uint256 xvsBalanceForScore;\\n // capital of the user\\n uint256 capital;\\n // capped supply of the user\\n uint256 cappedSupply;\\n // capped borrow of the user\\n uint256 cappedBorrow;\\n // capped supply of user in USD\\n uint256 supplyCapUSD;\\n // capped borrow of user in USD\\n uint256 borrowCapUSD;\\n }\\n\\n struct Capital {\\n // capital of the user\\n uint256 capital;\\n // capped supply of the user\\n uint256 cappedSupply;\\n // capped borrow of the user\\n uint256 cappedBorrow;\\n // capped supply of user in USD\\n uint256 supplyCapUSD;\\n // capped borrow of user in USD\\n uint256 borrowCapUSD;\\n }\\n\\n /**\\n * @notice Returns boosted pending interest accrued for a user for all markets\\n * @param user the account for which to get the accrued interests\\n * @return pendingRewards the number of underlying tokens accrued by the user for all markets\\n */\\n function getPendingRewards(address user) external returns (PrimeStorageV1.PendingReward[] memory pendingRewards);\\n\\n /**\\n * @notice Update total score of multiple users and market\\n * @param users accounts for which we need to update score\\n */\\n function updateScores(address[] memory users) external;\\n\\n /**\\n * @notice Update value of alpha\\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\\n */\\n function updateAlpha(uint128 _alphaNumerator, uint128 _alphaDenominator) external;\\n\\n /**\\n * @notice Update multipliers for a market\\n * @param market address of the market vToken\\n * @param supplyMultiplier new supply multiplier for the market, scaled by 1e18\\n * @param borrowMultiplier new borrow multiplier for the market, scaled by 1e18\\n */\\n function updateMultipliers(address market, uint256 supplyMultiplier, uint256 borrowMultiplier) external;\\n\\n /**\\n * @notice Add a market to prime program\\n * @param comptroller address of the comptroller\\n * @param market address of the market vToken\\n * @param supplyMultiplier the multiplier for supply cap. It should be converted to 1e18\\n * @param borrowMultiplier the multiplier for borrow cap. It should be converted to 1e18\\n */\\n function addMarket(\\n address comptroller,\\n address market,\\n uint256 supplyMultiplier,\\n uint256 borrowMultiplier\\n ) external;\\n\\n /**\\n * @notice Set limits for total tokens that can be minted\\n * @param _irrevocableLimit total number of irrevocable tokens that can be minted\\n * @param _revocableLimit total number of revocable tokens that can be minted\\n */\\n function setLimit(uint256 _irrevocableLimit, uint256 _revocableLimit) external;\\n\\n /**\\n * @notice Directly issue prime tokens to users\\n * @param isIrrevocable are the tokens being issued\\n * @param users list of address to issue tokens to\\n */\\n function issue(bool isIrrevocable, address[] calldata users) external;\\n\\n /**\\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\\n * @param user the account address whose balance was updated\\n */\\n function xvsUpdated(address user) external;\\n\\n /**\\n * @notice accrues interest and updates score for an user for a specific market\\n * @param user the account address for which to accrue interest and update score\\n * @param market the market for which to accrue interest and update score\\n */\\n function accrueInterestAndUpdateScore(address user, address market) external;\\n\\n /**\\n * @notice For claiming prime token when staking period is completed\\n */\\n function claim() external;\\n\\n /**\\n * @notice For burning any prime token\\n * @param user the account address for which the prime token will be burned\\n */\\n function burn(address user) external;\\n\\n /**\\n * @notice To pause or unpause claiming of interest\\n */\\n function togglePause() external;\\n\\n /**\\n * @notice For user to claim boosted yield\\n * @param vToken the market for which claim the accrued interest\\n * @return amount the amount of tokens transferred to the user\\n */\\n function claimInterest(address vToken) external returns (uint256);\\n\\n /**\\n * @notice For user to claim boosted yield\\n * @param vToken the market for which claim the accrued interest\\n * @param user the user for which to claim the accrued interest\\n * @return amount the amount of tokens transferred to the user\\n */\\n function claimInterest(address vToken, address user) external returns (uint256);\\n\\n /**\\n * @notice Distributes income from market since last distribution\\n * @param vToken the market for which to distribute the income\\n */\\n function accrueInterest(address vToken) external;\\n\\n /**\\n * @notice Returns boosted interest accrued for a user\\n * @param vToken the market for which to fetch the accrued interest\\n * @param user the account for which to get the accrued interest\\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\\n */\\n function getInterestAccrued(address vToken, address user) external returns (uint256);\\n\\n /**\\n * @notice Retrieves an array of all available markets\\n * @return an array of addresses representing all available markets\\n */\\n function getAllMarkets() external view returns (address[] memory);\\n\\n /**\\n * @notice fetch the numbers of seconds remaining for staking period to complete\\n * @param user the account address for which we are checking the remaining time\\n * @return timeRemaining the number of seconds the user needs to wait to claim prime token\\n */\\n function claimTimeRemaining(address user) external view returns (uint256);\\n\\n /**\\n * @notice Returns supply and borrow APR for user for a given market\\n * @param market the market for which to fetch the APR\\n * @param user the account for which to get the APR\\n * @return aprInfo APR information for the user for the given market\\n */\\n function calculateAPR(address market, address user) external view returns (APRInfo memory aprInfo);\\n\\n /**\\n * @notice Returns supply and borrow APR for estimated supply, borrow and XVS staked\\n * @param market the market for which to fetch the APR\\n * @param user the account for which to get the APR\\n * @param borrow hypothetical borrow amount\\n * @param supply hypothetical supply amount\\n * @param xvsStaked hypothetical staked XVS amount\\n * @return aprInfo APR information for the user for the given market\\n */\\n function estimateAPR(\\n address market,\\n address user,\\n uint256 borrow,\\n uint256 supply,\\n uint256 xvsStaked\\n ) external view returns (APRInfo memory aprInfo);\\n\\n /**\\n * @notice the total income that's going to be distributed in a year to prime token holders\\n * @param vToken the market for which to fetch the total income that's going to distributed in a year\\n * @return amount the total income\\n */\\n function incomeDistributionYearly(address vToken) external view returns (uint256 amount);\\n\\n /**\\n * @notice Returns if user is a prime holder\\n * @return isPrimeHolder true if user is a prime holder\\n */\\n function isUserPrimeHolder(address user) external view returns (bool);\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Number of loops limit\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external;\\n\\n /**\\n * @notice Update staked at timestamp for multiple users\\n * @param users accounts for which we need to update staked at timestamp\\n * @param timestamps new staked at timestamp for the users\\n */\\n function setStakedAt(address[] calldata users, uint256[] calldata timestamps) external;\\n}\\n\",\"keccak256\":\"0xd112f60183416ad796093b4a83a80ddc1b8b655965f02ae55ca82e2a0c68f97d\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IPrimeLiquidityProvider.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport { IERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IPrimeLiquidityProvider\\n * @author Venus\\n * @notice Interface for PrimeLiquidityProvider\\n */\\ninterface IPrimeLiquidityProvider {\\n /**\\n * @notice Initialize the distribution of the token\\n * @param tokens_ Array of addresses of the tokens to be intialized\\n */\\n function initializeTokens(address[] calldata tokens_) external;\\n\\n /**\\n * @notice Pause fund transfer of tokens to Prime contract\\n */\\n function pauseFundsTransfer() external;\\n\\n /**\\n * @notice Resume fund transfer of tokens to Prime contract\\n */\\n function resumeFundsTransfer() external;\\n\\n /**\\n * @notice Set distribution speed (amount of token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param distributionSpeeds_ New distribution speeds for tokens\\n */\\n function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external;\\n\\n /**\\n * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param maxDistributionSpeeds_ New distribution speeds for tokens\\n */\\n function setMaxTokensDistributionSpeed(\\n address[] calldata tokens_,\\n uint256[] calldata maxDistributionSpeeds_\\n ) external;\\n\\n /**\\n * @notice Set the prime token contract address\\n * @param prime_ The new address of the prime token contract\\n */\\n function setPrimeToken(address prime_) external;\\n\\n /**\\n * @notice Claim all the token accrued till last block or second\\n * @param token_ The token to release to the Prime contract\\n */\\n function releaseFunds(address token_) external;\\n\\n /**\\n * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\\n * @param token_ The address of the ERC-20 token to sweep\\n * @param to_ The address of the recipient\\n * @param amount_ The amount of tokens needs to transfer\\n */\\n function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external;\\n\\n /**\\n * @notice Accrue token by updating the distribution state\\n * @param token_ Address of the token\\n */\\n function accrueTokens(address token_) external;\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Limit for the max loops can execute at a time\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external;\\n\\n /**\\n * @notice Get rewards per block or second for token\\n * @param token_ Address of the token\\n * @return speed returns the per block or second reward\\n */\\n function getEffectiveDistributionSpeed(address token_) external view returns (uint256);\\n\\n /**\\n * @notice Get the amount of tokens accrued\\n * @param token_ Address of the token\\n * @return Amount of tokens that are accrued\\n */\\n function tokenAmountAccrued(address token_) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x4dca0341931008bcd81de18e627c2d0cd4f9d0be67db4d8f0d678d11ba0d330f\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IVToken.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\ninterface IVToken {\\n function borrowBalanceStored(address account) external view returns (uint256);\\n\\n function exchangeRateStored() external view returns (uint256);\\n\\n function balanceOf(address account) external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x63da84a1600e383a030e17b1a696bc168f6887e9f5ef6a986b5d6c1ec98a92ed\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IXVSVault.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\ninterface IXVSVault {\\n function getUserInfo(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals);\\n\\n function xvsAddress() external view returns (address);\\n}\\n\",\"keccak256\":\"0x576bb0e8c21891de2803251244133f948673bce5c8146aa53157f414889c476d\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/InterfaceComptroller.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity ^0.8.25;\\n\\ninterface InterfaceComptroller {\\n function markets(address) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xb3b6f9b8079d6b8ee93174fd2f96db394012f4f7d307cb389825a60cdb1dc3da\",\"license\":\"GPL-3.0-or-later\"},\"contracts/Tokens/Prime/Prime.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { SafeERC20Upgradeable, IERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport { AccessControlledV8 } from \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\nimport { ResilientOracleInterface } from \\\"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\\\";\\nimport { PausableUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport { MaxLoopsLimitHelper } from \\\"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\\\";\\nimport { TimeManagerV8 } from \\\"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\\\";\\n\\nimport { IERC20MetadataUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\\\";\\n\\nimport { PrimeStorageV1 } from \\\"./PrimeStorage.sol\\\";\\nimport { Scores } from \\\"./libs/Scores.sol\\\";\\n\\nimport { IPrimeLiquidityProvider } from \\\"./Interfaces/IPrimeLiquidityProvider.sol\\\";\\nimport { IPrime } from \\\"./Interfaces/IPrime.sol\\\";\\nimport { IXVSVault } from \\\"./Interfaces/IXVSVault.sol\\\";\\nimport { IVToken } from \\\"./Interfaces/IVToken.sol\\\";\\nimport { InterfaceComptroller } from \\\"./Interfaces/InterfaceComptroller.sol\\\";\\nimport { PoolRegistryInterface } from \\\"./Interfaces/IPoolRegistry.sol\\\";\\n\\n/**\\n * @title Prime\\n * @author Venus\\n * @notice Prime Token is used to provide extra rewards to the users who have staked a minimum of `MINIMUM_STAKED_XVS` XVS in the XVSVault for `STAKING_PERIOD` days\\n * @custom:security-contact https://github.com/VenusProtocol/venus-protocol\\n */\\ncontract Prime is IPrime, AccessControlledV8, PausableUpgradeable, MaxLoopsLimitHelper, PrimeStorageV1, TimeManagerV8 {\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n /// @notice address of wrapped native token contract\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WRAPPED_NATIVE_TOKEN;\\n\\n /// @notice address of native market contract\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable NATIVE_MARKET;\\n\\n /// @notice minimum amount of XVS user needs to stake to become a prime member\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable MINIMUM_STAKED_XVS;\\n\\n /// @notice maximum XVS taken in account when calculating user score\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable MAXIMUM_XVS_CAP;\\n\\n /// @notice number of days user need to stake to claim prime token\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable STAKING_PERIOD;\\n\\n /// @notice Emitted when prime token is minted\\n event Mint(address indexed user, bool isIrrevocable);\\n\\n /// @notice Emitted when prime token is burned\\n event Burn(address indexed user);\\n\\n /// @notice Emitted when a market is added to prime program\\n event MarketAdded(\\n address indexed comptroller,\\n address indexed market,\\n uint256 supplyMultiplier,\\n uint256 borrowMultiplier\\n );\\n\\n /// @notice Emitted when mint limits are updated\\n event MintLimitsUpdated(\\n uint256 indexed oldIrrevocableLimit,\\n uint256 indexed oldRevocableLimit,\\n uint256 indexed newIrrevocableLimit,\\n uint256 newRevocableLimit\\n );\\n\\n /// @notice Emitted when user score is updated\\n event UserScoreUpdated(address indexed user);\\n\\n /// @notice Emitted when alpha is updated\\n event AlphaUpdated(\\n uint128 indexed oldNumerator,\\n uint128 indexed oldDenominator,\\n uint128 indexed newNumerator,\\n uint128 newDenominator\\n );\\n\\n /// @notice Emitted when multiplier is updated\\n event MultiplierUpdated(\\n address indexed market,\\n uint256 indexed oldSupplyMultiplier,\\n uint256 indexed oldBorrowMultiplier,\\n uint256 newSupplyMultiplier,\\n uint256 newBorrowMultiplier\\n );\\n\\n /// @notice Emitted when interest is claimed\\n event InterestClaimed(address indexed user, address indexed market, uint256 amount);\\n\\n /// @notice Emitted when revocable token is upgraded to irrevocable token\\n event TokenUpgraded(address indexed user);\\n\\n /// @notice Emitted when stakedAt is updated\\n event StakedAtUpdated(address indexed user, uint256 timestamp);\\n\\n /// @notice Error thrown when market is not supported\\n error MarketNotSupported();\\n\\n /// @notice Error thrown when mint limit is reached\\n error InvalidLimit();\\n\\n /// @notice Error thrown when user is not eligible to claim prime token\\n error IneligibleToClaim();\\n\\n /// @notice Error thrown when user needs to wait more time to claim prime token\\n error WaitMoreTime();\\n\\n /// @notice Error thrown when user has no prime token\\n error UserHasNoPrimeToken();\\n\\n /// @notice Error thrown when no score updates are required\\n error NoScoreUpdatesRequired();\\n\\n /// @notice Error thrown when market already exists\\n error MarketAlreadyExists();\\n\\n /// @notice Error thrown when asset already exists\\n error AssetAlreadyExists();\\n\\n /// @notice Error thrown when invalid address is passed\\n error InvalidAddress();\\n\\n /// @notice Error thrown when invalid alpha arguments are passed\\n error InvalidAlphaArguments();\\n\\n /// @notice Error thrown when invalid vToken is passed\\n error InvalidVToken();\\n\\n /// @notice Error thrown when invalid length is passed\\n error InvalidLength();\\n\\n /// @notice Error thrown when timestamp is invalid\\n error InvalidTimestamp();\\n\\n /// @notice Error thrown when invalid comptroller is passed\\n error InvalidComptroller();\\n\\n /**\\n * @notice Prime constructor\\n * @param _wrappedNativeToken Address of wrapped native token\\n * @param _nativeMarket Address of native market\\n * @param _blocksPerYear total blocks per year\\n * @param _stakingPeriod total number of seconds for which user needs to stake to claim prime token\\n * @param _minimumStakedXVS minimum amount of XVS user needs to stake to become a prime member (scaled by 1e18)\\n * @param _maximumXVSCap maximum XVS taken in account when calculating user score (scaled by 1e18)\\n * @param _timeBased A boolean indicating whether the contract is based on time or block.\\n */\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n address _wrappedNativeToken,\\n address _nativeMarket,\\n uint256 _blocksPerYear,\\n uint256 _stakingPeriod,\\n uint256 _minimumStakedXVS,\\n uint256 _maximumXVSCap,\\n bool _timeBased\\n ) TimeManagerV8(_timeBased, _blocksPerYear) {\\n WRAPPED_NATIVE_TOKEN = _wrappedNativeToken;\\n NATIVE_MARKET = _nativeMarket;\\n STAKING_PERIOD = _stakingPeriod;\\n MINIMUM_STAKED_XVS = _minimumStakedXVS;\\n MAXIMUM_XVS_CAP = _maximumXVSCap;\\n\\n // Note that the contract is upgradeable. Use initialize() or reinitializers\\n // to set the state variables.\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice Prime initializer\\n * @param xvsVault_ Address of XVSVault\\n * @param xvsVaultRewardToken_ Address of XVSVault reward token\\n * @param xvsVaultPoolId_ Pool id of XVSVault\\n * @param alphaNumerator_ numerator of alpha. If alpha is 0.5 then numerator is 1.\\n alphaDenominator_ must be greater than alphaNumerator_, alphaDenominator_ cannot be zero and alphaNumerator_ cannot be zero\\n * @param alphaDenominator_ denominator of alpha. If alpha is 0.5 then denominator is 2.\\n alpha is alphaNumerator_/alphaDenominator_. So, 0 < alpha < 1\\n * @param accessControlManager_ Address of AccessControlManager\\n * @param primeLiquidityProvider_ Address of PrimeLiquidityProvider\\n * @param comptroller_ Address of core pool comptroller\\n * @param oracle_ Address of Oracle\\n * @param loopsLimit_ Maximum number of loops allowed in a single transaction\\n * @custom:error Throw InvalidAddress if any of the address is invalid\\n */\\n function initialize(\\n address xvsVault_,\\n address xvsVaultRewardToken_,\\n uint256 xvsVaultPoolId_,\\n uint128 alphaNumerator_,\\n uint128 alphaDenominator_,\\n address accessControlManager_,\\n address primeLiquidityProvider_,\\n address comptroller_,\\n address oracle_,\\n uint256 loopsLimit_\\n ) external initializer {\\n if (xvsVault_ == address(0)) revert InvalidAddress();\\n if (xvsVaultRewardToken_ == address(0)) revert InvalidAddress();\\n if (oracle_ == address(0)) revert InvalidAddress();\\n if (primeLiquidityProvider_ == address(0)) revert InvalidAddress();\\n\\n _checkAlphaArguments(alphaNumerator_, alphaDenominator_);\\n\\n alphaNumerator = alphaNumerator_;\\n alphaDenominator = alphaDenominator_;\\n xvsVaultRewardToken = xvsVaultRewardToken_;\\n xvsVaultPoolId = xvsVaultPoolId_;\\n xvsVault = xvsVault_;\\n nextScoreUpdateRoundId = 0;\\n primeLiquidityProvider = primeLiquidityProvider_;\\n corePoolComptroller = comptroller_;\\n oracle = ResilientOracleInterface(oracle_);\\n\\n __AccessControlled_init(accessControlManager_);\\n __Pausable_init();\\n _setMaxLoopsLimit(loopsLimit_);\\n\\n _pause();\\n }\\n\\n /**\\n * @notice Prime initializer V2 for initializing pool registry\\n * @param poolRegistry_ Address of IL pool registry\\n */\\n function initializeV2(address poolRegistry_) external reinitializer(2) {\\n poolRegistry = poolRegistry_;\\n }\\n\\n /**\\n * @notice Returns boosted pending interest accrued for a user for all markets\\n * @param user the account for which to get the accrued interests\\n * @return pendingRewards the number of underlying tokens accrued by the user for all markets\\n */\\n function getPendingRewards(address user) external returns (PendingReward[] memory pendingRewards) {\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n pendingRewards = new PendingReward[](marketsLength);\\n for (uint256 i; i < marketsLength; ) {\\n address market = allMarkets[i];\\n uint256 interestAccrued = getInterestAccrued(market, user);\\n uint256 accrued = interests[market][user].accrued;\\n\\n pendingRewards[i] = PendingReward({\\n vToken: market,\\n rewardToken: _getUnderlying(market),\\n amount: interestAccrued + accrued\\n });\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Update total score of multiple users and market\\n * @param users accounts for which we need to update score\\n * @custom:error Throw NoScoreUpdatesRequired if no score updates are required\\n * @custom:error Throw UserHasNoPrimeToken if user has no prime token\\n * @custom:event Emits UserScoreUpdated event\\n */\\n function updateScores(address[] calldata users) external {\\n if (pendingScoreUpdates == 0) revert NoScoreUpdatesRequired();\\n if (nextScoreUpdateRoundId == 0) revert NoScoreUpdatesRequired();\\n\\n for (uint256 i; i < users.length; ) {\\n address user = users[i];\\n\\n if (!tokens[user].exists) revert UserHasNoPrimeToken();\\n if (isScoreUpdated[nextScoreUpdateRoundId][user]) {\\n unchecked {\\n ++i;\\n }\\n continue;\\n }\\n\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n for (uint256 j; j < marketsLength; ) {\\n address market = allMarkets[j];\\n _executeBoost(user, market);\\n _updateScore(user, market);\\n\\n unchecked {\\n ++j;\\n }\\n }\\n\\n --pendingScoreUpdates;\\n isScoreUpdated[nextScoreUpdateRoundId][user] = true;\\n\\n unchecked {\\n ++i;\\n }\\n\\n emit UserScoreUpdated(user);\\n }\\n }\\n\\n /**\\n * @notice Update value of alpha\\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\\n * @custom:event Emits AlphaUpdated event\\n * @custom:access Controlled by ACM\\n */\\n function updateAlpha(uint128 _alphaNumerator, uint128 _alphaDenominator) external {\\n _checkAccessAllowed(\\\"updateAlpha(uint128,uint128)\\\");\\n _checkAlphaArguments(_alphaNumerator, _alphaDenominator);\\n\\n emit AlphaUpdated(alphaNumerator, alphaDenominator, _alphaNumerator, _alphaDenominator);\\n\\n alphaNumerator = _alphaNumerator;\\n alphaDenominator = _alphaDenominator;\\n\\n uint256 marketslength = _allMarkets.length;\\n\\n for (uint256 i; i < marketslength; ) {\\n accrueInterest(_allMarkets[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n\\n _startScoreUpdateRound();\\n }\\n\\n /**\\n * @notice Update multipliers for a market\\n * @param market address of the market vToken\\n * @param supplyMultiplier new supply multiplier for the market, scaled by 1e18\\n * @param borrowMultiplier new borrow multiplier for the market, scaled by 1e18\\n * @custom:error Throw MarketNotSupported if market is not supported\\n * @custom:event Emits MultiplierUpdated event\\n * @custom:access Controlled by ACM\\n */\\n function updateMultipliers(address market, uint256 supplyMultiplier, uint256 borrowMultiplier) external {\\n _checkAccessAllowed(\\\"updateMultipliers(address,uint256,uint256)\\\");\\n\\n Market storage _market = markets[market];\\n if (!_market.exists) revert MarketNotSupported();\\n\\n accrueInterest(market);\\n\\n emit MultiplierUpdated(\\n market,\\n _market.supplyMultiplier,\\n _market.borrowMultiplier,\\n supplyMultiplier,\\n borrowMultiplier\\n );\\n _market.supplyMultiplier = supplyMultiplier;\\n _market.borrowMultiplier = borrowMultiplier;\\n\\n _startScoreUpdateRound();\\n }\\n\\n /**\\n * @notice Update staked at timestamp for multiple users\\n * @param users accounts for which we need to update staked at timestamp\\n * @param timestamps new staked at timestamp for the users\\n * @custom:error Throw InvalidLength if users and timestamps length are not equal\\n * @custom:event Emits StakedAtUpdated event for each user\\n * @custom:access Controlled by ACM\\n */\\n function setStakedAt(address[] calldata users, uint256[] calldata timestamps) external {\\n _checkAccessAllowed(\\\"setStakedAt(address[],uint256[])\\\");\\n if (users.length != timestamps.length) revert InvalidLength();\\n\\n for (uint256 i; i < users.length; ) {\\n if (timestamps[i] > block.timestamp) revert InvalidTimestamp();\\n\\n stakedAt[users[i]] = timestamps[i];\\n emit StakedAtUpdated(users[i], timestamps[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Add a market to prime program\\n * @param comptroller address of the comptroller\\n * @param market address of the market vToken\\n * @param supplyMultiplier the multiplier for supply cap. It should be converted to 1e18\\n * @param borrowMultiplier the multiplier for borrow cap. It should be converted to 1e18\\n * @custom:error Throw MarketAlreadyExists if market already exists\\n * @custom:error Throw InvalidVToken if market is not valid\\n * @custom:event Emits MarketAdded event\\n * @custom:access Controlled by ACM\\n */\\n function addMarket(\\n address comptroller,\\n address market,\\n uint256 supplyMultiplier,\\n uint256 borrowMultiplier\\n ) external {\\n _checkAccessAllowed(\\\"addMarket(address,address,uint256,uint256)\\\");\\n\\n if (comptroller == address(0)) revert InvalidComptroller();\\n\\n if (\\n comptroller != corePoolComptroller &&\\n PoolRegistryInterface(poolRegistry).getPoolByComptroller(comptroller).comptroller != comptroller\\n ) revert InvalidComptroller();\\n\\n Market storage _market = markets[market];\\n if (_market.exists) revert MarketAlreadyExists();\\n\\n bool isMarketExist = InterfaceComptroller(comptroller).markets(market);\\n if (!isMarketExist) revert InvalidVToken();\\n\\n delete _market.rewardIndex;\\n _market.supplyMultiplier = supplyMultiplier;\\n _market.borrowMultiplier = borrowMultiplier;\\n delete _market.sumOfMembersScore;\\n _market.exists = true;\\n\\n address underlying = _getUnderlying(market);\\n\\n if (vTokenForAsset[underlying] != address(0)) revert AssetAlreadyExists();\\n vTokenForAsset[underlying] = market;\\n\\n _allMarkets.push(market);\\n _startScoreUpdateRound();\\n\\n _ensureMaxLoops(_allMarkets.length);\\n\\n emit MarketAdded(comptroller, market, supplyMultiplier, borrowMultiplier);\\n }\\n\\n /**\\n * @notice Set limits for total tokens that can be minted\\n * @param _irrevocableLimit total number of irrevocable tokens that can be minted\\n * @param _revocableLimit total number of revocable tokens that can be minted\\n * @custom:error Throw InvalidLimit if any of the limit is less than total tokens minted\\n * @custom:event Emits MintLimitsUpdated event\\n * @custom:access Controlled by ACM\\n */\\n function setLimit(uint256 _irrevocableLimit, uint256 _revocableLimit) external {\\n _checkAccessAllowed(\\\"setLimit(uint256,uint256)\\\");\\n if (_irrevocableLimit < totalIrrevocable || _revocableLimit < totalRevocable) revert InvalidLimit();\\n\\n emit MintLimitsUpdated(irrevocableLimit, revocableLimit, _irrevocableLimit, _revocableLimit);\\n\\n revocableLimit = _revocableLimit;\\n irrevocableLimit = _irrevocableLimit;\\n }\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Number of loops limit\\n * @custom:event Emits MaxLoopsLimitUpdated event on success\\n * @custom:access Controlled by ACM\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external {\\n _checkAccessAllowed(\\\"setMaxLoopsLimit(uint256)\\\");\\n _setMaxLoopsLimit(loopsLimit);\\n }\\n\\n /**\\n * @notice Directly issue prime tokens to users\\n * @param isIrrevocable are the tokens being issued\\n * @param users list of address to issue tokens to\\n * @custom:access Controlled by ACM\\n */\\n function issue(bool isIrrevocable, address[] calldata users) external {\\n _checkAccessAllowed(\\\"issue(bool,address[])\\\");\\n\\n if (isIrrevocable) {\\n for (uint256 i; i < users.length; ) {\\n Token storage userToken = tokens[users[i]];\\n if (userToken.exists && !userToken.isIrrevocable) {\\n _upgrade(users[i]);\\n } else {\\n _mint(true, users[i]);\\n _initializeMarkets(users[i]);\\n }\\n\\n unchecked {\\n ++i;\\n }\\n }\\n } else {\\n for (uint256 i; i < users.length; ) {\\n _mint(false, users[i]);\\n _initializeMarkets(users[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n }\\n\\n /**\\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\\n * @param user the account address whose balance was updated\\n */\\n function xvsUpdated(address user) external {\\n uint256 totalStaked = _xvsBalanceOfUser(user);\\n bool isAccountEligible = _isEligible(totalStaked);\\n\\n uint256 userStakedAt = stakedAt[user];\\n Token memory token = tokens[user];\\n\\n if (token.exists && !isAccountEligible) {\\n delete stakedAt[user];\\n emit StakedAtUpdated(user, 0);\\n\\n if (token.isIrrevocable) {\\n _accrueInterestAndUpdateScore(user);\\n } else {\\n _burn(user);\\n }\\n } else if (!isAccountEligible && !token.exists && userStakedAt != 0) {\\n delete stakedAt[user];\\n emit StakedAtUpdated(user, 0);\\n } else if (userStakedAt == 0 && isAccountEligible && !token.exists) {\\n stakedAt[user] = block.timestamp;\\n emit StakedAtUpdated(user, block.timestamp);\\n } else if (token.exists && isAccountEligible) {\\n _accrueInterestAndUpdateScore(user);\\n\\n if (stakedAt[user] == 0) {\\n stakedAt[user] = block.timestamp;\\n emit StakedAtUpdated(user, block.timestamp);\\n }\\n }\\n }\\n\\n /**\\n * @notice accrues interes and updates score for an user for a specific market\\n * @param user the account address for which to accrue interest and update score\\n * @param market the market for which to accrue interest and update score\\n */\\n function accrueInterestAndUpdateScore(address user, address market) external {\\n _executeBoost(user, market);\\n _updateScore(user, market);\\n }\\n\\n /**\\n * @notice For claiming prime token when staking period is completed\\n */\\n function claim() external {\\n uint256 userStakedAt = stakedAt[msg.sender];\\n if (userStakedAt == 0) revert IneligibleToClaim();\\n if (block.timestamp - userStakedAt < STAKING_PERIOD) revert WaitMoreTime();\\n\\n _mint(false, msg.sender);\\n _initializeMarkets(msg.sender);\\n }\\n\\n /**\\n * @notice For burning any prime token\\n * @param user the account address for which the prime token will be burned\\n * @custom:access Controlled by ACM\\n */\\n function burn(address user) external {\\n _checkAccessAllowed(\\\"burn(address)\\\");\\n _burn(user);\\n }\\n\\n /**\\n * @notice To pause or unpause claiming of interest\\n * @custom:access Controlled by ACM\\n */\\n function togglePause() external {\\n _checkAccessAllowed(\\\"togglePause()\\\");\\n if (paused()) {\\n _unpause();\\n } else {\\n _pause();\\n }\\n }\\n\\n /**\\n * @notice For user to claim boosted yield\\n * @param vToken the market for which claim the accrued interest\\n * @return amount the amount of tokens transferred to the msg.sender\\n */\\n function claimInterest(address vToken) external whenNotPaused returns (uint256) {\\n return _claimInterest(vToken, msg.sender);\\n }\\n\\n /**\\n * @notice For user to claim boosted yield\\n * @param vToken the market for which claim the accrued interest\\n * @param user the user for which to claim the accrued interest\\n * @return amount the amount of tokens transferred to the user\\n */\\n function claimInterest(address vToken, address user) external whenNotPaused returns (uint256) {\\n return _claimInterest(vToken, user);\\n }\\n\\n /**\\n * @notice Retrieves an array of all available markets\\n * @return an array of addresses representing all available markets\\n */\\n function getAllMarkets() external view returns (address[] memory) {\\n return _allMarkets;\\n }\\n\\n /**\\n * @notice Retrieves the core pool comptroller address\\n * @return the core pool comptroller address\\n */\\n function comptroller() external view returns (address) {\\n return corePoolComptroller;\\n }\\n\\n /**\\n * @notice fetch the numbers of seconds remaining for staking period to complete\\n * @param user the account address for which we are checking the remaining time\\n * @return timeRemaining the number of seconds the user needs to wait to claim prime token\\n */\\n function claimTimeRemaining(address user) external view returns (uint256) {\\n uint256 userStakedAt = stakedAt[user];\\n if (userStakedAt == 0) return STAKING_PERIOD;\\n\\n uint256 totalTimeStaked;\\n unchecked {\\n totalTimeStaked = block.timestamp - userStakedAt;\\n }\\n\\n if (totalTimeStaked < STAKING_PERIOD) {\\n unchecked {\\n return STAKING_PERIOD - totalTimeStaked;\\n }\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Returns if user is a prime holder\\n * @return isPrimeHolder true if user is a prime holder\\n */\\n function isUserPrimeHolder(address user) external view returns (bool) {\\n return tokens[user].exists;\\n }\\n\\n /**\\n * @notice Returns supply and borrow APR for user for a given market\\n * @param market the market for which to fetch the APR\\n * @param user the account for which to get the APR\\n * @return aprInfo APR information for the user for the given market\\n */\\n function calculateAPR(address market, address user) external view returns (APRInfo memory aprInfo) {\\n IVToken vToken = IVToken(market);\\n uint256 borrow = vToken.borrowBalanceStored(user);\\n uint256 exchangeRate = vToken.exchangeRateStored();\\n uint256 balanceOfAccount = vToken.balanceOf(user);\\n uint256 supply = (exchangeRate * balanceOfAccount) / EXP_SCALE;\\n\\n aprInfo.userScore = interests[market][user].score;\\n aprInfo.totalScore = markets[market].sumOfMembersScore;\\n\\n aprInfo.xvsBalanceForScore = _xvsBalanceForScore(_xvsBalanceOfUser(user));\\n Capital memory capital = _capitalForScore(aprInfo.xvsBalanceForScore, borrow, supply, address(vToken));\\n\\n aprInfo.capital = capital.capital;\\n aprInfo.cappedSupply = capital.cappedSupply;\\n aprInfo.cappedBorrow = capital.cappedBorrow;\\n aprInfo.supplyCapUSD = capital.supplyCapUSD;\\n aprInfo.borrowCapUSD = capital.borrowCapUSD;\\n\\n (aprInfo.supplyAPR, aprInfo.borrowAPR) = _calculateUserAPR(\\n market,\\n supply,\\n borrow,\\n aprInfo.cappedSupply,\\n aprInfo.cappedBorrow,\\n aprInfo.userScore,\\n aprInfo.totalScore\\n );\\n }\\n\\n /**\\n * @notice Returns supply and borrow APR for estimated supply, borrow and XVS staked\\n * @param market the market for which to fetch the APR\\n * @param user the account for which to get the APR\\n * @return aprInfo APR information for the user for the given market\\n */\\n function estimateAPR(\\n address market,\\n address user,\\n uint256 borrow,\\n uint256 supply,\\n uint256 xvsStaked\\n ) external view returns (APRInfo memory aprInfo) {\\n aprInfo.totalScore = markets[market].sumOfMembersScore - interests[market][user].score;\\n\\n aprInfo.xvsBalanceForScore = _xvsBalanceForScore(xvsStaked);\\n Capital memory capital = _capitalForScore(aprInfo.xvsBalanceForScore, borrow, supply, market);\\n\\n aprInfo.capital = capital.capital;\\n aprInfo.cappedSupply = capital.cappedSupply;\\n aprInfo.cappedBorrow = capital.cappedBorrow;\\n aprInfo.supplyCapUSD = capital.supplyCapUSD;\\n aprInfo.borrowCapUSD = capital.borrowCapUSD;\\n\\n uint256 decimals = IERC20MetadataUpgradeable(_getUnderlying(market)).decimals();\\n aprInfo.capital = aprInfo.capital * (10 ** (18 - decimals));\\n\\n aprInfo.userScore = Scores._calculateScore(\\n aprInfo.xvsBalanceForScore,\\n aprInfo.capital,\\n alphaNumerator,\\n alphaDenominator\\n );\\n\\n aprInfo.totalScore = aprInfo.totalScore + aprInfo.userScore;\\n\\n (aprInfo.supplyAPR, aprInfo.borrowAPR) = _calculateUserAPR(\\n market,\\n supply,\\n borrow,\\n aprInfo.cappedSupply,\\n aprInfo.cappedBorrow,\\n aprInfo.userScore,\\n aprInfo.totalScore\\n );\\n }\\n\\n /**\\n * @notice Distributes income from market since last distribution\\n * @param vToken the market for which to distribute the income\\n * @custom:error Throw MarketNotSupported if market is not supported\\n */\\n function accrueInterest(address vToken) public {\\n Market storage market = markets[vToken];\\n\\n if (!market.exists) revert MarketNotSupported();\\n\\n address underlying = _getUnderlying(vToken);\\n\\n IPrimeLiquidityProvider _primeLiquidityProvider = IPrimeLiquidityProvider(primeLiquidityProvider);\\n _primeLiquidityProvider.accrueTokens(underlying);\\n uint256 totalAccruedInPLP = _primeLiquidityProvider.tokenAmountAccrued(underlying);\\n uint256 unreleasedPLPAccruedInterest = totalAccruedInPLP - unreleasedPLPIncome[underlying];\\n uint256 distributionIncome = unreleasedPLPAccruedInterest;\\n\\n if (distributionIncome == 0) {\\n return;\\n }\\n\\n unreleasedPLPIncome[underlying] = totalAccruedInPLP;\\n\\n uint256 delta;\\n if (market.sumOfMembersScore != 0) {\\n delta = ((distributionIncome * EXP_SCALE) / market.sumOfMembersScore);\\n }\\n\\n market.rewardIndex += delta;\\n }\\n\\n /**\\n * @notice Returns boosted interest accrued for a user\\n * @param vToken the market for which to fetch the accrued interest\\n * @param user the account for which to get the accrued interest\\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\\n */\\n function getInterestAccrued(address vToken, address user) public returns (uint256) {\\n accrueInterest(vToken);\\n\\n return _interestAccrued(vToken, user);\\n }\\n\\n /**\\n * @notice accrues interest and updates score of all markets for an user\\n * @param user the account address for which to accrue interest and update score\\n */\\n function _accrueInterestAndUpdateScore(address user) internal {\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n for (uint256 i; i < marketsLength; ) {\\n address market = allMarkets[i];\\n _executeBoost(user, market);\\n _updateScore(user, market);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Initializes all the markets for the user when a prime token is minted\\n * @param account the account address for which markets needs to be initialized\\n */\\n function _initializeMarkets(address account) internal {\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n for (uint256 i; i < marketsLength; ) {\\n address market = allMarkets[i];\\n accrueInterest(market);\\n\\n interests[market][account].rewardIndex = markets[market].rewardIndex;\\n\\n uint256 score = _calculateScore(market, account);\\n interests[market][account].score = score;\\n markets[market].sumOfMembersScore = markets[market].sumOfMembersScore + score;\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice calculate the current score of user\\n * @param market the market for which to calculate the score\\n * @param user the account for which to calculate the score\\n * @return score the score of the user\\n */\\n function _calculateScore(address market, address user) internal returns (uint256) {\\n uint256 xvsBalanceForScore = _xvsBalanceForScore(_xvsBalanceOfUser(user));\\n\\n IVToken vToken = IVToken(market);\\n uint256 borrow = vToken.borrowBalanceStored(user);\\n uint256 exchangeRate = vToken.exchangeRateStored();\\n uint256 balanceOfAccount = vToken.balanceOf(user);\\n uint256 supply = (exchangeRate * balanceOfAccount) / EXP_SCALE;\\n\\n address xvsToken = IXVSVault(xvsVault).xvsAddress();\\n oracle.updateAssetPrice(xvsToken);\\n oracle.updatePrice(market);\\n\\n Capital memory capital = _capitalForScore(xvsBalanceForScore, borrow, supply, market);\\n\\n uint256 decimals = IERC20MetadataUpgradeable(_getUnderlying(market)).decimals();\\n\\n capital.capital = capital.capital * (10 ** (18 - decimals));\\n\\n return Scores._calculateScore(xvsBalanceForScore, capital.capital, alphaNumerator, alphaDenominator);\\n }\\n\\n /**\\n * @notice To transfer the accrued interest to user\\n * @param vToken the market for which to claim\\n * @param user the account for which to get the accrued interest\\n * @return amount the amount of tokens transferred to the user\\n * @custom:event Emits InterestClaimed event\\n */\\n function _claimInterest(address vToken, address user) internal returns (uint256) {\\n uint256 amount = getInterestAccrued(vToken, user);\\n amount += interests[vToken][user].accrued;\\n\\n interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;\\n delete interests[vToken][user].accrued;\\n\\n address underlying = _getUnderlying(vToken);\\n IERC20Upgradeable asset = IERC20Upgradeable(underlying);\\n\\n if (amount > asset.balanceOf(address(this))) {\\n delete unreleasedPLPIncome[underlying];\\n IPrimeLiquidityProvider(primeLiquidityProvider).releaseFunds(address(asset));\\n }\\n\\n asset.safeTransfer(user, amount);\\n\\n emit InterestClaimed(user, vToken, amount);\\n\\n return amount;\\n }\\n\\n /**\\n * @notice Used to mint a new prime token\\n * @param isIrrevocable is the tokens being issued is irrevocable\\n * @param user token owner\\n * @custom:error Throw IneligibleToClaim if user is not eligible to claim prime token\\n * @custom:event Emits Mint event\\n */\\n function _mint(bool isIrrevocable, address user) internal {\\n Token storage token = tokens[user];\\n if (token.exists) revert IneligibleToClaim();\\n\\n token.exists = true;\\n token.isIrrevocable = isIrrevocable;\\n\\n if (isIrrevocable) {\\n ++totalIrrevocable;\\n } else {\\n ++totalRevocable;\\n }\\n\\n if (totalIrrevocable > irrevocableLimit || totalRevocable > revocableLimit) revert InvalidLimit();\\n _updateRoundAfterTokenMinted(user);\\n\\n emit Mint(user, isIrrevocable);\\n }\\n\\n /**\\n * @notice Used to burn a new prime token\\n * @param user owner whose prime token to burn\\n * @custom:error Throw UserHasNoPrimeToken if user has no prime token\\n * @custom:event Emits Burn event\\n */\\n function _burn(address user) internal {\\n Token memory token = tokens[user];\\n if (!token.exists) revert UserHasNoPrimeToken();\\n\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n for (uint256 i; i < marketsLength; ) {\\n address market = allMarkets[i];\\n _executeBoost(user, market);\\n markets[market].sumOfMembersScore = markets[market].sumOfMembersScore - interests[market][user].score;\\n\\n delete interests[market][user].score;\\n delete interests[market][user].rewardIndex;\\n\\n unchecked {\\n ++i;\\n }\\n }\\n\\n if (token.isIrrevocable) {\\n --totalIrrevocable;\\n } else {\\n --totalRevocable;\\n }\\n\\n delete tokens[user].exists;\\n delete tokens[user].isIrrevocable;\\n\\n _updateRoundAfterTokenBurned(user);\\n\\n emit Burn(user);\\n }\\n\\n /**\\n * @notice Used to upgrade an token\\n * @param user owner whose prime token to upgrade\\n * @custom:error Throw InvalidLimit if total irrevocable tokens exceeds the limit\\n * @custom:event Emits TokenUpgraded event\\n */\\n function _upgrade(address user) internal {\\n Token storage userToken = tokens[user];\\n\\n userToken.isIrrevocable = true;\\n ++totalIrrevocable;\\n --totalRevocable;\\n\\n if (totalIrrevocable > irrevocableLimit) revert InvalidLimit();\\n\\n emit TokenUpgraded(user);\\n }\\n\\n /**\\n * @notice Accrue rewards for the user. Must be called before updating score\\n * @param user account for which we need to accrue rewards\\n * @param vToken the market for which we need to accrue rewards\\n */\\n function _executeBoost(address user, address vToken) internal {\\n if (!markets[vToken].exists || !tokens[user].exists) {\\n return;\\n }\\n\\n accrueInterest(vToken);\\n interests[vToken][user].accrued += _interestAccrued(vToken, user);\\n interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;\\n }\\n\\n /**\\n * @notice Update total score of user and market. Must be called after changing account's borrow or supply balance.\\n * @param user account for which we need to update score\\n * @param market the market for which we need to score\\n */\\n function _updateScore(address user, address market) internal {\\n Market storage _market = markets[market];\\n if (!_market.exists || !tokens[user].exists) {\\n return;\\n }\\n\\n uint256 score = _calculateScore(market, user);\\n _market.sumOfMembersScore = _market.sumOfMembersScore - interests[market][user].score + score;\\n\\n interests[market][user].score = score;\\n }\\n\\n /**\\n * @notice Verify new alpha arguments\\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\\n * @custom:error Throw InvalidAlphaArguments if alpha is invalid\\n */\\n function _checkAlphaArguments(uint128 _alphaNumerator, uint128 _alphaDenominator) internal pure {\\n if (_alphaNumerator >= _alphaDenominator || _alphaNumerator == 0) {\\n revert InvalidAlphaArguments();\\n }\\n }\\n\\n /**\\n * @notice starts round to update scores of a particular or all markets\\n */\\n function _startScoreUpdateRound() internal {\\n nextScoreUpdateRoundId++;\\n totalScoreUpdatesRequired = totalIrrevocable + totalRevocable;\\n pendingScoreUpdates = totalScoreUpdatesRequired;\\n }\\n\\n /**\\n * @notice update the required score updates when token is burned before round is completed\\n */\\n function _updateRoundAfterTokenBurned(address user) internal {\\n if (totalScoreUpdatesRequired != 0) --totalScoreUpdatesRequired;\\n\\n if (pendingScoreUpdates != 0 && !isScoreUpdated[nextScoreUpdateRoundId][user]) {\\n --pendingScoreUpdates;\\n }\\n }\\n\\n /**\\n * @notice update the required score updates when token is minted before round is completed\\n */\\n function _updateRoundAfterTokenMinted(address user) internal {\\n if (totalScoreUpdatesRequired != 0) isScoreUpdated[nextScoreUpdateRoundId][user] = true;\\n }\\n\\n /**\\n * @notice fetch the current XVS balance of user in the XVSVault\\n * @param user the account address\\n * @return xvsBalance the XVS balance of user\\n */\\n function _xvsBalanceOfUser(address user) internal view returns (uint256) {\\n (uint256 xvs, , uint256 pendingWithdrawals) = IXVSVault(xvsVault).getUserInfo(\\n xvsVaultRewardToken,\\n xvsVaultPoolId,\\n user\\n );\\n return (xvs - pendingWithdrawals);\\n }\\n\\n /**\\n * @notice calculate the current XVS balance that will be used in calculation of score\\n * @param xvs the actual XVS balance of user\\n * @return xvsBalanceForScore the XVS balance to use in score\\n */\\n function _xvsBalanceForScore(uint256 xvs) internal view returns (uint256) {\\n if (xvs > MAXIMUM_XVS_CAP) {\\n return MAXIMUM_XVS_CAP;\\n }\\n return xvs;\\n }\\n\\n /**\\n * @notice calculate the capital for calculation of score\\n * @param xvs the actual XVS balance of user\\n * @param borrow the borrow balance of user\\n * @param supply the supply balance of user\\n * @param market the market vToken address\\n * @return capital the capital to use in calculation of score\\n */\\n function _capitalForScore(\\n uint256 xvs,\\n uint256 borrow,\\n uint256 supply,\\n address market\\n ) internal view returns (Capital memory capital) {\\n address xvsToken = IXVSVault(xvsVault).xvsAddress();\\n\\n uint256 xvsPrice = oracle.getPrice(xvsToken);\\n capital.borrowCapUSD = (xvsPrice * ((xvs * markets[market].borrowMultiplier) / EXP_SCALE)) / EXP_SCALE;\\n capital.supplyCapUSD = (xvsPrice * ((xvs * markets[market].supplyMultiplier) / EXP_SCALE)) / EXP_SCALE;\\n\\n uint256 tokenPrice = oracle.getUnderlyingPrice(market);\\n uint256 supplyUSD = (tokenPrice * supply) / EXP_SCALE;\\n uint256 borrowUSD = (tokenPrice * borrow) / EXP_SCALE;\\n\\n if (supplyUSD >= capital.supplyCapUSD) {\\n supply = supplyUSD != 0 ? (supply * capital.supplyCapUSD) / supplyUSD : 0;\\n }\\n\\n if (borrowUSD >= capital.borrowCapUSD) {\\n borrow = borrowUSD != 0 ? (borrow * capital.borrowCapUSD) / borrowUSD : 0;\\n }\\n\\n capital.capital = supply + borrow;\\n capital.cappedSupply = supply;\\n capital.cappedBorrow = borrow;\\n }\\n\\n /**\\n * @notice Used to get if the XVS balance is eligible for prime token\\n * @param amount amount of XVS\\n * @return isEligible true if the staked XVS amount is enough to consider the associated user eligible for a Prime token, false otherwise\\n */\\n function _isEligible(uint256 amount) internal view returns (bool) {\\n if (amount >= MINIMUM_STAKED_XVS) {\\n return true;\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Calculate the interests accrued by the user in the market, since the last accrual\\n * @param vToken the market for which to calculate the accrued interest\\n * @param user the user for which to calculate the accrued interest\\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\\n */\\n function _interestAccrued(address vToken, address user) internal view returns (uint256) {\\n Interest memory interest = interests[vToken][user];\\n uint256 index = markets[vToken].rewardIndex - interest.rewardIndex;\\n\\n uint256 score = interest.score;\\n\\n return (index * score) / EXP_SCALE;\\n }\\n\\n /**\\n * @notice Returns the underlying token associated with the VToken, or wrapped native token if the market is native market\\n * @param vToken the market whose underlying token will be returned\\n * @return underlying The address of the underlying token associated with the VToken, or the address of the WRAPPED_NATIVE_TOKEN token if the market is NATIVE_MARKET\\n */\\n function _getUnderlying(address vToken) internal view returns (address) {\\n if (vToken == NATIVE_MARKET) {\\n return WRAPPED_NATIVE_TOKEN;\\n }\\n return IVToken(vToken).underlying();\\n }\\n\\n //////////////////////////////////////////////////\\n //////////////// APR Calculation ////////////////\\n ////////////////////////////////////////////////\\n\\n /**\\n * @notice the total income that's going to be distributed in a year to prime token holders\\n * @param vToken the market for which to fetch the total income that's going to distributed in a year\\n * @return amount the total income\\n */\\n function incomeDistributionYearly(address vToken) public view returns (uint256 amount) {\\n uint256 totalIncomePerBlockOrSecondFromPLP = IPrimeLiquidityProvider(primeLiquidityProvider)\\n .getEffectiveDistributionSpeed(_getUnderlying(vToken));\\n amount = blocksOrSecondsPerYear * totalIncomePerBlockOrSecondFromPLP;\\n }\\n\\n /**\\n * @notice used to calculate the supply and borrow APR of the user\\n * @param vToken the market for which to fetch the APR\\n * @param totalSupply the total token supply of the user\\n * @param totalBorrow the total tokens borrowed by the user\\n * @param totalCappedSupply the total token capped supply of the user\\n * @param totalCappedBorrow the total capped tokens borrowed by the user\\n * @param userScore the score of the user\\n * @param totalScore the total market score\\n * @return supplyAPR the supply APR of the user\\n * @return borrowAPR the borrow APR of the user\\n */\\n function _calculateUserAPR(\\n address vToken,\\n uint256 totalSupply,\\n uint256 totalBorrow,\\n uint256 totalCappedSupply,\\n uint256 totalCappedBorrow,\\n uint256 userScore,\\n uint256 totalScore\\n ) internal view returns (uint256 supplyAPR, uint256 borrowAPR) {\\n if (totalScore == 0) return (0, 0);\\n\\n uint256 userYearlyIncome = (userScore * incomeDistributionYearly(vToken)) / totalScore;\\n\\n uint256 totalCappedValue = totalCappedSupply + totalCappedBorrow;\\n\\n if (totalCappedValue == 0) return (0, 0);\\n\\n uint256 maximumBps = MAXIMUM_BPS;\\n uint256 userSupplyIncomeYearly;\\n uint256 userBorrowIncomeYearly;\\n userSupplyIncomeYearly = (userYearlyIncome * totalCappedSupply) / totalCappedValue;\\n userBorrowIncomeYearly = (userYearlyIncome * totalCappedBorrow) / totalCappedValue;\\n supplyAPR = totalSupply == 0 ? 0 : ((userSupplyIncomeYearly * maximumBps) / totalSupply);\\n borrowAPR = totalBorrow == 0 ? 0 : ((userBorrowIncomeYearly * maximumBps) / totalBorrow);\\n }\\n}\\n\",\"keccak256\":\"0xa0f8eb4edd3cba1ea9b35c3bd368c8694ff9c6ac0ce71501fdc5d8fb4902f1de\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/PrimeStorage.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { ResilientOracleInterface } from \\\"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\\\";\\n\\n/**\\n * @title PrimeStorageV1\\n * @author Venus\\n * @notice Storage for Prime Token\\n */\\ncontract PrimeStorageV1 {\\n struct Token {\\n bool exists;\\n bool isIrrevocable;\\n }\\n\\n struct Market {\\n uint256 supplyMultiplier;\\n uint256 borrowMultiplier;\\n uint256 rewardIndex;\\n uint256 sumOfMembersScore;\\n bool exists;\\n }\\n\\n struct Interest {\\n uint256 accrued;\\n uint256 score;\\n uint256 rewardIndex;\\n }\\n\\n struct PendingReward {\\n address vToken;\\n address rewardToken;\\n uint256 amount;\\n }\\n\\n /// @notice Base unit for computations, usually used in scaling (multiplications, divisions)\\n uint256 internal constant EXP_SCALE = 1e18;\\n\\n /// @notice maximum BPS = 100%\\n uint256 internal constant MAXIMUM_BPS = 1e4;\\n\\n /// @notice Mapping to get prime token's metadata\\n mapping(address => Token) public tokens;\\n\\n /// @notice Tracks total irrevocable tokens minted\\n uint256 public totalIrrevocable;\\n\\n /// @notice Tracks total revocable tokens minted\\n uint256 public totalRevocable;\\n\\n /// @notice Indicates maximum revocable tokens that can be minted\\n uint256 public revocableLimit;\\n\\n /// @notice Indicates maximum irrevocable tokens that can be minted\\n uint256 public irrevocableLimit;\\n\\n /// @notice Tracks when prime token eligible users started staking for claiming prime token\\n mapping(address => uint256) public stakedAt;\\n\\n /// @notice vToken to market configuration\\n mapping(address => Market) public markets;\\n\\n /// @notice vToken to user to user index\\n mapping(address => mapping(address => Interest)) public interests;\\n\\n /// @notice A list of boosted markets\\n address[] internal _allMarkets;\\n\\n /// @notice numerator of alpha. Ex: if alpha is 0.5 then this will be 1\\n uint128 public alphaNumerator;\\n\\n /// @notice denominator of alpha. Ex: if alpha is 0.5 then this will be 2\\n uint128 public alphaDenominator;\\n\\n /// @notice address of XVS vault\\n address public xvsVault;\\n\\n /// @notice address of XVS vault reward token\\n address public xvsVaultRewardToken;\\n\\n /// @notice address of XVS vault pool id\\n uint256 public xvsVaultPoolId;\\n\\n /// @notice mapping to check if a account's score was updated in the round\\n mapping(uint256 => mapping(address => bool)) public isScoreUpdated;\\n\\n /// @notice unique id for next round\\n uint256 public nextScoreUpdateRoundId;\\n\\n /// @notice total number of accounts whose score needs to be updated\\n uint256 public totalScoreUpdatesRequired;\\n\\n /// @notice total number of accounts whose score is yet to be updated\\n uint256 public pendingScoreUpdates;\\n\\n /// @notice mapping used to find if an asset is part of prime markets\\n mapping(address => address) public vTokenForAsset;\\n\\n /// @notice Address of core pool comptroller contract\\n address internal corePoolComptroller;\\n\\n /// @notice unreleased income from PLP that's already distributed to prime holders\\n /// @dev mapping of asset address => amount\\n mapping(address => uint256) public unreleasedPLPIncome;\\n\\n /// @notice The address of PLP contract\\n address public primeLiquidityProvider;\\n\\n /// @notice The address of ResilientOracle contract\\n ResilientOracleInterface public oracle;\\n\\n /// @notice The address of PoolRegistry contract\\n address public poolRegistry;\\n\\n /// @dev This empty reserved space is put in place to allow future versions to add new\\n /// variables without shifting down storage in the inheritance chain.\\n uint256[26] private __gap;\\n}\\n\",\"keccak256\":\"0x5285c875114db2ea2be0b81b65722d5761806217022db733323c4e03365a95e7\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/libs/FixedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// solhint-disable var-name-mixedcase\\n\\npragma solidity 0.8.25;\\n\\nimport { SafeCastUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\nimport { FixedMath0x } from \\\"./FixedMath0x.sol\\\";\\n\\nusing SafeCastUpgradeable for uint256;\\n\\nerror InvalidFixedPoint();\\n\\n/**\\n * @title FixedMath\\n * @author Venus\\n * @notice FixedMath library is used for complex mathematical operations\\n */\\nlibrary FixedMath {\\n error InvalidFraction(uint256 n, uint256 d);\\n\\n /**\\n * @notice Convert some uint256 fraction `n` numerator / `d` denominator to a fixed-point number `f`.\\n * @param n numerator\\n * @param d denominator\\n * @return fixed-point number\\n */\\n function _toFixed(uint256 n, uint256 d) internal pure returns (int256) {\\n if (d.toInt256() < n.toInt256()) revert InvalidFraction(n, d);\\n\\n return (n.toInt256() * FixedMath0x.FIXED_1) / int256(d.toInt256());\\n }\\n\\n /**\\n * @notice Divide some unsigned int `u` by a fixed point number `f`\\n * @param u unsigned dividend\\n * @param f fixed point divisor, in FIXED_1 units\\n * @return unsigned int quotient\\n */\\n function _uintDiv(uint256 u, int256 f) internal pure returns (uint256) {\\n if (f < 0) revert InvalidFixedPoint();\\n // multiply `u` by FIXED_1 to cancel out the built-in FIXED_1 in f\\n return uint256((u.toInt256() * FixedMath0x.FIXED_1) / f);\\n }\\n\\n /**\\n * @notice Multiply some unsigned int `u` by a fixed point number `f`\\n * @param u unsigned multiplicand\\n * @param f fixed point multiplier, in FIXED_1 units\\n * @return unsigned int product\\n */\\n function _uintMul(uint256 u, int256 f) internal pure returns (uint256) {\\n if (f < 0) revert InvalidFixedPoint();\\n // divide the product by FIXED_1 to cancel out the built-in FIXED_1 in f\\n return uint256((u.toInt256() * f) / FixedMath0x.FIXED_1);\\n }\\n\\n /// @notice see FixedMath0x\\n function _ln(int256 x) internal pure returns (int256) {\\n return FixedMath0x._ln(x);\\n }\\n\\n /// @notice see FixedMath0x\\n function _exp(int256 x) internal pure returns (int256) {\\n return FixedMath0x._exp(x);\\n }\\n}\\n\",\"keccak256\":\"0x9079477d98acfc1a1dab1279230eb33d5cc6898e17c3b61aec912de0ba4fee8a\",\"license\":\"MIT\"},\"contracts/Tokens/Prime/libs/FixedMath0x.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// solhint-disable max-line-length\\n\\npragma solidity 0.8.25;\\n\\n// Below is code from 0x's LibFixedMath.sol. Changes:\\n// - addition of 0.8-style errors\\n// - removal of unused functions\\n// - added comments for clarity\\n// https://github.com/0xProject/exchange-v3/blob/aae46bef841bfd1cc31028f41793db4fe7197084/contracts/staking/contracts/src/libs/LibFixedMath.sol\\n\\n/*\\n\\n Copyright 2017 Bprotocol Foundation, 2019 ZeroEx Intl.\\n\\n Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n you may not use this file except in compliance with the License.\\n You may obtain a copy of the License at\\n\\n http://www.apache.org/licenses/LICENSE-2.0\\n\\n Unless required by applicable law or agreed to in writing, software\\n distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n See the License for the specific language governing permissions and\\n limitations under the License.\\n\\n*/\\n/// Thrown when the natural log function is given too large of an argument\\nerror LnTooLarge(int256 x);\\n/// Thrown when the natural log would have returned a number outside of \\u211d\\nerror LnNonRealResult(int256 x);\\n/// Thrown when exp is given too large of an argument\\nerror ExpTooLarge(int256 x);\\n/// Thrown when an unsigned value is too large to be converted to a signed value\\nerror UnsignedValueTooLarge(uint256 x);\\n\\n/**\\n * @title FixedMath0x\\n * @notice Signed, fixed-point, 127-bit precision math library\\n */\\nlibrary FixedMath0x {\\n // Base for the fixed point numbers (this is our 1)\\n int256 internal constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000);\\n // Maximum ln argument (1)\\n int256 private constant LN_MAX_VAL = FIXED_1;\\n // Minimum ln argument. Notice this is related to EXP_MIN_VAL (e ^ -63.875)\\n int256 private constant LN_MIN_VAL = int256(0x0000000000000000000000000000000000000000000000000000000733048c5a);\\n // Maximum exp argument (0)\\n int256 private constant EXP_MAX_VAL = 0;\\n // Minimum exp argument. Notice this is related to LN_MIN_VAL (-63.875)\\n int256 private constant EXP_MIN_VAL = -int256(0x0000000000000000000000000000001ff0000000000000000000000000000000);\\n\\n /// @dev Get the natural logarithm of a fixed-point number 0 < `x` <= LN_MAX_VAL\\n function _ln(int256 x) internal pure returns (int256 r) {\\n if (x > LN_MAX_VAL) {\\n revert LnTooLarge(x);\\n }\\n if (x <= 0) {\\n revert LnNonRealResult(x);\\n }\\n if (x == FIXED_1) {\\n return 0;\\n }\\n if (x <= LN_MIN_VAL) {\\n return EXP_MIN_VAL;\\n }\\n\\n int256 y;\\n int256 z;\\n int256 w;\\n\\n // Rewrite the input as a quotient of negative natural exponents and a single residual q, such that 1 < q < 2\\n // For example: log(0.3) = log(e^-1 * e^-0.25 * 1.0471028872385522)\\n // = 1 - 0.25 - log(1 + 0.0471028872385522)\\n // e ^ -32\\n if (x <= int256(0x00000000000000000000000000000000000000000001c8464f76164760000000)) {\\n r -= int256(0x0000000000000000000000000000001000000000000000000000000000000000); // - 32\\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32\\n }\\n // e ^ -16\\n if (x <= int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000)) {\\n r -= int256(0x0000000000000000000000000000000800000000000000000000000000000000); // - 16\\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000); // / e ^ -16\\n }\\n // e ^ -8\\n if (x <= int256(0x00000000000000000000000000000000000afe10820813d78000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000400000000000000000000000000000000); // - 8\\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000afe10820813d78000000000000000); // / e ^ -8\\n }\\n // e ^ -4\\n if (x <= int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000200000000000000000000000000000000); // - 4\\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000); // / e ^ -4\\n }\\n // e ^ -2\\n if (x <= int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000100000000000000000000000000000000); // - 2\\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000); // / e ^ -2\\n }\\n // e ^ -1\\n if (x <= int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000080000000000000000000000000000000); // - 1\\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000); // / e ^ -1\\n }\\n // e ^ -0.5\\n if (x <= int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000040000000000000000000000000000000); // - 0.5\\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000); // / e ^ -0.5\\n }\\n // e ^ -0.25\\n if (x <= int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000020000000000000000000000000000000); // - 0.25\\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000); // / e ^ -0.25\\n }\\n // e ^ -0.125\\n if (x <= int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) {\\n r -= int256(0x0000000000000000000000000000000010000000000000000000000000000000); // - 0.125\\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d); // / e ^ -0.125\\n }\\n // `x` is now our residual in the range of 1 <= x <= 2 (or close enough).\\n\\n // Add the taylor series for log(1 + z), where z = x - 1\\n z = y = x - FIXED_1;\\n w = (y * y) / FIXED_1;\\n r += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02\\n r += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04\\n r += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06\\n r += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08\\n r += (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / 0x500000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^09 / 09 - y^10 / 10\\n r += (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / 0x600000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^11 / 11 - y^12 / 12\\n r += (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / 0x700000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^13 / 13 - y^14 / 14\\n r += (z * (0x088888888888888888888888888888888 - y)) / 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16\\n }\\n\\n /// @dev Compute the natural exponent for a fixed-point number EXP_MIN_VAL <= `x` <= 1\\n function _exp(int256 x) internal pure returns (int256 r) {\\n if (x < EXP_MIN_VAL) {\\n // Saturate to zero below EXP_MIN_VAL.\\n return 0;\\n }\\n if (x == 0) {\\n return FIXED_1;\\n }\\n if (x > EXP_MAX_VAL) {\\n revert ExpTooLarge(x);\\n }\\n\\n // Rewrite the input as a product of natural exponents and a\\n // single residual q, where q is a number of small magnitude.\\n // For example: e^-34.419 = e^(-32 - 2 - 0.25 - 0.125 - 0.044)\\n // = e^-32 * e^-2 * e^-0.25 * e^-0.125 * e^-0.044\\n // -> q = -0.044\\n\\n // Multiply with the taylor series for e^q\\n int256 y;\\n int256 z;\\n // q = x % 0.125 (the residual)\\n z = y = x % 0x0000000000000000000000000000000010000000000000000000000000000000;\\n z = (z * y) / FIXED_1;\\n r += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x004807432bc18000; // add y^05 * (20! / 05!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000017499f00; // add y^13 * (20! / 13!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x00000000001c6380; // add y^15 * (20! / 15!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000000000001c638; // add y^16 * (20! / 16!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000000000000017c; // add y^18 * (20! / 18!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000000000014; // add y^19 * (20! / 19!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000000000001; // add y^20 * (20! / 20!)\\n r = r / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!\\n\\n // Multiply with the non-residual terms.\\n x = -x;\\n // e ^ -32\\n if ((x & int256(0x0000000000000000000000000000001000000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x00000000000000000000000000000000000000f1aaddd7742e56d32fb9f99744)) /\\n int256(0x0000000000000000000000000043cbaf42a000812488fc5c220ad7b97bf6e99e); // * e ^ -32\\n }\\n // e ^ -16\\n if ((x & int256(0x0000000000000000000000000000000800000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x00000000000000000000000000000000000afe10820813d65dfe6a33c07f738f)) /\\n int256(0x000000000000000000000000000005d27a9f51c31b7c2f8038212a0574779991); // * e ^ -16\\n }\\n // e ^ -8\\n if ((x & int256(0x0000000000000000000000000000000400000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x0000000000000000000000000000000002582ab704279e8efd15e0265855c47a)) /\\n int256(0x0000000000000000000000000000001b4c902e273a58678d6d3bfdb93db96d02); // * e ^ -8\\n }\\n // e ^ -4\\n if ((x & int256(0x0000000000000000000000000000000200000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x000000000000000000000000000000001152aaa3bf81cb9fdb76eae12d029571)) /\\n int256(0x00000000000000000000000000000003b1cc971a9bb5b9867477440d6d157750); // * e ^ -4\\n }\\n // e ^ -2\\n if ((x & int256(0x0000000000000000000000000000000100000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x000000000000000000000000000000002f16ac6c59de6f8d5d6f63c1482a7c86)) /\\n int256(0x000000000000000000000000000000015bf0a8b1457695355fb8ac404e7a79e3); // * e ^ -2\\n }\\n // e ^ -1\\n if ((x & int256(0x0000000000000000000000000000000080000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x000000000000000000000000000000004da2cbf1be5827f9eb3ad1aa9866ebb3)) /\\n int256(0x00000000000000000000000000000000d3094c70f034de4b96ff7d5b6f99fcd8); // * e ^ -1\\n }\\n // e ^ -0.5\\n if ((x & int256(0x0000000000000000000000000000000040000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x0000000000000000000000000000000063afbe7ab2082ba1a0ae5e4eb1b479dc)) /\\n int256(0x00000000000000000000000000000000a45af1e1f40c333b3de1db4dd55f29a7); // * e ^ -0.5\\n }\\n // e ^ -0.25\\n if ((x & int256(0x0000000000000000000000000000000020000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) /\\n int256(0x00000000000000000000000000000000910b022db7ae67ce76b441c27035c6a1); // * e ^ -0.25\\n }\\n // e ^ -0.125\\n if ((x & int256(0x0000000000000000000000000000000010000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x00000000000000000000000000000000783eafef1c0a8f3978c7f81824d62ebf)) /\\n int256(0x0000000000000000000000000000000088415abbe9a76bead8d00cf112e4d4a8); // * e ^ -0.125\\n }\\n }\\n}\\n\",\"keccak256\":\"0xda0304ab7a6b5953a0fed087ba324eeaacbf826a412c5492cb0e445dc03a88a3\",\"license\":\"MIT\"},\"contracts/Tokens/Prime/libs/Scores.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.25;\\n\\nimport { SafeCastUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\nimport { FixedMath } from \\\"./FixedMath.sol\\\";\\n\\nusing SafeCastUpgradeable for uint256;\\n\\n/**\\n * @title Scores\\n * @author Venus\\n * @notice Scores library is used to calculate score of users\\n */\\nlibrary Scores {\\n /**\\n * @notice Calculate a membership score given some amount of `xvs` and `capital`, along\\n * with some \\ud835\\udf70 = `alphaNumerator` / `alphaDenominator`.\\n * @param xvs amount of xvs (xvs, 1e18 decimal places)\\n * @param capital amount of capital (1e18 decimal places)\\n * @param alphaNumerator alpha param numerator\\n * @param alphaDenominator alpha param denominator\\n * @return membership score with 1e18 decimal places\\n *\\n * @dev \\ud835\\udf70 must be in the range [0, 1]\\n */\\n function _calculateScore(\\n uint256 xvs,\\n uint256 capital,\\n uint256 alphaNumerator,\\n uint256 alphaDenominator\\n ) internal pure returns (uint256) {\\n // Score function is:\\n // xvs^\\ud835\\udf70 * capital^(1-\\ud835\\udf70)\\n // = capital * capital^(-\\ud835\\udf70) * xvs^\\ud835\\udf70\\n // = capital * (xvs / capital)^\\ud835\\udf70\\n // = capital * (e ^ (ln(xvs / capital))) ^ \\ud835\\udf70\\n // = capital * e ^ (\\ud835\\udf70 * ln(xvs / capital)) (1)\\n // or\\n // = capital / ( 1 / e ^ (\\ud835\\udf70 * ln(xvs / capital)))\\n // = capital / (e ^ (\\ud835\\udf70 * ln(xvs / capital)) ^ -1)\\n // = capital / e ^ (\\ud835\\udf70 * -1 * ln(xvs / capital))\\n // = capital / e ^ (\\ud835\\udf70 * ln(capital / xvs)) (2)\\n //\\n // To avoid overflows, use (1) when xvs < capital and\\n // use (2) when capital < xvs\\n\\n // If any side is 0, exit early\\n if (xvs == 0 || capital == 0) return 0;\\n\\n // If both sides are equal, we have:\\n // xvs^\\ud835\\udf70 * capital^(1-\\ud835\\udf70)\\n // = xvs^\\ud835\\udf70 * xvs^(1-\\ud835\\udf70)\\n // = xvs^(\\ud835\\udf70 + 1 - \\ud835\\udf70) = xvs\\n if (xvs == capital) return xvs;\\n\\n bool lessxvsThanCapital = xvs < capital;\\n\\n // (xvs / capital) or (capital / xvs), always in range (0, 1)\\n int256 ratio = lessxvsThanCapital ? FixedMath._toFixed(xvs, capital) : FixedMath._toFixed(capital, xvs);\\n\\n // e ^ ( ln(ratio) * \\ud835\\udf70 )\\n int256 exponentiation = FixedMath._exp(\\n (FixedMath._ln(ratio) * alphaNumerator.toInt256()) / alphaDenominator.toInt256()\\n );\\n\\n if (lessxvsThanCapital) {\\n // capital * e ^ (\\ud835\\udf70 * ln(xvs / capital))\\n return FixedMath._uintMul(capital, exponentiation);\\n }\\n\\n // capital / e ^ (\\ud835\\udf70 * ln(capital / xvs))\\n return FixedMath._uintDiv(capital, exponentiation);\\n }\\n}\\n\",\"keccak256\":\"0xa02a36d836711c975f20b8e67fc134d986881f5fd9f835be285ed8021ffc10ca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x61018060405234801561001157600080fd5b50604051615f00380380615f00833981016040819052610030916101ea565b80858115801561003e575080155b1561005c576040516302723dfb60e21b815260040160405180910390fd5b81801561006857508015155b156100865760405163ae0fcab360e01b815260040160405180910390fd5b81151560a05281610097578061009d565b6301e133805b608052816100b45761010760201b6125fb176100bf565b61010b60201b6125ff175b6001600160401b031660c05250506001600160a01b0380881660e0528616610100526101608490526101208390526101408290526100fb61010f565b5050505050505061025d565b4390565b4290565b600054610100900460ff161561017b5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146101cc576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146101e557600080fd5b919050565b600080600080600080600060e0888a03121561020557600080fd5b61020e886101ce565b965061021c602089016101ce565b955060408801519450606088015193506080880151925060a0880151915060c0880151801515811461024d57600080fd5b8091505092959891949750929550565b60805160a05160c05160e05161010051610120516101405161016051615bf8610308600039600081816103f00152818161107701528181612182015281816121ad01526121d5015260008181610ac301528181613416015261343f0152600081816105a40152612a180152600081816109330152612ebf01526000818161043f0152612ef901526000612132015260006108f80152600081816105cb01526113a60152615bf86000f3fe608060405234801561001057600080fd5b50600436106103e65760003560e01c80639f6506ce1161020a578063cdaa21b711610125578063e30c3978116100b8578063ef36bbde11610087578063ef36bbde14610a57578063f2fde38b14610a78578063f6ed201714610a8b578063fa6d5f1814610aab578063fe1006ad14610abe57600080fd5b8063e30c3978146109c5578063e4676f37146109d6578063e4860339146109e9578063ee6b13fc14610a2d57600080fd5b8063d88b9d2e116100f4578063d88b9d2e14610996578063da6ab4f8146109a0578063e18f8822146109aa578063e1d146fb146109bd57600080fd5b8063cdaa21b71461092e578063ce85361314610955578063cf329d1614610970578063d65bd2411461098357600080fd5b8063ba437c681161019d578063c3db3c361161016c578063c3db3c36146108e1578063c4ae3168146108eb578063c7ad0895146108f3578063c86d1a781461091a57600080fd5b8063ba437c68146108a8578063bc5dc4c3146108bb578063bd212c0e146108ce578063be26317e146108d857600080fd5b8063b1a250f2116101d9578063b1a250f2146107a2578063b4a0bdf3146107b5578063b7f2d258146107c6578063b9eb69f61461085257600080fd5b80639f6506ce14610765578063a15753dc1461076f578063afcff50f14610779578063b0772d0b1461078d57600080fd5b80635fe3b5671161030557806380d45a2d1161029857806389afcb441161026757806389afcb44146106945780638da5cb5b146106a75780638e8f294b146106b85780639198e515146107235780639565d3d21461073657600080fd5b806380d45a2d14610650578063856c3aa41461066357806388bead731461066d57806388d742c21461068157600080fd5b806379ba5097116102d457806379ba5097146105f55780637dafcd89146105fd5780637dc0d1d0146106105780637ef820701461062457600080fd5b80635fe3b5671461058d5780636426b4a71461059f5780636857249c146105c6578063715018a6146105ed57600080fd5b806337f23cd31161037d57806355d36c981161034c57806355d36c9814610549578063594a67ee1461055c5780635c975abb1461056f5780635d536d301461057a57600080fd5b806337f23cd3146104e757806338f6a434146104fa578063487b0dfb146105375780634e71d92d1461054157600080fd5b80631bffac89116103b95780631bffac891461048d578063207add91146104ae57806324e6baf2146104c157806329b6eca9146104d457600080fd5b80630104db1b146103eb5780630e32cb86146104255780631b3f8c5e1461043a5780631b9ce57514610479575b600080fd5b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6104386104333660046150ac565b610ae5565b005b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161041c565b61013754610461906001600160a01b031681565b61041261049b3660046150ac565b6101406020526000908152604090205481565b6104386104bc3660046150c9565b610af9565b6104386104cf366004615137565b610bb4565b6104386104e23660046150ac565b610d80565b6104386104f53660046150ac565b610e38565b6105276105083660046150ac565b6001600160a01b0316600090815261012d602052604090205460ff1690565b604051901515815260200161041c565b6104126101395481565b610438611044565b610438610557366004615179565b6110d3565b61043861056a3660046151ae565b61119e565b60c95460ff16610527565b6104126105883660046150ac565b611316565b61013f546001600160a01b0316610461565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104386113d1565b6104386113e5565b61043861060b366004615228565b61145c565b61014254610461906001600160a01b031681565b61013654610638906001600160801b031681565b6040516001600160801b03909116815260200161041c565b61043861065e36600461527d565b6115e6565b6104126101315481565b61013854610461906001600160a01b031681565b61041261068f3660046150ac565b61162d565b6104386106a23660046150ac565b611649565b6033546001600160a01b0316610461565b6106f96106c63660046150ac565b61013360205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161041c565b6104386107313660046150ac565b611680565b610527610744366004615296565b61013a60209081526000928352604080842090915290825290205460ff1681565b61041261012f5481565b61041261013b5481565b61014354610461906001600160a01b031681565b610795611844565b60405161041c91906152c6565b6104386107b036600461532a565b6118a7565b6097546001600160a01b0316610461565b6107d96107d43660046153e4565b611abc565b60405161041c9190600061014082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525092915050565b61088d610860366004615435565b61013460209081526000928352604080842090915290825290208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161041c565b6104126108b6366004615435565b611c76565b6104386108c9366004615463565b611c93565b61041261013c5481565b61041260fb5481565b61041261013d5481565b610438611fb1565b6105277f000000000000000000000000000000000000000000000000000000000000000081565b61014154610461906001600160a01b031681565b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6101365461063890600160801b90046001600160801b031681565b61043861097e366004615435565b611ffa565b610412610991366004615435565b612012565b61041261012e5481565b6104126101305481565b6104386109b83660046154a9565b612027565b61041261212b565b6065546001600160a01b0316610461565b6104126109e43660046150ac565b61215e565b610a166109f73660046150ac565b61012d6020526000908152604090205460ff8082169161010090041682565b60408051921515835290151560208301520161041c565b610461610a3b3660046150ac565b61013e602052600090815260409020546001600160a01b031681565b610412610a653660046150ac565b6101326020526000908152604090205481565b610438610a863660046150ac565b612206565b610a9e610a993660046150ac565b612277565b60405161041c91906154dc565b6107d9610ab9366004615435565b6123b9565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b610aed612603565b610af68161265d565b50565b610b376040518060400160405280601981526020017f7365744c696d69742875696e743235362c75696e74323536290000000000000081525061271b565b61012e54821080610b4a575061012f5481105b15610b685760405163e55fb50960e01b815260040160405180910390fd5b8161013054610131547f6c52f3e195bdc534883e903e0612c49261a466aacd492501870b0a0ac0b1835584604051610ba291815260200190565b60405180910390a46101305561013155565b61013d54600003610bd85760405163071a45dd60e31b815260040160405180910390fd5b61013b54600003610bfc5760405163071a45dd60e31b815260040160405180910390fd5b60005b81811015610d7b576000838383818110610c1b57610c1b615541565b9050602002016020810190610c3091906150ac565b6001600160a01b038116600090815261012d602052604090205490915060ff16610c6d57604051633aeb927b60e11b815260040160405180910390fd5b61013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff1615610ca65750600101610bff565b610135805460005b81811015610cfe576000838281548110610cca57610cca615541565b6000918252602090912001546001600160a01b03169050610ceb85826127b5565b610cf58582612891565b50600101610cae565b5061013d60008154610d0f9061556d565b9091555061013b54600090815261013a602090815260408083206001600160a01b0387168085529252808320805460ff19166001908117909155905196019590917fa699df4aa8f89fc1f5408fe78ae114651f18b25ed1601680e4c70c15177d8b1b91a2505050610bff565b505050565b600054600290610100900460ff16158015610da2575060005460ff8083169116105b610dc75760405162461bcd60e51b8152600401610dbe90615584565b60405180910390fd5b6000805461014380546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6000610e438261296e565b90506000610e5082612a14565b6001600160a01b0384166000908152610132602090815260408083205461012d83529281902081518083019092525460ff808216158015808552610100909304909116151593830193909352939450919290610eaa575082155b15610f0c576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615b79833981519152910160405180910390a2806020015115610f0357610efe85612a4d565b61103d565b610efe85612aa5565b82158015610f1957508051155b8015610f2457508115155b15610f6b576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615b7983398151915291015b60405180910390a261103d565b81158015610f765750825b8015610f8157508051155b15610fc3576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615b798339815191529101610f5e565b80518015610fce5750825b1561103d57610fdc85612a4d565b6001600160a01b03851660009081526101326020526040812054900361103d576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615b79833981519152910160405180910390a25b5050505050565b3360009081526101326020526040812054908190036110755760405162c4e3d160e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006110a082426155d2565b10156110bf5760405163beb98cab60e01b815260040160405180910390fd5b6110ca600033612c79565b610af633612d8a565b6110f46040518060600160405280602a8152602001615b4f602a913961271b565b6001600160a01b038316600090815261013360205260409020600481015460ff1661113257604051630ff2e4a960e31b815260040160405180910390fd5b61113b84611680565b6001810154815460408051868152602081018690526001600160a01b038816917f91e78a55b6df3a0eac1c12a64572a8c0faced385bafba688817f5ce6daa33537910160405180910390a482815560018101829055611198612e87565b50505050565b6111dc6040518060400160405280602081526020017f7365745374616b6564417428616464726573735b5d2c75696e743235365b5d2981525061271b565b8281146111fc5760405163251f56a160e21b815260040160405180910390fd5b60005b8381101561103d574283838381811061121a5761121a615541565b9050602002013511156112405760405163b7d0949760e01b815260040160405180910390fd5b82828281811061125257611252615541565b90506020020135610132600087878581811061127057611270615541565b905060200201602081019061128591906150ac565b6001600160a01b031681526020810191909152604001600020558484828181106112b1576112b1615541565b90506020020160208101906112c691906150ac565b6001600160a01b0316600080516020615b798339815191528484848181106112f0576112f0615541565b9050602002013560405161130691815260200190565b60405180910390a26001016111ff565b6101415460009081906001600160a01b031663a666642b61133685612ebb565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561137a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139e91906155e5565b90506113ca817f00000000000000000000000000000000000000000000000000000000000000006155fe565b9392505050565b6113d9612603565b6113e36000612f7f565b565b60655433906001600160a01b031681146114535760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610dbe565b610af681612f7f565b61149260405180604001604052806015815260200174697373756528626f6f6c2c616464726573735b5d2960581b81525061271b565b82156115a75760005b8181101561119857600061012d60008585858181106114bc576114bc615541565b90506020020160208101906114d191906150ac565b6001600160a01b031681526020810191909152604001600020805490915060ff16801561150557508054610100900460ff16155b1561153e5761153984848481811061151f5761151f615541565b905060200201602081019061153491906150ac565b612f98565b61159e565b61156f600185858581811061155557611555615541565b905060200201602081019061156a91906150ac565b612c79565b61159e84848481811061158457611584615541565b905060200201602081019061159991906150ac565b612d8a565b5060010161149b565b60005b81811015611198576115c9600084848481811061155557611555615541565b6115de83838381811061158457611584615541565b6001016115aa565b6116246040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e74323536290000000000000081525061271b565b610af681613048565b60006116376130e2565b6116418233613128565b90505b919050565b6116776040518060400160405280600d81526020016c6275726e28616464726573732960981b81525061271b565b610af681612aa5565b6001600160a01b038116600090815261013360205260409020600481015460ff166116be57604051630ff2e4a960e31b815260040160405180910390fd5b60006116c983612ebb565b61014154604051638aadf79960e01b81526001600160a01b0380841660048301529293509116908190638aadf79990602401600060405180830381600087803b15801561171557600080fd5b505af1158015611729573d6000803e3d6000fd5b505060405163fa7781ff60e01b81526001600160a01b038581166004830152600093508416915063fa7781ff90602401602060405180830381865afa158015611776573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179a91906155e5565b6001600160a01b03841660009081526101406020526040812054919250906117c290836155d2565b90508060008190036117d75750505050505050565b6001600160a01b038516600090815261014060205260408120849055600387015415611821576003870154611814670de0b6b3a7640000846155fe565b61181e919061562b565b90505b80876002016000828254611835919061563f565b90915550505050505050505050565b606061013580548060200260200160405190810160405280929190818152602001828054801561189d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161187f575b5050505050905090565b600054610100900460ff16158080156118c75750600054600160ff909116105b806118e15750303b1580156118e1575060005460ff166001145b6118fd5760405162461bcd60e51b8152600401610dbe90615584565b6000805460ff191660011790558015611920576000805461ff0019166101001790555b6001600160a01b038b166119475760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038a1661196e5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0383166119955760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0385166119bc5760405163e6c4247b60e01b815260040160405180910390fd5b6119c6888861330b565b6001600160801b03878116600160801b02908916176101365561013880546001600160a01b03808d166001600160a01b0319928316179092556101398b905561013780548e8416908316179055600061013b55610141805488841690831617905561013f8054878416908316179055610142805492861692909116919091179055611a5086613351565b611a58613389565b611a6182613048565b611a696133b8565b8015611aaf576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b611ac4615044565b6001600160a01b03808716600081815261013460209081526040808320948a1683529381528382206001015492825261013390529190912060030154611b0a91906155d2565b6040820152611b1882613412565b60808201819052600090611b2e9086868a613467565b805160a0840152602081015160c0840152604081015160e08401526060810151610100840152608081015161012084015290506000611b6c88612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcd9190615652565b60ff169050611bdd8160126155d2565b611be890600a615759565b8360a00151611bf791906155fe565b60a08401819052608084015161013654611c2592906001600160801b0380821691600160801b900416613775565b606084018190526040840151611c3b919061563f565b836040018181525050611c638886888660c001518760e001518860600151896040015161382d565b6020850152835250909695505050505050565b6000611c806130e2565b611c8a8383613128565b90505b92915050565b611cb46040518060600160405280602a8152602001615b99602a913961271b565b6001600160a01b038416611cdb576040516383aebebd60e01b815260040160405180910390fd5b61013f546001600160a01b03858116911614801590611d79575061014354604051637aee632d60e01b81526001600160a01b0386811660048301819052921690637aee632d90602401600060405180830381865afa158015611d41573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d699190810190615804565b604001516001600160a01b031614155b15611d97576040516383aebebd60e01b815260040160405180910390fd5b6001600160a01b038316600090815261013360205260409020600481015460ff1615611dd657604051630313b28560e01b815260040160405180910390fd5b604051638e8f294b60e01b81526001600160a01b03858116600483015260009190871690638e8f294b90602401602060405180830381865afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4491906158fa565b905080611e6457604051633d21810360e21b815260040160405180910390fd5b60006002830181905584835560018084018590556003840182905560048401805460ff19169091179055611e9786612ebb565b6001600160a01b03808216600090815261013e60205260409020549192501615611ed45760405163dc0d0aab60e01b815260040160405180910390fd5b6001600160a01b03808216600090815261013e6020526040812080549289166001600160a01b03199384168117909155610135805460018101825592527fdf37d27e88e3bd0b85262482997e409a463f5be0ebb19232abf994dd8474090d9091018054909216179055611f45612e87565b61013554611f5290613919565b856001600160a01b0316876001600160a01b03167f1322eaea77217179bf4ef6084dc2f48c897e0d5a6b8365213804360e4d8ba9a28787604051611fa0929190918252602082015260400190565b60405180910390a350505050505050565b611fdf6040518060400160405280600d81526020016c746f67676c655061757365282960981b81525061271b565b60c95460ff1615611ff2576113e361394a565b6113e36133b8565b61200482826127b5565b61200e8282612891565b5050565b600061201d83611680565b611c8a8383613983565b6120656040518060400160405280601c81526020017f757064617465416c7068612875696e743132382c75696e74313238290000000081525061271b565b61206f828261330b565b610136546040516001600160801b03838116825284811692600160801b81048216929116907f9122c3fdea272423a0586803b53902139919baf05be731f04724ef8f363d378d9060200160405180910390a46001600160801b03818116600160801b0290831617610136556101355460005b818110156121225761211a610135828154811061210057612100615541565b6000918252602090912001546001600160a01b0316611680565b6001016120e1565b50610d7b612e87565b60006121597f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b6001600160a01b038116600090815261013260205260408120548082036121a757507f000000000000000000000000000000000000000000000000000000000000000092915050565b428190037f00000000000000000000000000000000000000000000000000000000000000008110156121fc577f0000000000000000000000000000000000000000000000000000000000000000039392505050565b5060009392505050565b61220e612603565b606580546001600160a01b0383166001600160a01b0319909116811790915561223f6033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6101358054606091908067ffffffffffffffff81111561229957612299615765565b6040519080825280602002602001820160405280156122e457816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816122b75790505b50925060005b818110156123b157600083828154811061230657612306615541565b60009182526020822001546001600160a01b031691506123268288612012565b6001600160a01b03808416600081815261013460209081526040808320948d168352938152908390205483516060810190945291835292935091810161236b85612ebb565b6001600160a01b03168152602001612383838561563f565b81525087858151811061239857612398615541565b60200260200101819052508360010193505050506122ea565b505050919050565b6123c1615044565b6040516395dd919360e01b81526001600160a01b03838116600483015284916000918316906395dd919390602401602060405180830381865afa15801561240c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243091906155e5565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015612472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249691906155e5565b6040516370a0823160e01b81526001600160a01b0387811660048301529192506000918516906370a0823190602401602060405180830381865afa1580156124e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250691906155e5565b90506000670de0b6b3a764000061251d83856155fe565b612527919061562b565b6001600160a01b03808a16600081815261013460209081526040808320948d1683529381528382206001015460608c01529181526101339091528190206003015490880152905061257f61257a8861296e565b613412565b6080870181905260009061259590868489613467565b805160a0890152602081015160c0890181905260408083015160e08b018190526060808501516101008d015260808501516101208d01528b0151918b01519394506125e7938d9387938b93919261382d565b602089015287525094979650505050505050565b4390565b4290565b6033546001600160a01b031633146113e35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610dbe565b6001600160a01b0381166126c15760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610dbe565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa09101610e2c565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab9061274e9033908690600401615943565b602060405180830381865afa15801561276b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278f91906158fa565b90508061200e57333083604051634a3fa29360e01b8152600401610dbe93929190615967565b6001600160a01b0381166000908152610133602052604090206004015460ff1615806127fb57506001600160a01b038216600090815261012d602052604090205460ff16155b15612804575050565b61280d81611680565b6128178183613983565b6001600160a01b038083166000908152610134602090815260408083209387168352929052908120805490919061284f90849061563f565b90915550506001600160a01b03908116600090815261013360209081526040808320600290810154610134845282852096909516845294909152902090910155565b6001600160a01b038116600090815261013360205260409020600481015460ff1615806128d857506001600160a01b038316600090815261012d602052604090205460ff16155b156128e257505050565b60006128ee8385613a1a565b6001600160a01b03808516600090815261013460209081526040808320938916835292905220600101546003840154919250829161292c91906155d2565b612936919061563f565b6003909201919091556001600160a01b0391821660009081526101346020908152604080832095909416825293909352912060010155565b6101375461013854610139546040516398e1b31b60e01b81526001600160a01b03928316600482015260248101919091528382166044820152600092839283929116906398e1b31b90606401606060405180830381865afa1580156129d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fb9190615993565b92505091508082612a0c91906155d2565b949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000008210612a4557506001919050565b506000919050565b610135805460005b81811015611198576000838281548110612a7157612a71615541565b6000918252602090912001546001600160a01b03169050612a9285826127b5565b612a9c8582612891565b50600101612a55565b6001600160a01b038116600090815261012d602090815260409182902082518084019093525460ff808216151580855261010090920416151591830191909152612b0257604051633aeb927b60e11b815260040160405180910390fd5b610135805460005b81811015612bdb576000838281548110612b2657612b26615541565b6000918252602090912001546001600160a01b03169050612b4786826127b5565b6001600160a01b03808216600081815261013460209081526040808320948b1683529381528382206001015492825261013390529190912060030154612b8d91906155d2565b6001600160a01b039182166000908152610133602090815260408083206003019390935561013481528282209389168252929092528120600180820183905560029091019190915501612b0a565b50826020015115612bff5761012e60008154612bf69061556d565b90915550612c14565b61012f60008154612c0f9061556d565b909155505b6001600160a01b038416600090815261012d60205260409020805461ffff19169055612c3f84613daa565b6040516001600160a01b038516907fe22de1457cb61fb61b60176bc4235a9abd19466126b46692bc14fc573f09924990600090a250505050565b6001600160a01b038116600090815261012d60205260409020805460ff1615612cb45760405162c4e3d160e01b815260040160405180910390fd5b8054831580156101000261ffff19909216919091176001178255612ceb5761012e60008154612ce2906159c1565b90915550612d00565b61012f60008154612cfb906159c1565b909155505b6101315461012e541180612d1957506101305461012f54115b15612d375760405163e55fb50960e01b815260040160405180910390fd5b612d4082613e1e565b816001600160a01b03167fdd032f28700d4e4b1719b8fa26918a7d68608b4e36def571ce5fe7a3ecd69f4584604051612d7d911515815260200190565b60405180910390a2505050565b610135805460005b81811015611198576000838281548110612dae57612dae615541565b6000918252602090912001546001600160a01b03169050612dce81611680565b6001600160a01b038082166000908152610133602090815260408083206002908101546101348452828520958b1685529490925282200191909155612e138287613a1a565b6001600160a01b03808416600081815261013460209081526040808320948c1683529381528382206001018590559181526101339091522060030154909150612e5d90829061563f565b6001600160a01b039092166000908152610133602052604090206003019190915550600101612d92565b61013b8054906000612e98836159c1565b919050555061012f5461012e54612eaf919061563f565b61013c81905561013d55565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603612f1d57507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164191906159da565b606580546001600160a01b0319169055610af681613e5c565b6001600160a01b038116600090815261012d60205260408120805461ff00191661010017815561012e805491929091612fd0906159c1565b9091555061012f8054600090612fe59061556d565b909155506101315461012e5411156130105760405163e55fb50960e01b815260040160405180910390fd5b6040516001600160a01b038316907f5272e69bcef8da96614ac4a5d1e95ca02c35ea627bf7ecf389ec88d8d78b86bb90600090a25050565b60fb5481116130a45760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b6064820152608401610dbe565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa9101610e2c565b60c95460ff16156113e35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610dbe565b6000806131358484612012565b6001600160a01b0380861660009081526101346020908152604080832093881683529290522054909150613169908261563f565b6001600160a01b038581166000908152610133602090815260408083206002908101546101348452828520958a16855294909252822090810192909255908190559091506131b685612ebb565b6040516370a0823160e01b815230600482015290915081906001600160a01b038216906370a0823190602401602060405180830381865afa1580156131ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322391906155e5565b8311156132a0576001600160a01b03828116600090815261014060205260408082209190915561014154905163192e7a7b60e01b8152838316600482015291169063192e7a7b90602401600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b505050505b6132b46001600160a01b0382168685613eae565b856001600160a01b0316856001600160a01b03167fc7edf5cfe443c04a10a60ff6084c847114348c55b257a01d62700326219adbba856040516132f991815260200190565b60405180910390a35090949350505050565b806001600160801b0316826001600160801b031610158061333357506001600160801b038216155b1561200e57604051630381eb6d60e61b815260040160405180910390fd5b600054610100900460ff166133785760405162461bcd60e51b8152600401610dbe906159f7565b613380613f00565b610af681613f2f565b600054610100900460ff166133b05760405162461bcd60e51b8152600401610dbe906159f7565b6113e3613f56565b6133c06130e2565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586133f53390565b6040516001600160a01b03909116815260200160405180910390a1565b60007f000000000000000000000000000000000000000000000000000000000000000082111561346357507f0000000000000000000000000000000000000000000000000000000000000000919050565b5090565b6134996040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6101375460408051631ac5701b60e11b815290516000926001600160a01b03169163358ae0369160048083019260209291908290030181865afa1580156134e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061350891906159da565b610142546040516341976e0960e01b81526001600160a01b038084166004830152929350600092909116906341976e0990602401602060405180830381865afa158015613559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061357d91906155e5565b6001600160a01b03851660009081526101336020526040902060010154909150670de0b6b3a76400009081906135b3908a6155fe565b6135bd919061562b565b6135c790836155fe565b6135d1919061562b565b60808401526001600160a01b03841660009081526101336020526040902054670de0b6b3a7640000908190613606908a6155fe565b613610919061562b565b61361a90836155fe565b613624919061562b565b60608401526101425460405163fc57d4df60e01b81526001600160a01b038681166004830152600092169063fc57d4df90602401602060405180830381865afa158015613675573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369991906155e5565b90506000670de0b6b3a76400006136b088846155fe565b6136ba919061562b565b90506000670de0b6b3a76400006136d18a856155fe565b6136db919061562b565b90508560600151821061371557816000036136f7576000613712565b8186606001518961370891906155fe565b613712919061562b565b97505b8560800151811061374d578060000361372f57600061374a565b8086608001518a61374091906155fe565b61374a919061562b565b98505b613757898961563f565b86525050505060208201939093526040810193909352509092915050565b6000841580613782575083155b1561378f57506000612a0c565b83850361379d575083612a0c565b8385106000816137b6576137b18688613f89565b6137c0565b6137c08787613f89565b905060006137fb6137d086613ff1565b6137d988613ff1565b6137e28561405b565b6137ec9190615a42565b6137f69190615a72565b614066565b905082156138175761380d8782614071565b9350505050612a0c565b61382187826140a3565b98975050505050505050565b600080826000036138435750600090508061390d565b60008361384f8b611316565b61385990876155fe565b613863919061562b565b90506000613871878961563f565b9050806000036138895760008093509350505061390d565b6127106000808361389a8c876155fe565b6138a4919061562b565b9150836138b18b876155fe565b6138bb919061562b565b90508c156138dd578c6138ce84846155fe565b6138d8919061562b565b6138e0565b60005b96508b15613902578b6138f384836155fe565b6138fd919061562b565b613905565b60005b955050505050505b97509795505050505050565b60fb54811115610af65760fb5460405163792bfb1b60e11b8152600481019190915260248101829052604401610dbe565b6139526140d5565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336133f5565b6001600160a01b0380831660008181526101346020908152604080832094861683529381528382208451606081018652815481526001820154818401526002918201548187018190529484526101339092529382209093015490929183916139eb91906155d2565b6020830151909150670de0b6b3a7640000613a0682846155fe565b613a10919061562b565b9695505050505050565b600080613a2961257a8461296e565b6040516395dd919360e01b81526001600160a01b0385811660048301529192508591600091908316906395dd919390602401602060405180830381865afa158015613a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9c91906155e5565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0291906155e5565b6040516370a0823160e01b81526001600160a01b0388811660048301529192506000918516906370a0823190602401602060405180830381865afa158015613b4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7291906155e5565b90506000670de0b6b3a7640000613b8983856155fe565b613b93919061562b565b9050600061013760009054906101000a90046001600160a01b03166001600160a01b031663358ae0366040518163ffffffff1660e01b8152600401602060405180830381865afa158015613beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0f91906159da565b6101425460405163b62cad6960e01b81526001600160a01b03808416600483015292935091169063b62cad6990602401600060405180830381600087803b158015613c5957600080fd5b505af1158015613c6d573d6000803e3d6000fd5b5050610142546040516396e85ced60e01b81526001600160a01b038e8116600483015290911692506396e85ced9150602401600060405180830381600087803b158015613cb957600080fd5b505af1158015613ccd573d6000803e3d6000fd5b505050506000613cdf8887858e613467565b90506000613cec8c612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4d9190615652565b60ff169050613d5d8160126155d2565b613d6890600a615759565b8251613d7491906155fe565b80835261013654613d9a918b916001600160801b0380821691600160801b900416613775565b9c9b505050505050505050505050565b61013c5415613dc85761013c60008154613dc39061556d565b909155505b61013d5415801590613e02575061013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff16155b15610af65761013d60008154613e179061556d565b9091555050565b61013c5415610af65761013b54600090815261013a602090815260408083206001600160a01b03851684529091529020805460ff1916600117905550565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d7b90849061411e565b600054610100900460ff16613f275760405162461bcd60e51b8152600401610dbe906159f7565b6113e36141f3565b600054610100900460ff16610aed5760405162461bcd60e51b8152600401610dbe906159f7565b600054610100900460ff16613f7d5760405162461bcd60e51b8152600401610dbe906159f7565b60c9805460ff19169055565b6000613f9483613ff1565b613f9d83613ff1565b1215613fc6576040516360c1ae3960e01b81526004810184905260248101839052604401610dbe565b613fcf82613ff1565b6001607f1b613fdd85613ff1565b613fe79190615a42565b611c8a9190615a72565b60006001600160ff1b038211156134635760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610dbe565b600061164182614223565b600061164182614810565b60008082121561409457604051639603648160e01b815260040160405180910390fd5b6001607f1b82613fdd85613ff1565b6000808212156140c657604051639603648160e01b815260040160405180910390fd5b816001607f1b613fdd85613ff1565b60c95460ff166113e35760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610dbe565b6000614173826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614f219092919063ffffffff16565b905080516000148061419457508080602001905181019061419491906158fa565b610d7b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dbe565b600054610100900460ff1661421a5760405162461bcd60e51b8152600401610dbe906159f7565b6113e333612f7f565b60006001607f1b82131561424d57604051633ce23a3d60e11b815260048101839052602401610dbe565b60008213614271576040516330ecaa3d60e21b815260048101839052602401610dbe565b6001607f1b820361428457506000919050565b640733048c5a821361429e576116416101ff607c1b615aa0565b60008060006a01c8464f7616476000000085136142ec576142c3600160841b85615abc565b93506a01c8464f761647600000006142df6001607f1b87615a42565b6142e99190615a72565b94505b6cf1aaddd7742e9000000000000085136143395761430e600160831b85615abc565b93506cf1aaddd7742e9000000000000061432c6001607f1b87615a42565b6143369190615a72565b94505b6615fc21041027af603f1b851361438057614358600160821b85615abc565b93506615fc21041027af603f1b6143736001607f1b87615a42565b61437d9190615a72565b94505b660960aadc109e7b60461b85136143c75761439f600160811b85615abc565b9350660960aadc109e7b60461b6143ba6001607f1b87615a42565b6143c49190615a72565b94505b660454aaa8efe073604a1b851361440e576143e6600160801b85615abc565b9350660454aaa8efe073604a1b6144016001607f1b87615a42565b61440b9190615a72565b94505b6602f16ac6c59de7604c1b85136144555761442d6001607f1b85615abc565b93506602f16ac6c59de7604c1b6144486001607f1b87615a42565b6144529190615a72565b94505b6609b4597e37cb05604b1b851361449c576144746001607e1b85615abc565b93506609b4597e37cb05604b1b61448f6001607f1b87615a42565b6144999190615a72565b94505b6618ebef9eac820b604a1b85136144e3576144bb6001607d1b85615abc565b93506618ebef9eac820b604a1b6144d66001607f1b87615a42565b6144e09190615a72565b94505b6f70f5a893b608861e1f58934f97aea57d8513614536576145086001607c1b85615abc565b93506f70f5a893b608861e1f58934f97aea57d6145296001607f1b87615a42565b6145339190615a72565b94505b6145446001607f1b86615abc565b92508291506001607f1b6145588380615a42565b6145629190615a72565b9050600160801b6145738482615abc565b61457d9084615a42565b6145879190615a72565b6145919085615ae3565b93506001607f1b6145a28284615a42565b6145ac9190615a72565b9150600160811b6145cd846faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa615abc565b6145d79084615a42565b6145e19190615a72565b6145eb9085615ae3565b93506001607f1b6145fc8284615a42565b6146069190615a72565b9150600360801b614627846f99999999999999999999999999999999615abc565b6146319084615a42565b61463b9190615a72565b6146459085615ae3565b93506001607f1b6146568284615a42565b6146609190615a72565b9150600160821b614681846f92492492492492492492492492492492615abc565b61468b9084615a42565b6146959190615a72565b61469f9085615ae3565b93506001607f1b6146b08284615a42565b6146ba9190615a72565b9150600560801b6146db846f8e38e38e38e38e38e38e38e38e38e38e615abc565b6146e59084615a42565b6146ef9190615a72565b6146f99085615ae3565b93506001607f1b61470a8284615a42565b6147149190615a72565b9150600360811b614735846f8ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b615abc565b61473f9084615a42565b6147499190615a72565b6147539085615ae3565b93506001607f1b6147648284615a42565b61476e9190615a72565b9150600760801b61478f846f89d89d89d89d89d89d89d89d89d89d89615abc565b6147999084615a42565b6147a39190615a72565b6147ad9085615ae3565b93506001607f1b6147be8284615a42565b6147c89190615a72565b9150600160831b6147e9846f88888888888888888888888888888888615abc565b6147f39084615a42565b6147fd9190615a72565b6148079085615ae3565b95945050505050565b60006148206101ff607c1b615aa0565b82121561482f57506000919050565b8160000361484257506001607f1b919050565b600082131561486757604051631086170d60e01b815260048101839052602401610dbe565b6000806148786001607c1b85615b0b565b91508190506001607f1b61488c8280615a42565b6148969190615a72565b90506148aa816710e1b3be415a0000615a42565b6148b49084615ae3565b92506001607f1b6148c58383615a42565b6148cf9190615a72565b90506148e3816705a0913f6b1e0000615a42565b6148ed9084615ae3565b92506001607f1b6148fe8383615a42565b6149089190615a72565b905061491c81670168244fdac78000615a42565b6149269084615ae3565b92506001607f1b6149378383615a42565b6149419190615a72565b905061495481664807432bc18000615a42565b61495e9084615ae3565b92506001607f1b61496f8383615a42565b6149799190615a72565b905061498c81660c0135dca04000615a42565b6149969084615ae3565b92506001607f1b6149a78383615a42565b6149b19190615a72565b90506149c4816601b707b1cdc000615a42565b6149ce9084615ae3565b92506001607f1b6149df8383615a42565b6149e99190615a72565b90506149fb816536e0f639b800615a42565b614a059084615ae3565b92506001607f1b614a168383615a42565b614a209190615a72565b9050614a3281650618fee9f800615a42565b614a3c9084615ae3565b92506001607f1b614a4d8383615a42565b614a579190615a72565b9050614a6881649c197dcc00615a42565b614a729084615ae3565b92506001607f1b614a838383615a42565b614a8d9190615a72565b9050614a9e81640e30dce400615a42565b614aa89084615ae3565b92506001607f1b614ab98383615a42565b614ac39190615a72565b9050614ad48164012ebd1300615a42565b614ade9084615ae3565b92506001607f1b614aef8383615a42565b614af99190615a72565b9050614b09816317499f00615a42565b614b139084615ae3565b92506001607f1b614b248383615a42565b614b2e9190615a72565b9050614b3e816301a9d480615a42565b614b489084615ae3565b92506001607f1b614b598383615a42565b614b639190615a72565b9050614b7281621c6380615a42565b614b7c9084615ae3565b92506001607f1b614b8d8383615a42565b614b979190615a72565b9050614ba6816201c638615a42565b614bb09084615ae3565b92506001607f1b614bc18383615a42565b614bcb9190615a72565b9050614bd981611ab8615a42565b614be39084615ae3565b92506001607f1b614bf48383615a42565b614bfe9190615a72565b9050614c0c8161017c615a42565b614c169084615ae3565b92506001607f1b614c278383615a42565b614c319190615a72565b9050614c3e816014615a42565b614c489084615ae3565b92506001607f1b614c598383615a42565b614c639190615a72565b9050614c70816001615a42565b614c7a9084615ae3565b92506001607f1b82614c946721c3677c82b4000086615a72565b614c9e9190615ae3565b614ca89190615ae3565b9250614cb384615aa0565b9350600160841b841615614cf9577243cbaf42a000812488fc5c220ad7b97bf6e99e614cec6cf1aaddd7742e56d32fb9f9974485615a42565b614cf69190615a72565b92505b600160831b841615614d3e577105d27a9f51c31b7c2f8038212a0574779991614d316e0afe10820813d65dfe6a33c07f738f85615a42565b614d3b9190615a72565b92505b600160821b841615614d8357701b4c902e273a58678d6d3bfdb93db96d02614d766f02582ab704279e8efd15e0265855c47a85615a42565b614d809190615a72565b92505b600160811b841615614dc8577003b1cc971a9bb5b9867477440d6d157750614dbb6f1152aaa3bf81cb9fdb76eae12d02957185615a42565b614dc59190615a72565b92505b600160801b841615614e0d5770015bf0a8b1457695355fb8ac404e7a79e3614e006f2f16ac6c59de6f8d5d6f63c1482a7c8685615a42565b614e0a9190615a72565b92505b6001607f1b841615614e51576fd3094c70f034de4b96ff7d5b6f99fcd8614e446f4da2cbf1be5827f9eb3ad1aa9866ebb385615a42565b614e4e9190615a72565b92505b6001607e1b841615614e95576fa45af1e1f40c333b3de1db4dd55f29a7614e886f63afbe7ab2082ba1a0ae5e4eb1b479dc85615a42565b614e929190615a72565b92505b6001607d1b841615614ed9576f910b022db7ae67ce76b441c27035c6a1614ecc6f70f5a893b608861e1f58934f97aea57d85615a42565b614ed69190615a72565b92505b6001607c1b841615614f1a576f88415abbe9a76bead8d00cf112e4d4a8614f106f783eafef1c0a8f3978c7f81824d62ebf85615a42565b612a0c9190615a72565b5050919050565b6060612a0c848460008585600080866001600160a01b03168587604051614f489190615b1f565b60006040518083038185875af1925050503d8060008114614f85576040519150601f19603f3d011682016040523d82523d6000602084013e614f8a565b606091505b5091509150614f9b87838387614fa6565b979650505050505050565b6060831561501557825160000361500e576001600160a01b0385163b61500e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dbe565b5081612a0c565b612a0c838381511561502a5781518083602001fd5b8060405162461bcd60e51b8152600401610dbe9190615b3b565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0381168114610af657600080fd5b6000602082840312156150be57600080fd5b81356113ca81615097565b600080604083850312156150dc57600080fd5b50508035926020909101359150565b60008083601f8401126150fd57600080fd5b50813567ffffffffffffffff81111561511557600080fd5b6020830191508360208260051b850101111561513057600080fd5b9250929050565b6000806020838503121561514a57600080fd5b823567ffffffffffffffff81111561516157600080fd5b61516d858286016150eb565b90969095509350505050565b60008060006060848603121561518e57600080fd5b833561519981615097565b95602085013595506040909401359392505050565b600080600080604085870312156151c457600080fd5b843567ffffffffffffffff808211156151dc57600080fd5b6151e8888389016150eb565b9096509450602087013591508082111561520157600080fd5b5061520e878288016150eb565b95989497509550505050565b8015158114610af657600080fd5b60008060006040848603121561523d57600080fd5b83356152488161521a565b9250602084013567ffffffffffffffff81111561526457600080fd5b615270868287016150eb565b9497909650939450505050565b60006020828403121561528f57600080fd5b5035919050565b600080604083850312156152a957600080fd5b8235915060208301356152bb81615097565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156153075783516001600160a01b0316835292840192918401916001016152e2565b50909695505050505050565b80356001600160801b038116811461164457600080fd5b6000806000806000806000806000806101408b8d03121561534a57600080fd5b8a3561535581615097565b995060208b013561536581615097565b985060408b0135975061537a60608c01615313565b965061538860808c01615313565b955060a08b013561539881615097565b945060c08b01356153a881615097565b935060e08b01356153b881615097565b92506101008b01356153c981615097565b809250506101208b013590509295989b9194979a5092959850565b600080600080600060a086880312156153fc57600080fd5b853561540781615097565b9450602086013561541781615097565b94979496505050506040830135926060810135926080909101359150565b6000806040838503121561544857600080fd5b823561545381615097565b915060208301356152bb81615097565b6000806000806080858703121561547957600080fd5b843561548481615097565b9350602085013561549481615097565b93969395505050506040820135916060013590565b600080604083850312156154bc57600080fd5b6154c583615313565b91506154d360208401615313565b90509250929050565b602080825282518282018190526000919060409081850190868401855b8281101561553457815180516001600160a01b03908116865287820151168786015285015185850152606090930192908501906001016154f9565b5091979650505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008161557c5761557c615557565b506000190190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b81810381811115611c8d57611c8d615557565b6000602082840312156155f757600080fd5b5051919050565b8082028115828204841417611c8d57611c8d615557565b634e487b7160e01b600052601260045260246000fd5b60008261563a5761563a615615565b500490565b80820180821115611c8d57611c8d615557565b60006020828403121561566457600080fd5b815160ff811681146113ca57600080fd5b600181815b808511156156b057816000190482111561569657615696615557565b808516156156a357918102915b93841c939080029061567a565b509250929050565b6000826156c757506001611c8d565b816156d457506000611c8d565b81600181146156ea57600281146156f457615710565b6001915050611c8d565b60ff84111561570557615705615557565b50506001821b611c8d565b5060208310610133831016604e8410600b8410161715615733575081810a611c8d565b61573d8383615675565b806000190482111561575157615751615557565b029392505050565b6000611c8a83836156b8565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561579e5761579e615765565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156157cd576157cd615765565b604052919050565b60005b838110156157f05781810151838201526020016157d8565b50506000910152565b805161164481615097565b6000602080838503121561581757600080fd5b825167ffffffffffffffff8082111561582f57600080fd5b9084019060a0828703121561584357600080fd5b61584b61577b565b82518281111561585a57600080fd5b8301601f8101881361586b57600080fd5b80518381111561587d5761587d615765565b61588f601f8201601f191687016157a4565b935080845288868284010111156158a557600080fd5b6158b4818786018885016157d5565b50508181526158c48484016157f9565b848201526158d4604084016157f9565b604082015260608301516060820152608083015160808201528094505050505092915050565b60006020828403121561590c57600080fd5b81516113ca8161521a565b6000815180845261592f8160208601602086016157d5565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090612a0c90830184615917565b6001600160a01b0384811682528316602082015260606040820181905260009061480790830184615917565b6000806000606084860312156159a857600080fd5b8351925060208401519150604084015190509250925092565b6000600182016159d3576159d3615557565b5060010190565b6000602082840312156159ec57600080fd5b81516113ca81615097565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b80820260008212600160ff1b84141615615a5e57615a5e615557565b8181058314821517611c8d57611c8d615557565b600082615a8157615a81615615565b600160ff1b821460001984141615615a9b57615a9b615557565b500590565b6000600160ff1b8201615ab557615ab5615557565b5060000390565b8181036000831280158383131683831282161715615adc57615adc615557565b5092915050565b8082018281126000831280158216821582161715615b0357615b03615557565b505092915050565b600082615b1a57615b1a615615565b500790565b60008251615b318184602087016157d5565b9190910192915050565b602081526000611c8a602083018461591756fe7570646174654d756c7469706c6965727328616464726573732c75696e743235362c75696e743235362909d2594e8892daceca055f74be758146a8b8b1167444d0b4ccb96e74168198cc6164644d61726b657428616464726573732c616464726573732c75696e743235362c75696e7432353629a2646970667358221220d7842351882c76ed9cd16c268489fd8f3a58a0b4e004c3ca395a20eaf26d410a64736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103e65760003560e01c80639f6506ce1161020a578063cdaa21b711610125578063e30c3978116100b8578063ef36bbde11610087578063ef36bbde14610a57578063f2fde38b14610a78578063f6ed201714610a8b578063fa6d5f1814610aab578063fe1006ad14610abe57600080fd5b8063e30c3978146109c5578063e4676f37146109d6578063e4860339146109e9578063ee6b13fc14610a2d57600080fd5b8063d88b9d2e116100f4578063d88b9d2e14610996578063da6ab4f8146109a0578063e18f8822146109aa578063e1d146fb146109bd57600080fd5b8063cdaa21b71461092e578063ce85361314610955578063cf329d1614610970578063d65bd2411461098357600080fd5b8063ba437c681161019d578063c3db3c361161016c578063c3db3c36146108e1578063c4ae3168146108eb578063c7ad0895146108f3578063c86d1a781461091a57600080fd5b8063ba437c68146108a8578063bc5dc4c3146108bb578063bd212c0e146108ce578063be26317e146108d857600080fd5b8063b1a250f2116101d9578063b1a250f2146107a2578063b4a0bdf3146107b5578063b7f2d258146107c6578063b9eb69f61461085257600080fd5b80639f6506ce14610765578063a15753dc1461076f578063afcff50f14610779578063b0772d0b1461078d57600080fd5b80635fe3b5671161030557806380d45a2d1161029857806389afcb441161026757806389afcb44146106945780638da5cb5b146106a75780638e8f294b146106b85780639198e515146107235780639565d3d21461073657600080fd5b806380d45a2d14610650578063856c3aa41461066357806388bead731461066d57806388d742c21461068157600080fd5b806379ba5097116102d457806379ba5097146105f55780637dafcd89146105fd5780637dc0d1d0146106105780637ef820701461062457600080fd5b80635fe3b5671461058d5780636426b4a71461059f5780636857249c146105c6578063715018a6146105ed57600080fd5b806337f23cd31161037d57806355d36c981161034c57806355d36c9814610549578063594a67ee1461055c5780635c975abb1461056f5780635d536d301461057a57600080fd5b806337f23cd3146104e757806338f6a434146104fa578063487b0dfb146105375780634e71d92d1461054157600080fd5b80631bffac89116103b95780631bffac891461048d578063207add91146104ae57806324e6baf2146104c157806329b6eca9146104d457600080fd5b80630104db1b146103eb5780630e32cb86146104255780631b3f8c5e1461043a5780631b9ce57514610479575b600080fd5b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6104386104333660046150ac565b610ae5565b005b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161041c565b61013754610461906001600160a01b031681565b61041261049b3660046150ac565b6101406020526000908152604090205481565b6104386104bc3660046150c9565b610af9565b6104386104cf366004615137565b610bb4565b6104386104e23660046150ac565b610d80565b6104386104f53660046150ac565b610e38565b6105276105083660046150ac565b6001600160a01b0316600090815261012d602052604090205460ff1690565b604051901515815260200161041c565b6104126101395481565b610438611044565b610438610557366004615179565b6110d3565b61043861056a3660046151ae565b61119e565b60c95460ff16610527565b6104126105883660046150ac565b611316565b61013f546001600160a01b0316610461565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104386113d1565b6104386113e5565b61043861060b366004615228565b61145c565b61014254610461906001600160a01b031681565b61013654610638906001600160801b031681565b6040516001600160801b03909116815260200161041c565b61043861065e36600461527d565b6115e6565b6104126101315481565b61013854610461906001600160a01b031681565b61041261068f3660046150ac565b61162d565b6104386106a23660046150ac565b611649565b6033546001600160a01b0316610461565b6106f96106c63660046150ac565b61013360205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161041c565b6104386107313660046150ac565b611680565b610527610744366004615296565b61013a60209081526000928352604080842090915290825290205460ff1681565b61041261012f5481565b61041261013b5481565b61014354610461906001600160a01b031681565b610795611844565b60405161041c91906152c6565b6104386107b036600461532a565b6118a7565b6097546001600160a01b0316610461565b6107d96107d43660046153e4565b611abc565b60405161041c9190600061014082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525092915050565b61088d610860366004615435565b61013460209081526000928352604080842090915290825290208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161041c565b6104126108b6366004615435565b611c76565b6104386108c9366004615463565b611c93565b61041261013c5481565b61041260fb5481565b61041261013d5481565b610438611fb1565b6105277f000000000000000000000000000000000000000000000000000000000000000081565b61014154610461906001600160a01b031681565b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6101365461063890600160801b90046001600160801b031681565b61043861097e366004615435565b611ffa565b610412610991366004615435565b612012565b61041261012e5481565b6104126101305481565b6104386109b83660046154a9565b612027565b61041261212b565b6065546001600160a01b0316610461565b6104126109e43660046150ac565b61215e565b610a166109f73660046150ac565b61012d6020526000908152604090205460ff8082169161010090041682565b60408051921515835290151560208301520161041c565b610461610a3b3660046150ac565b61013e602052600090815260409020546001600160a01b031681565b610412610a653660046150ac565b6101326020526000908152604090205481565b610438610a863660046150ac565b612206565b610a9e610a993660046150ac565b612277565b60405161041c91906154dc565b6107d9610ab9366004615435565b6123b9565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b610aed612603565b610af68161265d565b50565b610b376040518060400160405280601981526020017f7365744c696d69742875696e743235362c75696e74323536290000000000000081525061271b565b61012e54821080610b4a575061012f5481105b15610b685760405163e55fb50960e01b815260040160405180910390fd5b8161013054610131547f6c52f3e195bdc534883e903e0612c49261a466aacd492501870b0a0ac0b1835584604051610ba291815260200190565b60405180910390a46101305561013155565b61013d54600003610bd85760405163071a45dd60e31b815260040160405180910390fd5b61013b54600003610bfc5760405163071a45dd60e31b815260040160405180910390fd5b60005b81811015610d7b576000838383818110610c1b57610c1b615541565b9050602002016020810190610c3091906150ac565b6001600160a01b038116600090815261012d602052604090205490915060ff16610c6d57604051633aeb927b60e11b815260040160405180910390fd5b61013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff1615610ca65750600101610bff565b610135805460005b81811015610cfe576000838281548110610cca57610cca615541565b6000918252602090912001546001600160a01b03169050610ceb85826127b5565b610cf58582612891565b50600101610cae565b5061013d60008154610d0f9061556d565b9091555061013b54600090815261013a602090815260408083206001600160a01b0387168085529252808320805460ff19166001908117909155905196019590917fa699df4aa8f89fc1f5408fe78ae114651f18b25ed1601680e4c70c15177d8b1b91a2505050610bff565b505050565b600054600290610100900460ff16158015610da2575060005460ff8083169116105b610dc75760405162461bcd60e51b8152600401610dbe90615584565b60405180910390fd5b6000805461014380546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6000610e438261296e565b90506000610e5082612a14565b6001600160a01b0384166000908152610132602090815260408083205461012d83529281902081518083019092525460ff808216158015808552610100909304909116151593830193909352939450919290610eaa575082155b15610f0c576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615b79833981519152910160405180910390a2806020015115610f0357610efe85612a4d565b61103d565b610efe85612aa5565b82158015610f1957508051155b8015610f2457508115155b15610f6b576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615b7983398151915291015b60405180910390a261103d565b81158015610f765750825b8015610f8157508051155b15610fc3576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615b798339815191529101610f5e565b80518015610fce5750825b1561103d57610fdc85612a4d565b6001600160a01b03851660009081526101326020526040812054900361103d576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615b79833981519152910160405180910390a25b5050505050565b3360009081526101326020526040812054908190036110755760405162c4e3d160e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006110a082426155d2565b10156110bf5760405163beb98cab60e01b815260040160405180910390fd5b6110ca600033612c79565b610af633612d8a565b6110f46040518060600160405280602a8152602001615b4f602a913961271b565b6001600160a01b038316600090815261013360205260409020600481015460ff1661113257604051630ff2e4a960e31b815260040160405180910390fd5b61113b84611680565b6001810154815460408051868152602081018690526001600160a01b038816917f91e78a55b6df3a0eac1c12a64572a8c0faced385bafba688817f5ce6daa33537910160405180910390a482815560018101829055611198612e87565b50505050565b6111dc6040518060400160405280602081526020017f7365745374616b6564417428616464726573735b5d2c75696e743235365b5d2981525061271b565b8281146111fc5760405163251f56a160e21b815260040160405180910390fd5b60005b8381101561103d574283838381811061121a5761121a615541565b9050602002013511156112405760405163b7d0949760e01b815260040160405180910390fd5b82828281811061125257611252615541565b90506020020135610132600087878581811061127057611270615541565b905060200201602081019061128591906150ac565b6001600160a01b031681526020810191909152604001600020558484828181106112b1576112b1615541565b90506020020160208101906112c691906150ac565b6001600160a01b0316600080516020615b798339815191528484848181106112f0576112f0615541565b9050602002013560405161130691815260200190565b60405180910390a26001016111ff565b6101415460009081906001600160a01b031663a666642b61133685612ebb565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561137a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139e91906155e5565b90506113ca817f00000000000000000000000000000000000000000000000000000000000000006155fe565b9392505050565b6113d9612603565b6113e36000612f7f565b565b60655433906001600160a01b031681146114535760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610dbe565b610af681612f7f565b61149260405180604001604052806015815260200174697373756528626f6f6c2c616464726573735b5d2960581b81525061271b565b82156115a75760005b8181101561119857600061012d60008585858181106114bc576114bc615541565b90506020020160208101906114d191906150ac565b6001600160a01b031681526020810191909152604001600020805490915060ff16801561150557508054610100900460ff16155b1561153e5761153984848481811061151f5761151f615541565b905060200201602081019061153491906150ac565b612f98565b61159e565b61156f600185858581811061155557611555615541565b905060200201602081019061156a91906150ac565b612c79565b61159e84848481811061158457611584615541565b905060200201602081019061159991906150ac565b612d8a565b5060010161149b565b60005b81811015611198576115c9600084848481811061155557611555615541565b6115de83838381811061158457611584615541565b6001016115aa565b6116246040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e74323536290000000000000081525061271b565b610af681613048565b60006116376130e2565b6116418233613128565b90505b919050565b6116776040518060400160405280600d81526020016c6275726e28616464726573732960981b81525061271b565b610af681612aa5565b6001600160a01b038116600090815261013360205260409020600481015460ff166116be57604051630ff2e4a960e31b815260040160405180910390fd5b60006116c983612ebb565b61014154604051638aadf79960e01b81526001600160a01b0380841660048301529293509116908190638aadf79990602401600060405180830381600087803b15801561171557600080fd5b505af1158015611729573d6000803e3d6000fd5b505060405163fa7781ff60e01b81526001600160a01b038581166004830152600093508416915063fa7781ff90602401602060405180830381865afa158015611776573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179a91906155e5565b6001600160a01b03841660009081526101406020526040812054919250906117c290836155d2565b90508060008190036117d75750505050505050565b6001600160a01b038516600090815261014060205260408120849055600387015415611821576003870154611814670de0b6b3a7640000846155fe565b61181e919061562b565b90505b80876002016000828254611835919061563f565b90915550505050505050505050565b606061013580548060200260200160405190810160405280929190818152602001828054801561189d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161187f575b5050505050905090565b600054610100900460ff16158080156118c75750600054600160ff909116105b806118e15750303b1580156118e1575060005460ff166001145b6118fd5760405162461bcd60e51b8152600401610dbe90615584565b6000805460ff191660011790558015611920576000805461ff0019166101001790555b6001600160a01b038b166119475760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038a1661196e5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0383166119955760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0385166119bc5760405163e6c4247b60e01b815260040160405180910390fd5b6119c6888861330b565b6001600160801b03878116600160801b02908916176101365561013880546001600160a01b03808d166001600160a01b0319928316179092556101398b905561013780548e8416908316179055600061013b55610141805488841690831617905561013f8054878416908316179055610142805492861692909116919091179055611a5086613351565b611a58613389565b611a6182613048565b611a696133b8565b8015611aaf576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b611ac4615044565b6001600160a01b03808716600081815261013460209081526040808320948a1683529381528382206001015492825261013390529190912060030154611b0a91906155d2565b6040820152611b1882613412565b60808201819052600090611b2e9086868a613467565b805160a0840152602081015160c0840152604081015160e08401526060810151610100840152608081015161012084015290506000611b6c88612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcd9190615652565b60ff169050611bdd8160126155d2565b611be890600a615759565b8360a00151611bf791906155fe565b60a08401819052608084015161013654611c2592906001600160801b0380821691600160801b900416613775565b606084018190526040840151611c3b919061563f565b836040018181525050611c638886888660c001518760e001518860600151896040015161382d565b6020850152835250909695505050505050565b6000611c806130e2565b611c8a8383613128565b90505b92915050565b611cb46040518060600160405280602a8152602001615b99602a913961271b565b6001600160a01b038416611cdb576040516383aebebd60e01b815260040160405180910390fd5b61013f546001600160a01b03858116911614801590611d79575061014354604051637aee632d60e01b81526001600160a01b0386811660048301819052921690637aee632d90602401600060405180830381865afa158015611d41573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d699190810190615804565b604001516001600160a01b031614155b15611d97576040516383aebebd60e01b815260040160405180910390fd5b6001600160a01b038316600090815261013360205260409020600481015460ff1615611dd657604051630313b28560e01b815260040160405180910390fd5b604051638e8f294b60e01b81526001600160a01b03858116600483015260009190871690638e8f294b90602401602060405180830381865afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4491906158fa565b905080611e6457604051633d21810360e21b815260040160405180910390fd5b60006002830181905584835560018084018590556003840182905560048401805460ff19169091179055611e9786612ebb565b6001600160a01b03808216600090815261013e60205260409020549192501615611ed45760405163dc0d0aab60e01b815260040160405180910390fd5b6001600160a01b03808216600090815261013e6020526040812080549289166001600160a01b03199384168117909155610135805460018101825592527fdf37d27e88e3bd0b85262482997e409a463f5be0ebb19232abf994dd8474090d9091018054909216179055611f45612e87565b61013554611f5290613919565b856001600160a01b0316876001600160a01b03167f1322eaea77217179bf4ef6084dc2f48c897e0d5a6b8365213804360e4d8ba9a28787604051611fa0929190918252602082015260400190565b60405180910390a350505050505050565b611fdf6040518060400160405280600d81526020016c746f67676c655061757365282960981b81525061271b565b60c95460ff1615611ff2576113e361394a565b6113e36133b8565b61200482826127b5565b61200e8282612891565b5050565b600061201d83611680565b611c8a8383613983565b6120656040518060400160405280601c81526020017f757064617465416c7068612875696e743132382c75696e74313238290000000081525061271b565b61206f828261330b565b610136546040516001600160801b03838116825284811692600160801b81048216929116907f9122c3fdea272423a0586803b53902139919baf05be731f04724ef8f363d378d9060200160405180910390a46001600160801b03818116600160801b0290831617610136556101355460005b818110156121225761211a610135828154811061210057612100615541565b6000918252602090912001546001600160a01b0316611680565b6001016120e1565b50610d7b612e87565b60006121597f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b6001600160a01b038116600090815261013260205260408120548082036121a757507f000000000000000000000000000000000000000000000000000000000000000092915050565b428190037f00000000000000000000000000000000000000000000000000000000000000008110156121fc577f0000000000000000000000000000000000000000000000000000000000000000039392505050565b5060009392505050565b61220e612603565b606580546001600160a01b0383166001600160a01b0319909116811790915561223f6033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6101358054606091908067ffffffffffffffff81111561229957612299615765565b6040519080825280602002602001820160405280156122e457816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816122b75790505b50925060005b818110156123b157600083828154811061230657612306615541565b60009182526020822001546001600160a01b031691506123268288612012565b6001600160a01b03808416600081815261013460209081526040808320948d168352938152908390205483516060810190945291835292935091810161236b85612ebb565b6001600160a01b03168152602001612383838561563f565b81525087858151811061239857612398615541565b60200260200101819052508360010193505050506122ea565b505050919050565b6123c1615044565b6040516395dd919360e01b81526001600160a01b03838116600483015284916000918316906395dd919390602401602060405180830381865afa15801561240c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243091906155e5565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015612472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249691906155e5565b6040516370a0823160e01b81526001600160a01b0387811660048301529192506000918516906370a0823190602401602060405180830381865afa1580156124e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250691906155e5565b90506000670de0b6b3a764000061251d83856155fe565b612527919061562b565b6001600160a01b03808a16600081815261013460209081526040808320948d1683529381528382206001015460608c01529181526101339091528190206003015490880152905061257f61257a8861296e565b613412565b6080870181905260009061259590868489613467565b805160a0890152602081015160c0890181905260408083015160e08b018190526060808501516101008d015260808501516101208d01528b0151918b01519394506125e7938d9387938b93919261382d565b602089015287525094979650505050505050565b4390565b4290565b6033546001600160a01b031633146113e35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610dbe565b6001600160a01b0381166126c15760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610dbe565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa09101610e2c565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab9061274e9033908690600401615943565b602060405180830381865afa15801561276b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278f91906158fa565b90508061200e57333083604051634a3fa29360e01b8152600401610dbe93929190615967565b6001600160a01b0381166000908152610133602052604090206004015460ff1615806127fb57506001600160a01b038216600090815261012d602052604090205460ff16155b15612804575050565b61280d81611680565b6128178183613983565b6001600160a01b038083166000908152610134602090815260408083209387168352929052908120805490919061284f90849061563f565b90915550506001600160a01b03908116600090815261013360209081526040808320600290810154610134845282852096909516845294909152902090910155565b6001600160a01b038116600090815261013360205260409020600481015460ff1615806128d857506001600160a01b038316600090815261012d602052604090205460ff16155b156128e257505050565b60006128ee8385613a1a565b6001600160a01b03808516600090815261013460209081526040808320938916835292905220600101546003840154919250829161292c91906155d2565b612936919061563f565b6003909201919091556001600160a01b0391821660009081526101346020908152604080832095909416825293909352912060010155565b6101375461013854610139546040516398e1b31b60e01b81526001600160a01b03928316600482015260248101919091528382166044820152600092839283929116906398e1b31b90606401606060405180830381865afa1580156129d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fb9190615993565b92505091508082612a0c91906155d2565b949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000008210612a4557506001919050565b506000919050565b610135805460005b81811015611198576000838281548110612a7157612a71615541565b6000918252602090912001546001600160a01b03169050612a9285826127b5565b612a9c8582612891565b50600101612a55565b6001600160a01b038116600090815261012d602090815260409182902082518084019093525460ff808216151580855261010090920416151591830191909152612b0257604051633aeb927b60e11b815260040160405180910390fd5b610135805460005b81811015612bdb576000838281548110612b2657612b26615541565b6000918252602090912001546001600160a01b03169050612b4786826127b5565b6001600160a01b03808216600081815261013460209081526040808320948b1683529381528382206001015492825261013390529190912060030154612b8d91906155d2565b6001600160a01b039182166000908152610133602090815260408083206003019390935561013481528282209389168252929092528120600180820183905560029091019190915501612b0a565b50826020015115612bff5761012e60008154612bf69061556d565b90915550612c14565b61012f60008154612c0f9061556d565b909155505b6001600160a01b038416600090815261012d60205260409020805461ffff19169055612c3f84613daa565b6040516001600160a01b038516907fe22de1457cb61fb61b60176bc4235a9abd19466126b46692bc14fc573f09924990600090a250505050565b6001600160a01b038116600090815261012d60205260409020805460ff1615612cb45760405162c4e3d160e01b815260040160405180910390fd5b8054831580156101000261ffff19909216919091176001178255612ceb5761012e60008154612ce2906159c1565b90915550612d00565b61012f60008154612cfb906159c1565b909155505b6101315461012e541180612d1957506101305461012f54115b15612d375760405163e55fb50960e01b815260040160405180910390fd5b612d4082613e1e565b816001600160a01b03167fdd032f28700d4e4b1719b8fa26918a7d68608b4e36def571ce5fe7a3ecd69f4584604051612d7d911515815260200190565b60405180910390a2505050565b610135805460005b81811015611198576000838281548110612dae57612dae615541565b6000918252602090912001546001600160a01b03169050612dce81611680565b6001600160a01b038082166000908152610133602090815260408083206002908101546101348452828520958b1685529490925282200191909155612e138287613a1a565b6001600160a01b03808416600081815261013460209081526040808320948c1683529381528382206001018590559181526101339091522060030154909150612e5d90829061563f565b6001600160a01b039092166000908152610133602052604090206003019190915550600101612d92565b61013b8054906000612e98836159c1565b919050555061012f5461012e54612eaf919061563f565b61013c81905561013d55565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603612f1d57507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164191906159da565b606580546001600160a01b0319169055610af681613e5c565b6001600160a01b038116600090815261012d60205260408120805461ff00191661010017815561012e805491929091612fd0906159c1565b9091555061012f8054600090612fe59061556d565b909155506101315461012e5411156130105760405163e55fb50960e01b815260040160405180910390fd5b6040516001600160a01b038316907f5272e69bcef8da96614ac4a5d1e95ca02c35ea627bf7ecf389ec88d8d78b86bb90600090a25050565b60fb5481116130a45760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b6064820152608401610dbe565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa9101610e2c565b60c95460ff16156113e35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610dbe565b6000806131358484612012565b6001600160a01b0380861660009081526101346020908152604080832093881683529290522054909150613169908261563f565b6001600160a01b038581166000908152610133602090815260408083206002908101546101348452828520958a16855294909252822090810192909255908190559091506131b685612ebb565b6040516370a0823160e01b815230600482015290915081906001600160a01b038216906370a0823190602401602060405180830381865afa1580156131ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322391906155e5565b8311156132a0576001600160a01b03828116600090815261014060205260408082209190915561014154905163192e7a7b60e01b8152838316600482015291169063192e7a7b90602401600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b505050505b6132b46001600160a01b0382168685613eae565b856001600160a01b0316856001600160a01b03167fc7edf5cfe443c04a10a60ff6084c847114348c55b257a01d62700326219adbba856040516132f991815260200190565b60405180910390a35090949350505050565b806001600160801b0316826001600160801b031610158061333357506001600160801b038216155b1561200e57604051630381eb6d60e61b815260040160405180910390fd5b600054610100900460ff166133785760405162461bcd60e51b8152600401610dbe906159f7565b613380613f00565b610af681613f2f565b600054610100900460ff166133b05760405162461bcd60e51b8152600401610dbe906159f7565b6113e3613f56565b6133c06130e2565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586133f53390565b6040516001600160a01b03909116815260200160405180910390a1565b60007f000000000000000000000000000000000000000000000000000000000000000082111561346357507f0000000000000000000000000000000000000000000000000000000000000000919050565b5090565b6134996040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6101375460408051631ac5701b60e11b815290516000926001600160a01b03169163358ae0369160048083019260209291908290030181865afa1580156134e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061350891906159da565b610142546040516341976e0960e01b81526001600160a01b038084166004830152929350600092909116906341976e0990602401602060405180830381865afa158015613559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061357d91906155e5565b6001600160a01b03851660009081526101336020526040902060010154909150670de0b6b3a76400009081906135b3908a6155fe565b6135bd919061562b565b6135c790836155fe565b6135d1919061562b565b60808401526001600160a01b03841660009081526101336020526040902054670de0b6b3a7640000908190613606908a6155fe565b613610919061562b565b61361a90836155fe565b613624919061562b565b60608401526101425460405163fc57d4df60e01b81526001600160a01b038681166004830152600092169063fc57d4df90602401602060405180830381865afa158015613675573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369991906155e5565b90506000670de0b6b3a76400006136b088846155fe565b6136ba919061562b565b90506000670de0b6b3a76400006136d18a856155fe565b6136db919061562b565b90508560600151821061371557816000036136f7576000613712565b8186606001518961370891906155fe565b613712919061562b565b97505b8560800151811061374d578060000361372f57600061374a565b8086608001518a61374091906155fe565b61374a919061562b565b98505b613757898961563f565b86525050505060208201939093526040810193909352509092915050565b6000841580613782575083155b1561378f57506000612a0c565b83850361379d575083612a0c565b8385106000816137b6576137b18688613f89565b6137c0565b6137c08787613f89565b905060006137fb6137d086613ff1565b6137d988613ff1565b6137e28561405b565b6137ec9190615a42565b6137f69190615a72565b614066565b905082156138175761380d8782614071565b9350505050612a0c565b61382187826140a3565b98975050505050505050565b600080826000036138435750600090508061390d565b60008361384f8b611316565b61385990876155fe565b613863919061562b565b90506000613871878961563f565b9050806000036138895760008093509350505061390d565b6127106000808361389a8c876155fe565b6138a4919061562b565b9150836138b18b876155fe565b6138bb919061562b565b90508c156138dd578c6138ce84846155fe565b6138d8919061562b565b6138e0565b60005b96508b15613902578b6138f384836155fe565b6138fd919061562b565b613905565b60005b955050505050505b97509795505050505050565b60fb54811115610af65760fb5460405163792bfb1b60e11b8152600481019190915260248101829052604401610dbe565b6139526140d5565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336133f5565b6001600160a01b0380831660008181526101346020908152604080832094861683529381528382208451606081018652815481526001820154818401526002918201548187018190529484526101339092529382209093015490929183916139eb91906155d2565b6020830151909150670de0b6b3a7640000613a0682846155fe565b613a10919061562b565b9695505050505050565b600080613a2961257a8461296e565b6040516395dd919360e01b81526001600160a01b0385811660048301529192508591600091908316906395dd919390602401602060405180830381865afa158015613a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9c91906155e5565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0291906155e5565b6040516370a0823160e01b81526001600160a01b0388811660048301529192506000918516906370a0823190602401602060405180830381865afa158015613b4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7291906155e5565b90506000670de0b6b3a7640000613b8983856155fe565b613b93919061562b565b9050600061013760009054906101000a90046001600160a01b03166001600160a01b031663358ae0366040518163ffffffff1660e01b8152600401602060405180830381865afa158015613beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0f91906159da565b6101425460405163b62cad6960e01b81526001600160a01b03808416600483015292935091169063b62cad6990602401600060405180830381600087803b158015613c5957600080fd5b505af1158015613c6d573d6000803e3d6000fd5b5050610142546040516396e85ced60e01b81526001600160a01b038e8116600483015290911692506396e85ced9150602401600060405180830381600087803b158015613cb957600080fd5b505af1158015613ccd573d6000803e3d6000fd5b505050506000613cdf8887858e613467565b90506000613cec8c612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4d9190615652565b60ff169050613d5d8160126155d2565b613d6890600a615759565b8251613d7491906155fe565b80835261013654613d9a918b916001600160801b0380821691600160801b900416613775565b9c9b505050505050505050505050565b61013c5415613dc85761013c60008154613dc39061556d565b909155505b61013d5415801590613e02575061013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff16155b15610af65761013d60008154613e179061556d565b9091555050565b61013c5415610af65761013b54600090815261013a602090815260408083206001600160a01b03851684529091529020805460ff1916600117905550565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d7b90849061411e565b600054610100900460ff16613f275760405162461bcd60e51b8152600401610dbe906159f7565b6113e36141f3565b600054610100900460ff16610aed5760405162461bcd60e51b8152600401610dbe906159f7565b600054610100900460ff16613f7d5760405162461bcd60e51b8152600401610dbe906159f7565b60c9805460ff19169055565b6000613f9483613ff1565b613f9d83613ff1565b1215613fc6576040516360c1ae3960e01b81526004810184905260248101839052604401610dbe565b613fcf82613ff1565b6001607f1b613fdd85613ff1565b613fe79190615a42565b611c8a9190615a72565b60006001600160ff1b038211156134635760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610dbe565b600061164182614223565b600061164182614810565b60008082121561409457604051639603648160e01b815260040160405180910390fd5b6001607f1b82613fdd85613ff1565b6000808212156140c657604051639603648160e01b815260040160405180910390fd5b816001607f1b613fdd85613ff1565b60c95460ff166113e35760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610dbe565b6000614173826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614f219092919063ffffffff16565b905080516000148061419457508080602001905181019061419491906158fa565b610d7b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dbe565b600054610100900460ff1661421a5760405162461bcd60e51b8152600401610dbe906159f7565b6113e333612f7f565b60006001607f1b82131561424d57604051633ce23a3d60e11b815260048101839052602401610dbe565b60008213614271576040516330ecaa3d60e21b815260048101839052602401610dbe565b6001607f1b820361428457506000919050565b640733048c5a821361429e576116416101ff607c1b615aa0565b60008060006a01c8464f7616476000000085136142ec576142c3600160841b85615abc565b93506a01c8464f761647600000006142df6001607f1b87615a42565b6142e99190615a72565b94505b6cf1aaddd7742e9000000000000085136143395761430e600160831b85615abc565b93506cf1aaddd7742e9000000000000061432c6001607f1b87615a42565b6143369190615a72565b94505b6615fc21041027af603f1b851361438057614358600160821b85615abc565b93506615fc21041027af603f1b6143736001607f1b87615a42565b61437d9190615a72565b94505b660960aadc109e7b60461b85136143c75761439f600160811b85615abc565b9350660960aadc109e7b60461b6143ba6001607f1b87615a42565b6143c49190615a72565b94505b660454aaa8efe073604a1b851361440e576143e6600160801b85615abc565b9350660454aaa8efe073604a1b6144016001607f1b87615a42565b61440b9190615a72565b94505b6602f16ac6c59de7604c1b85136144555761442d6001607f1b85615abc565b93506602f16ac6c59de7604c1b6144486001607f1b87615a42565b6144529190615a72565b94505b6609b4597e37cb05604b1b851361449c576144746001607e1b85615abc565b93506609b4597e37cb05604b1b61448f6001607f1b87615a42565b6144999190615a72565b94505b6618ebef9eac820b604a1b85136144e3576144bb6001607d1b85615abc565b93506618ebef9eac820b604a1b6144d66001607f1b87615a42565b6144e09190615a72565b94505b6f70f5a893b608861e1f58934f97aea57d8513614536576145086001607c1b85615abc565b93506f70f5a893b608861e1f58934f97aea57d6145296001607f1b87615a42565b6145339190615a72565b94505b6145446001607f1b86615abc565b92508291506001607f1b6145588380615a42565b6145629190615a72565b9050600160801b6145738482615abc565b61457d9084615a42565b6145879190615a72565b6145919085615ae3565b93506001607f1b6145a28284615a42565b6145ac9190615a72565b9150600160811b6145cd846faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa615abc565b6145d79084615a42565b6145e19190615a72565b6145eb9085615ae3565b93506001607f1b6145fc8284615a42565b6146069190615a72565b9150600360801b614627846f99999999999999999999999999999999615abc565b6146319084615a42565b61463b9190615a72565b6146459085615ae3565b93506001607f1b6146568284615a42565b6146609190615a72565b9150600160821b614681846f92492492492492492492492492492492615abc565b61468b9084615a42565b6146959190615a72565b61469f9085615ae3565b93506001607f1b6146b08284615a42565b6146ba9190615a72565b9150600560801b6146db846f8e38e38e38e38e38e38e38e38e38e38e615abc565b6146e59084615a42565b6146ef9190615a72565b6146f99085615ae3565b93506001607f1b61470a8284615a42565b6147149190615a72565b9150600360811b614735846f8ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b615abc565b61473f9084615a42565b6147499190615a72565b6147539085615ae3565b93506001607f1b6147648284615a42565b61476e9190615a72565b9150600760801b61478f846f89d89d89d89d89d89d89d89d89d89d89615abc565b6147999084615a42565b6147a39190615a72565b6147ad9085615ae3565b93506001607f1b6147be8284615a42565b6147c89190615a72565b9150600160831b6147e9846f88888888888888888888888888888888615abc565b6147f39084615a42565b6147fd9190615a72565b6148079085615ae3565b95945050505050565b60006148206101ff607c1b615aa0565b82121561482f57506000919050565b8160000361484257506001607f1b919050565b600082131561486757604051631086170d60e01b815260048101839052602401610dbe565b6000806148786001607c1b85615b0b565b91508190506001607f1b61488c8280615a42565b6148969190615a72565b90506148aa816710e1b3be415a0000615a42565b6148b49084615ae3565b92506001607f1b6148c58383615a42565b6148cf9190615a72565b90506148e3816705a0913f6b1e0000615a42565b6148ed9084615ae3565b92506001607f1b6148fe8383615a42565b6149089190615a72565b905061491c81670168244fdac78000615a42565b6149269084615ae3565b92506001607f1b6149378383615a42565b6149419190615a72565b905061495481664807432bc18000615a42565b61495e9084615ae3565b92506001607f1b61496f8383615a42565b6149799190615a72565b905061498c81660c0135dca04000615a42565b6149969084615ae3565b92506001607f1b6149a78383615a42565b6149b19190615a72565b90506149c4816601b707b1cdc000615a42565b6149ce9084615ae3565b92506001607f1b6149df8383615a42565b6149e99190615a72565b90506149fb816536e0f639b800615a42565b614a059084615ae3565b92506001607f1b614a168383615a42565b614a209190615a72565b9050614a3281650618fee9f800615a42565b614a3c9084615ae3565b92506001607f1b614a4d8383615a42565b614a579190615a72565b9050614a6881649c197dcc00615a42565b614a729084615ae3565b92506001607f1b614a838383615a42565b614a8d9190615a72565b9050614a9e81640e30dce400615a42565b614aa89084615ae3565b92506001607f1b614ab98383615a42565b614ac39190615a72565b9050614ad48164012ebd1300615a42565b614ade9084615ae3565b92506001607f1b614aef8383615a42565b614af99190615a72565b9050614b09816317499f00615a42565b614b139084615ae3565b92506001607f1b614b248383615a42565b614b2e9190615a72565b9050614b3e816301a9d480615a42565b614b489084615ae3565b92506001607f1b614b598383615a42565b614b639190615a72565b9050614b7281621c6380615a42565b614b7c9084615ae3565b92506001607f1b614b8d8383615a42565b614b979190615a72565b9050614ba6816201c638615a42565b614bb09084615ae3565b92506001607f1b614bc18383615a42565b614bcb9190615a72565b9050614bd981611ab8615a42565b614be39084615ae3565b92506001607f1b614bf48383615a42565b614bfe9190615a72565b9050614c0c8161017c615a42565b614c169084615ae3565b92506001607f1b614c278383615a42565b614c319190615a72565b9050614c3e816014615a42565b614c489084615ae3565b92506001607f1b614c598383615a42565b614c639190615a72565b9050614c70816001615a42565b614c7a9084615ae3565b92506001607f1b82614c946721c3677c82b4000086615a72565b614c9e9190615ae3565b614ca89190615ae3565b9250614cb384615aa0565b9350600160841b841615614cf9577243cbaf42a000812488fc5c220ad7b97bf6e99e614cec6cf1aaddd7742e56d32fb9f9974485615a42565b614cf69190615a72565b92505b600160831b841615614d3e577105d27a9f51c31b7c2f8038212a0574779991614d316e0afe10820813d65dfe6a33c07f738f85615a42565b614d3b9190615a72565b92505b600160821b841615614d8357701b4c902e273a58678d6d3bfdb93db96d02614d766f02582ab704279e8efd15e0265855c47a85615a42565b614d809190615a72565b92505b600160811b841615614dc8577003b1cc971a9bb5b9867477440d6d157750614dbb6f1152aaa3bf81cb9fdb76eae12d02957185615a42565b614dc59190615a72565b92505b600160801b841615614e0d5770015bf0a8b1457695355fb8ac404e7a79e3614e006f2f16ac6c59de6f8d5d6f63c1482a7c8685615a42565b614e0a9190615a72565b92505b6001607f1b841615614e51576fd3094c70f034de4b96ff7d5b6f99fcd8614e446f4da2cbf1be5827f9eb3ad1aa9866ebb385615a42565b614e4e9190615a72565b92505b6001607e1b841615614e95576fa45af1e1f40c333b3de1db4dd55f29a7614e886f63afbe7ab2082ba1a0ae5e4eb1b479dc85615a42565b614e929190615a72565b92505b6001607d1b841615614ed9576f910b022db7ae67ce76b441c27035c6a1614ecc6f70f5a893b608861e1f58934f97aea57d85615a42565b614ed69190615a72565b92505b6001607c1b841615614f1a576f88415abbe9a76bead8d00cf112e4d4a8614f106f783eafef1c0a8f3978c7f81824d62ebf85615a42565b612a0c9190615a72565b5050919050565b6060612a0c848460008585600080866001600160a01b03168587604051614f489190615b1f565b60006040518083038185875af1925050503d8060008114614f85576040519150601f19603f3d011682016040523d82523d6000602084013e614f8a565b606091505b5091509150614f9b87838387614fa6565b979650505050505050565b6060831561501557825160000361500e576001600160a01b0385163b61500e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dbe565b5081612a0c565b612a0c838381511561502a5781518083602001fd5b8060405162461bcd60e51b8152600401610dbe9190615b3b565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0381168114610af657600080fd5b6000602082840312156150be57600080fd5b81356113ca81615097565b600080604083850312156150dc57600080fd5b50508035926020909101359150565b60008083601f8401126150fd57600080fd5b50813567ffffffffffffffff81111561511557600080fd5b6020830191508360208260051b850101111561513057600080fd5b9250929050565b6000806020838503121561514a57600080fd5b823567ffffffffffffffff81111561516157600080fd5b61516d858286016150eb565b90969095509350505050565b60008060006060848603121561518e57600080fd5b833561519981615097565b95602085013595506040909401359392505050565b600080600080604085870312156151c457600080fd5b843567ffffffffffffffff808211156151dc57600080fd5b6151e8888389016150eb565b9096509450602087013591508082111561520157600080fd5b5061520e878288016150eb565b95989497509550505050565b8015158114610af657600080fd5b60008060006040848603121561523d57600080fd5b83356152488161521a565b9250602084013567ffffffffffffffff81111561526457600080fd5b615270868287016150eb565b9497909650939450505050565b60006020828403121561528f57600080fd5b5035919050565b600080604083850312156152a957600080fd5b8235915060208301356152bb81615097565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156153075783516001600160a01b0316835292840192918401916001016152e2565b50909695505050505050565b80356001600160801b038116811461164457600080fd5b6000806000806000806000806000806101408b8d03121561534a57600080fd5b8a3561535581615097565b995060208b013561536581615097565b985060408b0135975061537a60608c01615313565b965061538860808c01615313565b955060a08b013561539881615097565b945060c08b01356153a881615097565b935060e08b01356153b881615097565b92506101008b01356153c981615097565b809250506101208b013590509295989b9194979a5092959850565b600080600080600060a086880312156153fc57600080fd5b853561540781615097565b9450602086013561541781615097565b94979496505050506040830135926060810135926080909101359150565b6000806040838503121561544857600080fd5b823561545381615097565b915060208301356152bb81615097565b6000806000806080858703121561547957600080fd5b843561548481615097565b9350602085013561549481615097565b93969395505050506040820135916060013590565b600080604083850312156154bc57600080fd5b6154c583615313565b91506154d360208401615313565b90509250929050565b602080825282518282018190526000919060409081850190868401855b8281101561553457815180516001600160a01b03908116865287820151168786015285015185850152606090930192908501906001016154f9565b5091979650505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008161557c5761557c615557565b506000190190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b81810381811115611c8d57611c8d615557565b6000602082840312156155f757600080fd5b5051919050565b8082028115828204841417611c8d57611c8d615557565b634e487b7160e01b600052601260045260246000fd5b60008261563a5761563a615615565b500490565b80820180821115611c8d57611c8d615557565b60006020828403121561566457600080fd5b815160ff811681146113ca57600080fd5b600181815b808511156156b057816000190482111561569657615696615557565b808516156156a357918102915b93841c939080029061567a565b509250929050565b6000826156c757506001611c8d565b816156d457506000611c8d565b81600181146156ea57600281146156f457615710565b6001915050611c8d565b60ff84111561570557615705615557565b50506001821b611c8d565b5060208310610133831016604e8410600b8410161715615733575081810a611c8d565b61573d8383615675565b806000190482111561575157615751615557565b029392505050565b6000611c8a83836156b8565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561579e5761579e615765565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156157cd576157cd615765565b604052919050565b60005b838110156157f05781810151838201526020016157d8565b50506000910152565b805161164481615097565b6000602080838503121561581757600080fd5b825167ffffffffffffffff8082111561582f57600080fd5b9084019060a0828703121561584357600080fd5b61584b61577b565b82518281111561585a57600080fd5b8301601f8101881361586b57600080fd5b80518381111561587d5761587d615765565b61588f601f8201601f191687016157a4565b935080845288868284010111156158a557600080fd5b6158b4818786018885016157d5565b50508181526158c48484016157f9565b848201526158d4604084016157f9565b604082015260608301516060820152608083015160808201528094505050505092915050565b60006020828403121561590c57600080fd5b81516113ca8161521a565b6000815180845261592f8160208601602086016157d5565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090612a0c90830184615917565b6001600160a01b0384811682528316602082015260606040820181905260009061480790830184615917565b6000806000606084860312156159a857600080fd5b8351925060208401519150604084015190509250925092565b6000600182016159d3576159d3615557565b5060010190565b6000602082840312156159ec57600080fd5b81516113ca81615097565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b80820260008212600160ff1b84141615615a5e57615a5e615557565b8181058314821517611c8d57611c8d615557565b600082615a8157615a81615615565b600160ff1b821460001984141615615a9b57615a9b615557565b500590565b6000600160ff1b8201615ab557615ab5615557565b5060000390565b8181036000831280158383131683831282161715615adc57615adc615557565b5092915050565b8082018281126000831280158216821582161715615b0357615b03615557565b505092915050565b600082615b1a57615b1a615615565b500790565b60008251615b318184602087016157d5565b9190910192915050565b602081526000611c8a602083018461591756fe7570646174654d756c7469706c6965727328616464726573732c75696e743235362c75696e743235362909d2594e8892daceca055f74be758146a8b8b1167444d0b4ccb96e74168198cc6164644d61726b657428616464726573732c616464726573732c75696e743235362c75696e7432353629a2646970667358221220d7842351882c76ed9cd16c268489fd8f3a58a0b4e004c3ca395a20eaf26d410a64736f6c63430008190033", + "devdoc": { + "author": "Venus", + "custom:security-contact": "https://github.com/VenusProtocol/venus-protocol", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + }, + "Paused(address)": { + "details": "Emitted when the pause is triggered by `account`." + }, + "Unpaused(address)": { + "details": "Emitted when the pause is lifted by `account`." + } + }, + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "accrueInterest(address)": { + "custom:error": "Throw MarketNotSupported if market is not supported", + "params": { + "vToken": "the market for which to distribute the income" + } + }, + "accrueInterestAndUpdateScore(address,address)": { + "params": { + "market": "the market for which to accrue interest and update score", + "user": "the account address for which to accrue interest and update score" + } + }, + "addMarket(address,address,uint256,uint256)": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw MarketAlreadyExists if market already existsThrow InvalidVToken if market is not valid", + "custom:event": "Emits MarketAdded event", + "params": { + "borrowMultiplier": "the multiplier for borrow cap. It should be converted to 1e18", + "comptroller": "address of the comptroller", + "market": "address of the market vToken", + "supplyMultiplier": "the multiplier for supply cap. It should be converted to 1e18" + } + }, + "burn(address)": { + "custom:access": "Controlled by ACM", + "params": { + "user": "the account address for which the prime token will be burned" + } + }, + "calculateAPR(address,address)": { + "params": { + "market": "the market for which to fetch the APR", + "user": "the account for which to get the APR" + }, + "returns": { + "aprInfo": "APR information for the user for the given market" + } + }, + "claimInterest(address)": { + "params": { + "vToken": "the market for which claim the accrued interest" + }, + "returns": { + "_0": "amount the amount of tokens transferred to the msg.sender" + } + }, + "claimInterest(address,address)": { + "params": { + "user": "the user for which to claim the accrued interest", + "vToken": "the market for which claim the accrued interest" + }, + "returns": { + "_0": "amount the amount of tokens transferred to the user" + } + }, + "claimTimeRemaining(address)": { + "params": { + "user": "the account address for which we are checking the remaining time" + }, + "returns": { + "_0": "timeRemaining the number of seconds the user needs to wait to claim prime token" + } + }, + "comptroller()": { + "returns": { + "_0": "the core pool comptroller address" + } + }, + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor" + }, + "estimateAPR(address,address,uint256,uint256,uint256)": { + "params": { + "market": "the market for which to fetch the APR", + "user": "the account for which to get the APR" + }, + "returns": { + "aprInfo": "APR information for the user for the given market" + } + }, + "getAllMarkets()": { + "returns": { + "_0": "an array of addresses representing all available markets" + } + }, + "getBlockNumberOrTimestamp()": { + "details": "Function to simply retrieve block number or block timestamp", + "returns": { + "_0": "Current block number or block timestamp" + } + }, + "getInterestAccrued(address,address)": { + "params": { + "user": "the account for which to get the accrued interest", + "vToken": "the market for which to fetch the accrued interest" + }, + "returns": { + "_0": "interestAccrued the number of underlying tokens accrued by the user since the last accrual" + } + }, + "getPendingRewards(address)": { + "params": { + "user": "the account for which to get the accrued interests" + }, + "returns": { + "pendingRewards": "the number of underlying tokens accrued by the user for all markets" + } + }, + "incomeDistributionYearly(address)": { + "params": { + "vToken": "the market for which to fetch the total income that's going to distributed in a year" + }, + "returns": { + "amount": "the total income" + } + }, + "initialize(address,address,uint256,uint128,uint128,address,address,address,address,uint256)": { + "custom:error": "Throw InvalidAddress if any of the address is invalid", + "params": { + "accessControlManager_": "Address of AccessControlManager", + "alphaDenominator_": "denominator of alpha. If alpha is 0.5 then denominator is 2. alpha is alphaNumerator_/alphaDenominator_. So, 0 < alpha < 1", + "alphaNumerator_": "numerator of alpha. If alpha is 0.5 then numerator is 1. alphaDenominator_ must be greater than alphaNumerator_, alphaDenominator_ cannot be zero and alphaNumerator_ cannot be zero", + "comptroller_": "Address of core pool comptroller", + "loopsLimit_": "Maximum number of loops allowed in a single transaction", + "oracle_": "Address of Oracle", + "primeLiquidityProvider_": "Address of PrimeLiquidityProvider", + "xvsVaultPoolId_": "Pool id of XVSVault", + "xvsVaultRewardToken_": "Address of XVSVault reward token", + "xvsVault_": "Address of XVSVault" + } + }, + "initializeV2(address)": { + "params": { + "poolRegistry_": "Address of IL pool registry" + } + }, + "isUserPrimeHolder(address)": { + "returns": { + "_0": "isPrimeHolder true if user is a prime holder" + } + }, + "issue(bool,address[])": { + "custom:access": "Controlled by ACM", + "params": { + "isIrrevocable": "are the tokens being issued", + "users": "list of address to issue tokens to" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." + }, + "setAccessControlManager(address)": { + "custom:access": "Only Governance", + "custom:event": "Emits NewAccessControlManager event", + "details": "Admin function to set address of AccessControlManager", + "params": { + "accessControlManager_": "The new address of the AccessControlManager" + } + }, + "setLimit(uint256,uint256)": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw InvalidLimit if any of the limit is less than total tokens minted", + "custom:event": "Emits MintLimitsUpdated event", + "params": { + "_irrevocableLimit": "total number of irrevocable tokens that can be minted", + "_revocableLimit": "total number of revocable tokens that can be minted" + } + }, + "setMaxLoopsLimit(uint256)": { + "custom:access": "Controlled by ACM", + "custom:event": "Emits MaxLoopsLimitUpdated event on success", + "params": { + "loopsLimit": "Number of loops limit" + } + }, + "setStakedAt(address[],uint256[])": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw InvalidLength if users and timestamps length are not equal", + "custom:event": "Emits StakedAtUpdated event for each user", + "params": { + "timestamps": "new staked at timestamp for the users", + "users": "accounts for which we need to update staked at timestamp" + } + }, + "togglePause()": { + "custom:access": "Controlled by ACM" + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + }, + "updateAlpha(uint128,uint128)": { + "custom:access": "Controlled by ACM", + "custom:event": "Emits AlphaUpdated event", + "params": { + "_alphaDenominator": "denominator of alpha. If alpha is 0.5 then denominator is 2", + "_alphaNumerator": "numerator of alpha. If alpha is 0.5 then numerator is 1" + } + }, + "updateMultipliers(address,uint256,uint256)": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw MarketNotSupported if market is not supported", + "custom:event": "Emits MultiplierUpdated event", + "params": { + "borrowMultiplier": "new borrow multiplier for the market, scaled by 1e18", + "market": "address of the market vToken", + "supplyMultiplier": "new supply multiplier for the market, scaled by 1e18" + } + }, + "updateScores(address[])": { + "custom:error": "Throw NoScoreUpdatesRequired if no score updates are requiredThrow UserHasNoPrimeToken if user has no prime token", + "custom:event": "Emits UserScoreUpdated event", + "params": { + "users": "accounts for which we need to update score" + } + }, + "xvsUpdated(address)": { + "params": { + "user": "the account address whose balance was updated" + } + } + }, + "stateVariables": { + "MAXIMUM_XVS_CAP": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "MINIMUM_STAKED_XVS": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "NATIVE_MARKET": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "STAKING_PERIOD": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "WRAPPED_NATIVE_TOKEN": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + } + }, + "title": "Prime", + "version": 1 + }, + "userdoc": { + "errors": { + "AssetAlreadyExists()": [ + { + "notice": "Error thrown when asset already exists" + } + ], + "ExpTooLarge(int256)": [ + { + "notice": "Thrown when exp is given too large of an argument" + } + ], + "IneligibleToClaim()": [ + { + "notice": "Error thrown when user is not eligible to claim prime token" + } + ], + "InvalidAddress()": [ + { + "notice": "Error thrown when invalid address is passed" + } + ], + "InvalidAlphaArguments()": [ + { + "notice": "Error thrown when invalid alpha arguments are passed" + } + ], + "InvalidBlocksPerYear()": [ + { + "notice": "Thrown when blocks per year is invalid" + } + ], + "InvalidComptroller()": [ + { + "notice": "Error thrown when invalid comptroller is passed" + } + ], + "InvalidLength()": [ + { + "notice": "Error thrown when invalid length is passed" + } + ], + "InvalidLimit()": [ + { + "notice": "Error thrown when mint limit is reached" + } + ], + "InvalidTimeBasedConfiguration()": [ + { + "notice": "Thrown when time based but blocks per year is provided" + } + ], + "InvalidTimestamp()": [ + { + "notice": "Error thrown when timestamp is invalid" + } + ], + "InvalidVToken()": [ + { + "notice": "Error thrown when invalid vToken is passed" + } + ], + "LnNonRealResult(int256)": [ + { + "notice": "Thrown when the natural log would have returned a number outside of ℝ" + } + ], + "LnTooLarge(int256)": [ + { + "notice": "Thrown when the natural log function is given too large of an argument" + } + ], + "MarketAlreadyExists()": [ + { + "notice": "Error thrown when market already exists" + } + ], + "MarketNotSupported()": [ + { + "notice": "Error thrown when market is not supported" + } + ], + "MaxLoopsLimitExceeded(uint256,uint256)": [ + { + "notice": "Thrown an error on maxLoopsLimit exceeds for any loop" + } + ], + "NoScoreUpdatesRequired()": [ + { + "notice": "Error thrown when no score updates are required" + } + ], + "Unauthorized(address,address,string)": [ + { + "notice": "Thrown when the action is prohibited by AccessControlManager" + } + ], + "UserHasNoPrimeToken()": [ + { + "notice": "Error thrown when user has no prime token" + } + ], + "WaitMoreTime()": [ + { + "notice": "Error thrown when user needs to wait more time to claim prime token" + } + ] + }, + "events": { + "AlphaUpdated(uint128,uint128,uint128,uint128)": { + "notice": "Emitted when alpha is updated" + }, + "Burn(address)": { + "notice": "Emitted when prime token is burned" + }, + "InterestClaimed(address,address,uint256)": { + "notice": "Emitted when interest is claimed" + }, + "MarketAdded(address,address,uint256,uint256)": { + "notice": "Emitted when a market is added to prime program" + }, + "MaxLoopsLimitUpdated(uint256,uint256)": { + "notice": "Emitted when max loops limit is set" + }, + "Mint(address,bool)": { + "notice": "Emitted when prime token is minted" + }, + "MintLimitsUpdated(uint256,uint256,uint256,uint256)": { + "notice": "Emitted when mint limits are updated" + }, + "MultiplierUpdated(address,uint256,uint256,uint256,uint256)": { + "notice": "Emitted when multiplier is updated" + }, + "NewAccessControlManager(address,address)": { + "notice": "Emitted when access control manager contract address is changed" + }, + "StakedAtUpdated(address,uint256)": { + "notice": "Emitted when stakedAt is updated" + }, + "TokenUpgraded(address)": { + "notice": "Emitted when revocable token is upgraded to irrevocable token" + }, + "UserScoreUpdated(address)": { + "notice": "Emitted when user score is updated" + } + }, + "kind": "user", + "methods": { + "MAXIMUM_XVS_CAP()": { + "notice": "maximum XVS taken in account when calculating user score" + }, + "MINIMUM_STAKED_XVS()": { + "notice": "minimum amount of XVS user needs to stake to become a prime member" + }, + "NATIVE_MARKET()": { + "notice": "address of native market contract" + }, + "STAKING_PERIOD()": { + "notice": "number of days user need to stake to claim prime token" + }, + "WRAPPED_NATIVE_TOKEN()": { + "notice": "address of wrapped native token contract" + }, + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "accrueInterest(address)": { + "notice": "Distributes income from market since last distribution" + }, + "accrueInterestAndUpdateScore(address,address)": { + "notice": "accrues interes and updates score for an user for a specific market" + }, + "addMarket(address,address,uint256,uint256)": { + "notice": "Add a market to prime program" + }, + "alphaDenominator()": { + "notice": "denominator of alpha. Ex: if alpha is 0.5 then this will be 2" + }, + "alphaNumerator()": { + "notice": "numerator of alpha. Ex: if alpha is 0.5 then this will be 1" + }, + "blocksOrSecondsPerYear()": { + "notice": "Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored" + }, + "burn(address)": { + "notice": "For burning any prime token" + }, + "calculateAPR(address,address)": { + "notice": "Returns supply and borrow APR for user for a given market" + }, + "claim()": { + "notice": "For claiming prime token when staking period is completed" + }, + "claimInterest(address)": { + "notice": "For user to claim boosted yield" + }, + "claimInterest(address,address)": { + "notice": "For user to claim boosted yield" + }, + "claimTimeRemaining(address)": { + "notice": "fetch the numbers of seconds remaining for staking period to complete" + }, + "comptroller()": { + "notice": "Retrieves the core pool comptroller address" + }, + "estimateAPR(address,address,uint256,uint256,uint256)": { + "notice": "Returns supply and borrow APR for estimated supply, borrow and XVS staked" + }, + "getAllMarkets()": { + "notice": "Retrieves an array of all available markets" + }, + "getInterestAccrued(address,address)": { + "notice": "Returns boosted interest accrued for a user" + }, + "getPendingRewards(address)": { + "notice": "Returns boosted pending interest accrued for a user for all markets" + }, + "incomeDistributionYearly(address)": { + "notice": "the total income that's going to be distributed in a year to prime token holders" + }, + "initialize(address,address,uint256,uint128,uint128,address,address,address,address,uint256)": { + "notice": "Prime initializer" + }, + "initializeV2(address)": { + "notice": "Prime initializer V2 for initializing pool registry" + }, + "interests(address,address)": { + "notice": "vToken to user to user index" + }, + "irrevocableLimit()": { + "notice": "Indicates maximum irrevocable tokens that can be minted" + }, + "isScoreUpdated(uint256,address)": { + "notice": "mapping to check if a account's score was updated in the round" + }, + "isTimeBased()": { + "notice": "Acknowledges if a contract is time based or not" + }, + "isUserPrimeHolder(address)": { + "notice": "Returns if user is a prime holder" + }, + "issue(bool,address[])": { + "notice": "Directly issue prime tokens to users" + }, + "markets(address)": { + "notice": "vToken to market configuration" + }, + "nextScoreUpdateRoundId()": { + "notice": "unique id for next round" + }, + "oracle()": { + "notice": "The address of ResilientOracle contract" + }, + "pendingScoreUpdates()": { + "notice": "total number of accounts whose score is yet to be updated" + }, + "poolRegistry()": { + "notice": "The address of PoolRegistry contract" + }, + "primeLiquidityProvider()": { + "notice": "The address of PLP contract" + }, + "revocableLimit()": { + "notice": "Indicates maximum revocable tokens that can be minted" + }, + "setAccessControlManager(address)": { + "notice": "Sets the address of AccessControlManager" + }, + "setLimit(uint256,uint256)": { + "notice": "Set limits for total tokens that can be minted" + }, + "setMaxLoopsLimit(uint256)": { + "notice": "Set the limit for the loops can iterate to avoid the DOS" + }, + "setStakedAt(address[],uint256[])": { + "notice": "Update staked at timestamp for multiple users" + }, + "stakedAt(address)": { + "notice": "Tracks when prime token eligible users started staking for claiming prime token" + }, + "togglePause()": { + "notice": "To pause or unpause claiming of interest" + }, + "tokens(address)": { + "notice": "Mapping to get prime token's metadata" + }, + "totalIrrevocable()": { + "notice": "Tracks total irrevocable tokens minted" + }, + "totalRevocable()": { + "notice": "Tracks total revocable tokens minted" + }, + "totalScoreUpdatesRequired()": { + "notice": "total number of accounts whose score needs to be updated" + }, + "unreleasedPLPIncome(address)": { + "notice": "unreleased income from PLP that's already distributed to prime holders" + }, + "updateAlpha(uint128,uint128)": { + "notice": "Update value of alpha" + }, + "updateMultipliers(address,uint256,uint256)": { + "notice": "Update multipliers for a market" + }, + "updateScores(address[])": { + "notice": "Update total score of multiple users and market" + }, + "vTokenForAsset(address)": { + "notice": "mapping used to find if an asset is part of prime markets" + }, + "xvsUpdated(address)": { + "notice": "Executed by XVSVault whenever user's XVSVault balance changes" + }, + "xvsVault()": { + "notice": "address of XVS vault" + }, + "xvsVaultPoolId()": { + "notice": "address of XVS vault pool id" + }, + "xvsVaultRewardToken()": { + "notice": "address of XVS vault reward token" + } + }, + "notice": "Prime Token is used to provide extra rewards to the users who have staked a minimum of `MINIMUM_STAKED_XVS` XVS in the XVSVault for `STAKING_PERIOD` days", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 246, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 249, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1516, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 118, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 238, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 11, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 105, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 5863, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_accessControlManager", + "offset": 0, + "slot": "151", + "type": "t_contract(IAccessControlManagerV8)6048" + }, + { + "astId": 5868, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 430, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_paused", + "offset": 0, + "slot": "201", + "type": "t_bool" + }, + { + "astId": 535, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "202", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 6105, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "maxLoopsLimit", + "offset": 0, + "slot": "251", + "type": "t_uint256" + }, + { + "astId": 6110, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "252", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 22637, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "tokens", + "offset": 0, + "slot": "301", + "type": "t_mapping(t_address,t_struct(Token)22598_storage)" + }, + { + "astId": 22640, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "totalIrrevocable", + "offset": 0, + "slot": "302", + "type": "t_uint256" + }, + { + "astId": 22643, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "totalRevocable", + "offset": 0, + "slot": "303", + "type": "t_uint256" + }, + { + "astId": 22646, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "revocableLimit", + "offset": 0, + "slot": "304", + "type": "t_uint256" + }, + { + "astId": 22649, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "irrevocableLimit", + "offset": 0, + "slot": "305", + "type": "t_uint256" + }, + { + "astId": 22654, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "stakedAt", + "offset": 0, + "slot": "306", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22660, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "markets", + "offset": 0, + "slot": "307", + "type": "t_mapping(t_address,t_struct(Market)22609_storage)" + }, + { + "astId": 22668, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "interests", + "offset": 0, + "slot": "308", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(Interest)22616_storage))" + }, + { + "astId": 22672, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_allMarkets", + "offset": 0, + "slot": "309", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 22675, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "alphaNumerator", + "offset": 0, + "slot": "310", + "type": "t_uint128" + }, + { + "astId": 22678, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "alphaDenominator", + "offset": 16, + "slot": "310", + "type": "t_uint128" + }, + { + "astId": 22681, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "xvsVault", + "offset": 0, + "slot": "311", + "type": "t_address" + }, + { + "astId": 22684, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "xvsVaultRewardToken", + "offset": 0, + "slot": "312", + "type": "t_address" + }, + { + "astId": 22687, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "xvsVaultPoolId", + "offset": 0, + "slot": "313", + "type": "t_uint256" + }, + { + "astId": 22694, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "isScoreUpdated", + "offset": 0, + "slot": "314", + "type": "t_mapping(t_uint256,t_mapping(t_address,t_bool))" + }, + { + "astId": 22697, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "nextScoreUpdateRoundId", + "offset": 0, + "slot": "315", + "type": "t_uint256" + }, + { + "astId": 22700, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "totalScoreUpdatesRequired", + "offset": 0, + "slot": "316", + "type": "t_uint256" + }, + { + "astId": 22703, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "pendingScoreUpdates", + "offset": 0, + "slot": "317", + "type": "t_uint256" + }, + { + "astId": 22708, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "vTokenForAsset", + "offset": 0, + "slot": "318", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 22711, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "corePoolComptroller", + "offset": 0, + "slot": "319", + "type": "t_address" + }, + { + "astId": 22716, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "unreleasedPLPIncome", + "offset": 0, + "slot": "320", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22719, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "primeLiquidityProvider", + "offset": 0, + "slot": "321", + "type": "t_address" + }, + { + "astId": 22723, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "oracle", + "offset": 0, + "slot": "322", + "type": "t_contract(ResilientOracleInterface)6078" + }, + { + "astId": 22726, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "poolRegistry", + "offset": 0, + "slot": "323", + "type": "t_address" + }, + { + "astId": 22731, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "324", + "type": "t_array(t_uint256)26_storage" + }, + { + "astId": 6191, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "350", + "type": "t_array(t_uint256)48_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)26_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[26]", + "numberOfBytes": "832" + }, + "t_array(t_uint256)48_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IAccessControlManagerV8)6048": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV8", + "numberOfBytes": "20" + }, + "t_contract(ResilientOracleInterface)6078": { + "encoding": "inplace", + "label": "contract ResilientOracleInterface", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_mapping(t_address,t_struct(Interest)22616_storage))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => struct PrimeStorageV1.Interest))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_struct(Interest)22616_storage)" + }, + "t_mapping(t_address,t_struct(Interest)22616_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct PrimeStorageV1.Interest)", + "numberOfBytes": "32", + "value": "t_struct(Interest)22616_storage" + }, + "t_mapping(t_address,t_struct(Market)22609_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct PrimeStorageV1.Market)", + "numberOfBytes": "32", + "value": "t_struct(Market)22609_storage" + }, + "t_mapping(t_address,t_struct(Token)22598_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct PrimeStorageV1.Token)", + "numberOfBytes": "32", + "value": "t_struct(Token)22598_storage" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_struct(Interest)22616_storage": { + "encoding": "inplace", + "label": "struct PrimeStorageV1.Interest", + "members": [ + { + "astId": 22611, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "accrued", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 22613, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "score", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 22615, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "rewardIndex", + "offset": 0, + "slot": "2", + "type": "t_uint256" + } + ], + "numberOfBytes": "96" + }, + "t_struct(Market)22609_storage": { + "encoding": "inplace", + "label": "struct PrimeStorageV1.Market", + "members": [ + { + "astId": 22600, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "supplyMultiplier", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 22602, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "borrowMultiplier", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 22604, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "rewardIndex", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 22606, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "sumOfMembersScore", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 22608, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "exists", + "offset": 0, + "slot": "4", + "type": "t_bool" + } + ], + "numberOfBytes": "160" + }, + "t_struct(Token)22598_storage": { + "encoding": "inplace", + "label": "struct PrimeStorageV1.Token", + "members": [ + { + "astId": 22595, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "exists", + "offset": 0, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 22597, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "isIrrevocable", + "offset": 1, + "slot": "0", + "type": "t_bool" + } + ], + "numberOfBytes": "32" + }, + "t_uint128": { + "encoding": "inplace", + "label": "uint128", + "numberOfBytes": "16" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/opmainnet/Prime_Proxy.json b/deployments/opmainnet/Prime_Proxy.json new file mode 100644 index 000000000..4413b807b --- /dev/null +++ b/deployments/opmainnet/Prime_Proxy.json @@ -0,0 +1,282 @@ +{ + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "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": [], + "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": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "transactionIndex": 10, + "gasUsed": "774848", + "logsBloom": "0x00000000000000000000000000080000400000000000000004800000000000000000000000000000000000000000000000020000000000000000000000008000000000000000000000000000000002000001000000000400000000000000000000000000020000000000000000000800000000810800000000000080000000400000100000000000040008000000000000000000000081000000000000800000000000000000000000002000000400000000000000800000000000000000000000000020000000000000000001040000000040000400000000000000000020000000000200000000000000000000000000000800000000000000000000000000", + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b", + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "logs": [ + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000007dcf81746ffa44c4469eba2f6db86ae3d5f92b10" + ], + "data": "0x", + "logIndex": 16, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000c76363b887031e79e6a2954c5515f5e5507a6387" + ], + "data": "0x", + "logIndex": 17, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d71b1f33f6b0259683f11174ee4ddc2bb9ce4ed6", + "logIndex": 18, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0xc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014", + "logIndex": 19, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0x62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258"], + "data": "0x000000000000000000000000c76363b887031e79e6a2954c5515f5e5507a6387", + "logIndex": 20, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 21, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + }, + { + "transactionIndex": 10, + "blockNumber": 126396250, + "transactionHash": "0x18f61d2fb057481afb3e8c6462865decc7aa3ceaf3605c054c2c72f86c6879ed", + "address": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eaf9490cbea6ff9ba1d23671c39a799ced0dced2", + "logIndex": 22, + "blockHash": "0x46cd8d3fe46fe16fe55ef8deb38b9194a13b5adc79edc92bfb0b13c2267af62b" + } + ], + "blockNumber": 126396250, + "cumulativeGasUsed": "3174172", + "status": 1, + "byzantium": true + }, + "args": [ + "0x7DCF81746fFA44C4469eBA2F6Db86AE3d5f92b10", + "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "0xb1a250f2000000000000000000000000133120607c018c949e91ae333785519f6d947e010000000000000000000000004a971e87ad1f61f7f3081645f52a99277ae917cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d71b1f33f6b0259683f11174ee4ddc2bb9ce4ed60000000000000000000000006412f6cd58d0182ae150b90b5a99e285b91c1a12000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021fc48569bd3a6623281f55fc1f8b48b9386907b0000000000000000000000000000000000000000000000000000000000000014" + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"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\":[],\"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.\",\"events\":{\"AdminChanged(address,address)\":{\"details\":\"Emitted when the admin account has changed.\"},\"BeaconUpgraded(address)\":{\"details\":\"Emitted when the beacon is upgraded.\"},\"Upgraded(address)\":{\"details\":\"Emitted when the implementation is upgraded.\"}},\"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`\"},\"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\":{\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\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 _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a0604052604051610d1a380380610d1a833981016040819052610022916103d2565b828161004f60017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6104a2565b600080516020610cd38339815191521461006b5761006b6104c3565b61007782826000610128565b506100a5905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046104a2565b600080516020610cb3833981519152146100c1576100c16104c3565b6001600160a01b0382166080819052600080516020610cb38339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050610528565b61013183610154565b60008251118061013e5750805b1561014f5761014d8383610194565b505b505050565b61015d816101c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606101b98383604051806060016040528060278152602001610cf360279139610263565b90505b92915050565b6001600160a01b0381163b6102345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b600080516020610cd383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6102cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161022b565b600080856001600160a01b0316856040516102e691906104d9565b600060405180830381855af49150503d8060008114610321576040519150601f19603f3d011682016040523d82523d6000602084013e610326565b606091505b509092509050610337828286610343565b925050505b9392505050565b6060831561035257508161033c565b8251156103625782518084602001fd5b8160405162461bcd60e51b815260040161022b91906104f5565b80516001600160a01b038116811461039357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103c95781810151838201526020016103b1565b50506000910152565b6000806000606084860312156103e757600080fd5b6103f08461037c565b92506103fe6020850161037c565b60408501519092506001600160401b038082111561041b57600080fd5b818601915086601f83011261042f57600080fd5b81518181111561044157610441610398565b604051601f8201601f19908116603f0116810190838211818310171561046957610469610398565b8160405282815289602084870101111561048257600080fd5b6104938360208301602088016103ae565b80955050505050509250925092565b818103818111156101bc57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600082516104eb8184602087016103ae565b9190910192915050565b60208152600082518060208401526105148160408501602087016103ae565b601f01601f19169190910160400192915050565b60805161074e6105656000396000818160ef01528181610145015281816101c701528181610211015281816102420152610266015261074e6000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033", + "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.", + "events": { + "AdminChanged(address,address)": { + "details": "Emitted when the admin account has changed." + }, + "BeaconUpgraded(address)": { + "details": "Emitted when the beacon is upgraded." + }, + "Upgraded(address)": { + "details": "Emitted when the implementation is upgraded." + } + }, + "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`" + }, + "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/deployments/xlayertestnet/VTreasuryV8.json b/deployments/opmainnet/VTreasuryV8.json similarity index 97% rename from deployments/xlayertestnet/VTreasuryV8.json rename to deployments/opmainnet/VTreasuryV8.json index 07ff98ce1..a51d1e1aa 100644 --- a/deployments/xlayertestnet/VTreasuryV8.json +++ b/deployments/opmainnet/VTreasuryV8.json @@ -1,5 +1,5 @@ { - "address": "0x740aF73D4AB6300dc4c8D707a424EFC5f1bd04DA", + "address": "0x104c01EB7b4664551BE6A9bdB26a8C5c6Be7d3da", "abi": [ { "inputs": [], @@ -191,40 +191,40 @@ "type": "receive" } ], - "transactionHash": "0x4d174f8b5a29a8d52f9a3a4cf5b5ba3dc4c4ad1249d007c702f00cc6b8903951", + "transactionHash": "0x6796a7c6b544ab99d5a73dd2c9c3d3a57fe7cdc0e75495f33dc856ebff94923d", "receipt": { "to": null, - "from": "0x180C109568708F401a2C198a413164610a32b24b", - "contractAddress": "0x740aF73D4AB6300dc4c8D707a424EFC5f1bd04DA", - "transactionIndex": 0, - "gasUsed": "686753", - "logsBloom": "0x00000000000000000000000000000000000000000001000000800000000000000000000000000000000008000000000008000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000020000000000000000000000000000000000000000000000000000000", - "blockHash": "0x737053e12b3031b9852fd19e853db9843ee4d7865e9feba5c9357cac0d473717", - "transactionHash": "0x4d174f8b5a29a8d52f9a3a4cf5b5ba3dc4c4ad1249d007c702f00cc6b8903951", + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0x104c01EB7b4664551BE6A9bdB26a8C5c6Be7d3da", + "transactionIndex": 9, + "gasUsed": "686933", + "logsBloom": "0x00000000000000000000000000000000000000000000000004800000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000020000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000080000000400000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000008000000000000000000000000000000000000000000000000000", + "blockHash": "0x63bace785e336daae2011d3247b281038ad3c659c30aa645d014f15893fe6ede", + "transactionHash": "0x6796a7c6b544ab99d5a73dd2c9c3d3a57fe7cdc0e75495f33dc856ebff94923d", "logs": [ { - "transactionIndex": 0, - "blockNumber": 14403471, - "transactionHash": "0x4d174f8b5a29a8d52f9a3a4cf5b5ba3dc4c4ad1249d007c702f00cc6b8903951", - "address": "0x740aF73D4AB6300dc4c8D707a424EFC5f1bd04DA", + "transactionIndex": 9, + "blockNumber": 125489833, + "transactionHash": "0x6796a7c6b544ab99d5a73dd2c9c3d3a57fe7cdc0e75495f33dc856ebff94923d", + "address": "0x104c01EB7b4664551BE6A9bdB26a8C5c6Be7d3da", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000180c109568708f401a2c198a413164610a32b24b" + "0x000000000000000000000000c76363b887031e79e6a2954c5515f5e5507a6387" ], "data": "0x", - "logIndex": 0, - "blockHash": "0x737053e12b3031b9852fd19e853db9843ee4d7865e9feba5c9357cac0d473717" + "logIndex": 6, + "blockHash": "0x63bace785e336daae2011d3247b281038ad3c659c30aa645d014f15893fe6ede" } ], - "blockNumber": 14403471, - "cumulativeGasUsed": "686753", + "blockNumber": 125489833, + "cumulativeGasUsed": "2688967", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "61db31590278030f2b5f03e8109c4f65", + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"ZeroAddressNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"withdrawAddress\",\"type\":\"address\"}],\"name\":\"WithdrawTreasuryNative\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"withdrawAddress\",\"type\":\"address\"}],\"name\":\"WithdrawTreasuryToken\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"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\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"},{\"internalType\":\"address payable\",\"name\":\"withdrawAddress\",\"type\":\"address\"}],\"name\":\"withdrawTreasuryNative\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"withdrawAddress\",\"type\":\"address\"}],\"name\":\"withdrawTreasuryToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"author\":\"Venus\",\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"},\"withdrawTreasuryNative(uint256,address)\":{\"custom:error\":\"ZeroAddressNotAllowed thrown when withdrawAddress is zero.\",\"params\":{\"withdrawAddress\":\"The withdraw address\",\"withdrawAmount\":\"The withdraw amount to owner\"}},\"withdrawTreasuryToken(address,uint256,address)\":{\"custom:error\":\"ZeroAddressNotAllowed thrown when token or withdrawAddress is zero.\",\"params\":{\"tokenAddress\":\"The address of treasury token\",\"withdrawAddress\":\"The withdraw address\",\"withdrawAmount\":\"The withdraw amount to owner\"}}},\"title\":\"VTreasuryV8\",\"version\":1},\"userdoc\":{\"errors\":{\"ZeroAddressNotAllowed()\":[{\"notice\":\"Thrown if the supplied address is a zero address where it is not allowed\"}]},\"kind\":\"user\",\"methods\":{\"withdrawTreasuryNative(uint256,address)\":{\"notice\":\"Withdraw Treasury Native, Only owner call it\"},\"withdrawTreasuryToken(address,uint256,address)\":{\"notice\":\"Withdraw Treasury Tokens, Only owner call it\"}},\"notice\":\"Protocol treasury that holds tokens owned by Venus\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Governance/VTreasuryV8.sol\":\"VTreasuryV8\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (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 Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling 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\":\"0xba43b97fba0d32eb4254f6a5a297b39a19a247082a02d6e69349e071e2946218\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0xde231558366826d7cb61725af8147965a61c53b77a352cc8c9af38fc5a92ac3c\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\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 */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _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 making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n _nonReentrantBefore();\\n _;\\n _nonReentrantAfter();\\n }\\n\\n function _nonReentrantBefore() private {\\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n }\\n\\n function _nonReentrantAfter() private {\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Returns true if the reentrancy guard is currently set to \\\"entered\\\", which indicates there is a\\n * `nonReentrant` function in the call stack.\\n */\\n function _reentrancyGuardEntered() internal view returns (bool) {\\n return _status == _ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0xa535a5df777d44e945dd24aa43a11e44b024140fc340ad0dfe42acf4002aade1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.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(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x287b55befed2961a7eabd7d7b1b2839cbca8a5b80ef8dcbb25ed3d4c2002c305\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xec63854014a5b4f2b3290ab9103a21bdf902a508d0f41a8573fea49e98bf571a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/IERC20Permit.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 /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.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(IERC20 token, address spender, uint256 value) 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 /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\\n * Revert on invalid signature.\\n */\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\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 require(returndata.length == 0 || abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\\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 cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return\\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\\n }\\n}\\n\",\"keccak256\":\"0xabefac93435967b4d36a4fabcbdbb918d1f0b7ae3c3d85bc30923b326c927ed1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.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 * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(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 (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x006dd67219697fe68d7fbfdea512e7c4cb64a43565ed86171d67e844982da6fa\",\"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\"},\"contracts/Governance/VTreasuryV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { SafeERC20, IERC20 } from \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport { Ownable2Step } from \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\nimport { ReentrancyGuard } from \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\n\\n/**\\n * @title VTreasuryV8\\n * @author Venus\\n * @notice Protocol treasury that holds tokens owned by Venus\\n */\\ncontract VTreasuryV8 is Ownable2Step, ReentrancyGuard {\\n using SafeERC20 for IERC20;\\n\\n // WithdrawTreasuryToken Event\\n event WithdrawTreasuryToken(address indexed tokenAddress, uint256 withdrawAmount, address indexed withdrawAddress);\\n\\n // WithdrawTreasuryNative Event\\n event WithdrawTreasuryNative(uint256 withdrawAmount, address indexed withdrawAddress);\\n\\n /// @notice Thrown if the supplied address is a zero address where it is not allowed\\n error ZeroAddressNotAllowed();\\n\\n /**\\n * @notice To receive Native when msg.data is not empty\\n */\\n fallback() external payable {}\\n\\n /**\\n * @notice To receive Native when msg.data is empty\\n */\\n receive() external payable {}\\n\\n /**\\n * @notice Withdraw Treasury Tokens, Only owner call it\\n * @param tokenAddress The address of treasury token\\n * @param withdrawAmount The withdraw amount to owner\\n * @param withdrawAddress The withdraw address\\n * @custom:error ZeroAddressNotAllowed thrown when token or withdrawAddress is zero.\\n */\\n function withdrawTreasuryToken(\\n address tokenAddress,\\n uint256 withdrawAmount,\\n address withdrawAddress\\n ) external onlyOwner nonReentrant {\\n ensureNonzeroAddress(tokenAddress);\\n ensureNonzeroAddress(withdrawAddress);\\n require(withdrawAmount > 0, \\\"withdrawAmount must not be zero\\\");\\n\\n uint256 actualWithdrawAmount = withdrawAmount;\\n // Get Treasury Token Balance\\n uint256 treasuryBalance = IERC20(tokenAddress).balanceOf(address(this));\\n\\n // Check Withdraw Amount\\n if (withdrawAmount > treasuryBalance) {\\n // Update actualWithdrawAmount\\n actualWithdrawAmount = treasuryBalance;\\n }\\n\\n // Transfer Token to withdrawAddress\\n IERC20(tokenAddress).safeTransfer(withdrawAddress, actualWithdrawAmount);\\n\\n emit WithdrawTreasuryToken(tokenAddress, actualWithdrawAmount, withdrawAddress);\\n }\\n\\n /**\\n * @notice Withdraw Treasury Native, Only owner call it\\n * @param withdrawAmount The withdraw amount to owner\\n * @param withdrawAddress The withdraw address\\n * @custom:error ZeroAddressNotAllowed thrown when withdrawAddress is zero.\\n */\\n function withdrawTreasuryNative(\\n uint256 withdrawAmount,\\n address payable withdrawAddress\\n ) external payable onlyOwner nonReentrant {\\n ensureNonzeroAddress(withdrawAddress);\\n require(withdrawAmount > 0, \\\"withdrawAmount must not be zero\\\");\\n uint256 actualWithdrawAmount = withdrawAmount;\\n // Get Treasury Native Balance\\n uint256 nativeBalance = address(this).balance;\\n\\n // Check Withdraw Amount\\n if (withdrawAmount > nativeBalance) {\\n // Update actualWithdrawAmount\\n actualWithdrawAmount = nativeBalance;\\n }\\n // Transfer the native token to withdrawAddress\\n (bool sent, ) = withdrawAddress.call{ value: actualWithdrawAmount }(\\\"\\\");\\n require(sent, \\\"Call failed\\\");\\n emit WithdrawTreasuryNative(actualWithdrawAmount, withdrawAddress);\\n }\\n\\n /// @notice Checks if the provided address is nonzero, reverts otherwise\\n /// @param address_ Address to check\\n /// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\\n function ensureNonzeroAddress(address address_) internal pure {\\n if (address_ == address(0)) {\\n revert ZeroAddressNotAllowed();\\n }\\n }\\n}\\n\",\"keccak256\":\"0x254876cbfd6840dc6d610db8b4d930656f0eda51a00b3aeee6d91ed8c96dcfc1\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", "bytecode": "0x6080604052348015600f57600080fd5b506017336020565b6001600255608a565b600180546001600160a01b0319169055603781603a565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610a8e806100996000396000f3fe60806040526004361061006e5760003560e01c80638da5cb5b1161004b5780638da5cb5b146100c1578063e30c3978146100f7578063f2fde38b14610115578063fed7036e1461013557005b8063715018a61461007757806374c17a351461008c57806379ba5097146100ac57005b3661007557005b005b34801561008357600080fd5b50610075610148565b34801561009857600080fd5b506100756100a7366004610914565b61015c565b3480156100b857600080fd5b506100756102c0565b3480156100cd57600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b34801561010357600080fd5b506001546001600160a01b03166100db565b34801561012157600080fd5b50610075610130366004610956565b61033a565b61007561014336600461097a565b6103ab565b610150610507565b61015a6000610561565b565b610164610507565b61016c61057a565b610175836105d1565b61017e816105d1565b600082116101d35760405162461bcd60e51b815260206004820152601f60248201527f7769746864726177416d6f756e74206d757374206e6f74206265207a65726f0060448201526064015b60405180910390fd5b6040516370a0823160e01b815230600482015282906000906001600160a01b038616906370a0823190602401602060405180830381865afa15801561021c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024091906109aa565b90508084111561024e578091505b6102626001600160a01b03861684846105f8565b826001600160a01b0316856001600160a01b03167f6d043f5c542a67e836c8f8bdf640d0de840c85d79c130dcbda8d42c9c056980c846040516102a791815260200190565b60405180910390a350506102bb6001600255565b505050565b60015433906001600160a01b0316811461032e5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016101ca565b61033781610561565b50565b610342610507565b600180546001600160a01b0383166001600160a01b031990911681179091556103736000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6103b3610507565b6103bb61057a565b6103c4816105d1565b600082116104145760405162461bcd60e51b815260206004820152601f60248201527f7769746864726177416d6f756e74206d757374206e6f74206265207a65726f0060448201526064016101ca565b814780821115610422578091505b6000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461046f576040519150601f19603f3d011682016040523d82523d6000602084013e610474565b606091505b50509050806104b35760405162461bcd60e51b815260206004820152600b60248201526a10d85b1b0819985a5b195960aa1b60448201526064016101ca565b836001600160a01b03167f41448dfa44379fc602c636f8939b0b1b598c481af871c76fbdd8bdfcdaf30dfa846040516104ee91815260200190565b60405180910390a25050506105036001600255565b5050565b6000546001600160a01b0316331461015a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101ca565b600180546001600160a01b03191690556103378161064a565b60028054036105cb5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016101ca565b60028055565b6001600160a01b038116610337576040516342bcdf7f60e11b815260040160405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526102bb90849061069a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006106ef826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661076f9092919063ffffffff16565b905080516000148061071057508080602001905181019061071091906109c3565b6102bb5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101ca565b606061077e8484600085610786565b949350505050565b6060824710156107e75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101ca565b600080866001600160a01b031685876040516108039190610a09565b60006040518083038185875af1925050503d8060008114610840576040519150601f19603f3d011682016040523d82523d6000602084013e610845565b606091505b509150915061085687838387610861565b979650505050505050565b606083156108d05782516000036108c9576001600160a01b0385163b6108c95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101ca565b508161077e565b61077e83838151156108e55781518083602001fd5b8060405162461bcd60e51b81526004016101ca9190610a25565b6001600160a01b038116811461033757600080fd5b60008060006060848603121561092957600080fd5b8335610934816108ff565b925060208401359150604084013561094b816108ff565b809150509250925092565b60006020828403121561096857600080fd5b8135610973816108ff565b9392505050565b6000806040838503121561098d57600080fd5b82359150602083013561099f816108ff565b809150509250929050565b6000602082840312156109bc57600080fd5b5051919050565b6000602082840312156109d557600080fd5b8151801515811461097357600080fd5b60005b83811015610a005781810151838201526020016109e8565b50506000910152565b60008251610a1b8184602087016109e5565b9190910192915050565b6020815260008251806020840152610a448160408501602087016109e5565b601f01601f1916919091016040019291505056fea2646970667358221220487efce782941c68134d2ce3b82068b462757740ea04bee479d86bb1b1992e5d64736f6c63430008190033", "deployedBytecode": "0x60806040526004361061006e5760003560e01c80638da5cb5b1161004b5780638da5cb5b146100c1578063e30c3978146100f7578063f2fde38b14610115578063fed7036e1461013557005b8063715018a61461007757806374c17a351461008c57806379ba5097146100ac57005b3661007557005b005b34801561008357600080fd5b50610075610148565b34801561009857600080fd5b506100756100a7366004610914565b61015c565b3480156100b857600080fd5b506100756102c0565b3480156100cd57600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b34801561010357600080fd5b506001546001600160a01b03166100db565b34801561012157600080fd5b50610075610130366004610956565b61033a565b61007561014336600461097a565b6103ab565b610150610507565b61015a6000610561565b565b610164610507565b61016c61057a565b610175836105d1565b61017e816105d1565b600082116101d35760405162461bcd60e51b815260206004820152601f60248201527f7769746864726177416d6f756e74206d757374206e6f74206265207a65726f0060448201526064015b60405180910390fd5b6040516370a0823160e01b815230600482015282906000906001600160a01b038616906370a0823190602401602060405180830381865afa15801561021c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024091906109aa565b90508084111561024e578091505b6102626001600160a01b03861684846105f8565b826001600160a01b0316856001600160a01b03167f6d043f5c542a67e836c8f8bdf640d0de840c85d79c130dcbda8d42c9c056980c846040516102a791815260200190565b60405180910390a350506102bb6001600255565b505050565b60015433906001600160a01b0316811461032e5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016101ca565b61033781610561565b50565b610342610507565b600180546001600160a01b0383166001600160a01b031990911681179091556103736000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6103b3610507565b6103bb61057a565b6103c4816105d1565b600082116104145760405162461bcd60e51b815260206004820152601f60248201527f7769746864726177416d6f756e74206d757374206e6f74206265207a65726f0060448201526064016101ca565b814780821115610422578091505b6000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461046f576040519150601f19603f3d011682016040523d82523d6000602084013e610474565b606091505b50509050806104b35760405162461bcd60e51b815260206004820152600b60248201526a10d85b1b0819985a5b195960aa1b60448201526064016101ca565b836001600160a01b03167f41448dfa44379fc602c636f8939b0b1b598c481af871c76fbdd8bdfcdaf30dfa846040516104ee91815260200190565b60405180910390a25050506105036001600255565b5050565b6000546001600160a01b0316331461015a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101ca565b600180546001600160a01b03191690556103378161064a565b60028054036105cb5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016101ca565b60028055565b6001600160a01b038116610337576040516342bcdf7f60e11b815260040160405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526102bb90849061069a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006106ef826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661076f9092919063ffffffff16565b905080516000148061071057508080602001905181019061071091906109c3565b6102bb5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101ca565b606061077e8484600085610786565b949350505050565b6060824710156107e75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101ca565b600080866001600160a01b031685876040516108039190610a09565b60006040518083038185875af1925050503d8060008114610840576040519150601f19603f3d011682016040523d82523d6000602084013e610845565b606091505b509150915061085687838387610861565b979650505050505050565b606083156108d05782516000036108c9576001600160a01b0385163b6108c95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101ca565b508161077e565b61077e83838151156108e55781518083602001fd5b8060405162461bcd60e51b81526004016101ca9190610a25565b6001600160a01b038116811461033757600080fd5b60008060006060848603121561092957600080fd5b8335610934816108ff565b925060208401359150604084013561094b816108ff565b809150509250925092565b60006020828403121561096857600080fd5b8135610973816108ff565b9392505050565b6000806040838503121561098d57600080fd5b82359150602083013561099f816108ff565b809150509250929050565b6000602082840312156109bc57600080fd5b5051919050565b6000602082840312156109d557600080fd5b8151801515811461097357600080fd5b60005b83811015610a005781810151838201526020016109e8565b50506000910152565b60008251610a1b8184602087016109e5565b9190910192915050565b6020815260008251806020840152610a448160408501602087016109e5565b601f01601f1916919091016040019291505056fea2646970667358221220487efce782941c68134d2ce3b82068b462757740ea04bee479d86bb1b1992e5d64736f6c63430008190033", @@ -289,7 +289,7 @@ "storageLayout": { "storage": [ { - "astId": 3126, + "astId": 3139, "contract": "contracts/Governance/VTreasuryV8.sol:VTreasuryV8", "label": "_owner", "offset": 0, @@ -297,7 +297,7 @@ "type": "t_address" }, { - "astId": 3239, + "astId": 3252, "contract": "contracts/Governance/VTreasuryV8.sol:VTreasuryV8", "label": "_pendingOwner", "offset": 0, @@ -305,7 +305,7 @@ "type": "t_address" }, { - "astId": 4218, + "astId": 4231, "contract": "contracts/Governance/VTreasuryV8.sol:VTreasuryV8", "label": "_status", "offset": 0, diff --git a/deployments/opmainnet/XVSStore.json b/deployments/opmainnet/XVSStore.json new file mode 100644 index 000000000..58c2ccdf9 --- /dev/null +++ b/deployments/opmainnet/XVSStore.json @@ -0,0 +1,374 @@ +{ + "address": "0xFE548630954129923f63113923eF5373E10589d3", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerTransferred", + "type": "event" + }, + { + "constant": false, + "inputs": [], + "name": "acceptAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "emergencyRewardWithdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardTokens", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "safeRewardTransfer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "setNewOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_admin", + "type": "address" + } + ], + "name": "setPendingAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "setRewardToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x591994a5e4b925af623d18e3ea45127ce025bc2395d65524c388e1d70808554b", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0xFE548630954129923f63113923eF5373E10589d3", + "transactionIndex": 5, + "gasUsed": "634554", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xe86212c100535fe42dfcfa6592f21d02287b2dc8819626b170894586ecebe04e", + "transactionHash": "0x591994a5e4b925af623d18e3ea45127ce025bc2395d65524c388e1d70808554b", + "logs": [], + "blockNumber": 125559839, + "cumulativeGasUsed": "2448977", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "a2594572bdae270af6749f50c8019b6c", + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldAdmin\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"NewPendingAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnerTransferred\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[],\"name\":\"acceptAdmin\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"emergencyRewardWithdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"rewardTokens\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"safeRewardTransfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"setNewOwner\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_admin\",\"type\":\"address\"}],\"name\":\"setPendingAdmin\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"setRewardToken\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"methods\":{\"emergencyRewardWithdraw(address,uint256)\":{\"params\":{\"_amount\":\"Amount of token to withdraw\",\"_tokenAddress\":\"Reward token address to withdraw\"}},\"safeRewardTransfer(address,address,uint256)\":{\"details\":\"Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\",\"params\":{\"_amount\":\"Amount to transfer\",\"_to\":\"Destination address of the reward\",\"token\":\"Reward token to transfer\"}},\"setNewOwner(address)\":{\"params\":{\"_owner\":\"The address of the owner to set Only callable admin\"}},\"setPendingAdmin(address)\":{\"params\":{\"_admin\":\"Propose an account as admin of the XVS store\"}},\"setRewardToken(address,bool)\":{\"params\":{\"_tokenAddress\":\"The address of a token to set as active or inactive\",\"status\":\"Set whether a reward token is active or not\"}}},\"title\":\"XVS Store\"},\"userdoc\":{\"methods\":{\"acceptAdmin()\":{\"notice\":\"Allows an account that is pending as admin to accept the role nly calllable by the pending admin\"},\"emergencyRewardWithdraw(address,uint256)\":{\"notice\":\"Security function to allow the owner of the contract to withdraw from the contract\"},\"safeRewardTransfer(address,address,uint256)\":{\"notice\":\"Safely transfer rewards. Only active reward tokens can be sent using this function. Only callable by owner\"},\"setNewOwner(address)\":{\"notice\":\"Set the contract owner\"},\"setPendingAdmin(address)\":{\"notice\":\"Allows the admin to propose a new admin Only callable admin\"},\"setRewardToken(address,bool)\":{\"notice\":\"Set or disable a reward token\"}},\"notice\":\"XVS Store responsible for distributing XVS rewards\"}},\"settings\":{\"compilationTarget\":{\"contracts/XVSVault/XVSStore.sol\":\"XVSStore\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/Utils/Address.sol\":{\"content\":\"pragma solidity ^0.5.5;\\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 function isContract(address account) internal view returns (bool) {\\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\\n // for accounts without code, i.e. `keccak256('')`\\n bytes32 codehash;\\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n codehash := extcodehash(account)\\n }\\n return (codehash != accountHash && codehash != 0x0);\\n }\\n\\n /**\\n * @dev Converts an `address` into `address payable`. Note that this is\\n * simply a type cast: the actual underlying value is not changed.\\n *\\n * _Available since v2.4.0._\\n */\\n function toPayable(address account) internal pure returns (address payable) {\\n return address(uint160(account));\\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 * _Available since v2.4.0._\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-call-value\\n // solium-disable-next-line security/no-call-value\\n (bool success, ) = recipient.call.value(amount)(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n}\\n\",\"keccak256\":\"0x3c2ef780599a2ae6913282b982633f07e405a4a9c8511590df571e2b773aef9d\"},\"contracts/Utils/IBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\n/**\\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\\n * the optional functions; to access them see {BEP20Detailed}.\\n */\\ninterface IBEP20 {\\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 `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\\n\\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\",\"keccak256\":\"0x839b08895eb1ad83502d3631e8e9e3a856d2a8c63c46f070d604af7b26c62c07\"},\"contracts/Utils/SafeBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\nimport \\\"./SafeMath.sol\\\";\\nimport \\\"./IBEP20.sol\\\";\\nimport \\\"./Address.sol\\\";\\n\\n/**\\n * @title SafeBEP20\\n * @dev Wrappers around BEP20 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 SafeBEP20 for BEP20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeBEP20 {\\n using SafeMath for uint256;\\n using Address for address;\\n\\n function safeTransfer(IBEP20 token, address to, uint256 value) internal {\\n callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(IBEP20 token, address from, address to, uint256 value) internal {\\n callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n function safeApprove(IBEP20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeBEP20: approve from non-zero to non-zero allowance\\\"\\n );\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).sub(\\n value,\\n \\\"SafeBEP20: decreased allowance below zero\\\"\\n );\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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(IBEP20 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.\\n\\n // A Solidity high level call has three parts:\\n // 1. The target address is checked to verify it contains contract code\\n // 2. The call itself is made, and success asserted\\n // 3. The return value is decoded, which in turn checks the size of the returned data.\\n // solhint-disable-next-line max-line-length\\n require(address(token).isContract(), \\\"SafeBEP20: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = address(token).call(data);\\n require(success, \\\"SafeBEP20: low-level call failed\\\");\\n\\n if (returndata.length > 0) {\\n // Return data is optional\\n // solhint-disable-next-line max-line-length\\n require(abi.decode(returndata, (bool)), \\\"SafeBEP20: BEP20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x540ef6ddc47232a59d3ab0e95537f7a7d1c8a36f8dba315b010e60c6487bd768\"},\"contracts/Utils/SafeMath.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add(a, b, \\\"SafeMath: addition overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub(a, b, \\\"SafeMath: subtraction overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n uint256 c = a - b;\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) {\\n return 0;\\n }\\n\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div(a, b, \\\"SafeMath: division by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n // Solidity only automatically asserts when dividing by 0\\n require(b > 0, errorMessage);\\n uint256 c = a / b;\\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mod(a, b, \\\"SafeMath: modulo by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts with custom message when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b != 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x9431fd772ed4abc038cdfe9ce6c0066897bd1685ad45848748d1952935d5b8ef\"},\"contracts/XVSVault/XVSStore.sol\":{\"content\":\"pragma solidity 0.5.16;\\nimport \\\"../Utils/SafeBEP20.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\n\\n/**\\n * @title XVS Store\\n * @author Venus\\n * @notice XVS Store responsible for distributing XVS rewards\\n */\\ncontract XVSStore {\\n using SafeMath for uint256;\\n using SafeBEP20 for IBEP20;\\n\\n /// @notice The Admin Address\\n address public admin;\\n\\n /// @notice The pending admin address\\n address public pendingAdmin;\\n\\n /// @notice The Owner Address\\n address public owner;\\n\\n /// @notice The reward tokens\\n mapping(address => bool) public rewardTokens;\\n\\n /// @notice Emitted when pendingAdmin is changed\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /// @notice Event emitted when admin changed\\n event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);\\n\\n /// @notice Event emitted when owner changed\\n event OwnerTransferred(address indexed oldOwner, address indexed newOwner);\\n\\n constructor() public {\\n admin = msg.sender;\\n }\\n\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"only admin can\\\");\\n _;\\n }\\n\\n modifier onlyOwner() {\\n require(msg.sender == owner, \\\"only owner can\\\");\\n _;\\n }\\n\\n /**\\n * @notice Safely transfer rewards. Only active reward tokens can be sent using this function.\\n * Only callable by owner\\n * @dev Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\\n * @param token Reward token to transfer\\n * @param _to Destination address of the reward\\n * @param _amount Amount to transfer\\n */\\n function safeRewardTransfer(address token, address _to, uint256 _amount) external onlyOwner {\\n require(rewardTokens[token] == true, \\\"only reward token can\\\");\\n\\n if (address(token) != address(0)) {\\n uint256 tokenBalance = IBEP20(token).balanceOf(address(this));\\n if (_amount > tokenBalance) {\\n IBEP20(token).safeTransfer(_to, tokenBalance);\\n } else {\\n IBEP20(token).safeTransfer(_to, _amount);\\n }\\n }\\n }\\n\\n /**\\n * @notice Allows the admin to propose a new admin\\n * Only callable admin\\n * @param _admin Propose an account as admin of the XVS store\\n */\\n function setPendingAdmin(address _admin) external onlyAdmin {\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = _admin;\\n emit NewPendingAdmin(oldPendingAdmin, _admin);\\n }\\n\\n /**\\n * @notice Allows an account that is pending as admin to accept the role\\n * nly calllable by the pending admin\\n */\\n function acceptAdmin() external {\\n require(msg.sender == pendingAdmin, \\\"only pending admin\\\");\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n emit AdminTransferred(oldAdmin, admin);\\n }\\n\\n /**\\n * @notice Set the contract owner\\n * @param _owner The address of the owner to set\\n * Only callable admin\\n */\\n function setNewOwner(address _owner) external onlyAdmin {\\n require(_owner != address(0), \\\"new owner is the zero address\\\");\\n address oldOwner = owner;\\n owner = _owner;\\n emit OwnerTransferred(oldOwner, _owner);\\n }\\n\\n /**\\n * @notice Set or disable a reward token\\n * @param _tokenAddress The address of a token to set as active or inactive\\n * @param status Set whether a reward token is active or not\\n */\\n function setRewardToken(address _tokenAddress, bool status) external {\\n require(msg.sender == admin || msg.sender == owner, \\\"only admin or owner can\\\");\\n rewardTokens[_tokenAddress] = status;\\n }\\n\\n /**\\n * @notice Security function to allow the owner of the contract to withdraw from the contract\\n * @param _tokenAddress Reward token address to withdraw\\n * @param _amount Amount of token to withdraw\\n */\\n function emergencyRewardWithdraw(address _tokenAddress, uint256 _amount) external onlyOwner {\\n IBEP20(_tokenAddress).safeTransfer(address(msg.sender), _amount);\\n }\\n}\\n\",\"keccak256\":\"0x8082f92b13448bd4fa982c93c763439f10fe016a5f3be6d613dfe3cca68501ef\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b03191633179055610a1b806100326000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80639ad99e68116100665780639ad99e681461012b578063f5a1f5b414610161578063f5ab16cc14610187578063f851a440146101c1578063fb66fb4d146101c95761009e565b80630e18b681146100a357806326782247146100ad5780634dd18bf5146100d1578063804e523e146100f75780638da5cb5b14610123575b600080fd5b6100ab6101f7565b005b6100b56102f3565b604080516001600160a01b039092168252519081900360200190f35b6100ab600480360360208110156100e757600080fd5b50356001600160a01b0316610302565b6100ab6004803603604081101561010d57600080fd5b506001600160a01b0381351690602001356103b5565b6100b5610423565b6100ab6004803603606081101561014157600080fd5b506001600160a01b03813581169160208101359091169060400135610432565b6100ab6004803603602081101561017757600080fd5b50356001600160a01b03166105bb565b6101ad6004803603602081101561019d57600080fd5b50356001600160a01b03166106b8565b604080519115158252519081900360200190f35b6100b56106cd565b6100ab600480360360408110156101df57600080fd5b506001600160a01b03813516906020013515156106dc565b6001546001600160a01b0316331461024b576040805162461bcd60e51b815260206004820152601260248201527137b7363c903832b73234b7339030b236b4b760711b604482015290519081900360640190fd5b60008054600180546001600160a01b038082166001600160a01b0319808616821787559092169092556040805182815260208101959095528051929093169390927fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a992918290030190a1600080546040516001600160a01b0391821692918516917ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec691a35050565b6001546001600160a01b031681565b6000546001600160a01b03163314610352576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9030b236b4b71031b0b760911b604482015290519081900360640190fd5b600180546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a15050565b6002546001600160a01b03163314610405576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9037bbb732b91031b0b760911b604482015290519081900360640190fd5b61041f6001600160a01b038316338363ffffffff61077b16565b5050565b6002546001600160a01b031681565b6002546001600160a01b03163314610482576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9037bbb732b91031b0b760911b604482015290519081900360640190fd5b6001600160a01b03831660009081526003602052604090205460ff1615156001146104ec576040805162461bcd60e51b815260206004820152601560248201527437b7363c903932bbb0b932103a37b5b2b71031b0b760591b604482015290519081900360640190fd5b6001600160a01b038316156105b657604080516370a0823160e01b815230600482015290516000916001600160a01b038616916370a0823191602480820192602092909190829003018186803b15801561054557600080fd5b505afa158015610559573d6000803e3d6000fd5b505050506040513d602081101561056f57600080fd5b505190508082111561059a576105956001600160a01b038516848363ffffffff61077b16565b6105b4565b6105b46001600160a01b038516848463ffffffff61077b16565b505b505050565b6000546001600160a01b0316331461060b576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9030b236b4b71031b0b760911b604482015290519081900360640190fd5b6001600160a01b038116610666576040805162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f2061646472657373000000604482015290519081900360640190fd5b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8934ce4adea8d9ce0d714d2c22b86790e41b7731c84b926fbbdc1d40ff6533c990600090a35050565b60036020526000908152604090205460ff1681565b6000546001600160a01b031681565b6000546001600160a01b03163314806106ff57506002546001600160a01b031633145b610750576040805162461bcd60e51b815260206004820152601760248201527f6f6e6c792061646d696e206f72206f776e65722063616e000000000000000000604482015290519081900360640190fd5b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105b69084906107da826001600160a01b0316610980565b61082b576040805162461bcd60e51b815260206004820152601f60248201527f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106108695780518252601f19909201916020918201910161084a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146108cb576040519150601f19603f3d011682016040523d82523d6000602084013e6108d0565b606091505b509150915081610927576040805162461bcd60e51b815260206004820181905260248201527f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156105b45780806020019051602081101561094357600080fd5b50516105b45760405162461bcd60e51b815260040180806020018281038252602a8152602001806109bd602a913960400191505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906109b457508115155b94935050505056fe5361666542455032303a204245503230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a723158209e938a047cf0499058d9e6866f246e93c241e398b266c69ad7069ce461bc206364736f6c63430005100032", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80639ad99e68116100665780639ad99e681461012b578063f5a1f5b414610161578063f5ab16cc14610187578063f851a440146101c1578063fb66fb4d146101c95761009e565b80630e18b681146100a357806326782247146100ad5780634dd18bf5146100d1578063804e523e146100f75780638da5cb5b14610123575b600080fd5b6100ab6101f7565b005b6100b56102f3565b604080516001600160a01b039092168252519081900360200190f35b6100ab600480360360208110156100e757600080fd5b50356001600160a01b0316610302565b6100ab6004803603604081101561010d57600080fd5b506001600160a01b0381351690602001356103b5565b6100b5610423565b6100ab6004803603606081101561014157600080fd5b506001600160a01b03813581169160208101359091169060400135610432565b6100ab6004803603602081101561017757600080fd5b50356001600160a01b03166105bb565b6101ad6004803603602081101561019d57600080fd5b50356001600160a01b03166106b8565b604080519115158252519081900360200190f35b6100b56106cd565b6100ab600480360360408110156101df57600080fd5b506001600160a01b03813516906020013515156106dc565b6001546001600160a01b0316331461024b576040805162461bcd60e51b815260206004820152601260248201527137b7363c903832b73234b7339030b236b4b760711b604482015290519081900360640190fd5b60008054600180546001600160a01b038082166001600160a01b0319808616821787559092169092556040805182815260208101959095528051929093169390927fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a992918290030190a1600080546040516001600160a01b0391821692918516917ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec691a35050565b6001546001600160a01b031681565b6000546001600160a01b03163314610352576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9030b236b4b71031b0b760911b604482015290519081900360640190fd5b600180546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a15050565b6002546001600160a01b03163314610405576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9037bbb732b91031b0b760911b604482015290519081900360640190fd5b61041f6001600160a01b038316338363ffffffff61077b16565b5050565b6002546001600160a01b031681565b6002546001600160a01b03163314610482576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9037bbb732b91031b0b760911b604482015290519081900360640190fd5b6001600160a01b03831660009081526003602052604090205460ff1615156001146104ec576040805162461bcd60e51b815260206004820152601560248201527437b7363c903932bbb0b932103a37b5b2b71031b0b760591b604482015290519081900360640190fd5b6001600160a01b038316156105b657604080516370a0823160e01b815230600482015290516000916001600160a01b038616916370a0823191602480820192602092909190829003018186803b15801561054557600080fd5b505afa158015610559573d6000803e3d6000fd5b505050506040513d602081101561056f57600080fd5b505190508082111561059a576105956001600160a01b038516848363ffffffff61077b16565b6105b4565b6105b46001600160a01b038516848463ffffffff61077b16565b505b505050565b6000546001600160a01b0316331461060b576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9030b236b4b71031b0b760911b604482015290519081900360640190fd5b6001600160a01b038116610666576040805162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f2061646472657373000000604482015290519081900360640190fd5b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8934ce4adea8d9ce0d714d2c22b86790e41b7731c84b926fbbdc1d40ff6533c990600090a35050565b60036020526000908152604090205460ff1681565b6000546001600160a01b031681565b6000546001600160a01b03163314806106ff57506002546001600160a01b031633145b610750576040805162461bcd60e51b815260206004820152601760248201527f6f6e6c792061646d696e206f72206f776e65722063616e000000000000000000604482015290519081900360640190fd5b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105b69084906107da826001600160a01b0316610980565b61082b576040805162461bcd60e51b815260206004820152601f60248201527f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106108695780518252601f19909201916020918201910161084a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146108cb576040519150601f19603f3d011682016040523d82523d6000602084013e6108d0565b606091505b509150915081610927576040805162461bcd60e51b815260206004820181905260248201527f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156105b45780806020019051602081101561094357600080fd5b50516105b45760405162461bcd60e51b815260040180806020018281038252602a8152602001806109bd602a913960400191505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906109b457508115155b94935050505056fe5361666542455032303a204245503230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a723158209e938a047cf0499058d9e6866f246e93c241e398b266c69ad7069ce461bc206364736f6c63430005100032", + "devdoc": { + "author": "Venus", + "methods": { + "emergencyRewardWithdraw(address,uint256)": { + "params": { + "_amount": "Amount of token to withdraw", + "_tokenAddress": "Reward token address to withdraw" + } + }, + "safeRewardTransfer(address,address,uint256)": { + "details": "Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.", + "params": { + "_amount": "Amount to transfer", + "_to": "Destination address of the reward", + "token": "Reward token to transfer" + } + }, + "setNewOwner(address)": { + "params": { + "_owner": "The address of the owner to set Only callable admin" + } + }, + "setPendingAdmin(address)": { + "params": { + "_admin": "Propose an account as admin of the XVS store" + } + }, + "setRewardToken(address,bool)": { + "params": { + "_tokenAddress": "The address of a token to set as active or inactive", + "status": "Set whether a reward token is active or not" + } + } + }, + "title": "XVS Store" + }, + "userdoc": { + "methods": { + "acceptAdmin()": { + "notice": "Allows an account that is pending as admin to accept the role nly calllable by the pending admin" + }, + "emergencyRewardWithdraw(address,uint256)": { + "notice": "Security function to allow the owner of the contract to withdraw from the contract" + }, + "safeRewardTransfer(address,address,uint256)": { + "notice": "Safely transfer rewards. Only active reward tokens can be sent using this function. Only callable by owner" + }, + "setNewOwner(address)": { + "notice": "Set the contract owner" + }, + "setPendingAdmin(address)": { + "notice": "Allows the admin to propose a new admin Only callable admin" + }, + "setRewardToken(address,bool)": { + "notice": "Set or disable a reward token" + } + }, + "notice": "XVS Store responsible for distributing XVS rewards" + }, + "storageLayout": { + "storage": [ + { + "astId": 36731, + "contract": "contracts/XVSVault/XVSStore.sol:XVSStore", + "label": "admin", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 36733, + "contract": "contracts/XVSVault/XVSStore.sol:XVSStore", + "label": "pendingAdmin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 36735, + "contract": "contracts/XVSVault/XVSStore.sol:XVSStore", + "label": "owner", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 36739, + "contract": "contracts/XVSVault/XVSStore.sol:XVSStore", + "label": "rewardTokens", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_bool)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + } + } + } +} diff --git a/deployments/opmainnet/XVSVaultProxy.json b/deployments/opmainnet/XVSVaultProxy.json new file mode 100644 index 000000000..6abf9dc79 --- /dev/null +++ b/deployments/opmainnet/XVSVaultProxy.json @@ -0,0 +1,352 @@ +{ + "address": "0x133120607C018c949E91AE333785519F6d947e01", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "NewImplementation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "NewPendingImplementation", + "type": "event" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptImplementation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "_setPendingAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "_setPendingImplementation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x92f1d6301c1440112b0e6edc736b8bfa6521db05c30441c4800fe1da83a8110b", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0x133120607C018c949E91AE333785519F6d947e01", + "transactionIndex": 11, + "gasUsed": "394440", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x560ad6c3482f43d96fece021aace79924348751c02b40768b05a5c817b9b8066", + "transactionHash": "0x92f1d6301c1440112b0e6edc736b8bfa6521db05c30441c4800fe1da83a8110b", + "logs": [], + "blockNumber": 125559835, + "cumulativeGasUsed": "3319025", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "a2594572bdae270af6749f50c8019b6c", + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"error\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"info\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"detail\",\"type\":\"uint256\"}],\"name\":\"Failure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"NewAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"NewImplementation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"NewPendingAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingImplementation\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingImplementation\",\"type\":\"address\"}],\"name\":\"NewPendingImplementation\",\"type\":\"event\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"constant\":false,\"inputs\":[],\"name\":\"_acceptAdmin\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"_acceptImplementation\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"_setPendingAdmin\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingImplementation\",\"type\":\"address\"}],\"name\":\"_setPendingImplementation\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingXVSVaultImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"methods\":{\"_acceptAdmin()\":{\"details\":\"Admin function for pending admin to accept role and update admin\",\"return\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"},\"_acceptImplementation()\":{\"details\":\"Admin function for new implementation to accept it's role as implementation\",\"return\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"},\"_setPendingAdmin(address)\":{\"details\":\"Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\",\"params\":{\"newPendingAdmin\":\"New pending admin.\"},\"return\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"title\":\"XVS Vault Proxy\"},\"userdoc\":{\"methods\":{\"_acceptAdmin()\":{\"notice\":\"Accepts transfer of admin rights. msg.sender must be pendingAdmin\"},\"_acceptImplementation()\":{\"notice\":\"Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\"},\"_setPendingAdmin(address)\":{\"notice\":\"Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\"},\"_setPendingImplementation(address)\":{\"notice\":\"* Admin Functions **\"}},\"notice\":\"XVS Vault Proxy contract\"}},\"settings\":{\"compilationTarget\":{\"contracts/XVSVault/XVSVaultProxy.sol\":\"XVSVaultProxy\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/Tokens/Prime/IPrime.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.5.16;\\npragma experimental ABIEncoderV2;\\n\\n/**\\n * @title IPrime\\n * @author Venus\\n * @notice Interface for Prime Token\\n */\\ninterface IPrime {\\n /**\\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\\n * @param user the account address whose balance was updated\\n */\\n function xvsUpdated(address user) external;\\n\\n /**\\n * @notice accrues interest and updates score for an user for a specific market\\n * @param user the account address for which to accrue interest and update score\\n * @param market the market for which to accrue interest and update score\\n */\\n function accrueInterestAndUpdateScore(address user, address market) external;\\n\\n /**\\n * @notice Distributes income from market since last distribution\\n * @param vToken the market for which to distribute the income\\n */\\n function accrueInterest(address vToken) external;\\n\\n /**\\n * @notice Returns if user is a prime holder\\n * @param isPrimeHolder returns if the user is a prime holder\\n */\\n function isUserPrimeHolder(address user) external view returns (bool isPrimeHolder);\\n}\\n\",\"keccak256\":\"0x58861c0c05b8757f1a5d50b107eff479c8680878e6aa51bc93af420caf73f500\"},\"contracts/Utils/IBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\n/**\\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\\n * the optional functions; to access them see {BEP20Detailed}.\\n */\\ninterface IBEP20 {\\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 `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\\n\\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\",\"keccak256\":\"0x839b08895eb1ad83502d3631e8e9e3a856d2a8c63c46f070d604af7b26c62c07\"},\"contracts/Utils/SafeMath.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add(a, b, \\\"SafeMath: addition overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub(a, b, \\\"SafeMath: subtraction overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n uint256 c = a - b;\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) {\\n return 0;\\n }\\n\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div(a, b, \\\"SafeMath: division by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n // Solidity only automatically asserts when dividing by 0\\n require(b > 0, errorMessage);\\n uint256 c = a / b;\\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mod(a, b, \\\"SafeMath: modulo by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts with custom message when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b != 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x9431fd772ed4abc038cdfe9ce6c0066897bd1685ad45848748d1952935d5b8ef\"},\"contracts/XVSVault/XVSVaultErrorReporter.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\ncontract XVSVaultErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint error, uint info, uint detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint) {\\n emit Failure(uint(err), uint(info), 0);\\n\\n return uint(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\\n emit Failure(uint(err), uint(info), opaqueError);\\n\\n return uint(err);\\n }\\n}\\n\",\"keccak256\":\"0xa79877a281d024f0d03dbf1842a36a972ee6c1aa36ba93e3d646726d40684a26\"},\"contracts/XVSVault/XVSVaultProxy.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"./XVSVaultStorage.sol\\\";\\nimport \\\"./XVSVaultErrorReporter.sol\\\";\\n\\n/**\\n * @title XVS Vault Proxy\\n * @author Venus\\n * @notice XVS Vault Proxy contract\\n */\\ncontract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter {\\n /**\\n * @notice Emitted when pendingXVSVaultImplementation is changed\\n */\\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\\n\\n /**\\n * @notice Emitted when pendingXVSVaultImplementation is accepted, which means XVS Vault implementation is updated\\n */\\n event NewImplementation(address oldImplementation, address newImplementation);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor() public {\\n // Set admin to caller\\n admin = msg.sender;\\n }\\n\\n /*** Admin Functions ***/\\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\\n if (msg.sender != admin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\\n }\\n\\n address oldPendingImplementation = pendingXVSVaultImplementation;\\n\\n pendingXVSVaultImplementation = newPendingImplementation;\\n\\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\\n * @dev Admin function for new implementation to accept it's role as implementation\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptImplementation() public returns (uint) {\\n // Check caller is pendingImplementation\\n if (msg.sender != pendingXVSVaultImplementation) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldImplementation = implementation;\\n address oldPendingImplementation = pendingXVSVaultImplementation;\\n\\n implementation = pendingXVSVaultImplementation;\\n\\n pendingXVSVaultImplementation = address(0);\\n\\n emit NewImplementation(oldImplementation, implementation);\\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\\n // Check caller = admin\\n if (msg.sender != admin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n // Save current value, if any, for inclusion in log\\n address oldPendingAdmin = pendingAdmin;\\n\\n // Store pendingAdmin with value newPendingAdmin\\n pendingAdmin = newPendingAdmin;\\n\\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint) {\\n // Check caller is pendingAdmin\\n if (msg.sender != pendingAdmin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n // Store admin with value pendingAdmin\\n admin = pendingAdmin;\\n\\n // Clear the pending value\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @dev Delegates execution to an implementation contract.\\n * It returns to the external caller whatever the implementation returns\\n * or forwards reverts.\\n */\\n function() external payable {\\n // delegate all other functions to current implementation\\n (bool success, ) = implementation.delegatecall(msg.data);\\n\\n assembly {\\n let free_mem_ptr := mload(0x40)\\n returndatacopy(free_mem_ptr, 0, returndatasize)\\n\\n switch success\\n case 0 {\\n revert(free_mem_ptr, returndatasize)\\n }\\n default {\\n return(free_mem_ptr, returndatasize)\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb39af917833659fe38f2f76924deda420babed8259b27741dc6cb402ade4d124\"},\"contracts/XVSVault/XVSVaultStorage.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"../Utils/SafeMath.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\nimport \\\"../Tokens/Prime/IPrime.sol\\\";\\n\\ncontract XVSVaultAdminStorage {\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Active brains of XVS Vault\\n */\\n address public implementation;\\n\\n /**\\n * @notice Pending brains of XVS Vault\\n */\\n address public pendingXVSVaultImplementation;\\n}\\n\\ncontract XVSVaultStorageV1 is XVSVaultAdminStorage {\\n /// @notice Guard variable for re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @notice The reward token store\\n address public xvsStore;\\n\\n /// @notice The xvs token address\\n address public xvsAddress;\\n\\n // Reward tokens created per block or second indentified by reward token address.\\n mapping(address => uint256) public rewardTokenAmountsPerBlockOrSecond;\\n\\n /// @notice Info of each user.\\n struct UserInfo {\\n uint256 amount;\\n uint256 rewardDebt;\\n uint256 pendingWithdrawals;\\n }\\n\\n // Info of each pool.\\n struct PoolInfo {\\n IBEP20 token; // Address of token contract to stake.\\n uint256 allocPoint; // How many allocation points assigned to this pool.\\n uint256 lastRewardBlockOrSecond; // Last block number or second that reward tokens distribution occurs.\\n uint256 accRewardPerShare; // Accumulated per share, times 1e12. See below.\\n uint256 lockPeriod; // Min time between withdrawal request and its execution.\\n }\\n\\n // Infomation about a withdrawal request\\n struct WithdrawalRequest {\\n uint256 amount;\\n uint128 lockedUntil;\\n uint128 afterUpgrade;\\n }\\n\\n // Info of each user that stakes tokens.\\n mapping(address => mapping(uint256 => mapping(address => UserInfo))) internal userInfos;\\n\\n // Info of each pool.\\n mapping(address => PoolInfo[]) public poolInfos;\\n\\n // Total allocation points. Must be the sum of all allocation points in all pools.\\n mapping(address => uint256) public totalAllocPoints;\\n\\n // Info of requested but not yet executed withdrawals\\n mapping(address => mapping(uint256 => mapping(address => WithdrawalRequest[]))) internal withdrawalRequests;\\n\\n /// @notice DEPRECATED A record of each accounts delegate (before the voting power fix)\\n mapping(address => address) private __oldDelegatesSlot;\\n\\n /// @notice A checkpoint for marking number of votes from a given block or second\\n struct Checkpoint {\\n uint32 fromBlockOrSecond;\\n uint96 votes;\\n }\\n\\n /// @notice DEPRECATED A record of votes checkpoints for each account, by index (before the voting power fix)\\n mapping(address => mapping(uint32 => Checkpoint)) private __oldCheckpointsSlot;\\n\\n /// @notice DEPRECATED The number of checkpoints for each account (before the voting power fix)\\n mapping(address => uint32) private __oldNumCheckpointsSlot;\\n\\n /// @notice A record of states for signing / validating signatures\\n mapping(address => uint) public nonces;\\n\\n /// @notice The EIP-712 typehash for the contract's domain\\n bytes32 public constant DOMAIN_TYPEHASH =\\n keccak256(\\\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\\\");\\n\\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\\\");\\n}\\n\\ncontract XVSVaultStorage is XVSVaultStorageV1 {\\n /// @notice A record of each accounts delegate\\n mapping(address => address) public delegates;\\n\\n /// @notice A record of votes checkpoints for each account, by index\\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\\n\\n /// @notice The number of checkpoints for each account\\n mapping(address => uint32) public numCheckpoints;\\n\\n /// @notice Tracks pending withdrawals for all users for a particular reward token and pool id\\n mapping(address => mapping(uint256 => uint256)) public totalPendingWithdrawals;\\n\\n /// @notice pause indicator for Vault\\n bool public vaultPaused;\\n\\n /// @notice if the token is added to any of the pools\\n mapping(address => bool) public isStakedToken;\\n\\n /// @notice Amount we owe to users because of failed transfer attempts\\n mapping(address => mapping(address => uint256)) public pendingRewardTransfers;\\n\\n /// @notice Prime token contract address\\n IPrime public primeToken;\\n\\n /// @notice Reward token for which prime token is issued for staking\\n address public primeRewardToken;\\n\\n /// @notice Pool ID for which prime token is issued for staking\\n uint256 public primePoolId;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[46] private __gap;\\n}\\n\",\"keccak256\":\"0xb09f9295c41bdac1350a3607f2b4ea326cb295a6d08f4145bc33ff87844cd02b\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b031916331790556105c3806100326000396000f3fe60806040526004361061007b5760003560e01c8063de0368b21161004e578063de0368b21461019e578063e992a041146101b3578063e9c714f2146101e6578063f851a440146101fb5761007b565b806326782247146100fe5780635c60da1b1461012f578063b71d1a0c14610144578063c1e8033414610189575b6002546040516000916001600160a01b031690829036908083838082843760405192019450600093509091505080830381855af49150503d80600081146100de576040519150601f19603f3d011682016040523d82523d6000602084013e6100e3565b606091505b505090506040513d6000823e8180156100fa573d82f35b3d82fd5b34801561010a57600080fd5b50610113610210565b604080516001600160a01b039092168252519081900360200190f35b34801561013b57600080fd5b5061011361021f565b34801561015057600080fd5b506101776004803603602081101561016757600080fd5b50356001600160a01b031661022e565b60408051918252519081900360200190f35b34801561019557600080fd5b506101776102bf565b3480156101aa57600080fd5b506101136103a4565b3480156101bf57600080fd5b50610177600480360360208110156101d657600080fd5b50356001600160a01b03166103b3565b3480156101f257600080fd5b50610177610437565b34801561020757600080fd5b50610113610512565b6001546001600160a01b031681565b6002546001600160a01b031681565b600080546001600160a01b031633146102545761024d60016002610521565b90506102ba565b600180546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a160005b9150505b919050565b6003546000906001600160a01b031633146102e6576102df600180610521565b90506103a1565b60028054600380546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a92908290030190a1600354604080516001600160a01b038085168252909216602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160005b925050505b90565b6003546001600160a01b031681565b600080546001600160a01b031633146103d25761024d60016003610521565b600380546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160006102b6565b6001546000906001600160a01b03163314610458576102df60016000610521565b60008054600180546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600154604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a1600061039c565b6000546001600160a01b031681565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083600181111561055057fe5b83600381111561055c57fe5b604080519283526020830191909152600082820152519081900360600190a182600181111561058757fe5b939250505056fea265627a7a7231582084fdc8ea05652a3963f2e50c5c1aa2b7bce63ac2749395e3dffd6f658334c6ae64736f6c63430005100032", + "deployedBytecode": "0x60806040526004361061007b5760003560e01c8063de0368b21161004e578063de0368b21461019e578063e992a041146101b3578063e9c714f2146101e6578063f851a440146101fb5761007b565b806326782247146100fe5780635c60da1b1461012f578063b71d1a0c14610144578063c1e8033414610189575b6002546040516000916001600160a01b031690829036908083838082843760405192019450600093509091505080830381855af49150503d80600081146100de576040519150601f19603f3d011682016040523d82523d6000602084013e6100e3565b606091505b505090506040513d6000823e8180156100fa573d82f35b3d82fd5b34801561010a57600080fd5b50610113610210565b604080516001600160a01b039092168252519081900360200190f35b34801561013b57600080fd5b5061011361021f565b34801561015057600080fd5b506101776004803603602081101561016757600080fd5b50356001600160a01b031661022e565b60408051918252519081900360200190f35b34801561019557600080fd5b506101776102bf565b3480156101aa57600080fd5b506101136103a4565b3480156101bf57600080fd5b50610177600480360360208110156101d657600080fd5b50356001600160a01b03166103b3565b3480156101f257600080fd5b50610177610437565b34801561020757600080fd5b50610113610512565b6001546001600160a01b031681565b6002546001600160a01b031681565b600080546001600160a01b031633146102545761024d60016002610521565b90506102ba565b600180546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a160005b9150505b919050565b6003546000906001600160a01b031633146102e6576102df600180610521565b90506103a1565b60028054600380546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a92908290030190a1600354604080516001600160a01b038085168252909216602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160005b925050505b90565b6003546001600160a01b031681565b600080546001600160a01b031633146103d25761024d60016003610521565b600380546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160006102b6565b6001546000906001600160a01b03163314610458576102df60016000610521565b60008054600180546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600154604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a1600061039c565b6000546001600160a01b031681565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083600181111561055057fe5b83600381111561055c57fe5b604080519283526020830191909152600082820152519081900360600190a182600181111561058757fe5b939250505056fea265627a7a7231582084fdc8ea05652a3963f2e50c5c1aa2b7bce63ac2749395e3dffd6f658334c6ae64736f6c63430005100032", + "devdoc": { + "author": "Venus", + "methods": { + "_acceptAdmin()": { + "details": "Admin function for pending admin to accept role and update admin", + "return": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + }, + "_acceptImplementation()": { + "details": "Admin function for new implementation to accept it's role as implementation", + "return": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + }, + "_setPendingAdmin(address)": { + "details": "Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.", + "params": { + "newPendingAdmin": "New pending admin." + }, + "return": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "title": "XVS Vault Proxy" + }, + "userdoc": { + "methods": { + "_acceptAdmin()": { + "notice": "Accepts transfer of admin rights. msg.sender must be pendingAdmin" + }, + "_acceptImplementation()": { + "notice": "Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation" + }, + "_setPendingAdmin(address)": { + "notice": "Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer." + }, + "_setPendingImplementation(address)": { + "notice": "* Admin Functions **" + } + }, + "notice": "XVS Vault Proxy contract" + }, + "storageLayout": { + "storage": [ + { + "astId": 40377, + "contract": "contracts/XVSVault/XVSVaultProxy.sol:XVSVaultProxy", + "label": "admin", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 40379, + "contract": "contracts/XVSVault/XVSVaultProxy.sol:XVSVaultProxy", + "label": "pendingAdmin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 40381, + "contract": "contracts/XVSVault/XVSVaultProxy.sol:XVSVaultProxy", + "label": "implementation", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 40383, + "contract": "contracts/XVSVault/XVSVaultProxy.sol:XVSVaultProxy", + "label": "pendingXVSVaultImplementation", + "offset": 0, + "slot": "3", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + } + } + } +} diff --git a/deployments/opmainnet/XVSVaultProxy_Implementation.json b/deployments/opmainnet/XVSVaultProxy_Implementation.json new file mode 100644 index 000000000..598ac2b41 --- /dev/null +++ b/deployments/opmainnet/XVSVaultProxy_Implementation.json @@ -0,0 +1,2572 @@ +{ + "address": "0x8B8651EEB002a7991F2287500B17a395E8cfe7d9", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Claim", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ExecutedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IPrime", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IPrime", + "name": "newPrimeToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldPrimeRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPrimeRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldPrimePoolId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPrimePoolId", + "type": "uint256" + } + ], + "name": "NewPrimeToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "allocPoints", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardPerBlockOrSecond", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lockPeriod", + "type": "uint256" + } + ], + "name": "PoolAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldAllocPoints", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newAllocPoints", + "type": "uint256" + } + ], + "name": "PoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RequestedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldReward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReward", + "type": "uint256" + } + ], + "name": "RewardAmountUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldXvs", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldStore", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newXvs", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newStore", + "type": "address" + } + ], + "name": "StoreUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "userAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldOwedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newOwedAmount", + "type": "uint256" + } + ], + "name": "VaultDebtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "VaultPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "VaultResumed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldPeriod", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPeriod", + "type": "uint256" + } + ], + "name": "WithdrawalLockingPeriodUpdated", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_LOCK_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SECONDS_PER_YEAR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract XVSVaultProxy", + "name": "xvsVaultProxy", + "type": "address" + } + ], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV5", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_allocPoint", + "type": "uint256" + }, + { + "internalType": "contract IBEP20", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rewardPerBlockOrSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_lockPeriod", + "type": "uint256" + } + ], + "name": "add", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "fromBlockOrSecond", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "claim", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "delegateBySig", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "executeWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCurrentVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getEligibleWithdrawalAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "withdrawalAmount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumberOrSecond", + "type": "uint256" + } + ], + "name": "getPriorVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getRequestedAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getUserInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pendingWithdrawals", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getWithdrawalRequests", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "lockedUntil", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "afterUpgrade", + "type": "uint128" + } + ], + "internalType": "struct XVSVaultStorageV1.WithdrawalRequest[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "timeBased_", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "blocksPerYear_", + "type": "uint256" + } + ], + "name": "initializeTimeManager", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isStakedToken", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "pause", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "pendingReward", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pendingRewardTransfers", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "pendingWithdrawalsBeforeUpgrade", + "outputs": [ + { + "internalType": "uint256", + "name": "beforeUpgradeWithdrawalAmount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "poolInfos", + "outputs": [ + { + "internalType": "contract IBEP20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allocPoint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastRewardBlockOrSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "accRewardPerShare", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lockPeriod", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + } + ], + "name": "poolLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primePoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primeRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primeToken", + "outputs": [ + { + "internalType": "contract IPrime", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "requestWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "resume", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + } + ], + "name": "rewardTokenAmountsPerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardTokenAmountsPerBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_allocPoint", + "type": "uint256" + } + ], + "name": "set", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newAccessControlAddress", + "type": "address" + } + ], + "name": "setAccessControl", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract IPrime", + "name": "_primeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_primeRewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_primePoolId", + "type": "uint256" + } + ], + "name": "setPrimeToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rewardAmount", + "type": "uint256" + } + ], + "name": "setRewardAmountPerBlockOrSecond", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newPeriod", + "type": "uint256" + } + ], + "name": "setWithdrawalLockingPeriod", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_xvs", + "type": "address" + }, + { + "internalType": "address", + "name": "_xvsStore", + "type": "address" + } + ], + "name": "setXvsStore", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "totalAllocPoints", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "totalPendingWithdrawals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "updatePool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaultPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsStore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x8326643923b1b83c4436c259f78f97a3fa6a2a3cb3bb37e5ade0898c74534553", + "receipt": { + "to": null, + "from": "0xC76363B887031e79E6A2954c5515f5E5507A6387", + "contractAddress": "0x8B8651EEB002a7991F2287500B17a395E8cfe7d9", + "transactionIndex": 13, + "gasUsed": "4916687", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x3a2e4000b5189b0e2e30ab636573c0153f989bb0e7011d3a3f34a62dfa43f68e", + "transactionHash": "0x8326643923b1b83c4436c259f78f97a3fa6a2a3cb3bb37e5ade0898c74534553", + "logs": [], + "blockNumber": 125559832, + "cumulativeGasUsed": "11049820", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "a2594572bdae270af6749f50c8019b6c", + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Claim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"fromDelegate\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"toDelegate\",\"type\":\"address\"}],\"name\":\"DelegateChangedV2\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"DelegateVotesChangedV2\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ExecutedWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IPrime\",\"name\":\"oldPrimeToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IPrime\",\"name\":\"newPrimeToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPrimeRewardToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPrimeRewardToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldPrimePoolId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newPrimePoolId\",\"type\":\"uint256\"}],\"name\":\"NewPrimeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"allocPoints\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rewardPerBlockOrSecond\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lockPeriod\",\"type\":\"uint256\"}],\"name\":\"PoolAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAllocPoints\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAllocPoints\",\"type\":\"uint256\"}],\"name\":\"PoolUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RequestedWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldReward\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newReward\",\"type\":\"uint256\"}],\"name\":\"RewardAmountUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldXvs\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldStore\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newXvs\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newStore\",\"type\":\"address\"}],\"name\":\"StoreUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldOwedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newOwedAmount\",\"type\":\"uint256\"}],\"name\":\"VaultDebtUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"VaultPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"VaultResumed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newPeriod\",\"type\":\"uint256\"}],\"name\":\"WithdrawalLockingPeriodUpdated\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[],\"name\":\"DELEGATION_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"DOMAIN_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MAX_LOCK_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"SECONDS_PER_YEAR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"contract XVSVaultProxy\",\"name\":\"xvsVaultProxy\",\"type\":\"address\"}],\"name\":\"_become\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV5\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_allocPoint\",\"type\":\"uint256\"},{\"internalType\":\"contract IBEP20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_rewardPerBlockOrSecond\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_lockPeriod\",\"type\":\"uint256\"}],\"name\":\"add\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"blocksOrSecondsPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"checkpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"fromBlockOrSecond\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"}],\"name\":\"claim\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"delegate\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"delegateBySig\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"delegates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"}],\"name\":\"executeWithdrawal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getBlockNumberOrTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getCurrentVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getEligibleWithdrawalAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawalAmount\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumberOrSecond\",\"type\":\"uint256\"}],\"name\":\"getPriorVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getRequestedAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getUserInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardDebt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"pendingWithdrawals\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getWithdrawalRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"lockedUntil\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"afterUpgrade\",\"type\":\"uint128\"}],\"internalType\":\"struct XVSVaultStorageV1.WithdrawalRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bool\",\"name\":\"timeBased_\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"blocksPerYear_\",\"type\":\"uint256\"}],\"name\":\"initializeTimeManager\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isStakedToken\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isTimeBased\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"numCheckpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"pendingReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pendingRewardTransfers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"pendingWithdrawalsBeforeUpgrade\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"beforeUpgradeWithdrawalAmount\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingXVSVaultImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"poolInfos\",\"outputs\":[{\"internalType\":\"contract IBEP20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"allocPoint\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"lastRewardBlockOrSecond\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"accRewardPerShare\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"lockPeriod\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"}],\"name\":\"poolLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"primePoolId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"primeRewardToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"primeToken\",\"outputs\":[{\"internalType\":\"contract IPrime\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"requestWithdrawal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"resume\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"}],\"name\":\"rewardTokenAmountsPerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"rewardTokenAmountsPerBlockOrSecond\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_allocPoint\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAccessControlAddress\",\"type\":\"address\"}],\"name\":\"setAccessControl\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"contract IPrime\",\"name\":\"_primeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_primeRewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_primePoolId\",\"type\":\"uint256\"}],\"name\":\"setPrimeToken\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_rewardAmount\",\"type\":\"uint256\"}],\"name\":\"setRewardAmountPerBlockOrSecond\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_newPeriod\",\"type\":\"uint256\"}],\"name\":\"setWithdrawalLockingPeriod\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_xvs\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_xvsStore\",\"type\":\"address\"}],\"name\":\"setXvsStore\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"totalAllocPoints\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"totalPendingWithdrawals\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"}],\"name\":\"updatePool\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"vaultPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"xvsAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"xvsStore\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"methods\":{\"add(address,uint256,address,uint256,uint256)\":{\"details\":\"This vault DOES NOT support deflationary tokens \\u2014 it expects that the amount of transferred tokens would equal the actually deposited amount. In practice this means that this vault DOES NOT support USDT and similar tokens (that do not provide these guarantees).\",\"params\":{\"_allocPoint\":\"Number of allocation points assigned to this pool\",\"_lockPeriod\":\"A period between withdrawal request and a moment when it's executable\",\"_rewardPerBlockOrSecond\":\"Initial reward per block or second, in terms of _rewardToken\",\"_rewardToken\":\"Reward token address\",\"_token\":\"Staked token\"}},\"claim(address,address,uint256)\":{\"params\":{\"_account\":\"The account for which to claim rewards\",\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\"}},\"delegate(address)\":{\"params\":{\"delegatee\":\"The address to delegate votes to\"}},\"delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)\":{\"params\":{\"delegatee\":\"The address to delegate votes to\",\"expiry\":\"The time at which to expire the signature\",\"nonce\":\"The contract state required to match the signature\",\"r\":\"Half of the ECDSA signature pair\",\"s\":\"Half of the ECDSA signature pair\",\"v\":\"The recovery byte of the signature\"}},\"deposit(address,uint256,uint256)\":{\"params\":{\"_amount\":\"The amount to deposit to vault\",\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\"}},\"executeWithdrawal(address,uint256)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\"}},\"getBlockNumberOrTimestamp()\":{\"details\":\"Function to simply retrieve block number or block timestamp\",\"return\":\"Current block number or block timestamp\"},\"getCurrentVotes(address)\":{\"params\":{\"account\":\"The address to get votes balance\"},\"return\":\"The number of current votes for `account`\"},\"getEligibleWithdrawalAmount(address,uint256,address)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\",\"_user\":\"The User Address\"},\"return\":\"withdrawalAmount Amount that the user can withdraw\"},\"getPriorVotes(address,uint256)\":{\"params\":{\"account\":\"The address of the account to check\",\"blockNumberOrSecond\":\"The block number or second to get the vote balance at\"},\"return\":\"The balance that user staked\"},\"getRequestedAmount(address,uint256,address)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\",\"_user\":\"The User Address\"},\"return\":\"Total amount of requested but not yet executed withdrawals (including both executable and locked ones)\"},\"getUserInfo(address,uint256,address)\":{\"params\":{\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\",\"_user\":\"User address\"},\"return\":\"amount Deposited amountrewardDebt Reward debt (technical value used to track past payouts)pendingWithdrawals Requested but not yet executed withdrawals\"},\"getWithdrawalRequests(address,uint256,address)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\",\"_user\":\"The User Address\"},\"return\":\"An array of withdrawal requests\"},\"initializeTimeManager(bool,uint256)\":{\"details\":\"Initializes the contract to use either blocks or seconds\",\"params\":{\"blocksPerYear_\":\"The number of blocks per year\",\"timeBased_\":\"A boolean indicating whether the contract is based on time or block If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\"}},\"pendingReward(address,uint256,address)\":{\"params\":{\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\",\"_user\":\"User address\"},\"return\":\"Reward the user is eligible for in this pool, in terms of _rewardToken\"},\"pendingWithdrawalsBeforeUpgrade(address,uint256,address)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\",\"_user\":\"The address of the user\"},\"return\":\"beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade\"},\"poolLength(address)\":{\"params\":{\"rewardToken\":\"Reward token address\"},\"return\":\"Number of pools that distribute the specified token as a reward\"},\"requestWithdrawal(address,uint256,uint256)\":{\"params\":{\"_amount\":\"The amount to withdraw from the vault\",\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\"}},\"rewardTokenAmountsPerBlock(address)\":{\"params\":{\"_rewardToken\":\"Reward token address\"},\"return\":\"Number of reward tokens created per block or second\"},\"set(address,uint256,uint256)\":{\"params\":{\"_allocPoint\":\"Number of allocation points assigned to this pool\",\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\"}},\"setAccessControl(address)\":{\"details\":\"Admin function to set the access control address\",\"params\":{\"newAccessControlAddress\":\"New address for the access control\"}},\"setPrimeToken(address,address,uint256)\":{\"params\":{\"_primePoolId\":\"pool id for reward\",\"_primeRewardToken\":\"address of reward token\",\"_primeToken\":\"address of the prime token contract\"}},\"setRewardAmountPerBlockOrSecond(address,uint256)\":{\"params\":{\"_rewardAmount\":\"Number of allocation points assigned to this pool\",\"_rewardToken\":\"Reward token address\"}},\"setWithdrawalLockingPeriod(address,uint256,uint256)\":{\"params\":{\"_newPeriod\":\"New lock period\",\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\"}},\"updatePool(address,uint256)\":{\"params\":{\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\"}}},\"title\":\"XVS Vault\"},\"userdoc\":{\"methods\":{\"_become(address)\":{\"notice\":\"* Admin Functions **\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"add(address,uint256,address,uint256,uint256)\":{\"notice\":\"Add a new token pool\"},\"claim(address,address,uint256)\":{\"notice\":\"Claim rewards for pool\"},\"constructor\":\"XVSVault constructor\",\"delegate(address)\":{\"notice\":\"Delegate votes from `msg.sender` to `delegatee`\"},\"delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"Delegates votes from signatory to `delegatee`\"},\"deposit(address,uint256,uint256)\":{\"notice\":\"Deposit XVSVault for XVS allocation\"},\"executeWithdrawal(address,uint256)\":{\"notice\":\"Execute withdrawal to XVSVault for XVS allocation\"},\"getCurrentVotes(address)\":{\"notice\":\"Gets the current votes balance for `account`\"},\"getEligibleWithdrawalAmount(address,uint256,address)\":{\"notice\":\"Get unlocked withdrawal amount\"},\"getPriorVotes(address,uint256)\":{\"notice\":\"Determine the xvs stake balance for an account\"},\"getRequestedAmount(address,uint256,address)\":{\"notice\":\"Get requested amount\"},\"getUserInfo(address,uint256,address)\":{\"notice\":\"Get user info with reward token address and pid\"},\"getWithdrawalRequests(address,uint256,address)\":{\"notice\":\"Returns the array of withdrawal requests that have not been executed yet\"},\"pause()\":{\"notice\":\"Pauses vault\"},\"pendingReward(address,uint256,address)\":{\"notice\":\"View function to see pending XVSs on frontend\"},\"pendingWithdrawalsBeforeUpgrade(address,uint256,address)\":{\"notice\":\"Gets the total pending withdrawal amount of a user before upgrade\"},\"poolLength(address)\":{\"notice\":\"Returns the number of pools with the specified reward token\"},\"requestWithdrawal(address,uint256,uint256)\":{\"notice\":\"Request withdrawal to XVSVault for XVS allocation\"},\"resume()\":{\"notice\":\"Resume vault\"},\"rewardTokenAmountsPerBlock(address)\":{\"notice\":\"Returns the number of reward tokens created per block or second\"},\"set(address,uint256,uint256)\":{\"notice\":\"Update the given pool's reward allocation point\"},\"setAccessControl(address)\":{\"notice\":\"Sets the address of the access control of this contract\"},\"setPrimeToken(address,address,uint256)\":{\"notice\":\"Sets the address of the prime token contract\"},\"setRewardAmountPerBlockOrSecond(address,uint256)\":{\"notice\":\"Update the given reward token's amount per block or second\"},\"setWithdrawalLockingPeriod(address,uint256,uint256)\":{\"notice\":\"Update the lock period after which a requested withdrawal can be executed\"},\"updatePool(address,uint256)\":{\"notice\":\"Update reward variables of the given pool to be up-to-date\"}},\"notice\":\"The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS.\"}},\"settings\":{\"compilationTarget\":{\"contracts/XVSVault/XVSVault.sol\":\"XVSVault\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.5.16;\\n\\nimport \\\"./IAccessControlManagerV5.sol\\\";\\n\\n/**\\n * @title AccessControlledV5\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.5.16)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\ncontract AccessControlledV5 {\\n /// @notice Access control manager contract\\n IAccessControlManagerV5 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV5) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV5(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert(\\\"Unauthorized\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4b724928650b944935bc91713782a8cf5bbd9cdb98b3e3fedf31e611c7e6df19\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.5.16;\\n\\n/**\\n * @title IAccessControlManagerV5\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV5` contract.\\n */\\ninterface IAccessControlManagerV5 {\\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 */\\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 /**\\n * @notice Gives a function call permission to one single account\\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\\n * \\t\\tMay emit a {RoleGranted} event.\\n * @param contractAddress address of contract for which call permissions will be granted\\n * @param functionSig signature e.g. \\\"functionName(uint,bool)\\\"\\n */\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n /**\\n * @notice Revokes an account's permission to a particular function call\\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\\n * \\t\\tMay emit a {RoleRevoked} event.\\n * @param contractAddress address of contract for which call permissions will be revoked\\n * @param functionSig signature e.g. \\\"functionName(uint,bool)\\\"\\n */\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n /**\\n * @notice Verifies if the given account can call a praticular contract's function\\n * @dev Since the contract is calling itself this function, we can get contracts address with msg.sender\\n * @param account address (eoa or contract) for which call permissions will be checked\\n * @param functionSig signature e.g. \\\"functionName(uint,bool)\\\"\\n * @return false if the user account cannot call the particular contract function\\n *\\n */\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x3563db4c75f7aa0b8a982bab591907dda192438a2368511b62a9c587a3e54226\"},\"@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.5.16;\\n\\ncontract TimeManagerV5 {\\n /// @dev The approximate number of seconds per year\\n uint256 public constant SECONDS_PER_YEAR = 31_536_000;\\n\\n /// @notice Number of blocks per year or seconds per year\\n uint256 public blocksOrSecondsPerYear;\\n\\n /// @dev Sets true when block timestamp is used\\n bool public isTimeBased;\\n\\n /// @dev Sets true when contract is initialized\\n bool private isInitialized;\\n\\n /// @notice Deprecated slot for _getCurrentSlot function pointer\\n bytes8 private __deprecatedSlot1;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[48] private __gap;\\n\\n /**\\n * @dev Function to simply retrieve block number or block timestamp\\n * @return Current block number or block timestamp\\n */\\n function getBlockNumberOrTimestamp() public view returns (uint256) {\\n return isTimeBased ? _getBlockTimestamp() : _getBlockNumber();\\n }\\n\\n /**\\n * @dev Initializes the contract to use either blocks or seconds\\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\\n * @param blocksPerYear_ The number of blocks per year\\n */\\n function _initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) internal {\\n if (isInitialized) revert(\\\"Already initialized TimeManager\\\");\\n\\n if (!timeBased_ && blocksPerYear_ == 0) {\\n revert(\\\"Invalid blocks per year\\\");\\n }\\n if (timeBased_ && blocksPerYear_ != 0) {\\n revert(\\\"Invalid time based configuration\\\");\\n }\\n\\n isTimeBased = timeBased_;\\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\\n isInitialized = true;\\n }\\n\\n /**\\n * @dev Returns the current timestamp in seconds\\n * @return The current timestamp\\n */\\n function _getBlockTimestamp() private view returns (uint256) {\\n return block.timestamp;\\n }\\n\\n /**\\n * @dev Returns the current block number\\n * @return The current block number\\n */\\n function _getBlockNumber() private view returns (uint256) {\\n return block.number;\\n }\\n}\\n\",\"keccak256\":\"0x0d35813e9a6d4fe7cf466466573ca12b6b378cad8f6da0b36b13e0d428a757f0\"},\"contracts/Tokens/Prime/IPrime.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.5.16;\\npragma experimental ABIEncoderV2;\\n\\n/**\\n * @title IPrime\\n * @author Venus\\n * @notice Interface for Prime Token\\n */\\ninterface IPrime {\\n /**\\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\\n * @param user the account address whose balance was updated\\n */\\n function xvsUpdated(address user) external;\\n\\n /**\\n * @notice accrues interest and updates score for an user for a specific market\\n * @param user the account address for which to accrue interest and update score\\n * @param market the market for which to accrue interest and update score\\n */\\n function accrueInterestAndUpdateScore(address user, address market) external;\\n\\n /**\\n * @notice Distributes income from market since last distribution\\n * @param vToken the market for which to distribute the income\\n */\\n function accrueInterest(address vToken) external;\\n\\n /**\\n * @notice Returns if user is a prime holder\\n * @param isPrimeHolder returns if the user is a prime holder\\n */\\n function isUserPrimeHolder(address user) external view returns (bool isPrimeHolder);\\n}\\n\",\"keccak256\":\"0x58861c0c05b8757f1a5d50b107eff479c8680878e6aa51bc93af420caf73f500\"},\"contracts/Utils/Address.sol\":{\"content\":\"pragma solidity ^0.5.5;\\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 function isContract(address account) internal view returns (bool) {\\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\\n // for accounts without code, i.e. `keccak256('')`\\n bytes32 codehash;\\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n codehash := extcodehash(account)\\n }\\n return (codehash != accountHash && codehash != 0x0);\\n }\\n\\n /**\\n * @dev Converts an `address` into `address payable`. Note that this is\\n * simply a type cast: the actual underlying value is not changed.\\n *\\n * _Available since v2.4.0._\\n */\\n function toPayable(address account) internal pure returns (address payable) {\\n return address(uint160(account));\\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 * _Available since v2.4.0._\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-call-value\\n // solium-disable-next-line security/no-call-value\\n (bool success, ) = recipient.call.value(amount)(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n}\\n\",\"keccak256\":\"0x3c2ef780599a2ae6913282b982633f07e405a4a9c8511590df571e2b773aef9d\"},\"contracts/Utils/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// Adapted from OpenZeppelin Contracts v4.3.2 (utils/cryptography/ECDSA.sol)\\n\\n// SPDX-Copyright-Text: OpenZeppelin, 2021\\n// SPDX-Copyright-Text: Venus, 2021\\n\\npragma solidity ^0.5.16;\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\ncontract ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n}\\n\",\"keccak256\":\"0xf27d7ad488b72c627370afa6e9acc520d4834a082363d1dc46b5573ac40a2d0a\"},\"contracts/Utils/IBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\n/**\\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\\n * the optional functions; to access them see {BEP20Detailed}.\\n */\\ninterface IBEP20 {\\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 `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\\n\\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\",\"keccak256\":\"0x839b08895eb1ad83502d3631e8e9e3a856d2a8c63c46f070d604af7b26c62c07\"},\"contracts/Utils/SafeBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\nimport \\\"./SafeMath.sol\\\";\\nimport \\\"./IBEP20.sol\\\";\\nimport \\\"./Address.sol\\\";\\n\\n/**\\n * @title SafeBEP20\\n * @dev Wrappers around BEP20 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 SafeBEP20 for BEP20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeBEP20 {\\n using SafeMath for uint256;\\n using Address for address;\\n\\n function safeTransfer(IBEP20 token, address to, uint256 value) internal {\\n callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(IBEP20 token, address from, address to, uint256 value) internal {\\n callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n function safeApprove(IBEP20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeBEP20: approve from non-zero to non-zero allowance\\\"\\n );\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).sub(\\n value,\\n \\\"SafeBEP20: decreased allowance below zero\\\"\\n );\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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(IBEP20 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.\\n\\n // A Solidity high level call has three parts:\\n // 1. The target address is checked to verify it contains contract code\\n // 2. The call itself is made, and success asserted\\n // 3. The return value is decoded, which in turn checks the size of the returned data.\\n // solhint-disable-next-line max-line-length\\n require(address(token).isContract(), \\\"SafeBEP20: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = address(token).call(data);\\n require(success, \\\"SafeBEP20: low-level call failed\\\");\\n\\n if (returndata.length > 0) {\\n // Return data is optional\\n // solhint-disable-next-line max-line-length\\n require(abi.decode(returndata, (bool)), \\\"SafeBEP20: BEP20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x540ef6ddc47232a59d3ab0e95537f7a7d1c8a36f8dba315b010e60c6487bd768\"},\"contracts/Utils/SafeCast.sol\":{\"content\":\"pragma solidity ^0.5.16;\\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 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 < 2 ** 128, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(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 < 2 ** 64, \\\"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 < 2 ** 32, \\\"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 < 2 ** 16, \\\"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 < 2 ** 8, \\\"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 >= -2 ** 127 && value < 2 ** 127, \\\"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 >= -2 ** 63 && value < 2 ** 63, \\\"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 >= -2 ** 31 && value < 2 ** 31, \\\"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 >= -2 ** 15 && value < 2 ** 15, \\\"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 >= -2 ** 7 && value < 2 ** 7, \\\"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 require(value < 2 ** 255, \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xe6222292bd226980fd73c00eaf3a102c8638777aa3f9c7cd9b0d0fb621da0661\"},\"contracts/Utils/SafeMath.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add(a, b, \\\"SafeMath: addition overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub(a, b, \\\"SafeMath: subtraction overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n uint256 c = a - b;\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) {\\n return 0;\\n }\\n\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div(a, b, \\\"SafeMath: division by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n // Solidity only automatically asserts when dividing by 0\\n require(b > 0, errorMessage);\\n uint256 c = a / b;\\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mod(a, b, \\\"SafeMath: modulo by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts with custom message when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b != 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x9431fd772ed4abc038cdfe9ce6c0066897bd1685ad45848748d1952935d5b8ef\"},\"contracts/XVSVault/XVSStore.sol\":{\"content\":\"pragma solidity 0.5.16;\\nimport \\\"../Utils/SafeBEP20.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\n\\n/**\\n * @title XVS Store\\n * @author Venus\\n * @notice XVS Store responsible for distributing XVS rewards\\n */\\ncontract XVSStore {\\n using SafeMath for uint256;\\n using SafeBEP20 for IBEP20;\\n\\n /// @notice The Admin Address\\n address public admin;\\n\\n /// @notice The pending admin address\\n address public pendingAdmin;\\n\\n /// @notice The Owner Address\\n address public owner;\\n\\n /// @notice The reward tokens\\n mapping(address => bool) public rewardTokens;\\n\\n /// @notice Emitted when pendingAdmin is changed\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /// @notice Event emitted when admin changed\\n event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);\\n\\n /// @notice Event emitted when owner changed\\n event OwnerTransferred(address indexed oldOwner, address indexed newOwner);\\n\\n constructor() public {\\n admin = msg.sender;\\n }\\n\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"only admin can\\\");\\n _;\\n }\\n\\n modifier onlyOwner() {\\n require(msg.sender == owner, \\\"only owner can\\\");\\n _;\\n }\\n\\n /**\\n * @notice Safely transfer rewards. Only active reward tokens can be sent using this function.\\n * Only callable by owner\\n * @dev Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\\n * @param token Reward token to transfer\\n * @param _to Destination address of the reward\\n * @param _amount Amount to transfer\\n */\\n function safeRewardTransfer(address token, address _to, uint256 _amount) external onlyOwner {\\n require(rewardTokens[token] == true, \\\"only reward token can\\\");\\n\\n if (address(token) != address(0)) {\\n uint256 tokenBalance = IBEP20(token).balanceOf(address(this));\\n if (_amount > tokenBalance) {\\n IBEP20(token).safeTransfer(_to, tokenBalance);\\n } else {\\n IBEP20(token).safeTransfer(_to, _amount);\\n }\\n }\\n }\\n\\n /**\\n * @notice Allows the admin to propose a new admin\\n * Only callable admin\\n * @param _admin Propose an account as admin of the XVS store\\n */\\n function setPendingAdmin(address _admin) external onlyAdmin {\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = _admin;\\n emit NewPendingAdmin(oldPendingAdmin, _admin);\\n }\\n\\n /**\\n * @notice Allows an account that is pending as admin to accept the role\\n * nly calllable by the pending admin\\n */\\n function acceptAdmin() external {\\n require(msg.sender == pendingAdmin, \\\"only pending admin\\\");\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n emit AdminTransferred(oldAdmin, admin);\\n }\\n\\n /**\\n * @notice Set the contract owner\\n * @param _owner The address of the owner to set\\n * Only callable admin\\n */\\n function setNewOwner(address _owner) external onlyAdmin {\\n require(_owner != address(0), \\\"new owner is the zero address\\\");\\n address oldOwner = owner;\\n owner = _owner;\\n emit OwnerTransferred(oldOwner, _owner);\\n }\\n\\n /**\\n * @notice Set or disable a reward token\\n * @param _tokenAddress The address of a token to set as active or inactive\\n * @param status Set whether a reward token is active or not\\n */\\n function setRewardToken(address _tokenAddress, bool status) external {\\n require(msg.sender == admin || msg.sender == owner, \\\"only admin or owner can\\\");\\n rewardTokens[_tokenAddress] = status;\\n }\\n\\n /**\\n * @notice Security function to allow the owner of the contract to withdraw from the contract\\n * @param _tokenAddress Reward token address to withdraw\\n * @param _amount Amount of token to withdraw\\n */\\n function emergencyRewardWithdraw(address _tokenAddress, uint256 _amount) external onlyOwner {\\n IBEP20(_tokenAddress).safeTransfer(address(msg.sender), _amount);\\n }\\n}\\n\",\"keccak256\":\"0x8082f92b13448bd4fa982c93c763439f10fe016a5f3be6d613dfe3cca68501ef\"},\"contracts/XVSVault/XVSVault.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\n\\npragma solidity 0.5.16;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"../Utils/ECDSA.sol\\\";\\nimport \\\"../Utils/SafeBEP20.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\nimport \\\"./XVSVaultStorage.sol\\\";\\nimport \\\"../Tokens/Prime/IPrime.sol\\\";\\nimport \\\"../Utils/SafeCast.sol\\\";\\nimport \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\\\";\\nimport \\\"@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol\\\";\\n\\nimport { XVSStore } from \\\"./XVSStore.sol\\\";\\nimport { XVSVaultProxy } from \\\"./XVSVaultProxy.sol\\\";\\n\\n/**\\n * @title XVS Vault\\n * @author Venus\\n * @notice The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS.\\n */\\ncontract XVSVault is XVSVaultStorage, ECDSA, AccessControlledV5, TimeManagerV5 {\\n using SafeMath for uint256;\\n using SafeCast for uint256;\\n using SafeBEP20 for IBEP20;\\n\\n /// @notice The upper bound for the lock period in a pool, 10 years\\n uint256 public constant MAX_LOCK_PERIOD = 60 * 60 * 24 * 365 * 10;\\n\\n /// @notice Event emitted when deposit\\n event Deposit(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\\n\\n /// @notice Event emitted when execute withrawal\\n event ExecutedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\\n\\n /// @notice Event emitted when request withrawal\\n event RequestedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\\n\\n /// @notice An event thats emitted when an account changes its delegate\\n event DelegateChangedV2(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\\n\\n /// @notice An event thats emitted when a delegate account's vote balance changes\\n event DelegateVotesChangedV2(address indexed delegate, uint previousBalance, uint newBalance);\\n\\n /// @notice An event emitted when the reward store address is updated\\n event StoreUpdated(address oldXvs, address oldStore, address newXvs, address newStore);\\n\\n /// @notice An event emitted when the withdrawal locking period is updated for a pool\\n event WithdrawalLockingPeriodUpdated(address indexed rewardToken, uint indexed pid, uint oldPeriod, uint newPeriod);\\n\\n /// @notice An event emitted when the reward amount per block or second is modified for a pool\\n event RewardAmountUpdated(address indexed rewardToken, uint oldReward, uint newReward);\\n\\n /// @notice An event emitted when a new pool is added\\n event PoolAdded(\\n address indexed rewardToken,\\n uint indexed pid,\\n address indexed token,\\n uint allocPoints,\\n uint rewardPerBlockOrSecond,\\n uint lockPeriod\\n );\\n\\n /// @notice An event emitted when a pool allocation points are updated\\n event PoolUpdated(address indexed rewardToken, uint indexed pid, uint oldAllocPoints, uint newAllocPoints);\\n\\n /// @notice Event emitted when reward claimed\\n event Claim(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\\n\\n /// @notice Event emitted when vault is paused\\n event VaultPaused(address indexed admin);\\n\\n /// @notice Event emitted when vault is resumed after pause\\n event VaultResumed(address indexed admin);\\n\\n /// @notice Event emitted when protocol logs a debt to a user due to insufficient funds for pending reward distribution\\n event VaultDebtUpdated(\\n address indexed rewardToken,\\n address indexed userAddress,\\n uint256 oldOwedAmount,\\n uint256 newOwedAmount\\n );\\n\\n /// @notice Emitted when prime token contract address is changed\\n event NewPrimeToken(\\n IPrime indexed oldPrimeToken,\\n IPrime indexed newPrimeToken,\\n address oldPrimeRewardToken,\\n address newPrimeRewardToken,\\n uint256 oldPrimePoolId,\\n uint256 newPrimePoolId\\n );\\n\\n /**\\n * @notice XVSVault constructor\\n */\\n constructor() public {\\n admin = msg.sender;\\n }\\n\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"only admin can\\\");\\n _;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n */\\n modifier nonReentrant() {\\n require(_notEntered, \\\"re-entered\\\");\\n _notEntered = false;\\n _;\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n\\n /**\\n * @dev Prevents functions to execute when vault is paused.\\n */\\n modifier isActive() {\\n require(!vaultPaused, \\\"Vault is paused\\\");\\n _;\\n }\\n\\n /**\\n * @notice Pauses vault\\n */\\n function pause() external {\\n _checkAccessAllowed(\\\"pause()\\\");\\n require(!vaultPaused, \\\"Vault is already paused\\\");\\n vaultPaused = true;\\n emit VaultPaused(msg.sender);\\n }\\n\\n /**\\n * @notice Resume vault\\n */\\n function resume() external {\\n _checkAccessAllowed(\\\"resume()\\\");\\n require(vaultPaused, \\\"Vault is not paused\\\");\\n vaultPaused = false;\\n emit VaultResumed(msg.sender);\\n }\\n\\n /**\\n * @notice Returns the number of pools with the specified reward token\\n * @param rewardToken Reward token address\\n * @return Number of pools that distribute the specified token as a reward\\n */\\n function poolLength(address rewardToken) external view returns (uint256) {\\n return poolInfos[rewardToken].length;\\n }\\n\\n /**\\n * @notice Returns the number of reward tokens created per block or second\\n * @param _rewardToken Reward token address\\n * @return Number of reward tokens created per block or second\\n */\\n function rewardTokenAmountsPerBlock(address _rewardToken) external view returns (uint256) {\\n return rewardTokenAmountsPerBlockOrSecond[_rewardToken];\\n }\\n\\n /**\\n * @notice Add a new token pool\\n * @dev This vault DOES NOT support deflationary tokens \\u2014 it expects that\\n * the amount of transferred tokens would equal the actually deposited\\n * amount. In practice this means that this vault DOES NOT support USDT\\n * and similar tokens (that do not provide these guarantees).\\n * @param _rewardToken Reward token address\\n * @param _allocPoint Number of allocation points assigned to this pool\\n * @param _token Staked token\\n * @param _rewardPerBlockOrSecond Initial reward per block or second, in terms of _rewardToken\\n * @param _lockPeriod A period between withdrawal request and a moment when it's executable\\n */\\n function add(\\n address _rewardToken,\\n uint256 _allocPoint,\\n IBEP20 _token,\\n uint256 _rewardPerBlockOrSecond,\\n uint256 _lockPeriod\\n ) external {\\n _checkAccessAllowed(\\\"add(address,uint256,address,uint256,uint256)\\\");\\n _ensureNonzeroAddress(_rewardToken);\\n _ensureNonzeroAddress(address(_token));\\n require(address(xvsStore) != address(0), \\\"Store contract address is empty\\\");\\n require(_allocPoint > 0, \\\"Alloc points must not be zero\\\");\\n\\n massUpdatePools(_rewardToken);\\n\\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\\n\\n uint256 length = poolInfo.length;\\n for (uint256 pid = 0; pid < length; ++pid) {\\n require(poolInfo[pid].token != _token, \\\"Pool already added\\\");\\n }\\n\\n // We use balanceOf to get the supply amount, so shouldn't be possible to\\n // configure pools with different reward token but the same staked token\\n require(!isStakedToken[address(_token)], \\\"Token exists in other pool\\\");\\n\\n totalAllocPoints[_rewardToken] = totalAllocPoints[_rewardToken].add(_allocPoint);\\n\\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardPerBlockOrSecond;\\n\\n poolInfo.push(\\n PoolInfo({\\n token: _token,\\n allocPoint: _allocPoint,\\n lastRewardBlockOrSecond: getBlockNumberOrTimestamp(),\\n accRewardPerShare: 0,\\n lockPeriod: _lockPeriod\\n })\\n );\\n isStakedToken[address(_token)] = true;\\n\\n XVSStore(xvsStore).setRewardToken(_rewardToken, true);\\n\\n emit PoolAdded(\\n _rewardToken,\\n poolInfo.length - 1,\\n address(_token),\\n _allocPoint,\\n _rewardPerBlockOrSecond,\\n _lockPeriod\\n );\\n }\\n\\n /**\\n * @notice Update the given pool's reward allocation point\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n * @param _allocPoint Number of allocation points assigned to this pool\\n */\\n function set(address _rewardToken, uint256 _pid, uint256 _allocPoint) external {\\n _checkAccessAllowed(\\\"set(address,uint256,uint256)\\\");\\n _ensureValidPool(_rewardToken, _pid);\\n\\n massUpdatePools(_rewardToken);\\n\\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\\n uint256 newTotalAllocPoints = totalAllocPoints[_rewardToken].sub(poolInfo[_pid].allocPoint).add(_allocPoint);\\n require(newTotalAllocPoints > 0, \\\"Alloc points per reward token must not be zero\\\");\\n\\n uint256 oldAllocPoints = poolInfo[_pid].allocPoint;\\n poolInfo[_pid].allocPoint = _allocPoint;\\n totalAllocPoints[_rewardToken] = newTotalAllocPoints;\\n\\n emit PoolUpdated(_rewardToken, _pid, oldAllocPoints, _allocPoint);\\n }\\n\\n /**\\n * @notice Update the given reward token's amount per block or second\\n * @param _rewardToken Reward token address\\n * @param _rewardAmount Number of allocation points assigned to this pool\\n */\\n function setRewardAmountPerBlockOrSecond(address _rewardToken, uint256 _rewardAmount) external {\\n _checkAccessAllowed(\\\"setRewardAmountPerBlockOrSecond(address,uint256)\\\");\\n require(XVSStore(xvsStore).rewardTokens(_rewardToken), \\\"Invalid reward token\\\");\\n massUpdatePools(_rewardToken);\\n uint256 oldReward = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardAmount;\\n\\n emit RewardAmountUpdated(_rewardToken, oldReward, _rewardAmount);\\n }\\n\\n /**\\n * @notice Update the lock period after which a requested withdrawal can be executed\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n * @param _newPeriod New lock period\\n */\\n function setWithdrawalLockingPeriod(address _rewardToken, uint256 _pid, uint256 _newPeriod) external {\\n _checkAccessAllowed(\\\"setWithdrawalLockingPeriod(address,uint256,uint256)\\\");\\n _ensureValidPool(_rewardToken, _pid);\\n require(_newPeriod > 0 && _newPeriod < MAX_LOCK_PERIOD, \\\"Invalid new locking period\\\");\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n uint256 oldPeriod = pool.lockPeriod;\\n pool.lockPeriod = _newPeriod;\\n\\n emit WithdrawalLockingPeriodUpdated(_rewardToken, _pid, oldPeriod, _newPeriod);\\n }\\n\\n /**\\n * @notice Deposit XVSVault for XVS allocation\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _amount The amount to deposit to vault\\n */\\n function deposit(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\\n _updatePool(_rewardToken, _pid);\\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, msg.sender) == 0, \\\"execute pending withdrawal\\\");\\n\\n if (user.amount > 0) {\\n uint256 pending = _computeReward(user, pool);\\n if (pending > 0) {\\n _transferReward(_rewardToken, msg.sender, pending);\\n emit Claim(msg.sender, _rewardToken, _pid, pending);\\n }\\n }\\n pool.token.safeTransferFrom(msg.sender, address(this), _amount);\\n user.amount = user.amount.add(_amount);\\n user.rewardDebt = _cumulativeReward(user, pool);\\n\\n // Update Delegate Amount\\n if (address(pool.token) == xvsAddress) {\\n _moveDelegates(address(0), delegates[msg.sender], safe96(_amount, \\\"XVSVault::deposit: votes overflow\\\"));\\n }\\n\\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\\n primeToken.xvsUpdated(msg.sender);\\n }\\n\\n emit Deposit(msg.sender, _rewardToken, _pid, _amount);\\n }\\n\\n /**\\n * @notice Claim rewards for pool\\n * @param _account The account for which to claim rewards\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n */\\n function claim(address _account, address _rewardToken, uint256 _pid) external nonReentrant isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n UserInfo storage user = userInfos[_rewardToken][_pid][_account];\\n _updatePool(_rewardToken, _pid);\\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, _account) == 0, \\\"execute pending withdrawal\\\");\\n\\n if (user.amount > 0) {\\n uint256 pending = _computeReward(user, pool);\\n\\n if (pending > 0) {\\n user.rewardDebt = _cumulativeReward(user, pool);\\n\\n _transferReward(_rewardToken, _account, pending);\\n emit Claim(_account, _rewardToken, _pid, pending);\\n }\\n }\\n }\\n\\n /**\\n * @notice Pushes withdrawal request to the requests array and updates\\n * the pending withdrawals amount. The requests are always sorted\\n * by unlock time (descending) so that the earliest to execute requests\\n * are always at the end of the array.\\n * @param _user The user struct storage pointer\\n * @param _requests The user's requests array storage pointer\\n * @param _amount The amount being requested\\n */\\n function pushWithdrawalRequest(\\n UserInfo storage _user,\\n WithdrawalRequest[] storage _requests,\\n uint _amount,\\n uint _lockedUntil\\n ) internal {\\n uint i = _requests.length;\\n _requests.push(WithdrawalRequest(0, 0, 1));\\n // Keep it sorted so that the first to get unlocked request is always at the end\\n for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) {\\n _requests[i] = _requests[i - 1];\\n }\\n _requests[i] = WithdrawalRequest(_amount, _lockedUntil.toUint128(), 1);\\n _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount);\\n }\\n\\n /**\\n * @notice Pops the requests with unlock time < now from the requests\\n * array and deducts the computed amount from the user's pending\\n * withdrawals counter. Assumes that the requests array is sorted\\n * by unclock time (descending).\\n * @dev This function **removes** the eligible requests from the requests\\n * array. If this function is called, the withdrawal should actually\\n * happen (or the transaction should be reverted).\\n * @param _user The user struct storage pointer\\n * @param _requests The user's requests array storage pointer\\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade (this amount should be\\n * sent to the user, otherwise the state would be inconsistent).\\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade (this amount should be\\n * sent to the user, otherwise the state would be inconsistent).\\n */\\n function popEligibleWithdrawalRequests(\\n UserInfo storage _user,\\n WithdrawalRequest[] storage _requests\\n ) internal returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\\n // Since the requests are sorted by their unlock time, we can just\\n // pop them from the array and stop at the first not-yet-eligible one\\n for (uint i = _requests.length; i > 0 && isUnlocked(_requests[i - 1]); --i) {\\n if (_requests[i - 1].afterUpgrade == 1) {\\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\\n } else {\\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\\n }\\n\\n _requests.pop();\\n }\\n _user.pendingWithdrawals = _user.pendingWithdrawals.sub(\\n afterUpgradeWithdrawalAmount.add(beforeUpgradeWithdrawalAmount)\\n );\\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\\n }\\n\\n /**\\n * @notice Checks if the request is eligible for withdrawal.\\n * @param _request The request struct storage pointer\\n * @return True if the request is eligible for withdrawal, false otherwise\\n */\\n function isUnlocked(WithdrawalRequest storage _request) private view returns (bool) {\\n return _request.lockedUntil <= block.timestamp;\\n }\\n\\n /**\\n * @notice Execute withdrawal to XVSVault for XVS allocation\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n */\\n function executeWithdrawal(address _rewardToken, uint256 _pid) external nonReentrant isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\\n\\n uint256 beforeUpgradeWithdrawalAmount;\\n uint256 afterUpgradeWithdrawalAmount;\\n\\n (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount) = popEligibleWithdrawalRequests(user, requests);\\n require(beforeUpgradeWithdrawalAmount > 0 || afterUpgradeWithdrawalAmount > 0, \\\"nothing to withdraw\\\");\\n\\n // Having both old-style and new-style requests is not allowed and shouldn't be possible\\n require(beforeUpgradeWithdrawalAmount == 0 || afterUpgradeWithdrawalAmount == 0, \\\"inconsistent state\\\");\\n\\n if (beforeUpgradeWithdrawalAmount > 0) {\\n _updatePool(_rewardToken, _pid);\\n uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub(user.rewardDebt);\\n XVSStore(xvsStore).safeRewardTransfer(_rewardToken, msg.sender, pending);\\n user.amount = user.amount.sub(beforeUpgradeWithdrawalAmount);\\n user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);\\n pool.token.safeTransfer(address(msg.sender), beforeUpgradeWithdrawalAmount);\\n } else {\\n user.amount = user.amount.sub(afterUpgradeWithdrawalAmount);\\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].sub(\\n afterUpgradeWithdrawalAmount\\n );\\n pool.token.safeTransfer(address(msg.sender), afterUpgradeWithdrawalAmount);\\n }\\n\\n emit ExecutedWithdrawal(\\n msg.sender,\\n _rewardToken,\\n _pid,\\n beforeUpgradeWithdrawalAmount.add(afterUpgradeWithdrawalAmount)\\n );\\n }\\n\\n /**\\n * @notice Returns before and after upgrade pending withdrawal amount\\n * @param _requests The user's requests array storage pointer\\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade\\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade\\n */\\n function getRequestedWithdrawalAmount(\\n WithdrawalRequest[] storage _requests\\n ) internal view returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\\n for (uint i = _requests.length; i > 0; --i) {\\n if (_requests[i - 1].afterUpgrade == 1) {\\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\\n } else {\\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\\n }\\n }\\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\\n }\\n\\n /**\\n * @notice Request withdrawal to XVSVault for XVS allocation\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _amount The amount to withdraw from the vault\\n */\\n function requestWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n require(_amount > 0, \\\"requested amount cannot be zero\\\");\\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\\n require(user.amount >= user.pendingWithdrawals.add(_amount), \\\"requested amount is invalid\\\");\\n\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\\n\\n uint beforeUpgradeWithdrawalAmount;\\n\\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\\n require(beforeUpgradeWithdrawalAmount == 0, \\\"execute pending withdrawal\\\");\\n\\n _updatePool(_rewardToken, _pid);\\n uint256 pending = _computeReward(user, pool);\\n _transferReward(_rewardToken, msg.sender, pending);\\n\\n uint lockedUntil = pool.lockPeriod.add(block.timestamp);\\n\\n pushWithdrawalRequest(user, requests, _amount, lockedUntil);\\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].add(_amount);\\n user.rewardDebt = _cumulativeReward(user, pool);\\n\\n // Update Delegate Amount\\n if (address(pool.token) == xvsAddress) {\\n _moveDelegates(\\n delegates[msg.sender],\\n address(0),\\n safe96(_amount, \\\"XVSVault::requestWithdrawal: votes overflow\\\")\\n );\\n }\\n\\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\\n primeToken.xvsUpdated(msg.sender);\\n }\\n\\n emit Claim(msg.sender, _rewardToken, _pid, pending);\\n emit RequestedWithdrawal(msg.sender, _rewardToken, _pid, _amount);\\n }\\n\\n /**\\n * @notice Get unlocked withdrawal amount\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _user The User Address\\n * @return withdrawalAmount Amount that the user can withdraw\\n */\\n function getEligibleWithdrawalAmount(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) external view returns (uint withdrawalAmount) {\\n _ensureValidPool(_rewardToken, _pid);\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\\n // Since the requests are sorted by their unlock time, we can take\\n // the entries from the end of the array and stop at the first\\n // not-yet-eligible one\\n for (uint i = requests.length; i > 0 && isUnlocked(requests[i - 1]); --i) {\\n withdrawalAmount = withdrawalAmount.add(requests[i - 1].amount);\\n }\\n return withdrawalAmount;\\n }\\n\\n /**\\n * @notice Get requested amount\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _user The User Address\\n * @return Total amount of requested but not yet executed withdrawals (including both executable and locked ones)\\n */\\n function getRequestedAmount(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\\n _ensureValidPool(_rewardToken, _pid);\\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\\n return user.pendingWithdrawals;\\n }\\n\\n /**\\n * @notice Returns the array of withdrawal requests that have not been executed yet\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _user The User Address\\n * @return An array of withdrawal requests\\n */\\n function getWithdrawalRequests(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) external view returns (WithdrawalRequest[] memory) {\\n _ensureValidPool(_rewardToken, _pid);\\n return withdrawalRequests[_rewardToken][_pid][_user];\\n }\\n\\n /**\\n * @notice View function to see pending XVSs on frontend\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n * @param _user User address\\n * @return Reward the user is eligible for in this pool, in terms of _rewardToken\\n */\\n function pendingReward(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\\n _ensureValidPool(_rewardToken, _pid);\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\\n uint256 accRewardPerShare = pool.accRewardPerShare;\\n uint256 supply = pool.token.balanceOf(address(this)).sub(totalPendingWithdrawals[_rewardToken][_pid]);\\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\\n uint256 rewardTokenPerBlockOrSecond = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\\n if (curBlockNumberOrSecond > pool.lastRewardBlockOrSecond && supply != 0) {\\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\\n uint256 reward = multiplier.mul(rewardTokenPerBlockOrSecond).mul(pool.allocPoint).div(\\n totalAllocPoints[_rewardToken]\\n );\\n accRewardPerShare = accRewardPerShare.add(reward.mul(1e12).div(supply));\\n }\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\\n (, uint256 afterUpgradeWithdrawalAmount) = getRequestedWithdrawalAmount(requests);\\n return user.amount.sub(afterUpgradeWithdrawalAmount).mul(accRewardPerShare).div(1e12).sub(user.rewardDebt);\\n }\\n\\n // Update reward variables for all pools. Be careful of gas spending!\\n function massUpdatePools(address _rewardToken) internal {\\n uint256 length = poolInfos[_rewardToken].length;\\n for (uint256 pid = 0; pid < length; ++pid) {\\n _updatePool(_rewardToken, pid);\\n }\\n }\\n\\n /**\\n * @notice Update reward variables of the given pool to be up-to-date\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n */\\n function updatePool(address _rewardToken, uint256 _pid) external isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n _updatePool(_rewardToken, _pid);\\n }\\n\\n // Update reward variables of the given pool to be up-to-date.\\n function _updatePool(address _rewardToken, uint256 _pid) internal {\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n if (getBlockNumberOrTimestamp() <= pool.lastRewardBlockOrSecond) {\\n return;\\n }\\n uint256 supply = pool.token.balanceOf(address(this));\\n supply = supply.sub(totalPendingWithdrawals[_rewardToken][_pid]);\\n if (supply == 0) {\\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\\n return;\\n }\\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\\n uint256 reward = multiplier.mul(rewardTokenAmountsPerBlockOrSecond[_rewardToken]).mul(pool.allocPoint).div(\\n totalAllocPoints[_rewardToken]\\n );\\n pool.accRewardPerShare = pool.accRewardPerShare.add(reward.mul(1e12).div(supply));\\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\\n }\\n\\n function _ensureValidPool(address rewardToken, uint256 pid) internal view {\\n require(pid < poolInfos[rewardToken].length, \\\"vault: pool exists?\\\");\\n }\\n\\n /**\\n * @notice Get user info with reward token address and pid\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n * @param _user User address\\n * @return amount Deposited amount\\n * @return rewardDebt Reward debt (technical value used to track past payouts)\\n * @return pendingWithdrawals Requested but not yet executed withdrawals\\n */\\n function getUserInfo(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals) {\\n _ensureValidPool(_rewardToken, _pid);\\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\\n amount = user.amount;\\n rewardDebt = user.rewardDebt;\\n pendingWithdrawals = user.pendingWithdrawals;\\n }\\n\\n /**\\n * @notice Gets the total pending withdrawal amount of a user before upgrade\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _user The address of the user\\n * @return beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade\\n */\\n function pendingWithdrawalsBeforeUpgrade(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) public view returns (uint256 beforeUpgradeWithdrawalAmount) {\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\\n return beforeUpgradeWithdrawalAmount;\\n }\\n\\n /**\\n * @notice Get the XVS stake balance of an account (excluding the pending withdrawals)\\n * @param account The address of the account to check\\n * @return The balance that user staked\\n */\\n function getStakeAmount(address account) internal view returns (uint96) {\\n require(xvsAddress != address(0), \\\"XVSVault::getStakeAmount: xvs address is not set\\\");\\n\\n PoolInfo[] storage poolInfo = poolInfos[xvsAddress];\\n\\n uint256 length = poolInfo.length;\\n for (uint256 pid = 0; pid < length; ++pid) {\\n if (address(poolInfo[pid].token) == address(xvsAddress)) {\\n UserInfo storage user = userInfos[xvsAddress][pid][account];\\n return safe96(user.amount.sub(user.pendingWithdrawals), \\\"XVSVault::getStakeAmount: votes overflow\\\");\\n }\\n }\\n return uint96(0);\\n }\\n\\n /**\\n * @notice Delegate votes from `msg.sender` to `delegatee`\\n * @param delegatee The address to delegate votes to\\n */\\n function delegate(address delegatee) external isActive {\\n return _delegate(msg.sender, delegatee);\\n }\\n\\n /**\\n * @notice Delegates votes from signatory to `delegatee`\\n * @param delegatee The address to delegate votes to\\n * @param nonce The contract state required to match the signature\\n * @param expiry The time at which to expire the signature\\n * @param v The recovery byte of the signature\\n * @param r Half of the ECDSA signature pair\\n * @param s Half of the ECDSA signature pair\\n */\\n function delegateBySig(\\n address delegatee,\\n uint nonce,\\n uint expiry,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external isActive {\\n bytes32 domainSeparator = keccak256(\\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(\\\"XVSVault\\\")), getChainId(), address(this))\\n );\\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\\n bytes32 digest = keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n address signatory = ECDSA.recover(digest, v, r, s);\\n require(nonce == nonces[signatory]++, \\\"XVSVault::delegateBySig: invalid nonce\\\");\\n require(block.timestamp <= expiry, \\\"XVSVault::delegateBySig: signature expired\\\");\\n return _delegate(signatory, delegatee);\\n }\\n\\n /**\\n * @notice Gets the current votes balance for `account`\\n * @param account The address to get votes balance\\n * @return The number of current votes for `account`\\n */\\n function getCurrentVotes(address account) external view returns (uint96) {\\n uint32 nCheckpoints = numCheckpoints[account];\\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\\n }\\n\\n function _delegate(address delegator, address delegatee) internal {\\n address currentDelegate = delegates[delegator];\\n uint96 delegatorBalance = getStakeAmount(delegator);\\n delegates[delegator] = delegatee;\\n\\n emit DelegateChangedV2(delegator, currentDelegate, delegatee);\\n\\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\\n }\\n\\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\\n if (srcRep != dstRep && amount > 0) {\\n if (srcRep != address(0)) {\\n uint32 srcRepNum = numCheckpoints[srcRep];\\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\\n uint96 srcRepNew = sub96(srcRepOld, amount, \\\"XVSVault::_moveVotes: vote amount underflows\\\");\\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\\n }\\n\\n if (dstRep != address(0)) {\\n uint32 dstRepNum = numCheckpoints[dstRep];\\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\\n uint96 dstRepNew = add96(dstRepOld, amount, \\\"XVSVault::_moveVotes: vote amount overflows\\\");\\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\\n }\\n }\\n }\\n\\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\\n uint32 blockNumberOrSecond = safe32(\\n getBlockNumberOrTimestamp(),\\n \\\"XVSVault::_writeCheckpoint: block number or second exceeds 32 bits\\\"\\n );\\n\\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlockOrSecond == blockNumberOrSecond) {\\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\\n } else {\\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumberOrSecond, newVotes);\\n numCheckpoints[delegatee] = nCheckpoints + 1;\\n }\\n\\n emit DelegateVotesChangedV2(delegatee, oldVotes, newVotes);\\n }\\n\\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2 ** 32, errorMessage);\\n return uint32(n);\\n }\\n\\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\\n require(n < 2 ** 96, errorMessage);\\n return uint96(n);\\n }\\n\\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\\n uint96 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function getChainId() internal pure returns (uint) {\\n uint256 chainId;\\n assembly {\\n chainId := chainid()\\n }\\n return chainId;\\n }\\n\\n /**\\n * @notice Determine the xvs stake balance for an account\\n * @param account The address of the account to check\\n * @param blockNumberOrSecond The block number or second to get the vote balance at\\n * @return The balance that user staked\\n */\\n function getPriorVotes(address account, uint256 blockNumberOrSecond) external view returns (uint96) {\\n require(blockNumberOrSecond < getBlockNumberOrTimestamp(), \\\"XVSVault::getPriorVotes: not yet determined\\\");\\n\\n uint32 nCheckpoints = numCheckpoints[account];\\n if (nCheckpoints == 0) {\\n return 0;\\n }\\n\\n // First check most recent balance\\n if (checkpoints[account][nCheckpoints - 1].fromBlockOrSecond <= blockNumberOrSecond) {\\n return checkpoints[account][nCheckpoints - 1].votes;\\n }\\n\\n // Next check implicit zero balance\\n if (checkpoints[account][0].fromBlockOrSecond > blockNumberOrSecond) {\\n return 0;\\n }\\n\\n uint32 lower = 0;\\n uint32 upper = nCheckpoints - 1;\\n while (upper > lower) {\\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\\n Checkpoint memory cp = checkpoints[account][center];\\n if (cp.fromBlockOrSecond == blockNumberOrSecond) {\\n return cp.votes;\\n } else if (cp.fromBlockOrSecond < blockNumberOrSecond) {\\n lower = center;\\n } else {\\n upper = center - 1;\\n }\\n }\\n return checkpoints[account][lower].votes;\\n }\\n\\n /*** Admin Functions ***/\\n\\n function _become(XVSVaultProxy xvsVaultProxy) external {\\n require(msg.sender == xvsVaultProxy.admin(), \\\"only proxy admin can change brains\\\");\\n require(xvsVaultProxy._acceptImplementation() == 0, \\\"change not authorized\\\");\\n }\\n\\n function setXvsStore(address _xvs, address _xvsStore) external onlyAdmin {\\n _ensureNonzeroAddress(_xvs);\\n _ensureNonzeroAddress(_xvsStore);\\n\\n address oldXvsContract = xvsAddress;\\n address oldStore = xvsStore;\\n require(oldXvsContract == address(0), \\\"already initialized\\\");\\n\\n xvsAddress = _xvs;\\n xvsStore = _xvsStore;\\n\\n _notEntered = true;\\n\\n emit StoreUpdated(oldXvsContract, oldStore, _xvs, _xvsStore);\\n }\\n\\n /**\\n * @notice Sets the address of the prime token contract\\n * @param _primeToken address of the prime token contract\\n * @param _primeRewardToken address of reward token\\n * @param _primePoolId pool id for reward\\n */\\n function setPrimeToken(IPrime _primeToken, address _primeRewardToken, uint256 _primePoolId) external onlyAdmin {\\n require(address(_primeToken) != address(0), \\\"prime token cannot be zero address\\\");\\n require(_primeRewardToken != address(0), \\\"reward cannot be zero address\\\");\\n\\n _ensureValidPool(_primeRewardToken, _primePoolId);\\n\\n emit NewPrimeToken(primeToken, _primeToken, primeRewardToken, _primeRewardToken, primePoolId, _primePoolId);\\n\\n primeToken = _primeToken;\\n primeRewardToken = _primeRewardToken;\\n primePoolId = _primePoolId;\\n }\\n\\n /**\\n * @dev Initializes the contract to use either blocks or seconds\\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\\n * @param blocksPerYear_ The number of blocks per year\\n */\\n function initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) external onlyAdmin {\\n _initializeTimeManager(timeBased_, blocksPerYear_);\\n }\\n\\n /**\\n * @notice Sets the address of the access control of this contract\\n * @dev Admin function to set the access control address\\n * @param newAccessControlAddress New address for the access control\\n */\\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\\n _setAccessControlManager(newAccessControlAddress);\\n }\\n\\n /**\\n * @dev Reverts if the provided address is a zero address\\n * @param address_ Address to check\\n */\\n function _ensureNonzeroAddress(address address_) internal pure {\\n require(address_ != address(0), \\\"zero address not allowed\\\");\\n }\\n\\n /**\\n * @dev Transfers the reward to the user, taking into account the rewards store\\n * balance and the previous debt. If there are not enough rewards in the store,\\n * transfers the available funds and records the debt amount in pendingRewardTransfers.\\n * @param rewardToken Reward token address\\n * @param userAddress User address\\n * @param amount Reward amount, in reward tokens\\n */\\n function _transferReward(address rewardToken, address userAddress, uint256 amount) internal {\\n address xvsStore_ = xvsStore;\\n uint256 storeBalance = IBEP20(rewardToken).balanceOf(xvsStore_);\\n uint256 debtDueToFailedTransfers = pendingRewardTransfers[rewardToken][userAddress];\\n uint256 fullAmount = amount.add(debtDueToFailedTransfers);\\n\\n if (fullAmount <= storeBalance) {\\n if (debtDueToFailedTransfers != 0) {\\n pendingRewardTransfers[rewardToken][userAddress] = 0;\\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, 0);\\n }\\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, fullAmount);\\n return;\\n }\\n // Overflow isn't possible due to the check above\\n uint256 newOwedAmount = fullAmount - storeBalance;\\n pendingRewardTransfers[rewardToken][userAddress] = newOwedAmount;\\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, newOwedAmount);\\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, storeBalance);\\n }\\n\\n /**\\n * @dev Computes cumulative reward for all user's shares\\n * @param user UserInfo storage struct\\n * @param pool PoolInfo storage struct\\n */\\n function _cumulativeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\\n return user.amount.sub(user.pendingWithdrawals).mul(pool.accRewardPerShare).div(1e12);\\n }\\n\\n /**\\n * @dev Computes the reward for all user's shares\\n * @param user UserInfo storage struct\\n * @param pool PoolInfo storage struct\\n */\\n function _computeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\\n return _cumulativeReward(user, pool).sub(user.rewardDebt);\\n }\\n}\\n\",\"keccak256\":\"0xb60ac3238f6c088bc105fd784fb15e7e8d3e7c8fd14640f1945563c0ecd1a68c\"},\"contracts/XVSVault/XVSVaultErrorReporter.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\ncontract XVSVaultErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint error, uint info, uint detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint) {\\n emit Failure(uint(err), uint(info), 0);\\n\\n return uint(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\\n emit Failure(uint(err), uint(info), opaqueError);\\n\\n return uint(err);\\n }\\n}\\n\",\"keccak256\":\"0xa79877a281d024f0d03dbf1842a36a972ee6c1aa36ba93e3d646726d40684a26\"},\"contracts/XVSVault/XVSVaultProxy.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"./XVSVaultStorage.sol\\\";\\nimport \\\"./XVSVaultErrorReporter.sol\\\";\\n\\n/**\\n * @title XVS Vault Proxy\\n * @author Venus\\n * @notice XVS Vault Proxy contract\\n */\\ncontract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter {\\n /**\\n * @notice Emitted when pendingXVSVaultImplementation is changed\\n */\\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\\n\\n /**\\n * @notice Emitted when pendingXVSVaultImplementation is accepted, which means XVS Vault implementation is updated\\n */\\n event NewImplementation(address oldImplementation, address newImplementation);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor() public {\\n // Set admin to caller\\n admin = msg.sender;\\n }\\n\\n /*** Admin Functions ***/\\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\\n if (msg.sender != admin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\\n }\\n\\n address oldPendingImplementation = pendingXVSVaultImplementation;\\n\\n pendingXVSVaultImplementation = newPendingImplementation;\\n\\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\\n * @dev Admin function for new implementation to accept it's role as implementation\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptImplementation() public returns (uint) {\\n // Check caller is pendingImplementation\\n if (msg.sender != pendingXVSVaultImplementation) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldImplementation = implementation;\\n address oldPendingImplementation = pendingXVSVaultImplementation;\\n\\n implementation = pendingXVSVaultImplementation;\\n\\n pendingXVSVaultImplementation = address(0);\\n\\n emit NewImplementation(oldImplementation, implementation);\\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\\n // Check caller = admin\\n if (msg.sender != admin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n // Save current value, if any, for inclusion in log\\n address oldPendingAdmin = pendingAdmin;\\n\\n // Store pendingAdmin with value newPendingAdmin\\n pendingAdmin = newPendingAdmin;\\n\\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint) {\\n // Check caller is pendingAdmin\\n if (msg.sender != pendingAdmin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n // Store admin with value pendingAdmin\\n admin = pendingAdmin;\\n\\n // Clear the pending value\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @dev Delegates execution to an implementation contract.\\n * It returns to the external caller whatever the implementation returns\\n * or forwards reverts.\\n */\\n function() external payable {\\n // delegate all other functions to current implementation\\n (bool success, ) = implementation.delegatecall(msg.data);\\n\\n assembly {\\n let free_mem_ptr := mload(0x40)\\n returndatacopy(free_mem_ptr, 0, returndatasize)\\n\\n switch success\\n case 0 {\\n revert(free_mem_ptr, returndatasize)\\n }\\n default {\\n return(free_mem_ptr, returndatasize)\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb39af917833659fe38f2f76924deda420babed8259b27741dc6cb402ade4d124\"},\"contracts/XVSVault/XVSVaultStorage.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"../Utils/SafeMath.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\nimport \\\"../Tokens/Prime/IPrime.sol\\\";\\n\\ncontract XVSVaultAdminStorage {\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Active brains of XVS Vault\\n */\\n address public implementation;\\n\\n /**\\n * @notice Pending brains of XVS Vault\\n */\\n address public pendingXVSVaultImplementation;\\n}\\n\\ncontract XVSVaultStorageV1 is XVSVaultAdminStorage {\\n /// @notice Guard variable for re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @notice The reward token store\\n address public xvsStore;\\n\\n /// @notice The xvs token address\\n address public xvsAddress;\\n\\n // Reward tokens created per block or second indentified by reward token address.\\n mapping(address => uint256) public rewardTokenAmountsPerBlockOrSecond;\\n\\n /// @notice Info of each user.\\n struct UserInfo {\\n uint256 amount;\\n uint256 rewardDebt;\\n uint256 pendingWithdrawals;\\n }\\n\\n // Info of each pool.\\n struct PoolInfo {\\n IBEP20 token; // Address of token contract to stake.\\n uint256 allocPoint; // How many allocation points assigned to this pool.\\n uint256 lastRewardBlockOrSecond; // Last block number or second that reward tokens distribution occurs.\\n uint256 accRewardPerShare; // Accumulated per share, times 1e12. See below.\\n uint256 lockPeriod; // Min time between withdrawal request and its execution.\\n }\\n\\n // Infomation about a withdrawal request\\n struct WithdrawalRequest {\\n uint256 amount;\\n uint128 lockedUntil;\\n uint128 afterUpgrade;\\n }\\n\\n // Info of each user that stakes tokens.\\n mapping(address => mapping(uint256 => mapping(address => UserInfo))) internal userInfos;\\n\\n // Info of each pool.\\n mapping(address => PoolInfo[]) public poolInfos;\\n\\n // Total allocation points. Must be the sum of all allocation points in all pools.\\n mapping(address => uint256) public totalAllocPoints;\\n\\n // Info of requested but not yet executed withdrawals\\n mapping(address => mapping(uint256 => mapping(address => WithdrawalRequest[]))) internal withdrawalRequests;\\n\\n /// @notice DEPRECATED A record of each accounts delegate (before the voting power fix)\\n mapping(address => address) private __oldDelegatesSlot;\\n\\n /// @notice A checkpoint for marking number of votes from a given block or second\\n struct Checkpoint {\\n uint32 fromBlockOrSecond;\\n uint96 votes;\\n }\\n\\n /// @notice DEPRECATED A record of votes checkpoints for each account, by index (before the voting power fix)\\n mapping(address => mapping(uint32 => Checkpoint)) private __oldCheckpointsSlot;\\n\\n /// @notice DEPRECATED The number of checkpoints for each account (before the voting power fix)\\n mapping(address => uint32) private __oldNumCheckpointsSlot;\\n\\n /// @notice A record of states for signing / validating signatures\\n mapping(address => uint) public nonces;\\n\\n /// @notice The EIP-712 typehash for the contract's domain\\n bytes32 public constant DOMAIN_TYPEHASH =\\n keccak256(\\\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\\\");\\n\\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\\\");\\n}\\n\\ncontract XVSVaultStorage is XVSVaultStorageV1 {\\n /// @notice A record of each accounts delegate\\n mapping(address => address) public delegates;\\n\\n /// @notice A record of votes checkpoints for each account, by index\\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\\n\\n /// @notice The number of checkpoints for each account\\n mapping(address => uint32) public numCheckpoints;\\n\\n /// @notice Tracks pending withdrawals for all users for a particular reward token and pool id\\n mapping(address => mapping(uint256 => uint256)) public totalPendingWithdrawals;\\n\\n /// @notice pause indicator for Vault\\n bool public vaultPaused;\\n\\n /// @notice if the token is added to any of the pools\\n mapping(address => bool) public isStakedToken;\\n\\n /// @notice Amount we owe to users because of failed transfer attempts\\n mapping(address => mapping(address => uint256)) public pendingRewardTransfers;\\n\\n /// @notice Prime token contract address\\n IPrime public primeToken;\\n\\n /// @notice Reward token for which prime token is issued for staking\\n address public primeRewardToken;\\n\\n /// @notice Pool ID for which prime token is issued for staking\\n uint256 public primePoolId;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[46] private __gap;\\n}\\n\",\"keccak256\":\"0xb09f9295c41bdac1350a3607f2b4ea326cb295a6d08f4145bc33ff87844cd02b\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905561578980620000336000396000f3fe608060405234801561001057600080fd5b50600436106103785760003560e01c806392e35000116101d3578063c7ad089511610104578063e7a324dc116100a2578063f55401621161007c578063f554016214610732578063f851a4401461073a578063fba1b1f914610742578063fe5a451a1461075557610378565b8063e7a324dc14610701578063e8f2be6f14610709578063f1127ed81461071157610378565b8063dae66bbe116100de578063dae66bbe146106d6578063de0368b2146106e9578063e1d146fb146106f1578063e6a69ab8146106f957610378565b8063c7ad0895146106a8578063cd9b94e7146106b0578063d7ae45e2146106c357610378565b8063add8933711610171578063b6a5fd2f1161014b578063b6a5fd2f1461064f578063c210259614610662578063c3c754a814610682578063c3cda5201461069557610378565b8063add893371461061f578063b4a0bdf314610627578063b4b5ea571461063c57610378565b80639e2b6c4d116101ad5780639e2b6c4d146105d3578063a09eab7a146105e6578063a6997762146105f9578063a9d69a691461060c57610378565b806392e350001461057a57806398e1b31b1461059e578063996cba68146105c057610378565b80635c19a95c116102ad57806373d025d61161024b5780637ecebe00116102255780637ecebe00146105395780638308d7e91461054c5780638456cb591461055f5780638ed7333d1461056757610378565b806373d025d6146104f1578063782d6fe1146105065780637ac924561461052657610378565b80635ff56315116102875780635ff56315146104a35780636857249c146104b65780636dd77cbd146104be5780636fcfff45146104d157610378565b80635c19a95c146104755780635c60da1b146104885780635f14e7001461049057610378565b806324f52bbf1161031a578063358ae036116102f4578063358ae036146104345780633d4180f91461043c5780634298bdbd1461044f578063587cde1e1461046257610378565b806324f52bbf1461040457806326782247146104195780632eda5c6c1461042157610378565b8063115b512f11610356578063115b512f146103c357806319129e5a146103d65780631d504dc6146103e957806320606b70146103fc57610378565b8063046f7da21461037d5780630af13728146103875780630efe6a8b146103b0575b600080fd5b61038561075d565b005b61039a6103953660046140be565b6107e8565b6040516103a791906150ae565b60405180910390f35b6103856103be366004614176565b61082e565b6103856103d1366004614176565b610b23565b6103856103e4366004613fcb565b610ed7565b6103856103f73660046142bd565b610f0d565b61039a61103e565b61040c611055565b6040516103a79190614f4c565b61040c611064565b61039a61042f366004613fcb565b611073565b61040c611092565b61039a61044a366004614007565b6110a1565b61039a61045d366004613fcb565b6110be565b61040c610470366004613fcb565b6110d0565b610385610483366004613fcb565b6110eb565b61040c611118565b61039a61049e36600461408e565b611127565b6103856104b1366004614007565b611144565b61039a611238565b61039a6104cc3660046140be565b61123e565b6104e46104df366004613fcb565b6112f3565b6040516103a7919061545c565b6104f961130b565b6040516103a791906150a0565b61051961051436600461408e565b611314565b6040516103a79190615485565b61038561053436600461408e565b61152a565b61039a610547366004613fcb565b611873565b61038561055a366004614176565b611885565b610385611a2b565b61038561057536600461408e565b611ab0565b61058d61058836600461408e565b611aeb565b6040516103a795949392919061511b565b6105b16105ac3660046140be565b611b40565b6040516103a793929190615441565b6103856105ce366004614041565b611b92565b6103856105e1366004614176565b611d24565b61039a6105f43660046140be565b611e0f565b61038561060736600461427d565b61205f565b61039a61061a3660046140be565b612093565b61040c6120d5565b61062f6120e4565b6040516103a7919061510d565b61051961064a366004613fcb565b6120f3565b61038561065d36600461408e565b612163565b6106756106703660046140be565b612289565b6040516103a7919061508f565b6104f9610690366004613fcb565b612343565b6103856106a33660046141a8565b612358565b6104f96124fc565b61039a6106be366004613fcb565b612505565b61039a6106d1366004613fcb565b612517565b6103856106e436600461429c565b612532565b61040c61263e565b61039a61264d565b61039a612674565b61039a61267c565b61039a612688565b61072461071f36600461422f565b61268e565b6040516103a792919061546a565b61039a6126c3565b61040c6126cb565b610385610750366004614101565b6126da565b61062f6129bf565b61078660405180604001604052806008815260200167726573756d65282960c01b8152506129ce565b60135460ff166107b15760405162461bcd60e51b81526004016107a8906151d8565b60405180910390fd5b6013805460ff1916905560405133907fd2619572a1464e0df0bb351d834fd47f3350984d7bfdb1ab69cfcb0b8e42141590600090a2565b60006107f48484612a70565b506001600160a01b0380841660009081526007602090815260408083208684528252808320938516835292905220600201545b9392505050565b600354600160a01b900460ff166108575760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff16156108875760405162461bcd60e51b81526004016107a8906151c8565b6108918383612a70565b6001600160a01b03831660009081526008602052604081208054849081106108b557fe5b600091825260208083206001600160a01b038816845260078252604080852088865283528085203386529092529220600590910290910191506108f88585612aa7565b610903858533612093565b156109205760405162461bcd60e51b81526004016107a8906152e8565b8054156109955760006109338284612c84565b9050801561099357610946863383612c98565b84866001600160a01b0316336001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946458460405161098a91906150ae565b60405180910390a45b505b81546109b2906001600160a01b031633308663ffffffff612f1116565b80546109c4908463ffffffff612f7216565b81556109d08183612fb4565b600182015560055482546001600160a01b0390811691161415610a3757336000908152600f60209081526040808320548151606081019092526021808352610a3794936001600160a01b0390921692610a329289929061562990830139612fe2565b613011565b6017546001600160a01b038681169116148015610a55575060185484145b15610abd576016546040516337f23cd360e01b81526001600160a01b03909116906337f23cd390610a8a903390600401614f5a565b600060405180830381600087803b158015610aa457600080fd5b505af1158015610ab8573d6000803e3d6000fd5b505050505b83856001600160a01b0316336001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d786604051610b0191906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b179055505050565b600354600160a01b900460ff16610b4c5760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff1615610b7c5760405162461bcd60e51b81526004016107a8906151c8565b610b868383612a70565b60008111610ba65760405162461bcd60e51b81526004016107a890615308565b6001600160a01b0383166000908152600760209081526040808320858452825280832033845290915290206002810154610be6908363ffffffff612f7216565b81541015610c065760405162461bcd60e51b81526004016107a8906153e8565b6001600160a01b0384166000908152600860205260408120805485908110610c2a57fe5b600091825260208083206001600160a01b0389168452600a825260408085208986528352808520338652909252908320600590920201925090610c6c826131a3565b5090508015610c8d5760405162461bcd60e51b81526004016107a8906152e8565b610c978787612aa7565b6000610ca38585612c84565b9050610cb0883383612c98565b6004840154600090610cc8904263ffffffff612f7216565b9050610cd686858984613247565b6001600160a01b03891660009081526012602090815260408083208b8452909152902054610d0a908863ffffffff612f7216565b6001600160a01b038a1660009081526012602090815260408083208c8452909152902055610d388686612fb4565b600187015560055485546001600160a01b0390811691161415610d9b57336000908152600f6020908152604080832054815160608101909252602b808352610d9b946001600160a01b03909216939192610a32928d92906155d690830139612fe2565b6017546001600160a01b038a81169116148015610db9575060185488145b15610e21576016546040516337f23cd360e01b81526001600160a01b03909116906337f23cd390610dee903390600401614f5a565b600060405180830381600087803b158015610e0857600080fd5b505af1158015610e1c573d6000803e3d6000fd5b505050505b87896001600160a01b0316336001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464585604051610e6591906150ae565b60405180910390a487896001600160a01b0316336001600160a01b03167f88a254a0ef28a0b9e957ff600beae69870f6f924065147f3627c3f814e60ec118a604051610eb191906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b17905550505050505050565b6000546001600160a01b03163314610f015760405162461bcd60e51b81526004016107a890615368565b610f0a8161342b565b50565b806001600160a01b031663f851a4406040518163ffffffff1660e01b815260040160206040518083038186803b158015610f4657600080fd5b505afa158015610f5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f7e9190810190613fe9565b6001600160a01b0316336001600160a01b031614610fae5760405162461bcd60e51b81526004016107a8906153f8565b806001600160a01b031663c1e803346040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610fe957600080fd5b505af1158015610ffd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061102191908101906142db565b15610f0a5760405162461bcd60e51b81526004016107a890615378565b60405161104a90614f36565b604051809103902081565b6004546001600160a01b031681565b6001546001600160a01b031681565b6001600160a01b0381166000908152600660205260409020545b919050565b6005546001600160a01b031681565b601560209081526000928352604080842090915290825290205481565b60096020526000908152604090205481565b600f602052600090815260409020546001600160a01b031681565b60135460ff161561110e5760405162461bcd60e51b81526004016107a8906151c8565b610f0a33826134b0565b6002546001600160a01b031681565b601260209081526000928352604080842090915290825290205481565b6000546001600160a01b0316331461116e5760405162461bcd60e51b81526004016107a890615368565b6111778261353f565b6111808161353f565b6005546004546001600160a01b03918216911681156111b15760405162461bcd60e51b81526004016107a8906152a8565b600580546001600160a01b038087166001600160a01b03199283161790925560048054928616929091169190911790556003805460ff60a01b1916600160a01b1790556040517f559f314bb90394a4a9ceb724f365b36a53587d894352c43d12901fd6801014569061122a908490849088908890614fcb565b60405180910390a150505050565b60795481565b600061124a8484612a70565b6001600160a01b038085166000908152600a60209081526040808320878452825280832093861683529290522080545b6000811180156112aa57506112aa82600183038154811061129757fe5b9060005260206000209060020201613565565b156112ea576112df8260018303815481106112c157fe5b6000918252602090912060029091020154849063ffffffff612f7216565b92506000190161127a565b50509392505050565b60116020526000908152604090205463ffffffff1681565b60135460ff1681565b600061131e61264d565b821061133c5760405162461bcd60e51b81526004016107a8906152b8565b6001600160a01b03831660009081526011602052604090205463ffffffff168061136a576000915050611524565b6001600160a01b038416600090815260106020908152604080832063ffffffff6000198601811685529252909120541683106113e6576001600160a01b03841660009081526010602090815260408083206000199490940163ffffffff1683529290522054600160201b90046001600160601b03169050611524565b6001600160a01b038416600090815260106020908152604080832083805290915290205463ffffffff16831015611421576000915050611524565b600060001982015b8163ffffffff168163ffffffff1611156114e457600282820363ffffffff16048103611453613f51565b506001600160a01b038716600090815260106020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b031691810191909152908714156114bf576020015194506115249350505050565b805163ffffffff168711156114d6578193506114dd565b6001820392505b5050611429565b506001600160a01b038516600090815260106020908152604080832063ffffffff909416835292905220546001600160601b03600160201b909104169150505b92915050565b600354600160a01b900460ff166115535760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff16156115835760405162461bcd60e51b81526004016107a8906151c8565b61158d8282612a70565b6001600160a01b03821660009081526008602052604081208054839081106115b157fe5b600091825260208083206001600160a01b038716808552600783526040808620888752845280862033808852908552818720928752600a8552818720898852855281872090875290935291842060059093020193509180611612848461357a565b9092509050811515806116255750600081115b6116415760405162461bcd60e51b81526004016107a890615388565b81158061164c575080155b6116685760405162461bcd60e51b81526004016107a890615188565b8115611781576116788787612aa7565b60006116be85600101546116b264e8d4a510006116a68a600301548a6000015461367190919063ffffffff16565b9063ffffffff6136ab16565b9063ffffffff6136ed16565b6004805460405163135b33cd60e31b81529293506001600160a01b031691639ad99e68916116f2918c913391879101614fa3565b600060405180830381600087803b15801561170c57600080fd5b505af1158015611720573d6000803e3d6000fd5b50508654611737925090508463ffffffff6136ed16565b808655600387015461175a9164e8d4a51000916116a6919063ffffffff61367116565b6001860155855461177b906001600160a01b0316338563ffffffff61372f16565b50611805565b8354611793908263ffffffff6136ed16565b84556001600160a01b03871660009081526012602090815260408083208984529091529020546117c9908263ffffffff6136ed16565b6001600160a01b0380891660009081526012602090815260408083208b845290915290209190915585546118059116338363ffffffff61372f16565b856001600160a01b038816337fe31da05fae6db869f5ea51f4b638aa6884070b6c87f18f63bd2291a12cb2f518611842868663ffffffff612f7216565b60405161184f91906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b1790555050505050565b600e6020526000908152604090205481565b6118c36040518060400160405280601c81526020017f73657428616464726573732c75696e743235362c75696e7432353629000000008152506129ce565b6118cd8383612a70565b6118d683613751565b6001600160a01b0383166000908152600860205260408120805490919061194f9084906119439085908890811061190957fe5b60009182526020808320600160059093020191909101546001600160a01b038b16835260099091526040909120549063ffffffff6136ed16565b9063ffffffff612f7216565b9050600081116119715760405162461bcd60e51b81526004016107a890615408565b600082858154811061197f57fe5b9060005260206000209060050201600101549050838386815481106119a057fe5b9060005260206000209060050201600101819055508160096000886001600160a01b03166001600160a01b031681526020019081526020016000208190555084866001600160a01b03167f6ee09c6cb801194690c195c69f465aaf7c80255cbeafaab9600f47ed79de2ca98387604051611a1b929190615433565b60405180910390a3505050505050565b611a53604051806040016040528060078152602001667061757365282960c81b8152506129ce565b60135460ff1615611a765760405162461bcd60e51b81526004016107a890615268565b6013805460ff1916600117905560405133907fdffada2889ebfab9224c24069d833f3de835d8cf99872d49e7b7ba5fccb7a46f90600090a2565b60135460ff1615611ad35760405162461bcd60e51b81526004016107a8906151c8565b611add8282612a70565b611ae78282612aa7565b5050565b60086020528160005260406000208181548110611b0457fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b039093169550909350919085565b6000806000611b4f8686612a70565b5050506001600160a01b03928316600090815260076020908152604080832094835293815283822092909416815292529020805460018201546002909201549092565b600354600160a01b900460ff16611bbb5760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff1615611beb5760405162461bcd60e51b81526004016107a8906151c8565b611bf58282612a70565b6001600160a01b0382166000908152600860205260408120805483908110611c1957fe5b600091825260208083206001600160a01b0380881685526007835260408086208887528452808620918a1686529252922060059091029091019150611c5e8484612aa7565b611c69848487612093565b15611c865760405162461bcd60e51b81526004016107a8906152e8565b805415611d0a576000611c998284612c84565b90508015611d0857611cab8284612fb4565b6001830155611cbb858783612c98565b83856001600160a01b0316876001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464584604051611cff91906150ae565b60405180910390a45b505b50506003805460ff60a01b1916600160a01b179055505050565b611d4560405180606001604052806033815260200161568c603391396129ce565b611d4f8383612a70565b600081118015611d6257506312cc030081105b611d7e5760405162461bcd60e51b81526004016107a890615398565b6001600160a01b0383166000908152600860205260408120805484908110611da257fe5b9060005260206000209060050201905060008160040154905082826004018190555083856001600160a01b03167f0bcf80c5060ccf99b7a993c57a94b232fc2c5c04bd74c7c7d174595fee6bc31f8386604051611e00929190615433565b60405180910390a35050505050565b6000611e1b8484612a70565b6001600160a01b0384166000908152600860205260408120805485908110611e3f57fe5b600091825260208083206001600160a01b03808a168086526007845260408087208b885285528087208a8416885285528087206003600590970290940195860154918752601285528087208b885290945283862054855494516370a0823160e01b8152959750929590949093611f16939216906370a0823190611ec6903090600401614f4c565b60206040518083038186803b158015611ede57600080fd5b505afa158015611ef2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116b291908101906142db565b90506000611f2261264d565b6001600160a01b038a1660009081526006602052604090205460028701549192509082118015611f5157508215155b15611fe7576000611f6f8760020154846136ed90919063ffffffff16565b6001600160a01b038c1660009081526009602052604081205460018a01549293509091611fb791906116a690611fab868863ffffffff61367116565b9063ffffffff61367116565b9050611fe2611fd5866116a68464e8d4a5100063ffffffff61367116565b879063ffffffff612f7216565b955050505b6001600160a01b03808b166000908152600a602090815260408083208d84528252808320938c16835292905290812090612020826131a3565b91505061204f87600101546116b264e8d4a510006116a68a611fab878e600001546136ed90919063ffffffff16565b9c9b505050505050505050505050565b6000546001600160a01b031633146120895760405162461bcd60e51b81526004016107a890615368565b611ae78282613786565b6001600160a01b038084166000908152600a60209081526040808320868452825280832093851683529290529081206120cb816131a3565b5095945050505050565b6017546001600160a01b031681565b6047546001600160a01b031690565b6001600160a01b03811660009081526011602052604081205463ffffffff168061211e576000610827565b6001600160a01b0383166000908152601060209081526040808320600019850163ffffffff168452909152902054600160201b90046001600160601b03169392505050565b6121846040518060600160405280603081526020016156eb603091396129ce565b60048054604051633d6ac5b360e21b81526001600160a01b039091169163f5ab16cc916121b391869101614f4c565b60206040518083038186803b1580156121cb57600080fd5b505afa1580156121df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612203919081019061425f565b61221f5760405162461bcd60e51b81526004016107a890615358565b61222882613751565b6001600160a01b0382166000818152600660205260409081902080549084905590519091907fad96cee0d692f0250b98e085504f399da6733854908215f6203fe3c69366d9f59061227c9084908690615433565b60405180910390a2505050565b60606122958484612a70565b6001600160a01b038085166000908152600a602090815260408083208784528252808320938616835292815282822080548451818402810184019095528085529092909184015b828210156123365760008481526020908190206040805160608101825260028602909201805483526001908101546001600160801b0380821685870152600160801b909104169183019190915290835290920191016122dc565b5050505090509392505050565b60146020526000908152604090205460ff1681565b60135460ff161561237b5760405162461bcd60e51b81526004016107a8906151c8565b600060405161238990614f36565b604080519182900382208282019091526008825267161594d5985d5b1d60c21b6020909201919091527fddfcc46608a8bd52ebf900f03a24cc97b73a6046cec8c5d0f74a211e376e967a6123db613835565b306040516020016123ef94939291906150ca565b604051602081830303815290604052805190602001209050600060405161241590614f41565b604051908190038120612430918a908a908a906020016150bc565b6040516020818303038152906040528051906020012090506000828260405160200161245d929190614f05565b604051602081830303815290604052805190602001209050600061248382888888613839565b6001600160a01b0381166000908152600e6020526040902080546001810190915590915089146124c55760405162461bcd60e51b81526004016107a890615238565b874211156124e55760405162461bcd60e51b81526004016107a890615218565b6124ef818b6134b0565b505050505b505050505050565b607a5460ff1681565b60066020526000908152604090205481565b6001600160a01b031660009081526008602052604090205490565b6000546001600160a01b0316331461255c5760405162461bcd60e51b81526004016107a890615368565b6001600160a01b0383166125825760405162461bcd60e51b81526004016107a890615228565b6001600160a01b0382166125a85760405162461bcd60e51b81526004016107a8906152c8565b6125b28282612a70565b6016546017546018546040516001600160a01b03808816948116937f8def9436d6e31b89ed00948ba91d0cb6936eada5154cb1b45b55683fb9e492379361260193919092169188918890615024565b60405180910390a3601680546001600160a01b039485166001600160a01b0319918216179091556017805493909416921691909117909155601855565b6003546001600160a01b031681565b607a5460009060ff1661266757612662613863565b61266f565b61266f613867565b905090565b6301e1338081565b60405161104a90614f41565b60185481565b601060209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b6312cc030081565b6000546001600160a01b031681565b6126fb6040518060600160405280602c815260200161571b602c91396129ce565b6127048561353f565b61270d8361353f565b6004546001600160a01b03166127355760405162461bcd60e51b81526004016107a8906151a8565b600084116127555760405162461bcd60e51b81526004016107a8906153a8565b61275e85613751565b6001600160a01b0385166000908152600860205260408120805490915b818110156127d957856001600160a01b031683828154811061279957fe5b60009182526020909120600590910201546001600160a01b031614156127d15760405162461bcd60e51b81526004016107a890615328565b60010161277b565b506001600160a01b03851660009081526014602052604090205460ff16156128135760405162461bcd60e51b81526004016107a890615298565b6001600160a01b03871660009081526009602052604090205461283c908763ffffffff612f7216565b6001600160a01b038089166000908152600960209081526040808320949094556006815290839020879055825160a081018452918816825281018890528391810161288561264d565b8152600060208083018290526040928301889052845460018082018755958352818320855160059092020180546001600160a01b0319166001600160a01b039283161781558583015181880155858501516002820155606086015160038201556080909501516004958601558a81168352601490915290829020805460ff1916851790558254915163fb66fb4d60e01b815291169263fb66fb4d9261292d928c929101615059565b600060405180830381600087803b15801561294757600080fd5b505af115801561295b573d6000803e3d6000fd5b50505050846001600160a01b03166001838054905003886001600160a01b03167fd7fa4bff1cd2253c0789c3291a786a6f6b1a3b4569a75af683a15d52abb6a0bf8988886040516129ae93929190615441565b60405180910390a450505050505050565b6016546001600160a01b031681565b6047546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab90612a019033908690600401614f68565b60206040518083038186803b158015612a1957600080fd5b505afa158015612a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a51919081019061425f565b905080611ae75760405162461bcd60e51b81526004016107a8906151e8565b6001600160a01b0382166000908152600860205260409020548110611ae75760405162461bcd60e51b81526004016107a890615198565b6001600160a01b0382166000908152600860205260408120805483908110612acb57fe5b906000526020600020906005020190508060020154612ae861264d565b11612af35750611ae7565b80546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612b23903090600401614f4c565b60206040518083038186803b158015612b3b57600080fd5b505afa158015612b4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b7391908101906142db565b6001600160a01b0385166000908152601260209081526040808320878452909152902054909150612bab90829063ffffffff6136ed16565b905080612bc957612bba61264d565b82600201819055505050611ae7565b6000612bd361264d565b90506000612bee8460020154836136ed90919063ffffffff16565b6001600160a01b03871660009081526009602090815260408083205460018901546006909352908320549394509192612c3792916116a691611fab90879063ffffffff61367116565b9050612c66612c55856116a68464e8d4a5100063ffffffff61367116565b60038701549063ffffffff612f7216565b6003860155612c7361264d565b856002018190555050505050505050565b600061082783600101546116b28585612fb4565b600480546040516370a0823160e01b81526001600160a01b03918216926000928716916370a0823191612ccd91869101614f4c565b60206040518083038186803b158015612ce557600080fd5b505afa158015612cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612d1d91908101906142db565b6001600160a01b038087166000908152601560209081526040808320938916835292905290812054919250612d58858363ffffffff612f7216565b9050828111612e36578115612dcb576001600160a01b038088166000818152601560209081526040808320948b1680845294909152808220829055517f6bdfd5e51d01475945224d3d37965916fd8df699ef9e8888af4359aa8622216091612dc291879190615418565b60405180910390a35b60405163135b33cd60e31b81526001600160a01b03851690639ad99e6890612dfb908a908a908690600401615009565b600060405180830381600087803b158015612e1557600080fd5b505af1158015612e29573d6000803e3d6000fd5b5050505050505050612f0c565b6001600160a01b038088166000818152601560209081526040808320948b168084529490915290819020868503908190559051909291907f6bdfd5e51d01475945224d3d37965916fd8df699ef9e8888af4359aa8622216090612e9c9087908690615433565b60405180910390a360405163135b33cd60e31b81526001600160a01b03861690639ad99e6890612ed4908b908b908990600401615009565b600060405180830381600087803b158015612eee57600080fd5b505af1158015612f02573d6000803e3d6000fd5b5050505050505050505b505050565b604051612f6c9085906323b872dd60e01b90612f3590879087908790602401615009565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261386b565b50505050565b600061082783836040518060400160405280601b81526020017f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815250613950565b600061082764e8d4a510006116a68460030154611fab876002015488600001546136ed90919063ffffffff16565b600081600160601b84106130095760405162461bcd60e51b81526004016107a89190615167565b509192915050565b816001600160a01b0316836001600160a01b03161415801561303c57506000816001600160601b0316115b15612f0c576001600160a01b038316156130f4576001600160a01b03831660009081526011602052604081205463ffffffff16908161307c5760006130bb565b6001600160a01b0385166000908152601060209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b905060006130e282856040518060600160405280602c81526020016156bf602c9139613980565b90506130f0868484846139bf565b5050505b6001600160a01b03821615612f0c576001600160a01b03821660009081526011602052604081205463ffffffff16908161312f57600061316e565b6001600160a01b0384166000908152601060209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b9050600061319582856040518060600160405280602b81526020016155ab602b9139613b7b565b90506124f4858484846139bf565b805460009081905b8015613241578360018203815481106131c057fe5b6000918252602090912060016002909202018101546001600160801b03600160801b9091041614156132235761321c8460018303815481106131fe57fe5b6000918252602090912060029091020154839063ffffffff612f7216565b9150613238565b6132358460018303815481106112c157fe5b92505b600019016131ab565b50915091565b8254604080516060810182526000808252602080830182815260019484018581528587018a5589845291909220925160028602909301928355905191909201805492516001600160801b03908116600160801b029281166001600160801b0319909416939093179092161790555b6000811180156132f05750818460018303815481106132d057fe5b60009182526020909120600160029092020101546001600160801b031611155b156133775783600182038154811061330457fe5b906000526020600020906002020184828154811061331e57fe5b600091825260209091208254600290920201908155600191820180549290910180546001600160801b0319166001600160801b03938416178082559154600160801b9081900484160291909216179055600019016132b5565b604051806060016040528084815260200161339184613bae565b6001600160801b0316815260200160016001600160801b03168152508482815481106133b957fe5b60009182526020918290208351600292830290910190815591830151600190920180546040909401516001600160801b03199094166001600160801b03938416178316600160801b939094169290920292909217905585015461341c9084612f72565b85600201819055505050505050565b6001600160a01b0381166134515760405162461bcd60e51b81526004016107a890615278565b604780546001600160a01b038381166001600160a01b03198316179092556040519116907f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0906134a49083908590614f88565b60405180910390a15050565b6001600160a01b038083166000908152600f6020526040812054909116906134d784613bd7565b6001600160a01b038581166000818152600f602052604080822080546001600160a01b031916898616908117909155905194955093928616927f0cc323ffec3ea49cbcddc0de1480978126d350c6a45dff33ad2f1cda6ae992619190a4612f6c828483613011565b6001600160a01b038116610f0a5760405162461bcd60e51b81526004016107a8906152d8565b60010154426001600160801b03909116111590565b805460009081905b60008111801561359f575061359f84600183038154811061129757fe5b15613640578360018203815481106135b357fe5b6000918252602090912060016002909202018101546001600160801b03600160801b9091041614156135f8576135f18460018303815481106131fe57fe5b915061360d565b61360a8460018303815481106112c157fe5b92505b8380548061361757fe5b600082815260208120600019928301600281029091018281556001019190915590915501613582565b50613665613654828463ffffffff612f7216565b60028601549063ffffffff6136ed16565b60028501559250929050565b60008261368057506000611524565b8282028284828161368d57fe5b04146108275760405162461bcd60e51b81526004016107a890615318565b600061082783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613ced565b600061082783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613d24565b604051612f0c90849063a9059cbb60e01b90612f359086908690602401615074565b6001600160a01b038116600090815260086020526040812054905b81811015612f0c5761377e8382612aa7565b60010161376c565b607a54610100900460ff16156137ae5760405162461bcd60e51b81526004016107a8906153b8565b811580156137ba575080155b156137d75760405162461bcd60e51b81526004016107a890615338565b8180156137e357508015155b156138005760405162461bcd60e51b81526004016107a890615258565b607a805460ff191683151517905581613819578061381f565b6301e133805b6079555050607a805461ff001916610100179055565b4690565b600080600061384a87878787613d48565b9150915061385781613e28565b5090505b949350505050565b4390565b4290565b61387d826001600160a01b0316613ef1565b6138995760405162461bcd60e51b81526004016107a8906153d8565b60006060836001600160a01b0316836040516138b59190614ef9565b6000604051808303816000865af19150503d80600081146138f2576040519150601f19603f3d011682016040523d82523d6000602084013e6138f7565b606091505b5091509150816139195760405162461bcd60e51b81526004016107a8906153c8565b805115612f6c5780806020019051613934919081019061425f565b612f6c5760405162461bcd60e51b81526004016107a890615208565b600083830182858210156139775760405162461bcd60e51b81526004016107a89190615167565b50949350505050565b6000836001600160601b0316836001600160601b0316111582906139b75760405162461bcd60e51b81526004016107a89190615167565b505050900390565b60006139ea6139cc61264d565b60405180608001604052806042815260200161564a60429139613f2a565b905060008463ffffffff16118015613a3357506001600160a01b038516600090815260106020908152604080832063ffffffff6000198901811685529252909120548282169116145b15613a92576001600160a01b0385166000908152601060209081526040808320600019880163ffffffff168452909152902080546fffffffffffffffffffffffff000000001916600160201b6001600160601b03851602179055613b31565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000818152601083528781208c871682528352878120965187549451909516600160201b026fffffffffffffffffffffffff000000001995871663ffffffff19958616179590951694909417909555938252601190935292909220805460018801909316929091169190911790555b846001600160a01b03167f6adb589fed1e8542fb7a6b10f00a85e02265e77f9ae3ca8ff93b22983e1af9a08484604051613b6c929190615493565b60405180910390a25050505050565b6000838301826001600160601b0380871690831610156139775760405162461bcd60e51b81526004016107a89190615167565b6000600160801b8210613bd35760405162461bcd60e51b81526004016107a890615248565b5090565b6005546000906001600160a01b0316613c025760405162461bcd60e51b81526004016107a8906151f8565b6005546001600160a01b03166000908152600860205260408120805490915b81811015613ce25760055483546001600160a01b0390911690849083908110613c4657fe5b60009182526020909120600590910201546001600160a01b03161415613cda576005546001600160a01b039081166000908152600760209081526040808320858452825280832093891683529290522060028101548154613ccf91613cb1919063ffffffff6136ed16565b60405180606001604052806028815260200161560160289139612fe2565b94505050505061108d565b600101613c21565b506000949350505050565b60008183613d0e5760405162461bcd60e51b81526004016107a89190615167565b506000838581613d1a57fe5b0495945050505050565b600081848411156139b75760405162461bcd60e51b81526004016107a89190615167565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613d7f5750600090506003613e1f565b8460ff16601b14158015613d9757508460ff16601c14155b15613da85750600090506004613e1f565b600060018787878760405160008152602001604052604051613dcd94939291906150f2565b6020604051602081039080840390855afa158015613def573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613e1857506000915060019050613e1f565b9150600090505b94509492505050565b6000816004811115613e3657fe5b1415613e4157610f0a565b6001816004811115613e4f57fe5b1415613e6d5760405162461bcd60e51b81526004016107a890615178565b6002816004811115613e7b57fe5b1415613e995760405162461bcd60e51b81526004016107a8906151b8565b6003816004811115613ea757fe5b1415613ec55760405162461bcd60e51b81526004016107a890615288565b6004816004811115613ed357fe5b1415610f0a5760405162461bcd60e51b81526004016107a8906152f8565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061385b575050151592915050565b600081600160201b84106130095760405162461bcd60e51b81526004016107a89190615167565b604080518082019091526000808252602082015290565b803561152481615569565b805161152481615569565b80356115248161557d565b80516115248161557d565b803561152481615586565b80356115248161558f565b805161152481615586565b803561152481615598565b8035611524816155a1565b600060208284031215613fdd57600080fd5b600061385b8484613f68565b600060208284031215613ffb57600080fd5b600061385b8484613f73565b6000806040838503121561401a57600080fd5b60006140268585613f68565b925050602061403785828601613f68565b9150509250929050565b60008060006060848603121561405657600080fd5b60006140628686613f68565b935050602061407386828701613f68565b925050604061408486828701613f94565b9150509250925092565b600080604083850312156140a157600080fd5b60006140ad8585613f68565b925050602061403785828601613f94565b6000806000606084860312156140d357600080fd5b60006140df8686613f68565b93505060206140f086828701613f94565b925050604061408486828701613f68565b600080600080600060a0868803121561411957600080fd5b60006141258888613f68565b955050602061413688828901613f94565b945050604061414788828901613f9f565b935050606061415888828901613f94565b925050608061416988828901613f94565b9150509295509295909350565b60008060006060848603121561418b57600080fd5b60006141978686613f68565b935050602061407386828701613f94565b60008060008060008060c087890312156141c157600080fd5b60006141cd8989613f68565b96505060206141de89828a01613f94565b95505060406141ef89828a01613f94565b945050606061420089828a01613fc0565b935050608061421189828a01613f94565b92505060a061422289828a01613f94565b9150509295509295509295565b6000806040838503121561424257600080fd5b600061424e8585613f68565b925050602061403785828601613fb5565b60006020828403121561427157600080fd5b600061385b8484613f89565b6000806040838503121561429057600080fd5b60006140ad8585613f7e565b6000806000606084860312156142b157600080fd5b60006140628686613f9f565b6000602082840312156142cf57600080fd5b600061385b8484613f9f565b6000602082840312156142ed57600080fd5b600061385b8484613faa565b60006143058383614e99565b505060600190565b61431681615512565b82525050565b614316816154c1565b6000614330826154b4565b61433a81856154b8565b9350614345836154ae565b8060005b8381101561437357815161435d88826142f9565b9750614368836154ae565b925050600101614349565b509495945050505050565b614316816154cc565b614316816154d1565b61431661439c826154d1565b6154d1565b60006143ac826154b4565b6143b6818561108d565b93506143c6818560208601615533565b9290920192915050565b614316816154d4565b6143168161551d565b60006143ed826154b4565b6143f781856154b8565b9350614407818560208601615533565b6144108161555f565b9093019392505050565b60006144276018836154b8565b7f45434453413a20696e76616c6964207369676e61747572650000000000000000815260200192915050565b60006144606012836154b8565b71696e636f6e73697374656e7420737461746560701b815260200192915050565b600061448e6013836154b8565b727661756c743a20706f6f6c206578697374733f60681b815260200192915050565b60006144bd601f836154b8565b7f53746f726520636f6e7472616374206164647265737320697320656d70747900815260200192915050565b60006144f6601f836154b8565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800815260200192915050565b600061452f600f836154b8565b6e15985d5b1d081a5cc81c185d5cd959608a1b815260200192915050565b600061455a6013836154b8565b7215985d5b1d081a5cc81b9bdd081c185d5cd959606a1b815260200192915050565b6000614589600c836154b8565b6b155b985d5d1a1bdc9a5e995960a21b815260200192915050565b60006145b16030836154b8565b7f5856535661756c743a3a6765745374616b65416d6f756e743a2078767320616481526f191c995cdcc81a5cc81b9bdd081cd95d60821b602082015260400192915050565b6000614603602a836154b8565b7f5361666542455032303a204245503230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b602082015260400192915050565b600061464f602a836154b8565b7f5856535661756c743a3a64656c656761746542795369673a207369676e6174758152691c9948195e1c1a5c995960b21b602082015260400192915050565b600061469b6022836154b8565b7f7072696d6520746f6b656e2063616e6e6f74206265207a65726f206164647265815261737360f01b602082015260400192915050565b60006146df6026836154b8565b7f5856535661756c743a3a64656c656761746542795369673a20696e76616c6964815265206e6f6e636560d01b602082015260400192915050565b600061472760028361108d565b61190160f01b815260020192915050565b60006147456027836154b8565b7f53616665436173743a2076616c756520646f65736e27742066697420696e20318152663238206269747360c81b602082015260400192915050565b600061478e6020836154b8565b7f496e76616c69642074696d6520626173656420636f6e66696775726174696f6e815260200192915050565b60006147c76017836154b8565b7f5661756c7420697320616c726561647920706175736564000000000000000000815260200192915050565b60006148006025836154b8565b7f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164815264647265737360d81b602082015260400192915050565b60006148476022836154b8565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b602082015260400192915050565b600061488b601a836154b8565b7f546f6b656e2065786973747320696e206f7468657220706f6f6c000000000000815260200192915050565b60006148c46013836154b8565b72185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b815260200192915050565b60006148f3602b836154b8565b7f5856535661756c743a3a6765745072696f72566f7465733a206e6f742079657481526a0819195d195c9b5a5b995960aa1b602082015260400192915050565b6000614940601d836154b8565b7f7265776172642063616e6e6f74206265207a65726f2061646472657373000000815260200192915050565b60006149796018836154b8565b7f7a65726f2061646472657373206e6f7420616c6c6f7765640000000000000000815260200192915050565b60006149b2601a836154b8565b7f657865637574652070656e64696e67207769746864726177616c000000000000815260200192915050565b60006149eb6022836154b8565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b602082015260400192915050565b6000614a2f60438361108d565b7f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353681527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208201526263742960e81b604082015260430192915050565b6000614a9a601f836154b8565b7f72657175657374656420616d6f756e742063616e6e6f74206265207a65726f00815260200192915050565b6000614ad36021836154b8565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000614b166012836154b8565b71141bdbdb08185b1c9958591e48185919195960721b815260200192915050565b6000614b446017836154b8565b7f496e76616c696420626c6f636b73207065722079656172000000000000000000815260200192915050565b6000614b7d600a836154b8565b691c994b595b9d195c995960b21b815260200192915050565b6000614ba36014836154b8565b7324b73b30b634b2103932bbb0b932103a37b5b2b760611b815260200192915050565b6000614bd3600e836154b8565b6d37b7363c9030b236b4b71031b0b760911b815260200192915050565b6000614bfd6015836154b8565b7418da185b99d9481b9bdd08185d5d1a1bdc9a5e9959605a1b815260200192915050565b6000614c2e6013836154b8565b726e6f7468696e6720746f20776974686472617760681b815260200192915050565b6000614c5d601a836154b8565b7f496e76616c6964206e6577206c6f636b696e6720706572696f64000000000000815260200192915050565b6000614c96601d836154b8565b7f416c6c6f6320706f696e7473206d757374206e6f74206265207a65726f000000815260200192915050565b6000614ccf601f836154b8565b7f416c726561647920696e697469616c697a65642054696d654d616e6167657200815260200192915050565b6000614d086020836154b8565b7f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564815260200192915050565b6000614d41603a8361108d565b7f44656c65676174696f6e28616464726573732064656c6567617465652c75696e81527f74323536206e6f6e63652c75696e7432353620657870697279290000000000006020820152603a0192915050565b6000614da0601f836154b8565b7f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e747261637400815260200192915050565b6000614dd9601b836154b8565b7f72657175657374656420616d6f756e7420697320696e76616c69640000000000815260200192915050565b6000614e126022836154b8565b7f6f6e6c792070726f78792061646d696e2063616e206368616e676520627261698152616e7360f01b602082015260400192915050565b6000614e56602e836154b8565b7f416c6c6f6320706f696e7473207065722072657761726420746f6b656e206d7581526d7374206e6f74206265207a65726f60901b602082015260400192915050565b80516060830190614eaa8482614387565b506020820151614ebd6020850182614ecc565b506040820151612f6c60408501825b614316816154df565b614316816154f7565b61431681615500565b61431681615528565b61431681615506565b600061082782846143a1565b6000614f108261471a565b9150614f1c8285614390565b602082019150614f2c8284614390565b5060200192915050565b600061152482614a22565b600061152482614d34565b60208101611524828461431c565b60208101611524828461430d565b60408101614f76828561430d565b818103602083015261385b81846143e2565b60408101614f96828561431c565b610827602083018461431c565b60608101614fb1828661431c565b614fbe602083018561430d565b61385b6040830184614387565b60808101614fd9828761431c565b614fe6602083018661431c565b614ff3604083018561431c565b615000606083018461431c565b95945050505050565b60608101615017828661431c565b614fbe602083018561431c565b60808101615032828761431c565b61503f602083018661431c565b61504c6040830185614387565b6150006060830184614387565b60408101615067828561431c565b610827602083018461437e565b60408101615082828561431c565b6108276020830184614387565b602080825281016108278184614325565b60208101611524828461437e565b602081016115248284614387565b608081016150328287614387565b608081016150d88287614387565b6150e56020830186614387565b614ff36040830185614387565b608081016151008287614387565b61503f6020830186614ede565b6020810161152482846143d0565b60a0810161512982886143d0565b6151366020830187614387565b6151436040830186614387565b6151506060830185614387565b61515d6080830184614387565b9695505050505050565b6020808252810161082781846143e2565b602080825281016115248161441a565b6020808252810161152481614453565b6020808252810161152481614481565b60208082528101611524816144b0565b60208082528101611524816144e9565b6020808252810161152481614522565b602080825281016115248161454d565b602080825281016115248161457c565b60208082528101611524816145a4565b60208082528101611524816145f6565b6020808252810161152481614642565b602080825281016115248161468e565b60208082528101611524816146d2565b6020808252810161152481614738565b6020808252810161152481614781565b60208082528101611524816147ba565b60208082528101611524816147f3565b602080825281016115248161483a565b602080825281016115248161487e565b60208082528101611524816148b7565b60208082528101611524816148e6565b6020808252810161152481614933565b602080825281016115248161496c565b60208082528101611524816149a5565b60208082528101611524816149de565b6020808252810161152481614a8d565b6020808252810161152481614ac6565b6020808252810161152481614b09565b6020808252810161152481614b37565b6020808252810161152481614b70565b6020808252810161152481614b96565b6020808252810161152481614bc6565b6020808252810161152481614bf0565b6020808252810161152481614c21565b6020808252810161152481614c50565b6020808252810161152481614c89565b6020808252810161152481614cc2565b6020808252810161152481614cfb565b6020808252810161152481614d93565b6020808252810161152481614dcc565b6020808252810161152481614e05565b6020808252810161152481614e49565b604081016154268285614387565b61082760208301846143d9565b604081016150828285614387565b6060810161544f8286614387565b614fbe6020830185614387565b602081016115248284614ed5565b604081016154788285614ed5565b6108276020830184614ef0565b602081016115248284614ef0565b604081016154a18285614ee7565b6108276020830184614ee7565b60200190565b5190565b90815260200190565b6000611524826154eb565b151590565b90565b6000611524826154c1565b6001600160801b031690565b6001600160a01b031690565b63ffffffff1690565b60ff1690565b6001600160601b031690565b6000611524826154d4565b6000611524826154d1565b600061152482615506565b60005b8381101561554e578181015183820152602001615536565b83811115612f6c5750506000910152565b601f01601f191690565b615572816154c1565b8114610f0a57600080fd5b615572816154cc565b615572816154d1565b615572816154d4565b615572816154f7565b6155728161550056fe5856535661756c743a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f77735856535661756c743a3a726571756573745769746864726177616c3a20766f746573206f766572666c6f775856535661756c743a3a6765745374616b65416d6f756e743a20766f746573206f766572666c6f775856535661756c743a3a6465706f7369743a20766f746573206f766572666c6f775856535661756c743a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206f72207365636f6e64206578636565647320333220626974737365745769746864726177616c4c6f636b696e67506572696f6428616464726573732c75696e743235362c75696e74323536295856535661756c743a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f7773736574526577617264416d6f756e74506572426c6f636b4f725365636f6e6428616464726573732c75696e743235362961646428616464726573732c75696e743235362c616464726573732c75696e743235362c75696e7432353629a365627a7a7231582053ba350123a86f07263e7bddf3bcee0f7cf11e72f5d2678781f0eb1ebd599dc16c6578706572696d656e74616cf564736f6c63430005100040", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103785760003560e01c806392e35000116101d3578063c7ad089511610104578063e7a324dc116100a2578063f55401621161007c578063f554016214610732578063f851a4401461073a578063fba1b1f914610742578063fe5a451a1461075557610378565b8063e7a324dc14610701578063e8f2be6f14610709578063f1127ed81461071157610378565b8063dae66bbe116100de578063dae66bbe146106d6578063de0368b2146106e9578063e1d146fb146106f1578063e6a69ab8146106f957610378565b8063c7ad0895146106a8578063cd9b94e7146106b0578063d7ae45e2146106c357610378565b8063add8933711610171578063b6a5fd2f1161014b578063b6a5fd2f1461064f578063c210259614610662578063c3c754a814610682578063c3cda5201461069557610378565b8063add893371461061f578063b4a0bdf314610627578063b4b5ea571461063c57610378565b80639e2b6c4d116101ad5780639e2b6c4d146105d3578063a09eab7a146105e6578063a6997762146105f9578063a9d69a691461060c57610378565b806392e350001461057a57806398e1b31b1461059e578063996cba68146105c057610378565b80635c19a95c116102ad57806373d025d61161024b5780637ecebe00116102255780637ecebe00146105395780638308d7e91461054c5780638456cb591461055f5780638ed7333d1461056757610378565b806373d025d6146104f1578063782d6fe1146105065780637ac924561461052657610378565b80635ff56315116102875780635ff56315146104a35780636857249c146104b65780636dd77cbd146104be5780636fcfff45146104d157610378565b80635c19a95c146104755780635c60da1b146104885780635f14e7001461049057610378565b806324f52bbf1161031a578063358ae036116102f4578063358ae036146104345780633d4180f91461043c5780634298bdbd1461044f578063587cde1e1461046257610378565b806324f52bbf1461040457806326782247146104195780632eda5c6c1461042157610378565b8063115b512f11610356578063115b512f146103c357806319129e5a146103d65780631d504dc6146103e957806320606b70146103fc57610378565b8063046f7da21461037d5780630af13728146103875780630efe6a8b146103b0575b600080fd5b61038561075d565b005b61039a6103953660046140be565b6107e8565b6040516103a791906150ae565b60405180910390f35b6103856103be366004614176565b61082e565b6103856103d1366004614176565b610b23565b6103856103e4366004613fcb565b610ed7565b6103856103f73660046142bd565b610f0d565b61039a61103e565b61040c611055565b6040516103a79190614f4c565b61040c611064565b61039a61042f366004613fcb565b611073565b61040c611092565b61039a61044a366004614007565b6110a1565b61039a61045d366004613fcb565b6110be565b61040c610470366004613fcb565b6110d0565b610385610483366004613fcb565b6110eb565b61040c611118565b61039a61049e36600461408e565b611127565b6103856104b1366004614007565b611144565b61039a611238565b61039a6104cc3660046140be565b61123e565b6104e46104df366004613fcb565b6112f3565b6040516103a7919061545c565b6104f961130b565b6040516103a791906150a0565b61051961051436600461408e565b611314565b6040516103a79190615485565b61038561053436600461408e565b61152a565b61039a610547366004613fcb565b611873565b61038561055a366004614176565b611885565b610385611a2b565b61038561057536600461408e565b611ab0565b61058d61058836600461408e565b611aeb565b6040516103a795949392919061511b565b6105b16105ac3660046140be565b611b40565b6040516103a793929190615441565b6103856105ce366004614041565b611b92565b6103856105e1366004614176565b611d24565b61039a6105f43660046140be565b611e0f565b61038561060736600461427d565b61205f565b61039a61061a3660046140be565b612093565b61040c6120d5565b61062f6120e4565b6040516103a7919061510d565b61051961064a366004613fcb565b6120f3565b61038561065d36600461408e565b612163565b6106756106703660046140be565b612289565b6040516103a7919061508f565b6104f9610690366004613fcb565b612343565b6103856106a33660046141a8565b612358565b6104f96124fc565b61039a6106be366004613fcb565b612505565b61039a6106d1366004613fcb565b612517565b6103856106e436600461429c565b612532565b61040c61263e565b61039a61264d565b61039a612674565b61039a61267c565b61039a612688565b61072461071f36600461422f565b61268e565b6040516103a792919061546a565b61039a6126c3565b61040c6126cb565b610385610750366004614101565b6126da565b61062f6129bf565b61078660405180604001604052806008815260200167726573756d65282960c01b8152506129ce565b60135460ff166107b15760405162461bcd60e51b81526004016107a8906151d8565b60405180910390fd5b6013805460ff1916905560405133907fd2619572a1464e0df0bb351d834fd47f3350984d7bfdb1ab69cfcb0b8e42141590600090a2565b60006107f48484612a70565b506001600160a01b0380841660009081526007602090815260408083208684528252808320938516835292905220600201545b9392505050565b600354600160a01b900460ff166108575760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff16156108875760405162461bcd60e51b81526004016107a8906151c8565b6108918383612a70565b6001600160a01b03831660009081526008602052604081208054849081106108b557fe5b600091825260208083206001600160a01b038816845260078252604080852088865283528085203386529092529220600590910290910191506108f88585612aa7565b610903858533612093565b156109205760405162461bcd60e51b81526004016107a8906152e8565b8054156109955760006109338284612c84565b9050801561099357610946863383612c98565b84866001600160a01b0316336001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946458460405161098a91906150ae565b60405180910390a45b505b81546109b2906001600160a01b031633308663ffffffff612f1116565b80546109c4908463ffffffff612f7216565b81556109d08183612fb4565b600182015560055482546001600160a01b0390811691161415610a3757336000908152600f60209081526040808320548151606081019092526021808352610a3794936001600160a01b0390921692610a329289929061562990830139612fe2565b613011565b6017546001600160a01b038681169116148015610a55575060185484145b15610abd576016546040516337f23cd360e01b81526001600160a01b03909116906337f23cd390610a8a903390600401614f5a565b600060405180830381600087803b158015610aa457600080fd5b505af1158015610ab8573d6000803e3d6000fd5b505050505b83856001600160a01b0316336001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d786604051610b0191906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b179055505050565b600354600160a01b900460ff16610b4c5760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff1615610b7c5760405162461bcd60e51b81526004016107a8906151c8565b610b868383612a70565b60008111610ba65760405162461bcd60e51b81526004016107a890615308565b6001600160a01b0383166000908152600760209081526040808320858452825280832033845290915290206002810154610be6908363ffffffff612f7216565b81541015610c065760405162461bcd60e51b81526004016107a8906153e8565b6001600160a01b0384166000908152600860205260408120805485908110610c2a57fe5b600091825260208083206001600160a01b0389168452600a825260408085208986528352808520338652909252908320600590920201925090610c6c826131a3565b5090508015610c8d5760405162461bcd60e51b81526004016107a8906152e8565b610c978787612aa7565b6000610ca38585612c84565b9050610cb0883383612c98565b6004840154600090610cc8904263ffffffff612f7216565b9050610cd686858984613247565b6001600160a01b03891660009081526012602090815260408083208b8452909152902054610d0a908863ffffffff612f7216565b6001600160a01b038a1660009081526012602090815260408083208c8452909152902055610d388686612fb4565b600187015560055485546001600160a01b0390811691161415610d9b57336000908152600f6020908152604080832054815160608101909252602b808352610d9b946001600160a01b03909216939192610a32928d92906155d690830139612fe2565b6017546001600160a01b038a81169116148015610db9575060185488145b15610e21576016546040516337f23cd360e01b81526001600160a01b03909116906337f23cd390610dee903390600401614f5a565b600060405180830381600087803b158015610e0857600080fd5b505af1158015610e1c573d6000803e3d6000fd5b505050505b87896001600160a01b0316336001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464585604051610e6591906150ae565b60405180910390a487896001600160a01b0316336001600160a01b03167f88a254a0ef28a0b9e957ff600beae69870f6f924065147f3627c3f814e60ec118a604051610eb191906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b17905550505050505050565b6000546001600160a01b03163314610f015760405162461bcd60e51b81526004016107a890615368565b610f0a8161342b565b50565b806001600160a01b031663f851a4406040518163ffffffff1660e01b815260040160206040518083038186803b158015610f4657600080fd5b505afa158015610f5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f7e9190810190613fe9565b6001600160a01b0316336001600160a01b031614610fae5760405162461bcd60e51b81526004016107a8906153f8565b806001600160a01b031663c1e803346040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610fe957600080fd5b505af1158015610ffd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061102191908101906142db565b15610f0a5760405162461bcd60e51b81526004016107a890615378565b60405161104a90614f36565b604051809103902081565b6004546001600160a01b031681565b6001546001600160a01b031681565b6001600160a01b0381166000908152600660205260409020545b919050565b6005546001600160a01b031681565b601560209081526000928352604080842090915290825290205481565b60096020526000908152604090205481565b600f602052600090815260409020546001600160a01b031681565b60135460ff161561110e5760405162461bcd60e51b81526004016107a8906151c8565b610f0a33826134b0565b6002546001600160a01b031681565b601260209081526000928352604080842090915290825290205481565b6000546001600160a01b0316331461116e5760405162461bcd60e51b81526004016107a890615368565b6111778261353f565b6111808161353f565b6005546004546001600160a01b03918216911681156111b15760405162461bcd60e51b81526004016107a8906152a8565b600580546001600160a01b038087166001600160a01b03199283161790925560048054928616929091169190911790556003805460ff60a01b1916600160a01b1790556040517f559f314bb90394a4a9ceb724f365b36a53587d894352c43d12901fd6801014569061122a908490849088908890614fcb565b60405180910390a150505050565b60795481565b600061124a8484612a70565b6001600160a01b038085166000908152600a60209081526040808320878452825280832093861683529290522080545b6000811180156112aa57506112aa82600183038154811061129757fe5b9060005260206000209060020201613565565b156112ea576112df8260018303815481106112c157fe5b6000918252602090912060029091020154849063ffffffff612f7216565b92506000190161127a565b50509392505050565b60116020526000908152604090205463ffffffff1681565b60135460ff1681565b600061131e61264d565b821061133c5760405162461bcd60e51b81526004016107a8906152b8565b6001600160a01b03831660009081526011602052604090205463ffffffff168061136a576000915050611524565b6001600160a01b038416600090815260106020908152604080832063ffffffff6000198601811685529252909120541683106113e6576001600160a01b03841660009081526010602090815260408083206000199490940163ffffffff1683529290522054600160201b90046001600160601b03169050611524565b6001600160a01b038416600090815260106020908152604080832083805290915290205463ffffffff16831015611421576000915050611524565b600060001982015b8163ffffffff168163ffffffff1611156114e457600282820363ffffffff16048103611453613f51565b506001600160a01b038716600090815260106020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b031691810191909152908714156114bf576020015194506115249350505050565b805163ffffffff168711156114d6578193506114dd565b6001820392505b5050611429565b506001600160a01b038516600090815260106020908152604080832063ffffffff909416835292905220546001600160601b03600160201b909104169150505b92915050565b600354600160a01b900460ff166115535760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff16156115835760405162461bcd60e51b81526004016107a8906151c8565b61158d8282612a70565b6001600160a01b03821660009081526008602052604081208054839081106115b157fe5b600091825260208083206001600160a01b038716808552600783526040808620888752845280862033808852908552818720928752600a8552818720898852855281872090875290935291842060059093020193509180611612848461357a565b9092509050811515806116255750600081115b6116415760405162461bcd60e51b81526004016107a890615388565b81158061164c575080155b6116685760405162461bcd60e51b81526004016107a890615188565b8115611781576116788787612aa7565b60006116be85600101546116b264e8d4a510006116a68a600301548a6000015461367190919063ffffffff16565b9063ffffffff6136ab16565b9063ffffffff6136ed16565b6004805460405163135b33cd60e31b81529293506001600160a01b031691639ad99e68916116f2918c913391879101614fa3565b600060405180830381600087803b15801561170c57600080fd5b505af1158015611720573d6000803e3d6000fd5b50508654611737925090508463ffffffff6136ed16565b808655600387015461175a9164e8d4a51000916116a6919063ffffffff61367116565b6001860155855461177b906001600160a01b0316338563ffffffff61372f16565b50611805565b8354611793908263ffffffff6136ed16565b84556001600160a01b03871660009081526012602090815260408083208984529091529020546117c9908263ffffffff6136ed16565b6001600160a01b0380891660009081526012602090815260408083208b845290915290209190915585546118059116338363ffffffff61372f16565b856001600160a01b038816337fe31da05fae6db869f5ea51f4b638aa6884070b6c87f18f63bd2291a12cb2f518611842868663ffffffff612f7216565b60405161184f91906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b1790555050505050565b600e6020526000908152604090205481565b6118c36040518060400160405280601c81526020017f73657428616464726573732c75696e743235362c75696e7432353629000000008152506129ce565b6118cd8383612a70565b6118d683613751565b6001600160a01b0383166000908152600860205260408120805490919061194f9084906119439085908890811061190957fe5b60009182526020808320600160059093020191909101546001600160a01b038b16835260099091526040909120549063ffffffff6136ed16565b9063ffffffff612f7216565b9050600081116119715760405162461bcd60e51b81526004016107a890615408565b600082858154811061197f57fe5b9060005260206000209060050201600101549050838386815481106119a057fe5b9060005260206000209060050201600101819055508160096000886001600160a01b03166001600160a01b031681526020019081526020016000208190555084866001600160a01b03167f6ee09c6cb801194690c195c69f465aaf7c80255cbeafaab9600f47ed79de2ca98387604051611a1b929190615433565b60405180910390a3505050505050565b611a53604051806040016040528060078152602001667061757365282960c81b8152506129ce565b60135460ff1615611a765760405162461bcd60e51b81526004016107a890615268565b6013805460ff1916600117905560405133907fdffada2889ebfab9224c24069d833f3de835d8cf99872d49e7b7ba5fccb7a46f90600090a2565b60135460ff1615611ad35760405162461bcd60e51b81526004016107a8906151c8565b611add8282612a70565b611ae78282612aa7565b5050565b60086020528160005260406000208181548110611b0457fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b039093169550909350919085565b6000806000611b4f8686612a70565b5050506001600160a01b03928316600090815260076020908152604080832094835293815283822092909416815292529020805460018201546002909201549092565b600354600160a01b900460ff16611bbb5760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff1615611beb5760405162461bcd60e51b81526004016107a8906151c8565b611bf58282612a70565b6001600160a01b0382166000908152600860205260408120805483908110611c1957fe5b600091825260208083206001600160a01b0380881685526007835260408086208887528452808620918a1686529252922060059091029091019150611c5e8484612aa7565b611c69848487612093565b15611c865760405162461bcd60e51b81526004016107a8906152e8565b805415611d0a576000611c998284612c84565b90508015611d0857611cab8284612fb4565b6001830155611cbb858783612c98565b83856001600160a01b0316876001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464584604051611cff91906150ae565b60405180910390a45b505b50506003805460ff60a01b1916600160a01b179055505050565b611d4560405180606001604052806033815260200161568c603391396129ce565b611d4f8383612a70565b600081118015611d6257506312cc030081105b611d7e5760405162461bcd60e51b81526004016107a890615398565b6001600160a01b0383166000908152600860205260408120805484908110611da257fe5b9060005260206000209060050201905060008160040154905082826004018190555083856001600160a01b03167f0bcf80c5060ccf99b7a993c57a94b232fc2c5c04bd74c7c7d174595fee6bc31f8386604051611e00929190615433565b60405180910390a35050505050565b6000611e1b8484612a70565b6001600160a01b0384166000908152600860205260408120805485908110611e3f57fe5b600091825260208083206001600160a01b03808a168086526007845260408087208b885285528087208a8416885285528087206003600590970290940195860154918752601285528087208b885290945283862054855494516370a0823160e01b8152959750929590949093611f16939216906370a0823190611ec6903090600401614f4c565b60206040518083038186803b158015611ede57600080fd5b505afa158015611ef2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116b291908101906142db565b90506000611f2261264d565b6001600160a01b038a1660009081526006602052604090205460028701549192509082118015611f5157508215155b15611fe7576000611f6f8760020154846136ed90919063ffffffff16565b6001600160a01b038c1660009081526009602052604081205460018a01549293509091611fb791906116a690611fab868863ffffffff61367116565b9063ffffffff61367116565b9050611fe2611fd5866116a68464e8d4a5100063ffffffff61367116565b879063ffffffff612f7216565b955050505b6001600160a01b03808b166000908152600a602090815260408083208d84528252808320938c16835292905290812090612020826131a3565b91505061204f87600101546116b264e8d4a510006116a68a611fab878e600001546136ed90919063ffffffff16565b9c9b505050505050505050505050565b6000546001600160a01b031633146120895760405162461bcd60e51b81526004016107a890615368565b611ae78282613786565b6001600160a01b038084166000908152600a60209081526040808320868452825280832093851683529290529081206120cb816131a3565b5095945050505050565b6017546001600160a01b031681565b6047546001600160a01b031690565b6001600160a01b03811660009081526011602052604081205463ffffffff168061211e576000610827565b6001600160a01b0383166000908152601060209081526040808320600019850163ffffffff168452909152902054600160201b90046001600160601b03169392505050565b6121846040518060600160405280603081526020016156eb603091396129ce565b60048054604051633d6ac5b360e21b81526001600160a01b039091169163f5ab16cc916121b391869101614f4c565b60206040518083038186803b1580156121cb57600080fd5b505afa1580156121df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612203919081019061425f565b61221f5760405162461bcd60e51b81526004016107a890615358565b61222882613751565b6001600160a01b0382166000818152600660205260409081902080549084905590519091907fad96cee0d692f0250b98e085504f399da6733854908215f6203fe3c69366d9f59061227c9084908690615433565b60405180910390a2505050565b60606122958484612a70565b6001600160a01b038085166000908152600a602090815260408083208784528252808320938616835292815282822080548451818402810184019095528085529092909184015b828210156123365760008481526020908190206040805160608101825260028602909201805483526001908101546001600160801b0380821685870152600160801b909104169183019190915290835290920191016122dc565b5050505090509392505050565b60146020526000908152604090205460ff1681565b60135460ff161561237b5760405162461bcd60e51b81526004016107a8906151c8565b600060405161238990614f36565b604080519182900382208282019091526008825267161594d5985d5b1d60c21b6020909201919091527fddfcc46608a8bd52ebf900f03a24cc97b73a6046cec8c5d0f74a211e376e967a6123db613835565b306040516020016123ef94939291906150ca565b604051602081830303815290604052805190602001209050600060405161241590614f41565b604051908190038120612430918a908a908a906020016150bc565b6040516020818303038152906040528051906020012090506000828260405160200161245d929190614f05565b604051602081830303815290604052805190602001209050600061248382888888613839565b6001600160a01b0381166000908152600e6020526040902080546001810190915590915089146124c55760405162461bcd60e51b81526004016107a890615238565b874211156124e55760405162461bcd60e51b81526004016107a890615218565b6124ef818b6134b0565b505050505b505050505050565b607a5460ff1681565b60066020526000908152604090205481565b6001600160a01b031660009081526008602052604090205490565b6000546001600160a01b0316331461255c5760405162461bcd60e51b81526004016107a890615368565b6001600160a01b0383166125825760405162461bcd60e51b81526004016107a890615228565b6001600160a01b0382166125a85760405162461bcd60e51b81526004016107a8906152c8565b6125b28282612a70565b6016546017546018546040516001600160a01b03808816948116937f8def9436d6e31b89ed00948ba91d0cb6936eada5154cb1b45b55683fb9e492379361260193919092169188918890615024565b60405180910390a3601680546001600160a01b039485166001600160a01b0319918216179091556017805493909416921691909117909155601855565b6003546001600160a01b031681565b607a5460009060ff1661266757612662613863565b61266f565b61266f613867565b905090565b6301e1338081565b60405161104a90614f41565b60185481565b601060209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b6312cc030081565b6000546001600160a01b031681565b6126fb6040518060600160405280602c815260200161571b602c91396129ce565b6127048561353f565b61270d8361353f565b6004546001600160a01b03166127355760405162461bcd60e51b81526004016107a8906151a8565b600084116127555760405162461bcd60e51b81526004016107a8906153a8565b61275e85613751565b6001600160a01b0385166000908152600860205260408120805490915b818110156127d957856001600160a01b031683828154811061279957fe5b60009182526020909120600590910201546001600160a01b031614156127d15760405162461bcd60e51b81526004016107a890615328565b60010161277b565b506001600160a01b03851660009081526014602052604090205460ff16156128135760405162461bcd60e51b81526004016107a890615298565b6001600160a01b03871660009081526009602052604090205461283c908763ffffffff612f7216565b6001600160a01b038089166000908152600960209081526040808320949094556006815290839020879055825160a081018452918816825281018890528391810161288561264d565b8152600060208083018290526040928301889052845460018082018755958352818320855160059092020180546001600160a01b0319166001600160a01b039283161781558583015181880155858501516002820155606086015160038201556080909501516004958601558a81168352601490915290829020805460ff1916851790558254915163fb66fb4d60e01b815291169263fb66fb4d9261292d928c929101615059565b600060405180830381600087803b15801561294757600080fd5b505af115801561295b573d6000803e3d6000fd5b50505050846001600160a01b03166001838054905003886001600160a01b03167fd7fa4bff1cd2253c0789c3291a786a6f6b1a3b4569a75af683a15d52abb6a0bf8988886040516129ae93929190615441565b60405180910390a450505050505050565b6016546001600160a01b031681565b6047546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab90612a019033908690600401614f68565b60206040518083038186803b158015612a1957600080fd5b505afa158015612a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a51919081019061425f565b905080611ae75760405162461bcd60e51b81526004016107a8906151e8565b6001600160a01b0382166000908152600860205260409020548110611ae75760405162461bcd60e51b81526004016107a890615198565b6001600160a01b0382166000908152600860205260408120805483908110612acb57fe5b906000526020600020906005020190508060020154612ae861264d565b11612af35750611ae7565b80546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612b23903090600401614f4c565b60206040518083038186803b158015612b3b57600080fd5b505afa158015612b4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b7391908101906142db565b6001600160a01b0385166000908152601260209081526040808320878452909152902054909150612bab90829063ffffffff6136ed16565b905080612bc957612bba61264d565b82600201819055505050611ae7565b6000612bd361264d565b90506000612bee8460020154836136ed90919063ffffffff16565b6001600160a01b03871660009081526009602090815260408083205460018901546006909352908320549394509192612c3792916116a691611fab90879063ffffffff61367116565b9050612c66612c55856116a68464e8d4a5100063ffffffff61367116565b60038701549063ffffffff612f7216565b6003860155612c7361264d565b856002018190555050505050505050565b600061082783600101546116b28585612fb4565b600480546040516370a0823160e01b81526001600160a01b03918216926000928716916370a0823191612ccd91869101614f4c565b60206040518083038186803b158015612ce557600080fd5b505afa158015612cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612d1d91908101906142db565b6001600160a01b038087166000908152601560209081526040808320938916835292905290812054919250612d58858363ffffffff612f7216565b9050828111612e36578115612dcb576001600160a01b038088166000818152601560209081526040808320948b1680845294909152808220829055517f6bdfd5e51d01475945224d3d37965916fd8df699ef9e8888af4359aa8622216091612dc291879190615418565b60405180910390a35b60405163135b33cd60e31b81526001600160a01b03851690639ad99e6890612dfb908a908a908690600401615009565b600060405180830381600087803b158015612e1557600080fd5b505af1158015612e29573d6000803e3d6000fd5b5050505050505050612f0c565b6001600160a01b038088166000818152601560209081526040808320948b168084529490915290819020868503908190559051909291907f6bdfd5e51d01475945224d3d37965916fd8df699ef9e8888af4359aa8622216090612e9c9087908690615433565b60405180910390a360405163135b33cd60e31b81526001600160a01b03861690639ad99e6890612ed4908b908b908990600401615009565b600060405180830381600087803b158015612eee57600080fd5b505af1158015612f02573d6000803e3d6000fd5b5050505050505050505b505050565b604051612f6c9085906323b872dd60e01b90612f3590879087908790602401615009565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261386b565b50505050565b600061082783836040518060400160405280601b81526020017f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815250613950565b600061082764e8d4a510006116a68460030154611fab876002015488600001546136ed90919063ffffffff16565b600081600160601b84106130095760405162461bcd60e51b81526004016107a89190615167565b509192915050565b816001600160a01b0316836001600160a01b03161415801561303c57506000816001600160601b0316115b15612f0c576001600160a01b038316156130f4576001600160a01b03831660009081526011602052604081205463ffffffff16908161307c5760006130bb565b6001600160a01b0385166000908152601060209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b905060006130e282856040518060600160405280602c81526020016156bf602c9139613980565b90506130f0868484846139bf565b5050505b6001600160a01b03821615612f0c576001600160a01b03821660009081526011602052604081205463ffffffff16908161312f57600061316e565b6001600160a01b0384166000908152601060209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b9050600061319582856040518060600160405280602b81526020016155ab602b9139613b7b565b90506124f4858484846139bf565b805460009081905b8015613241578360018203815481106131c057fe5b6000918252602090912060016002909202018101546001600160801b03600160801b9091041614156132235761321c8460018303815481106131fe57fe5b6000918252602090912060029091020154839063ffffffff612f7216565b9150613238565b6132358460018303815481106112c157fe5b92505b600019016131ab565b50915091565b8254604080516060810182526000808252602080830182815260019484018581528587018a5589845291909220925160028602909301928355905191909201805492516001600160801b03908116600160801b029281166001600160801b0319909416939093179092161790555b6000811180156132f05750818460018303815481106132d057fe5b60009182526020909120600160029092020101546001600160801b031611155b156133775783600182038154811061330457fe5b906000526020600020906002020184828154811061331e57fe5b600091825260209091208254600290920201908155600191820180549290910180546001600160801b0319166001600160801b03938416178082559154600160801b9081900484160291909216179055600019016132b5565b604051806060016040528084815260200161339184613bae565b6001600160801b0316815260200160016001600160801b03168152508482815481106133b957fe5b60009182526020918290208351600292830290910190815591830151600190920180546040909401516001600160801b03199094166001600160801b03938416178316600160801b939094169290920292909217905585015461341c9084612f72565b85600201819055505050505050565b6001600160a01b0381166134515760405162461bcd60e51b81526004016107a890615278565b604780546001600160a01b038381166001600160a01b03198316179092556040519116907f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0906134a49083908590614f88565b60405180910390a15050565b6001600160a01b038083166000908152600f6020526040812054909116906134d784613bd7565b6001600160a01b038581166000818152600f602052604080822080546001600160a01b031916898616908117909155905194955093928616927f0cc323ffec3ea49cbcddc0de1480978126d350c6a45dff33ad2f1cda6ae992619190a4612f6c828483613011565b6001600160a01b038116610f0a5760405162461bcd60e51b81526004016107a8906152d8565b60010154426001600160801b03909116111590565b805460009081905b60008111801561359f575061359f84600183038154811061129757fe5b15613640578360018203815481106135b357fe5b6000918252602090912060016002909202018101546001600160801b03600160801b9091041614156135f8576135f18460018303815481106131fe57fe5b915061360d565b61360a8460018303815481106112c157fe5b92505b8380548061361757fe5b600082815260208120600019928301600281029091018281556001019190915590915501613582565b50613665613654828463ffffffff612f7216565b60028601549063ffffffff6136ed16565b60028501559250929050565b60008261368057506000611524565b8282028284828161368d57fe5b04146108275760405162461bcd60e51b81526004016107a890615318565b600061082783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613ced565b600061082783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613d24565b604051612f0c90849063a9059cbb60e01b90612f359086908690602401615074565b6001600160a01b038116600090815260086020526040812054905b81811015612f0c5761377e8382612aa7565b60010161376c565b607a54610100900460ff16156137ae5760405162461bcd60e51b81526004016107a8906153b8565b811580156137ba575080155b156137d75760405162461bcd60e51b81526004016107a890615338565b8180156137e357508015155b156138005760405162461bcd60e51b81526004016107a890615258565b607a805460ff191683151517905581613819578061381f565b6301e133805b6079555050607a805461ff001916610100179055565b4690565b600080600061384a87878787613d48565b9150915061385781613e28565b5090505b949350505050565b4390565b4290565b61387d826001600160a01b0316613ef1565b6138995760405162461bcd60e51b81526004016107a8906153d8565b60006060836001600160a01b0316836040516138b59190614ef9565b6000604051808303816000865af19150503d80600081146138f2576040519150601f19603f3d011682016040523d82523d6000602084013e6138f7565b606091505b5091509150816139195760405162461bcd60e51b81526004016107a8906153c8565b805115612f6c5780806020019051613934919081019061425f565b612f6c5760405162461bcd60e51b81526004016107a890615208565b600083830182858210156139775760405162461bcd60e51b81526004016107a89190615167565b50949350505050565b6000836001600160601b0316836001600160601b0316111582906139b75760405162461bcd60e51b81526004016107a89190615167565b505050900390565b60006139ea6139cc61264d565b60405180608001604052806042815260200161564a60429139613f2a565b905060008463ffffffff16118015613a3357506001600160a01b038516600090815260106020908152604080832063ffffffff6000198901811685529252909120548282169116145b15613a92576001600160a01b0385166000908152601060209081526040808320600019880163ffffffff168452909152902080546fffffffffffffffffffffffff000000001916600160201b6001600160601b03851602179055613b31565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000818152601083528781208c871682528352878120965187549451909516600160201b026fffffffffffffffffffffffff000000001995871663ffffffff19958616179590951694909417909555938252601190935292909220805460018801909316929091169190911790555b846001600160a01b03167f6adb589fed1e8542fb7a6b10f00a85e02265e77f9ae3ca8ff93b22983e1af9a08484604051613b6c929190615493565b60405180910390a25050505050565b6000838301826001600160601b0380871690831610156139775760405162461bcd60e51b81526004016107a89190615167565b6000600160801b8210613bd35760405162461bcd60e51b81526004016107a890615248565b5090565b6005546000906001600160a01b0316613c025760405162461bcd60e51b81526004016107a8906151f8565b6005546001600160a01b03166000908152600860205260408120805490915b81811015613ce25760055483546001600160a01b0390911690849083908110613c4657fe5b60009182526020909120600590910201546001600160a01b03161415613cda576005546001600160a01b039081166000908152600760209081526040808320858452825280832093891683529290522060028101548154613ccf91613cb1919063ffffffff6136ed16565b60405180606001604052806028815260200161560160289139612fe2565b94505050505061108d565b600101613c21565b506000949350505050565b60008183613d0e5760405162461bcd60e51b81526004016107a89190615167565b506000838581613d1a57fe5b0495945050505050565b600081848411156139b75760405162461bcd60e51b81526004016107a89190615167565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613d7f5750600090506003613e1f565b8460ff16601b14158015613d9757508460ff16601c14155b15613da85750600090506004613e1f565b600060018787878760405160008152602001604052604051613dcd94939291906150f2565b6020604051602081039080840390855afa158015613def573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613e1857506000915060019050613e1f565b9150600090505b94509492505050565b6000816004811115613e3657fe5b1415613e4157610f0a565b6001816004811115613e4f57fe5b1415613e6d5760405162461bcd60e51b81526004016107a890615178565b6002816004811115613e7b57fe5b1415613e995760405162461bcd60e51b81526004016107a8906151b8565b6003816004811115613ea757fe5b1415613ec55760405162461bcd60e51b81526004016107a890615288565b6004816004811115613ed357fe5b1415610f0a5760405162461bcd60e51b81526004016107a8906152f8565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061385b575050151592915050565b600081600160201b84106130095760405162461bcd60e51b81526004016107a89190615167565b604080518082019091526000808252602082015290565b803561152481615569565b805161152481615569565b80356115248161557d565b80516115248161557d565b803561152481615586565b80356115248161558f565b805161152481615586565b803561152481615598565b8035611524816155a1565b600060208284031215613fdd57600080fd5b600061385b8484613f68565b600060208284031215613ffb57600080fd5b600061385b8484613f73565b6000806040838503121561401a57600080fd5b60006140268585613f68565b925050602061403785828601613f68565b9150509250929050565b60008060006060848603121561405657600080fd5b60006140628686613f68565b935050602061407386828701613f68565b925050604061408486828701613f94565b9150509250925092565b600080604083850312156140a157600080fd5b60006140ad8585613f68565b925050602061403785828601613f94565b6000806000606084860312156140d357600080fd5b60006140df8686613f68565b93505060206140f086828701613f94565b925050604061408486828701613f68565b600080600080600060a0868803121561411957600080fd5b60006141258888613f68565b955050602061413688828901613f94565b945050604061414788828901613f9f565b935050606061415888828901613f94565b925050608061416988828901613f94565b9150509295509295909350565b60008060006060848603121561418b57600080fd5b60006141978686613f68565b935050602061407386828701613f94565b60008060008060008060c087890312156141c157600080fd5b60006141cd8989613f68565b96505060206141de89828a01613f94565b95505060406141ef89828a01613f94565b945050606061420089828a01613fc0565b935050608061421189828a01613f94565b92505060a061422289828a01613f94565b9150509295509295509295565b6000806040838503121561424257600080fd5b600061424e8585613f68565b925050602061403785828601613fb5565b60006020828403121561427157600080fd5b600061385b8484613f89565b6000806040838503121561429057600080fd5b60006140ad8585613f7e565b6000806000606084860312156142b157600080fd5b60006140628686613f9f565b6000602082840312156142cf57600080fd5b600061385b8484613f9f565b6000602082840312156142ed57600080fd5b600061385b8484613faa565b60006143058383614e99565b505060600190565b61431681615512565b82525050565b614316816154c1565b6000614330826154b4565b61433a81856154b8565b9350614345836154ae565b8060005b8381101561437357815161435d88826142f9565b9750614368836154ae565b925050600101614349565b509495945050505050565b614316816154cc565b614316816154d1565b61431661439c826154d1565b6154d1565b60006143ac826154b4565b6143b6818561108d565b93506143c6818560208601615533565b9290920192915050565b614316816154d4565b6143168161551d565b60006143ed826154b4565b6143f781856154b8565b9350614407818560208601615533565b6144108161555f565b9093019392505050565b60006144276018836154b8565b7f45434453413a20696e76616c6964207369676e61747572650000000000000000815260200192915050565b60006144606012836154b8565b71696e636f6e73697374656e7420737461746560701b815260200192915050565b600061448e6013836154b8565b727661756c743a20706f6f6c206578697374733f60681b815260200192915050565b60006144bd601f836154b8565b7f53746f726520636f6e7472616374206164647265737320697320656d70747900815260200192915050565b60006144f6601f836154b8565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800815260200192915050565b600061452f600f836154b8565b6e15985d5b1d081a5cc81c185d5cd959608a1b815260200192915050565b600061455a6013836154b8565b7215985d5b1d081a5cc81b9bdd081c185d5cd959606a1b815260200192915050565b6000614589600c836154b8565b6b155b985d5d1a1bdc9a5e995960a21b815260200192915050565b60006145b16030836154b8565b7f5856535661756c743a3a6765745374616b65416d6f756e743a2078767320616481526f191c995cdcc81a5cc81b9bdd081cd95d60821b602082015260400192915050565b6000614603602a836154b8565b7f5361666542455032303a204245503230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b602082015260400192915050565b600061464f602a836154b8565b7f5856535661756c743a3a64656c656761746542795369673a207369676e6174758152691c9948195e1c1a5c995960b21b602082015260400192915050565b600061469b6022836154b8565b7f7072696d6520746f6b656e2063616e6e6f74206265207a65726f206164647265815261737360f01b602082015260400192915050565b60006146df6026836154b8565b7f5856535661756c743a3a64656c656761746542795369673a20696e76616c6964815265206e6f6e636560d01b602082015260400192915050565b600061472760028361108d565b61190160f01b815260020192915050565b60006147456027836154b8565b7f53616665436173743a2076616c756520646f65736e27742066697420696e20318152663238206269747360c81b602082015260400192915050565b600061478e6020836154b8565b7f496e76616c69642074696d6520626173656420636f6e66696775726174696f6e815260200192915050565b60006147c76017836154b8565b7f5661756c7420697320616c726561647920706175736564000000000000000000815260200192915050565b60006148006025836154b8565b7f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164815264647265737360d81b602082015260400192915050565b60006148476022836154b8565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b602082015260400192915050565b600061488b601a836154b8565b7f546f6b656e2065786973747320696e206f7468657220706f6f6c000000000000815260200192915050565b60006148c46013836154b8565b72185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b815260200192915050565b60006148f3602b836154b8565b7f5856535661756c743a3a6765745072696f72566f7465733a206e6f742079657481526a0819195d195c9b5a5b995960aa1b602082015260400192915050565b6000614940601d836154b8565b7f7265776172642063616e6e6f74206265207a65726f2061646472657373000000815260200192915050565b60006149796018836154b8565b7f7a65726f2061646472657373206e6f7420616c6c6f7765640000000000000000815260200192915050565b60006149b2601a836154b8565b7f657865637574652070656e64696e67207769746864726177616c000000000000815260200192915050565b60006149eb6022836154b8565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b602082015260400192915050565b6000614a2f60438361108d565b7f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353681527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208201526263742960e81b604082015260430192915050565b6000614a9a601f836154b8565b7f72657175657374656420616d6f756e742063616e6e6f74206265207a65726f00815260200192915050565b6000614ad36021836154b8565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000614b166012836154b8565b71141bdbdb08185b1c9958591e48185919195960721b815260200192915050565b6000614b446017836154b8565b7f496e76616c696420626c6f636b73207065722079656172000000000000000000815260200192915050565b6000614b7d600a836154b8565b691c994b595b9d195c995960b21b815260200192915050565b6000614ba36014836154b8565b7324b73b30b634b2103932bbb0b932103a37b5b2b760611b815260200192915050565b6000614bd3600e836154b8565b6d37b7363c9030b236b4b71031b0b760911b815260200192915050565b6000614bfd6015836154b8565b7418da185b99d9481b9bdd08185d5d1a1bdc9a5e9959605a1b815260200192915050565b6000614c2e6013836154b8565b726e6f7468696e6720746f20776974686472617760681b815260200192915050565b6000614c5d601a836154b8565b7f496e76616c6964206e6577206c6f636b696e6720706572696f64000000000000815260200192915050565b6000614c96601d836154b8565b7f416c6c6f6320706f696e7473206d757374206e6f74206265207a65726f000000815260200192915050565b6000614ccf601f836154b8565b7f416c726561647920696e697469616c697a65642054696d654d616e6167657200815260200192915050565b6000614d086020836154b8565b7f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564815260200192915050565b6000614d41603a8361108d565b7f44656c65676174696f6e28616464726573732064656c6567617465652c75696e81527f74323536206e6f6e63652c75696e7432353620657870697279290000000000006020820152603a0192915050565b6000614da0601f836154b8565b7f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e747261637400815260200192915050565b6000614dd9601b836154b8565b7f72657175657374656420616d6f756e7420697320696e76616c69640000000000815260200192915050565b6000614e126022836154b8565b7f6f6e6c792070726f78792061646d696e2063616e206368616e676520627261698152616e7360f01b602082015260400192915050565b6000614e56602e836154b8565b7f416c6c6f6320706f696e7473207065722072657761726420746f6b656e206d7581526d7374206e6f74206265207a65726f60901b602082015260400192915050565b80516060830190614eaa8482614387565b506020820151614ebd6020850182614ecc565b506040820151612f6c60408501825b614316816154df565b614316816154f7565b61431681615500565b61431681615528565b61431681615506565b600061082782846143a1565b6000614f108261471a565b9150614f1c8285614390565b602082019150614f2c8284614390565b5060200192915050565b600061152482614a22565b600061152482614d34565b60208101611524828461431c565b60208101611524828461430d565b60408101614f76828561430d565b818103602083015261385b81846143e2565b60408101614f96828561431c565b610827602083018461431c565b60608101614fb1828661431c565b614fbe602083018561430d565b61385b6040830184614387565b60808101614fd9828761431c565b614fe6602083018661431c565b614ff3604083018561431c565b615000606083018461431c565b95945050505050565b60608101615017828661431c565b614fbe602083018561431c565b60808101615032828761431c565b61503f602083018661431c565b61504c6040830185614387565b6150006060830184614387565b60408101615067828561431c565b610827602083018461437e565b60408101615082828561431c565b6108276020830184614387565b602080825281016108278184614325565b60208101611524828461437e565b602081016115248284614387565b608081016150328287614387565b608081016150d88287614387565b6150e56020830186614387565b614ff36040830185614387565b608081016151008287614387565b61503f6020830186614ede565b6020810161152482846143d0565b60a0810161512982886143d0565b6151366020830187614387565b6151436040830186614387565b6151506060830185614387565b61515d6080830184614387565b9695505050505050565b6020808252810161082781846143e2565b602080825281016115248161441a565b6020808252810161152481614453565b6020808252810161152481614481565b60208082528101611524816144b0565b60208082528101611524816144e9565b6020808252810161152481614522565b602080825281016115248161454d565b602080825281016115248161457c565b60208082528101611524816145a4565b60208082528101611524816145f6565b6020808252810161152481614642565b602080825281016115248161468e565b60208082528101611524816146d2565b6020808252810161152481614738565b6020808252810161152481614781565b60208082528101611524816147ba565b60208082528101611524816147f3565b602080825281016115248161483a565b602080825281016115248161487e565b60208082528101611524816148b7565b60208082528101611524816148e6565b6020808252810161152481614933565b602080825281016115248161496c565b60208082528101611524816149a5565b60208082528101611524816149de565b6020808252810161152481614a8d565b6020808252810161152481614ac6565b6020808252810161152481614b09565b6020808252810161152481614b37565b6020808252810161152481614b70565b6020808252810161152481614b96565b6020808252810161152481614bc6565b6020808252810161152481614bf0565b6020808252810161152481614c21565b6020808252810161152481614c50565b6020808252810161152481614c89565b6020808252810161152481614cc2565b6020808252810161152481614cfb565b6020808252810161152481614d93565b6020808252810161152481614dcc565b6020808252810161152481614e05565b6020808252810161152481614e49565b604081016154268285614387565b61082760208301846143d9565b604081016150828285614387565b6060810161544f8286614387565b614fbe6020830185614387565b602081016115248284614ed5565b604081016154788285614ed5565b6108276020830184614ef0565b602081016115248284614ef0565b604081016154a18285614ee7565b6108276020830184614ee7565b60200190565b5190565b90815260200190565b6000611524826154eb565b151590565b90565b6000611524826154c1565b6001600160801b031690565b6001600160a01b031690565b63ffffffff1690565b60ff1690565b6001600160601b031690565b6000611524826154d4565b6000611524826154d1565b600061152482615506565b60005b8381101561554e578181015183820152602001615536565b83811115612f6c5750506000910152565b601f01601f191690565b615572816154c1565b8114610f0a57600080fd5b615572816154cc565b615572816154d1565b615572816154d4565b615572816154f7565b6155728161550056fe5856535661756c743a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f77735856535661756c743a3a726571756573745769746864726177616c3a20766f746573206f766572666c6f775856535661756c743a3a6765745374616b65416d6f756e743a20766f746573206f766572666c6f775856535661756c743a3a6465706f7369743a20766f746573206f766572666c6f775856535661756c743a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206f72207365636f6e64206578636565647320333220626974737365745769746864726177616c4c6f636b696e67506572696f6428616464726573732c75696e743235362c75696e74323536295856535661756c743a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f7773736574526577617264416d6f756e74506572426c6f636b4f725365636f6e6428616464726573732c75696e743235362961646428616464726573732c75696e743235362c616464726573732c75696e743235362c75696e7432353629a365627a7a7231582053ba350123a86f07263e7bddf3bcee0f7cf11e72f5d2678781f0eb1ebd599dc16c6578706572696d656e74616cf564736f6c63430005100040", + "devdoc": { + "author": "Venus", + "methods": { + "add(address,uint256,address,uint256,uint256)": { + "details": "This vault DOES NOT support deflationary tokens — it expects that the amount of transferred tokens would equal the actually deposited amount. In practice this means that this vault DOES NOT support USDT and similar tokens (that do not provide these guarantees).", + "params": { + "_allocPoint": "Number of allocation points assigned to this pool", + "_lockPeriod": "A period between withdrawal request and a moment when it's executable", + "_rewardPerBlockOrSecond": "Initial reward per block or second, in terms of _rewardToken", + "_rewardToken": "Reward token address", + "_token": "Staked token" + } + }, + "claim(address,address,uint256)": { + "params": { + "_account": "The account for which to claim rewards", + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address" + } + }, + "delegate(address)": { + "params": { + "delegatee": "The address to delegate votes to" + } + }, + "delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)": { + "params": { + "delegatee": "The address to delegate votes to", + "expiry": "The time at which to expire the signature", + "nonce": "The contract state required to match the signature", + "r": "Half of the ECDSA signature pair", + "s": "Half of the ECDSA signature pair", + "v": "The recovery byte of the signature" + } + }, + "deposit(address,uint256,uint256)": { + "params": { + "_amount": "The amount to deposit to vault", + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address" + } + }, + "executeWithdrawal(address,uint256)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address" + } + }, + "getBlockNumberOrTimestamp()": { + "details": "Function to simply retrieve block number or block timestamp", + "return": "Current block number or block timestamp" + }, + "getCurrentVotes(address)": { + "params": { + "account": "The address to get votes balance" + }, + "return": "The number of current votes for `account`" + }, + "getEligibleWithdrawalAmount(address,uint256,address)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address", + "_user": "The User Address" + }, + "return": "withdrawalAmount Amount that the user can withdraw" + }, + "getPriorVotes(address,uint256)": { + "params": { + "account": "The address of the account to check", + "blockNumberOrSecond": "The block number or second to get the vote balance at" + }, + "return": "The balance that user staked" + }, + "getRequestedAmount(address,uint256,address)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address", + "_user": "The User Address" + }, + "return": "Total amount of requested but not yet executed withdrawals (including both executable and locked ones)" + }, + "getUserInfo(address,uint256,address)": { + "params": { + "_pid": "Pool index", + "_rewardToken": "Reward token address", + "_user": "User address" + }, + "return": "amount Deposited amountrewardDebt Reward debt (technical value used to track past payouts)pendingWithdrawals Requested but not yet executed withdrawals" + }, + "getWithdrawalRequests(address,uint256,address)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address", + "_user": "The User Address" + }, + "return": "An array of withdrawal requests" + }, + "initializeTimeManager(bool,uint256)": { + "details": "Initializes the contract to use either blocks or seconds", + "params": { + "blocksPerYear_": "The number of blocks per year", + "timeBased_": "A boolean indicating whether the contract is based on time or block If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR" + } + }, + "pendingReward(address,uint256,address)": { + "params": { + "_pid": "Pool index", + "_rewardToken": "Reward token address", + "_user": "User address" + }, + "return": "Reward the user is eligible for in this pool, in terms of _rewardToken" + }, + "pendingWithdrawalsBeforeUpgrade(address,uint256,address)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address", + "_user": "The address of the user" + }, + "return": "beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade" + }, + "poolLength(address)": { + "params": { + "rewardToken": "Reward token address" + }, + "return": "Number of pools that distribute the specified token as a reward" + }, + "requestWithdrawal(address,uint256,uint256)": { + "params": { + "_amount": "The amount to withdraw from the vault", + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address" + } + }, + "rewardTokenAmountsPerBlock(address)": { + "params": { + "_rewardToken": "Reward token address" + }, + "return": "Number of reward tokens created per block or second" + }, + "set(address,uint256,uint256)": { + "params": { + "_allocPoint": "Number of allocation points assigned to this pool", + "_pid": "Pool index", + "_rewardToken": "Reward token address" + } + }, + "setAccessControl(address)": { + "details": "Admin function to set the access control address", + "params": { + "newAccessControlAddress": "New address for the access control" + } + }, + "setPrimeToken(address,address,uint256)": { + "params": { + "_primePoolId": "pool id for reward", + "_primeRewardToken": "address of reward token", + "_primeToken": "address of the prime token contract" + } + }, + "setRewardAmountPerBlockOrSecond(address,uint256)": { + "params": { + "_rewardAmount": "Number of allocation points assigned to this pool", + "_rewardToken": "Reward token address" + } + }, + "setWithdrawalLockingPeriod(address,uint256,uint256)": { + "params": { + "_newPeriod": "New lock period", + "_pid": "Pool index", + "_rewardToken": "Reward token address" + } + }, + "updatePool(address,uint256)": { + "params": { + "_pid": "Pool index", + "_rewardToken": "Reward token address" + } + } + }, + "title": "XVS Vault" + }, + "userdoc": { + "methods": { + "_become(address)": { + "notice": "* Admin Functions **" + }, + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "add(address,uint256,address,uint256,uint256)": { + "notice": "Add a new token pool" + }, + "claim(address,address,uint256)": { + "notice": "Claim rewards for pool" + }, + "constructor": "XVSVault constructor", + "delegate(address)": { + "notice": "Delegate votes from `msg.sender` to `delegatee`" + }, + "delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)": { + "notice": "Delegates votes from signatory to `delegatee`" + }, + "deposit(address,uint256,uint256)": { + "notice": "Deposit XVSVault for XVS allocation" + }, + "executeWithdrawal(address,uint256)": { + "notice": "Execute withdrawal to XVSVault for XVS allocation" + }, + "getCurrentVotes(address)": { + "notice": "Gets the current votes balance for `account`" + }, + "getEligibleWithdrawalAmount(address,uint256,address)": { + "notice": "Get unlocked withdrawal amount" + }, + "getPriorVotes(address,uint256)": { + "notice": "Determine the xvs stake balance for an account" + }, + "getRequestedAmount(address,uint256,address)": { + "notice": "Get requested amount" + }, + "getUserInfo(address,uint256,address)": { + "notice": "Get user info with reward token address and pid" + }, + "getWithdrawalRequests(address,uint256,address)": { + "notice": "Returns the array of withdrawal requests that have not been executed yet" + }, + "pause()": { + "notice": "Pauses vault" + }, + "pendingReward(address,uint256,address)": { + "notice": "View function to see pending XVSs on frontend" + }, + "pendingWithdrawalsBeforeUpgrade(address,uint256,address)": { + "notice": "Gets the total pending withdrawal amount of a user before upgrade" + }, + "poolLength(address)": { + "notice": "Returns the number of pools with the specified reward token" + }, + "requestWithdrawal(address,uint256,uint256)": { + "notice": "Request withdrawal to XVSVault for XVS allocation" + }, + "resume()": { + "notice": "Resume vault" + }, + "rewardTokenAmountsPerBlock(address)": { + "notice": "Returns the number of reward tokens created per block or second" + }, + "set(address,uint256,uint256)": { + "notice": "Update the given pool's reward allocation point" + }, + "setAccessControl(address)": { + "notice": "Sets the address of the access control of this contract" + }, + "setPrimeToken(address,address,uint256)": { + "notice": "Sets the address of the prime token contract" + }, + "setRewardAmountPerBlockOrSecond(address,uint256)": { + "notice": "Update the given reward token's amount per block or second" + }, + "setWithdrawalLockingPeriod(address,uint256,uint256)": { + "notice": "Update the lock period after which a requested withdrawal can be executed" + }, + "updatePool(address,uint256)": { + "notice": "Update reward variables of the given pool to be up-to-date" + } + }, + "notice": "The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS." + }, + "storageLayout": { + "storage": [ + { + "astId": 40377, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "admin", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 40379, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "pendingAdmin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 40381, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "implementation", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 40383, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "pendingXVSVaultImplementation", + "offset": 0, + "slot": "3", + "type": "t_address" + }, + { + "astId": 40388, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "_notEntered", + "offset": 20, + "slot": "3", + "type": "t_bool" + }, + { + "astId": 40390, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "xvsStore", + "offset": 0, + "slot": "4", + "type": "t_address" + }, + { + "astId": 40392, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "xvsAddress", + "offset": 0, + "slot": "5", + "type": "t_address" + }, + { + "astId": 40396, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "rewardTokenAmountsPerBlockOrSecond", + "offset": 0, + "slot": "6", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 40429, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "userInfos", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_mapping(t_address,t_struct(UserInfo)40403_storage)))" + }, + { + "astId": 40434, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "poolInfos", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_array(t_struct(PoolInfo)40414_storage)dyn_storage)" + }, + { + "astId": 40438, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "totalAllocPoints", + "offset": 0, + "slot": "9", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 40447, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "withdrawalRequests", + "offset": 0, + "slot": "10", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_mapping(t_address,t_array(t_struct(WithdrawalRequest)40421_storage)dyn_storage)))" + }, + { + "astId": 40451, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__oldDelegatesSlot", + "offset": 0, + "slot": "11", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 40462, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__oldCheckpointsSlot", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_address,t_mapping(t_uint32,t_struct(Checkpoint)40456_storage))" + }, + { + "astId": 40466, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__oldNumCheckpointsSlot", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_address,t_uint32)" + }, + { + "astId": 40470, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "nonces", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 40487, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "delegates", + "offset": 0, + "slot": "15", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 40493, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "checkpoints", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_mapping(t_uint32,t_struct(Checkpoint)40456_storage))" + }, + { + "astId": 40497, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "numCheckpoints", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_uint32)" + }, + { + "astId": 40503, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "totalPendingWithdrawals", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))" + }, + { + "astId": 40505, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "vaultPaused", + "offset": 0, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 40509, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "isStakedToken", + "offset": 0, + "slot": "20", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 40515, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "pendingRewardTransfers", + "offset": 0, + "slot": "21", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 40517, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "primeToken", + "offset": 0, + "slot": "22", + "type": "t_contract(IPrime)12523" + }, + { + "astId": 40519, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "primeRewardToken", + "offset": 0, + "slot": "23", + "type": "t_address" + }, + { + "astId": 40521, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "primePoolId", + "offset": 0, + "slot": "24", + "type": "t_uint256" + }, + { + "astId": 40525, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__gap", + "offset": 0, + "slot": "25", + "type": "t_array(t_uint256)46_storage" + }, + { + "astId": 4, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "_accessControlManager", + "offset": 0, + "slot": "71", + "type": "t_contract(IAccessControlManagerV5)1917" + }, + { + "astId": 8, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__gap", + "offset": 0, + "slot": "72", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 1924, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "blocksOrSecondsPerYear", + "offset": 0, + "slot": "121", + "type": "t_uint256" + }, + { + "astId": 1926, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "isTimeBased", + "offset": 0, + "slot": "122", + "type": "t_bool" + }, + { + "astId": 1928, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "isInitialized", + "offset": 1, + "slot": "122", + "type": "t_bool" + }, + { + "astId": 1930, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__deprecatedSlot1", + "offset": 2, + "slot": "122", + "type": "t_bytes8" + }, + { + "astId": 1934, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__gap", + "offset": 0, + "slot": "123", + "type": "t_array(t_uint256)48_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_struct(PoolInfo)40414_storage)dyn_storage": { + "base": "t_struct(PoolInfo)40414_storage", + "encoding": "dynamic_array", + "label": "struct XVSVaultStorageV1.PoolInfo[]", + "numberOfBytes": "32" + }, + "t_array(t_struct(WithdrawalRequest)40421_storage)dyn_storage": { + "base": "t_struct(WithdrawalRequest)40421_storage", + "encoding": "dynamic_array", + "label": "struct XVSVaultStorageV1.WithdrawalRequest[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)46_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[46]", + "numberOfBytes": "1472" + }, + "t_array(t_uint256)48_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes8": { + "encoding": "inplace", + "label": "bytes8", + "numberOfBytes": "8" + }, + "t_contract(IAccessControlManagerV5)1917": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV5", + "numberOfBytes": "20" + }, + "t_contract(IBEP20)33670": { + "encoding": "inplace", + "label": "contract IBEP20", + "numberOfBytes": "20" + }, + "t_contract(IPrime)12523": { + "encoding": "inplace", + "label": "contract IPrime", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_array(t_struct(PoolInfo)40414_storage)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct XVSVaultStorageV1.PoolInfo[])", + "numberOfBytes": "32", + "value": "t_array(t_struct(PoolInfo)40414_storage)dyn_storage" + }, + "t_mapping(t_address,t_array(t_struct(WithdrawalRequest)40421_storage)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct XVSVaultStorageV1.WithdrawalRequest[])", + "numberOfBytes": "32", + "value": "t_array(t_struct(WithdrawalRequest)40421_storage)dyn_storage" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_mapping(t_address,t_array(t_struct(WithdrawalRequest)40421_storage)dyn_storage)))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint256 => mapping(address => struct XVSVaultStorageV1.WithdrawalRequest[])))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint256,t_mapping(t_address,t_array(t_struct(WithdrawalRequest)40421_storage)dyn_storage))" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_mapping(t_address,t_struct(UserInfo)40403_storage)))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint256 => mapping(address => struct XVSVaultStorageV1.UserInfo)))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint256,t_mapping(t_address,t_struct(UserInfo)40403_storage))" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint256 => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint256,t_uint256)" + }, + "t_mapping(t_address,t_mapping(t_uint32,t_struct(Checkpoint)40456_storage))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint32 => struct XVSVaultStorageV1.Checkpoint))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint32,t_struct(Checkpoint)40456_storage)" + }, + "t_mapping(t_address,t_struct(UserInfo)40403_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct XVSVaultStorageV1.UserInfo)", + "numberOfBytes": "32", + "value": "t_struct(UserInfo)40403_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_uint32)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint32)", + "numberOfBytes": "32", + "value": "t_uint32" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_array(t_struct(WithdrawalRequest)40421_storage)dyn_storage))": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => mapping(address => struct XVSVaultStorageV1.WithdrawalRequest[]))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_array(t_struct(WithdrawalRequest)40421_storage)dyn_storage)" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_struct(UserInfo)40403_storage))": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => mapping(address => struct XVSVaultStorageV1.UserInfo))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_struct(UserInfo)40403_storage)" + }, + "t_mapping(t_uint256,t_uint256)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_uint32,t_struct(Checkpoint)40456_storage)": { + "encoding": "mapping", + "key": "t_uint32", + "label": "mapping(uint32 => struct XVSVaultStorageV1.Checkpoint)", + "numberOfBytes": "32", + "value": "t_struct(Checkpoint)40456_storage" + }, + "t_struct(Checkpoint)40456_storage": { + "encoding": "inplace", + "label": "struct XVSVaultStorageV1.Checkpoint", + "members": [ + { + "astId": 40453, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "fromBlockOrSecond", + "offset": 0, + "slot": "0", + "type": "t_uint32" + }, + { + "astId": 40455, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "votes", + "offset": 4, + "slot": "0", + "type": "t_uint96" + } + ], + "numberOfBytes": "32" + }, + "t_struct(PoolInfo)40414_storage": { + "encoding": "inplace", + "label": "struct XVSVaultStorageV1.PoolInfo", + "members": [ + { + "astId": 40405, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "token", + "offset": 0, + "slot": "0", + "type": "t_contract(IBEP20)33670" + }, + { + "astId": 40407, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "allocPoint", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 40409, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "lastRewardBlockOrSecond", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 40411, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "accRewardPerShare", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 40413, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "lockPeriod", + "offset": 0, + "slot": "4", + "type": "t_uint256" + } + ], + "numberOfBytes": "160" + }, + "t_struct(UserInfo)40403_storage": { + "encoding": "inplace", + "label": "struct XVSVaultStorageV1.UserInfo", + "members": [ + { + "astId": 40398, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "amount", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 40400, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "rewardDebt", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 40402, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "pendingWithdrawals", + "offset": 0, + "slot": "2", + "type": "t_uint256" + } + ], + "numberOfBytes": "96" + }, + "t_struct(WithdrawalRequest)40421_storage": { + "encoding": "inplace", + "label": "struct XVSVaultStorageV1.WithdrawalRequest", + "members": [ + { + "astId": 40416, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "amount", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 40418, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "lockedUntil", + "offset": 0, + "slot": "1", + "type": "t_uint128" + }, + { + "astId": 40420, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "afterUpgrade", + "offset": 16, + "slot": "1", + "type": "t_uint128" + } + ], + "numberOfBytes": "64" + }, + "t_uint128": { + "encoding": "inplace", + "label": "uint128", + "numberOfBytes": "16" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint32": { + "encoding": "inplace", + "label": "uint32", + "numberOfBytes": "4" + }, + "t_uint96": { + "encoding": "inplace", + "label": "uint96", + "numberOfBytes": "12" + } + } + } +} diff --git a/deployments/xlayertestnet/solcInputs/61db31590278030f2b5f03e8109c4f65.json b/deployments/opmainnet/solcInputs/7584667b44eb77970ba8d274006d81ae.json similarity index 85% rename from deployments/xlayertestnet/solcInputs/61db31590278030f2b5f03e8109c4f65.json rename to deployments/opmainnet/solcInputs/7584667b44eb77970ba8d274006d81ae.json index 0461bea29..7f7c8eae5 100644 --- a/deployments/xlayertestnet/solcInputs/61db31590278030f2b5f03e8109c4f65.json +++ b/deployments/opmainnet/solcInputs/7584667b44eb77970ba8d274006d81ae.json @@ -2,25 +2,25 @@ "language": "Solidity", "sources": { "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n function __Ownable2Step_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable2Step_init_unchained() internal onlyInitializing {\n }\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() public virtual {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n function __Ownable2Step_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable2Step_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() public virtual {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" }, "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling 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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling 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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" }, "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" }, "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\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 function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\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 _requireNotPaused();\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 _requirePaused();\n _;\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 Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\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 function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\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 _requireNotPaused();\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 _requirePaused();\n _;\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 Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" }, "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.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 */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _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 making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.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 */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _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 making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" }, "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.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 \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\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-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" }, "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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 IERC20Upgradeable {\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(address from, address to, uint256 amount) external returns (bool);\n}\n" @@ -32,7 +32,7 @@ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\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 * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(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 (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" }, "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" }, "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" @@ -119,10 +119,10 @@ "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\nerror ZeroAddressNotAllowed();\n\n/// @notice Thrown if the supplied value is 0 where it is not allowed\nerror ZeroValueNotAllowed();\n\n/// @notice Checks if the provided address is nonzero, reverts otherwise\n/// @param address_ Address to check\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\nfunction ensureNonzeroAddress(address address_) pure {\n if (address_ == address(0)) {\n revert ZeroAddressNotAllowed();\n }\n}\n\n/// @notice Checks if the provided value is nonzero, reverts otherwise\n/// @param value_ Value to check\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\nfunction ensureNonzeroValue(uint256 value_) pure {\n if (value_ == 0) {\n revert ZeroValueNotAllowed();\n }\n}\n" }, "contracts/Admin/VBNBAdmin.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IProtocolShareReserve, IWBNB, VBNBAdminStorage, VTokenInterface } from \"./VBNBAdminStorage.sol\";\n\n/**\n * @title VBNBAdmin\n * @author Venus\n * @notice This contract is the \"admin\" of the vBNB market, reducing the reserves of the market, sending them to the `ProtocolShareReserve` contract,\n * and allowing the executions of the rest of the privileged functions in the vBNB contract (after checking if the sender has the required permissions).\n */\ncontract VBNBAdmin is ReentrancyGuardUpgradeable, AccessControlledV8, VBNBAdminStorage {\n using SafeERC20Upgradeable for IWBNB;\n\n /// @notice address of vBNB\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n VTokenInterface public immutable vBNB;\n\n /// @notice address of WBNB contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IWBNB public immutable WBNB;\n\n /// @notice Emitted when PSR is updated\n event ProtocolShareReserveUpdated(\n IProtocolShareReserve indexed oldProtocolShareReserve,\n IProtocolShareReserve indexed newProtocolShareReserve\n );\n\n /// @notice Emitted reserves are reduced\n event ReservesReduced(uint256 reduceAmount);\n\n /// @param _vBNB Address of the vBNB contract\n /// @param _WBNB Address of the WBNB token\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(VTokenInterface _vBNB, IWBNB _WBNB) {\n require(address(_WBNB) != address(0), \"WBNB address invalid\");\n require(address(_vBNB) != address(0), \"vBNB address invalid\");\n\n vBNB = _vBNB;\n WBNB = _WBNB;\n\n // Note that the contract is upgradeable. Use initialize() or reinitializers\n // to set the state variables.\n _disableInitializers();\n }\n\n /// @notice Used to initialize non-immutable variables\n function initialize(\n IProtocolShareReserve _protocolShareReserve,\n address accessControlManager\n ) external initializer {\n require(address(_protocolShareReserve) != address(0), \"PSR address invalid\");\n protocolShareReserve = _protocolShareReserve;\n\n __ReentrancyGuard_init();\n __AccessControlled_init(accessControlManager);\n }\n\n /**\n * @notice PSR setter.\n * @param protocolShareReserve_ Address of the PSR contract\n * @custom:access Only owner (Governance)\n * @custom:event Emits ProtocolShareReserveUpdated event.\n */\n function setProtocolShareReserve(IProtocolShareReserve protocolShareReserve_) external onlyOwner {\n require(address(protocolShareReserve_) != address(0), \"PSR address invalid\");\n emit ProtocolShareReserveUpdated(protocolShareReserve, protocolShareReserve_);\n protocolShareReserve = protocolShareReserve_;\n }\n\n /**\n * @notice Reduce reserves of vBNB, wrap them and send them to the PSR contract\n * @param reduceAmount amount of reserves to reduce\n * @custom:event Emits ReservesReduced event.\n */\n function reduceReserves(uint reduceAmount) external nonReentrant {\n require(vBNB._reduceReserves(reduceAmount) == 0, \"reduceReserves failed\");\n _wrapBNB();\n\n uint256 balance = WBNB.balanceOf(address(this));\n WBNB.safeTransfer(address(protocolShareReserve), balance);\n protocolShareReserve.updateAssetsState(\n vBNB.comptroller(),\n address(WBNB),\n IProtocolShareReserve.IncomeType.SPREAD\n );\n\n emit ReservesReduced(reduceAmount);\n }\n\n /**\n * @notice Wraps BNB into WBNB\n */\n function _wrapBNB() internal {\n uint256 bnbBalance = address(this).balance;\n WBNB.deposit{ value: bnbBalance }();\n }\n\n /**\n * @notice Invoked when BNB is sent to this contract\n * @custom:access Only vBNB is considered a valid sender\n */\n receive() external payable {\n require(msg.sender == address(vBNB), \"only vBNB can send BNB to this contract\");\n }\n\n /**\n * @notice Invoked when called function does not exist in the contract. The function will be executed in the vBNB contract.\n * @custom:access Only owner (Governance)\n */\n fallback(bytes calldata data) external payable onlyOwner returns (bytes memory) {\n (bool ok, bytes memory res) = address(vBNB).call{ value: msg.value }(data);\n require(ok, \"call failed\");\n return res;\n }\n}\n" + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IProtocolShareReserve, IWBNB, VBNBAdminStorage, VTokenInterface } from \"./VBNBAdminStorage.sol\";\n\n/**\n * @title VBNBAdmin\n * @author Venus\n * @notice This contract is the \"admin\" of the vBNB market, reducing the reserves of the market, sending them to the `ProtocolShareReserve` contract,\n * and allowing the executions of the rest of the privileged functions in the vBNB contract (after checking if the sender has the required permissions).\n */\ncontract VBNBAdmin is ReentrancyGuardUpgradeable, AccessControlledV8, VBNBAdminStorage {\n using SafeERC20Upgradeable for IWBNB;\n\n /// @notice address of vBNB\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n VTokenInterface public immutable vBNB;\n\n /// @notice address of WBNB contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IWBNB public immutable WBNB;\n\n /// @notice Emitted when PSR is updated\n event ProtocolShareReserveUpdated(\n IProtocolShareReserve indexed oldProtocolShareReserve,\n IProtocolShareReserve indexed newProtocolShareReserve\n );\n\n /// @notice Emitted reserves are reduced\n event ReservesReduced(uint256 reduceAmount);\n\n /// @param _vBNB Address of the vBNB contract\n /// @param _WBNB Address of the WBNB token\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(VTokenInterface _vBNB, IWBNB _WBNB) {\n require(address(_WBNB) != address(0), \"WBNB address invalid\");\n require(address(_vBNB) != address(0), \"vBNB address invalid\");\n\n vBNB = _vBNB;\n WBNB = _WBNB;\n\n // Note that the contract is upgradeable. Use initialize() or reinitializers\n // to set the state variables.\n _disableInitializers();\n }\n\n /// @notice Used to initialize non-immutable variables\n function initialize(\n IProtocolShareReserve _protocolShareReserve,\n address accessControlManager\n ) external initializer {\n require(address(_protocolShareReserve) != address(0), \"PSR address invalid\");\n protocolShareReserve = _protocolShareReserve;\n\n __ReentrancyGuard_init();\n __AccessControlled_init(accessControlManager);\n }\n\n /**\n * @notice PSR setter.\n * @param protocolShareReserve_ Address of the PSR contract\n * @custom:access Only owner (Governance)\n * @custom:event Emits ProtocolShareReserveUpdated event.\n */\n function setProtocolShareReserve(IProtocolShareReserve protocolShareReserve_) external onlyOwner {\n require(address(protocolShareReserve_) != address(0), \"PSR address invalid\");\n emit ProtocolShareReserveUpdated(protocolShareReserve, protocolShareReserve_);\n protocolShareReserve = protocolShareReserve_;\n }\n\n /**\n * @notice Reduce reserves of vBNB, wrap them and send them to the PSR contract\n * @param reduceAmount amount of reserves to reduce\n * @custom:event Emits ReservesReduced event.\n */\n function reduceReserves(uint reduceAmount) external nonReentrant {\n require(vBNB._reduceReserves(reduceAmount) == 0, \"reduceReserves failed\");\n _wrapBNB();\n\n uint256 balance = WBNB.balanceOf(address(this));\n WBNB.safeTransfer(address(protocolShareReserve), balance);\n protocolShareReserve.updateAssetsState(\n vBNB.comptroller(),\n address(WBNB),\n IProtocolShareReserve.IncomeType.SPREAD\n );\n\n emit ReservesReduced(reduceAmount);\n }\n\n /**\n * @notice Sets the interest rate model of the vBNB contract\n * @param newInterestRateModel Address of the new interest rate model\n * @custom:access Controlled by ACM\n */\n function setInterestRateModel(address newInterestRateModel) public returns (uint256) {\n _checkAccessAllowed(\"setInterestRateModel(address)\");\n return vBNB._setInterestRateModel(newInterestRateModel);\n }\n\n /**\n * @notice Wraps BNB into WBNB\n */\n function _wrapBNB() internal {\n uint256 bnbBalance = address(this).balance;\n WBNB.deposit{ value: bnbBalance }();\n }\n\n /**\n * @notice Invoked when BNB is sent to this contract\n * @custom:access Only vBNB is considered a valid sender\n */\n receive() external payable {\n require(msg.sender == address(vBNB), \"only vBNB can send BNB to this contract\");\n }\n\n /**\n * @notice Invoked when called function does not exist in the contract. The function will be executed in the vBNB contract.\n * @custom:access Only owner (Governance)\n */\n fallback(bytes calldata data) external payable onlyOwner returns (bytes memory) {\n (bool ok, bytes memory res) = address(vBNB).call{ value: msg.value }(data);\n require(ok, \"call failed\");\n return res;\n }\n}\n" }, "contracts/Admin/VBNBAdminStorage.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ninterface VTokenInterface {\n function _reduceReserves(uint reduceAmount) external returns (uint);\n\n function _acceptAdmin() external returns (uint);\n\n function comptroller() external returns (address);\n}\n\ninterface IWBNB is IERC20Upgradeable {\n function deposit() external payable;\n}\n\ninterface IProtocolShareReserve {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType incomeType) external;\n}\n\ncontract VBNBAdminStorage {\n /// @notice address of protocol share reserve contract\n IProtocolShareReserve public protocolShareReserve;\n\n /// @dev gap to prevent collision in inheritence\n uint256[49] private __gap;\n}\n" + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ninterface VTokenInterface {\n function _reduceReserves(uint reduceAmount) external returns (uint);\n\n function _acceptAdmin() external returns (uint);\n\n function comptroller() external returns (address);\n\n function _setInterestRateModel(address newInterestRateModel) external returns (uint);\n}\n\ninterface IWBNB is IERC20Upgradeable {\n function deposit() external payable;\n}\n\ninterface IProtocolShareReserve {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType incomeType) external;\n}\n\ncontract VBNBAdminStorage {\n /// @notice address of protocol share reserve contract\n IProtocolShareReserve public protocolShareReserve;\n\n /// @dev gap to prevent collision in inheritence\n uint256[49] private __gap;\n}\n" }, "contracts/DelegateBorrowers/MoveDebtDelegate.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { Ownable2StepUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\n\nimport { approveOrRevert } from \"../lib/approveOrRevert.sol\";\nimport { IVBep20, IComptroller } from \"../InterfacesV8.sol\";\n\ncontract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable {\n /// @dev VToken return value signalling about successful execution\n uint256 internal constant NO_ERROR = 0;\n\n /// @notice A wildcard indicating that repayment is allowed for _any_ user in the market\n address public constant ANY_USER = address(1);\n\n /// @notice User to borrow on behalf of\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable newBorrower;\n\n /// @notice Whether to allow borrowing from the corresponding vToken\n mapping(address => bool) public borrowAllowed;\n\n /// @notice Whether to allow repaying to the corresponding vToken on behalf of\n /// a certain user. Use ANY_USER to check if repayment is allowed for any user.\n mapping(address => mapping(address => bool)) public repaymentAllowed;\n\n /// @notice Emitted when vToken is allowed or denied to be borrowed from\n event BorrowAllowedSet(address indexed vTokenToBorrow, bool allowed);\n\n /// @notice Emitted when vToken is allowed or denied to be borrowed from\n event RepaymentAllowedSet(address indexed vTokenToRepay, address indexed originalBorrower, bool allowed);\n\n /// @notice Emitted if debt is swapped successfully\n event DebtMoved(\n address indexed originalBorrower,\n address indexed vTokenRepaid,\n uint256 repaidAmount,\n address newBorrower,\n address indexed vTokenBorrowed,\n uint256 borrowedAmount\n );\n\n /// @notice Emitted when the owner transfers tokens, accidentially sent to this contract,\n /// to their account\n event SweptTokens(address indexed token, uint256 amount);\n\n /// @notice Thrown if VTokens' comptrollers are not equal\n error ComptrollerMismatch();\n\n /// @notice Thrown if repayment fails with an error code\n error RepaymentFailed(uint256 errorCode);\n\n /// @notice Thrown if borrow fails with an error code\n error BorrowFailed(uint256 errorCode);\n\n /// @notice Thrown if borrowing from the corresponding vToken is not allowed\n error BorrowNotAllowed(address vToken);\n\n /// @notice Thrown if repaying the debts of the borrower to the corresponding vToken is not allowed\n error RepaymentNotAllowed(address vToken, address borrower);\n\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param newBorrower_ User to borrow on behalf of\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address newBorrower_) {\n newBorrower = newBorrower_;\n _disableInitializers();\n }\n\n function initialize() external initializer {\n __Ownable2Step_init();\n __ReentrancyGuard_init();\n }\n\n /**\n * @notice Repays originalBorrower's borrow in vTokenToRepay.underlying() and borrows\n * vTokenToBorrow.underlying() on behalf of newBorrower.\n *\n * @param originalBorrower The address of the borrower, whose debt to repay\n * @param vTokenToRepay VToken to repay to on behalf of originalBorrower\n * @param repayAmount The amount to repay in terms of vTokenToRepay.underlying()\n * @param vTokenToBorrow VToken to borrow from\n */\n function moveDebt(\n IVBep20 vTokenToRepay,\n address originalBorrower,\n uint256 repayAmount,\n IVBep20 vTokenToBorrow\n ) external nonReentrant {\n if (!borrowAllowed[address(vTokenToBorrow)]) {\n revert BorrowNotAllowed(address(vTokenToBorrow));\n }\n\n mapping(address => bool) storage repaymentAllowedFor = repaymentAllowed[address(vTokenToRepay)];\n if (!repaymentAllowedFor[ANY_USER] && !repaymentAllowedFor[originalBorrower]) {\n revert RepaymentNotAllowed(address(vTokenToRepay), originalBorrower);\n }\n\n uint256 actualRepaymentAmount = _repay(vTokenToRepay, originalBorrower, repayAmount);\n uint256 amountToBorrow = _convert(vTokenToRepay, vTokenToBorrow, actualRepaymentAmount);\n _borrow(vTokenToBorrow, amountToBorrow);\n emit DebtMoved(\n originalBorrower,\n address(vTokenToRepay),\n actualRepaymentAmount,\n newBorrower,\n address(vTokenToBorrow),\n amountToBorrow\n );\n }\n\n /**\n * @notice Allows or denies borrowing from the corresponding vToken\n * @param vTokenToBorrow VToken to borrow from\n * @param allow Whether to allow borrowing from the corresponding vToken\n */\n function setBorrowAllowed(address vTokenToBorrow, bool allow) external onlyOwner {\n ensureNonzeroAddress(vTokenToBorrow);\n if (borrowAllowed[vTokenToBorrow] != allow) {\n borrowAllowed[vTokenToBorrow] = allow;\n emit BorrowAllowedSet(vTokenToBorrow, allow);\n }\n }\n\n /**\n * @notice Allows or denies repaying the debts of originalBorrower to the corresponding vToken\n * @param vTokenToRepay VToken to repay to\n * @param originalBorrower The address of the borrower, whose debt to repay (or ANY_USER to allow\n * repayments for all users in the market, e.g. if the market is going to be deprecated soon)\n * @param allow Whether to allow repaying to the corresponding vToken on behalf of originalBorrower\n */\n function setRepaymentAllowed(address vTokenToRepay, address originalBorrower, bool allow) external onlyOwner {\n ensureNonzeroAddress(vTokenToRepay);\n ensureNonzeroAddress(originalBorrower);\n if (repaymentAllowed[vTokenToRepay][originalBorrower] != allow) {\n repaymentAllowed[vTokenToRepay][originalBorrower] = allow;\n emit RepaymentAllowedSet(vTokenToRepay, originalBorrower, allow);\n }\n }\n\n /**\n * @notice Transfers tokens, accidentially sent to this contract, to the owner\n * @param token ERC-20 token to sweep\n */\n function sweepTokens(IERC20Upgradeable token) external onlyOwner {\n uint256 amount = token.balanceOf(address(this));\n token.safeTransfer(owner(), amount);\n emit SweptTokens(address(token), amount);\n }\n\n /**\n * @dev Transfers the funds from the sender and repays a borrow in vToken on behalf of the borrower\n * @param vTokenToRepay VToken to repay to\n * @param borrower The address of the borrower, whose debt to repay\n * @param repayAmount The amount to repay in terms of underlying\n */\n function _repay(\n IVBep20 vTokenToRepay,\n address borrower,\n uint256 repayAmount\n ) internal returns (uint256 actualRepaymentAmount) {\n IERC20Upgradeable underlying = IERC20Upgradeable(vTokenToRepay.underlying());\n uint256 balanceBefore = underlying.balanceOf(address(this));\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n uint256 balanceAfter = underlying.balanceOf(address(this));\n uint256 repayAmountMinusFee = balanceAfter - balanceBefore;\n\n uint256 borrowBalanceBefore = vTokenToRepay.borrowBalanceCurrent(borrower);\n approveOrRevert(underlying, address(vTokenToRepay), repayAmountMinusFee);\n uint256 err = vTokenToRepay.repayBorrowBehalf(borrower, repayAmountMinusFee);\n if (err != NO_ERROR) {\n revert RepaymentFailed(err);\n }\n approveOrRevert(underlying, address(vTokenToRepay), 0);\n uint256 borrowBalanceAfter = vTokenToRepay.borrowBalanceCurrent(borrower);\n return borrowBalanceBefore - borrowBalanceAfter;\n }\n\n /**\n * @dev Borrows in vToken on behalf of the borrower and transfers the funds to the sender\n * @param vTokenToBorrow VToken to borrow from\n * @param borrowAmount The amount to borrow in terms of underlying\n */\n function _borrow(IVBep20 vTokenToBorrow, uint256 borrowAmount) internal {\n IERC20Upgradeable underlying = IERC20Upgradeable(vTokenToBorrow.underlying());\n uint256 balanceBefore = underlying.balanceOf(address(this));\n uint256 err = vTokenToBorrow.borrowBehalf(newBorrower, borrowAmount);\n if (err != NO_ERROR) {\n revert BorrowFailed(err);\n }\n uint256 balanceAfter = underlying.balanceOf(address(this));\n uint256 actualBorrowedAmount = balanceAfter - balanceBefore;\n underlying.safeTransfer(msg.sender, actualBorrowedAmount);\n }\n\n /**\n * @dev Converts the value expressed in convertFrom.underlying() to a value\n * in convertTo.underlying(), using the oracle price\n * @param convertFrom VToken to convert from\n * @param convertTo VToken to convert to\n * @param amount The amount in convertFrom.underlying()\n */\n function _convert(IVBep20 convertFrom, IVBep20 convertTo, uint256 amount) internal view returns (uint256) {\n IComptroller comptroller = convertFrom.comptroller();\n if (comptroller != convertTo.comptroller()) {\n revert ComptrollerMismatch();\n }\n ResilientOracleInterface oracle = comptroller.oracle();\n\n // Decimals are accounted for in the oracle contract\n uint256 scaledUsdValue = oracle.getUnderlyingPrice(address(convertFrom)) * amount; // the USD value here has 36 decimals\n return scaledUsdValue / oracle.getUnderlyingPrice(address(convertTo));\n }\n}\n" @@ -131,13 +131,25 @@ "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { Ownable2StepUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\n\nimport { approveOrRevert } from \"../lib/approveOrRevert.sol\";\nimport { IVBep20, IComptroller } from \"../InterfacesV8.sol\";\n\ncontract SwapDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable {\n /// @dev VToken return value signalling about successful execution\n uint256 internal constant NO_ERROR = 0;\n\n /// @notice Emitted if debt is swapped successfully\n event DebtSwapped(\n address indexed borrower,\n address indexed vTokenRepaid,\n uint256 repaidAmount,\n address indexed vTokenBorrowed,\n uint256 borrowedAmount\n );\n\n /// @notice Emitted when the owner transfers tokens, accidentially sent to this contract,\n /// to their account\n event SweptTokens(address indexed token, uint256 amount);\n\n /// @notice Thrown if VTokens' comptrollers are not equal\n error ComptrollerMismatch();\n\n /// @notice Thrown if repayment fails with an error code\n error RepaymentFailed(uint256 errorCode);\n\n /// @notice Thrown if borrow fails with an error code\n error BorrowFailed(uint256 errorCode);\n\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n function initialize() external initializer {\n __Ownable2Step_init();\n __ReentrancyGuard_init();\n }\n\n /**\n * @notice Repays a borrow in repayTo.underlying() and borrows borrowFrom.underlying()\n * @param borrower The address of the borrower, whose debt to swap\n * @param repayTo VToken to repay the debt to\n * @param borrowFrom VToken to borrow from\n * @param repayAmount The amount to repay in terms of repayTo.underlying()\n */\n function swapDebt(\n address borrower,\n IVBep20 repayTo,\n IVBep20 borrowFrom,\n uint256 repayAmount\n ) external onlyOwner nonReentrant {\n uint256 actualRepaymentAmount = _repay(repayTo, borrower, repayAmount);\n uint256 amountToBorrow = _convert(repayTo, borrowFrom, actualRepaymentAmount);\n _borrow(borrowFrom, borrower, amountToBorrow);\n emit DebtSwapped(borrower, address(repayTo), actualRepaymentAmount, address(borrowFrom), amountToBorrow);\n }\n\n /**\n * @notice Transfers tokens, accidentially sent to this contract, to the owner\n * @param token ERC-20 token to sweep\n */\n function sweepTokens(IERC20Upgradeable token) external onlyOwner {\n uint256 amount = token.balanceOf(address(this));\n token.safeTransfer(owner(), amount);\n emit SweptTokens(address(token), amount);\n }\n\n /**\n * @dev Transfers the funds from the sender and repays a borrow in vToken on behalf of the borrower\n * @param vToken VToken to repay the debt to\n * @param borrower The address of the borrower, whose debt to repay\n * @param repayAmount The amount to repay in terms of underlying\n */\n function _repay(\n IVBep20 vToken,\n address borrower,\n uint256 repayAmount\n ) internal returns (uint256 actualRepaymentAmount) {\n IERC20Upgradeable underlying = IERC20Upgradeable(vToken.underlying());\n uint256 balanceBefore = underlying.balanceOf(address(this));\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n uint256 balanceAfter = underlying.balanceOf(address(this));\n uint256 repayAmountMinusFee = balanceAfter - balanceBefore;\n\n underlying.safeApprove(address(vToken), 0);\n underlying.safeApprove(address(vToken), repayAmountMinusFee);\n uint256 borrowBalanceBefore = vToken.borrowBalanceCurrent(borrower);\n uint256 err = vToken.repayBorrowBehalf(borrower, repayAmountMinusFee);\n if (err != NO_ERROR) {\n revert RepaymentFailed(err);\n }\n uint256 borrowBalanceAfter = vToken.borrowBalanceCurrent(borrower);\n return borrowBalanceBefore - borrowBalanceAfter;\n }\n\n /**\n * @dev Borrows in vToken on behalf of the borrower and transfers the funds to the sender\n * @param vToken VToken to borrow from\n * @param borrower The address of the borrower, who will own the borrow\n * @param borrowAmount The amount to borrow in terms of underlying\n */\n function _borrow(IVBep20 vToken, address borrower, uint256 borrowAmount) internal {\n IERC20Upgradeable underlying = IERC20Upgradeable(vToken.underlying());\n uint256 balanceBefore = underlying.balanceOf(address(this));\n uint256 err = vToken.borrowBehalf(borrower, borrowAmount);\n if (err != NO_ERROR) {\n revert BorrowFailed(err);\n }\n uint256 balanceAfter = underlying.balanceOf(address(this));\n uint256 actualBorrowedAmount = balanceAfter - balanceBefore;\n underlying.safeTransfer(msg.sender, actualBorrowedAmount);\n }\n\n /**\n * @dev Converts the value expressed in convertFrom.underlying() to a value\n * in convertTo.underlying(), using the oracle price\n * @param convertFrom VToken to convert from\n * @param convertTo VToken to convert to\n * @param amount The amount in convertFrom.underlying()\n */\n function _convert(IVBep20 convertFrom, IVBep20 convertTo, uint256 amount) internal view returns (uint256) {\n IComptroller comptroller = convertFrom.comptroller();\n if (comptroller != convertTo.comptroller()) {\n revert ComptrollerMismatch();\n }\n ResilientOracleInterface oracle = comptroller.oracle();\n\n // Decimals are accounted for in the oracle contract\n uint256 scaledUsdValue = oracle.getUnderlyingPrice(address(convertFrom)) * amount; // the USD value here has 36 decimals\n return scaledUsdValue / oracle.getUnderlyingPrice(address(convertTo));\n }\n}\n" }, "contracts/Governance/TokenRedeemer.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { ReentrancyGuard } from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\n\nimport { IVToken, IVBep20, IVBNB } from \"../InterfacesV8.sol\";\nimport { Currency, CurrencyLibrary } from \"../lib/Currency.sol\";\n\ncontract TokenRedeemer is ReentrancyGuard, Ownable2Step {\n using CurrencyLibrary for Currency;\n\n struct AccountBorrows {\n address borrower;\n uint256 amount;\n }\n\n struct Borrows {\n uint256 totalBorrows;\n AccountBorrows[] accountBorrows;\n }\n\n IVBNB public immutable VBNB;\n\n error AccrueInterestFailed(uint256 errCode);\n error RedeemFailed(uint256 errCode);\n error RepaymentFailed(uint256 errCode);\n error NativeTokenTransferFailed();\n\n constructor(address owner_, IVBNB vBNB) {\n ensureNonzeroAddress(owner_);\n VBNB = vBNB;\n _transferOwnership(owner_);\n }\n\n receive() external payable {}\n\n function redeemAndTransfer(IVToken vToken, address destination) external nonReentrant onlyOwner {\n Currency underlying = _underlying(vToken);\n uint256 err = vToken.redeem(vToken.balanceOf(address(this)));\n if (err != 0) {\n revert RedeemFailed(err);\n }\n underlying.transferAll(destination);\n }\n\n function redeemUnderlyingAndRepayBorrowBehalf(\n IVToken vToken,\n address borrower,\n uint256 amount,\n address receiver\n ) external nonReentrant onlyOwner {\n Currency underlying = _underlying(vToken);\n\n uint256 err = vToken.redeemUnderlying(amount);\n if (err != 0) {\n revert RedeemFailed(err);\n }\n\n underlying.approve(address(vToken), amount);\n\n _repay(vToken, borrower, amount);\n\n underlying.approve(address(vToken), 0);\n\n underlying.transferAll(receiver);\n Currency.wrap(address(vToken)).transferAll(receiver);\n }\n\n function redeemAndBatchRepay(\n IVToken vToken,\n address[] calldata borrowers,\n address receiver\n ) external nonReentrant onlyOwner {\n _accrueInterest(vToken);\n\n (uint256 totalBorrowedAmount, AccountBorrows[] memory borrows) = _getBorrows(vToken, borrowers);\n _redeemUpTo(vToken, totalBorrowedAmount);\n\n Currency underlying = _underlying(vToken);\n uint256 balance = underlying.balanceOfSelf();\n underlying.approve(address(vToken), totalBorrowedAmount);\n uint256 borrowsCount = borrows.length;\n // The code below assumes no fees on transfer\n if (balance >= totalBorrowedAmount) {\n // If we're doing a full repayment, we can optimize it by skipping the balance checks\n for (uint256 i = 0; i < borrowsCount; ++i) {\n AccountBorrows memory accountBorrows = borrows[i];\n _repay(vToken, accountBorrows.borrower, accountBorrows.amount);\n }\n } else {\n // Otherwise, we have to check and update the balance on every iteration\n for (uint256 i = 0; i < borrowsCount && balance != 0; ++i) {\n AccountBorrows memory accountBorrows = borrows[i];\n _repay(vToken, accountBorrows.borrower, _min(accountBorrows.amount, balance));\n balance = underlying.balanceOfSelf();\n }\n }\n underlying.approve(address(vToken), 0);\n\n underlying.transferAll(receiver);\n Currency.wrap(address(vToken)).transferAll(receiver);\n }\n\n function sweepTokens(address token, address destination) external onlyOwner {\n Currency.wrap(token).transferAll(destination);\n }\n\n function _accrueInterest(IVToken vToken) internal {\n uint256 err = vToken.accrueInterest();\n if (err != 0) {\n revert AccrueInterestFailed(err);\n }\n }\n\n function _redeemUpTo(IVToken vToken, uint256 amount) internal {\n uint256 unredeemedUnderlying = vToken.balanceOfUnderlying(address(this));\n if (unredeemedUnderlying > 0) {\n uint256 err = vToken.redeemUnderlying(_min(amount, unredeemedUnderlying));\n if (err != 0) {\n revert RedeemFailed(err);\n }\n }\n }\n\n function _repay(IVToken vToken, address borrower, uint256 amount) internal {\n if (amount == 0) {\n return;\n }\n if (_isVBNB(vToken)) {\n IVBNB(address(vToken)).repayBorrowBehalf{ value: amount }(borrower);\n } else {\n uint256 err = IVBep20(address(vToken)).repayBorrowBehalf(borrower, amount);\n if (err != 0) {\n revert RepaymentFailed(err);\n }\n }\n }\n\n function _getBorrows(\n IVToken vToken,\n address[] calldata borrowers\n ) internal view returns (uint256, AccountBorrows[] memory) {\n uint256 borrowersCount = borrowers.length;\n AccountBorrows[] memory borrows = new AccountBorrows[](borrowersCount);\n uint256 totalBorrowedAmount = 0;\n for (uint256 i = 0; i < borrowers.length; ++i) {\n address borrower = borrowers[i];\n uint256 amount = vToken.borrowBalanceStored(borrower);\n totalBorrowedAmount += amount;\n borrows[i] = AccountBorrows({ borrower: borrower, amount: amount });\n }\n return (totalBorrowedAmount, borrows);\n }\n\n function _underlying(IVToken vToken) internal view returns (Currency) {\n if (_isVBNB(vToken)) {\n return CurrencyLibrary.NATIVE;\n }\n return Currency.wrap(IVBep20(address(vToken)).underlying());\n }\n\n function _isVBNB(IVToken vToken) internal view returns (bool) {\n return address(vToken) == address(VBNB);\n }\n\n function _min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n}\n" + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { ReentrancyGuard } from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\n\nimport { IVAIController, IVToken, IVBep20, IVBNB } from \"../InterfacesV8.sol\";\nimport { Currency, CurrencyLibrary } from \"../lib/Currency.sol\";\n\ncontract TokenRedeemer is ReentrancyGuard, Ownable2Step {\n using CurrencyLibrary for Currency;\n\n struct Repayment {\n address borrower;\n uint256 amount;\n }\n\n IVBNB public immutable VBNB;\n\n error AccrueInterestFailed(uint256 errCode);\n error RedeemFailed(uint256 errCode);\n error RepaymentFailed(uint256 errCode);\n error NativeTokenTransferFailed();\n\n constructor(address owner_, IVBNB vBNB) {\n ensureNonzeroAddress(owner_);\n VBNB = vBNB;\n _transferOwnership(owner_);\n }\n\n receive() external payable {}\n\n function redeemAndTransfer(IVToken vToken, address destination) external nonReentrant onlyOwner {\n Currency underlying = _underlying(vToken);\n uint256 err = vToken.redeem(vToken.balanceOf(address(this)));\n if (err != 0) {\n revert RedeemFailed(err);\n }\n underlying.transferAll(destination);\n }\n\n function redeemUnderlyingAndTransfer(\n IVToken vToken,\n address destination,\n uint256 amount,\n address receiver\n ) external nonReentrant onlyOwner {\n Currency underlying = _underlying(vToken);\n underlying.transferAll(receiver); // Just in case there were some underlying tokens on the contract\n uint256 err = vToken.redeemUnderlying(amount);\n if (err != 0) {\n revert RedeemFailed(err);\n }\n underlying.transferAll(destination);\n Currency.wrap(address(vToken)).transferAll(receiver);\n }\n\n function redeemUnderlyingAndRepayBorrowBehalf(\n IVToken vToken,\n address borrower,\n uint256 amount,\n address receiver\n ) external nonReentrant onlyOwner {\n Currency underlying = _underlying(vToken);\n\n uint256 err = vToken.redeemUnderlying(amount);\n if (err != 0) {\n revert RedeemFailed(err);\n }\n\n underlying.approve(address(vToken), amount);\n\n _repay(vToken, borrower, amount);\n\n underlying.approve(address(vToken), 0);\n\n underlying.transferAll(receiver);\n Currency.wrap(address(vToken)).transferAll(receiver);\n }\n\n function redeemAndBatchRepay(\n IVToken vToken,\n Repayment[] calldata requestedRepayments,\n address receiver\n ) external nonReentrant onlyOwner {\n _accrueInterest(vToken);\n\n (uint256 totalBorrowedAmount, Repayment[] memory repayments) = _getAmountsToRepay(vToken, requestedRepayments);\n _redeemUpTo(vToken, totalBorrowedAmount);\n\n Currency underlying = _underlying(vToken);\n uint256 balance = underlying.balanceOfSelf();\n underlying.approve(address(vToken), totalBorrowedAmount);\n uint256 repaymentsCount = repayments.length;\n // The code below assumes no fees on transfer\n if (balance >= totalBorrowedAmount) {\n // If we're doing a full repayment, we can optimize it by skipping the balance checks\n for (uint256 i = 0; i < repaymentsCount; ++i) {\n Repayment memory repayment = repayments[i];\n _repay(vToken, repayment.borrower, repayment.amount);\n }\n } else {\n // Otherwise, we have to check and update the balance on every iteration\n for (uint256 i = 0; i < repaymentsCount && balance != 0; ++i) {\n Repayment memory repayment = repayments[i];\n _repay(vToken, repayment.borrower, _min(repayment.amount, balance));\n balance = underlying.balanceOfSelf();\n }\n }\n underlying.approve(address(vToken), 0);\n\n underlying.transferAll(receiver);\n Currency.wrap(address(vToken)).transferAll(receiver);\n }\n\n function batchRepayVAI(\n IVAIController vaiController,\n Repayment[] calldata requestedRepayments,\n address receiver\n ) external nonReentrant onlyOwner {\n vaiController.accrueVAIInterest();\n Currency vai = Currency.wrap(vaiController.getVAIAddress());\n uint256 balance = vai.balanceOfSelf();\n vai.approve(address(vaiController), type(uint256).max);\n uint256 repaymentsCount = requestedRepayments.length;\n for (uint256 i = 0; i < repaymentsCount && balance != 0; ++i) {\n Repayment calldata requestedRepayment = requestedRepayments[i];\n uint256 repaymentCap = requestedRepayment.amount;\n uint256 debt = vaiController.getVAIRepayAmount(requestedRepayment.borrower);\n uint256 amount = _min(repaymentCap, debt);\n _repayVAI(vaiController, requestedRepayment.borrower, _min(amount, balance));\n balance = vai.balanceOfSelf();\n }\n vai.approve(address(vaiController), 0);\n vai.transferAll(receiver);\n }\n\n function sweepTokens(address token, address destination) external onlyOwner {\n Currency.wrap(token).transferAll(destination);\n }\n\n function _accrueInterest(IVToken vToken) internal {\n uint256 err = vToken.accrueInterest();\n if (err != 0) {\n revert AccrueInterestFailed(err);\n }\n }\n\n function _redeemUpTo(IVToken vToken, uint256 amount) internal {\n uint256 unredeemedUnderlying = vToken.balanceOfUnderlying(address(this));\n if (unredeemedUnderlying > 0) {\n uint256 err = vToken.redeemUnderlying(_min(amount, unredeemedUnderlying));\n if (err != 0) {\n revert RedeemFailed(err);\n }\n }\n }\n\n function _repay(IVToken vToken, address borrower, uint256 amount) internal {\n if (amount == 0) {\n return;\n }\n if (_isVBNB(vToken)) {\n IVBNB(address(vToken)).repayBorrowBehalf{ value: amount }(borrower);\n } else {\n uint256 err = IVBep20(address(vToken)).repayBorrowBehalf(borrower, amount);\n if (err != 0) {\n revert RepaymentFailed(err);\n }\n }\n }\n\n function _repayVAI(IVAIController vaiController, address borrower, uint256 amount) internal {\n if (amount == 0) {\n return;\n }\n (uint256 err, ) = vaiController.repayVAIBehalf(borrower, amount);\n if (err != 0) {\n revert RepaymentFailed(err);\n }\n }\n\n function _getAmountsToRepay(\n IVToken vToken,\n Repayment[] calldata requestedRepayments\n ) internal view returns (uint256, Repayment[] memory) {\n uint256 repaymentsCount = requestedRepayments.length;\n Repayment[] memory actualRepayments = new Repayment[](repaymentsCount);\n uint256 totalAmountToRepay = 0;\n for (uint256 i = 0; i < repaymentsCount; ++i) {\n Repayment calldata requestedRepayment = requestedRepayments[i];\n uint256 repaymentCap = requestedRepayment.amount;\n uint256 debt = vToken.borrowBalanceStored(requestedRepayment.borrower);\n uint256 amountToRepay = _min(repaymentCap, debt);\n totalAmountToRepay += amountToRepay;\n actualRepayments[i] = Repayment({ borrower: requestedRepayment.borrower, amount: amountToRepay });\n }\n return (totalAmountToRepay, actualRepayments);\n }\n\n function _underlying(IVToken vToken) internal view returns (Currency) {\n if (_isVBNB(vToken)) {\n return CurrencyLibrary.NATIVE;\n }\n return Currency.wrap(IVBep20(address(vToken)).underlying());\n }\n\n function _isVBNB(IVToken vToken) internal view returns (bool) {\n return address(vToken) == address(VBNB);\n }\n\n function _min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n}\n" }, "contracts/Governance/VTreasuryV8.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { SafeERC20, IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport { ReentrancyGuard } from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\n/**\n * @title VTreasuryV8\n * @author Venus\n * @notice Protocol treasury that holds tokens owned by Venus\n */\ncontract VTreasuryV8 is Ownable2Step, ReentrancyGuard {\n using SafeERC20 for IERC20;\n\n // WithdrawTreasuryToken Event\n event WithdrawTreasuryToken(address indexed tokenAddress, uint256 withdrawAmount, address indexed withdrawAddress);\n\n // WithdrawTreasuryNative Event\n event WithdrawTreasuryNative(uint256 withdrawAmount, address indexed withdrawAddress);\n\n /// @notice Thrown if the supplied address is a zero address where it is not allowed\n error ZeroAddressNotAllowed();\n\n /**\n * @notice To receive Native when msg.data is not empty\n */\n fallback() external payable {}\n\n /**\n * @notice To receive Native when msg.data is empty\n */\n receive() external payable {}\n\n /**\n * @notice Withdraw Treasury Tokens, Only owner call it\n * @param tokenAddress The address of treasury token\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n * @custom:error ZeroAddressNotAllowed thrown when token or withdrawAddress is zero.\n */\n function withdrawTreasuryToken(\n address tokenAddress,\n uint256 withdrawAmount,\n address withdrawAddress\n ) external onlyOwner nonReentrant {\n ensureNonzeroAddress(tokenAddress);\n ensureNonzeroAddress(withdrawAddress);\n require(withdrawAmount > 0, \"withdrawAmount must not be zero\");\n\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury Token Balance\n uint256 treasuryBalance = IERC20(tokenAddress).balanceOf(address(this));\n\n // Check Withdraw Amount\n if (withdrawAmount > treasuryBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = treasuryBalance;\n }\n\n // Transfer Token to withdrawAddress\n IERC20(tokenAddress).safeTransfer(withdrawAddress, actualWithdrawAmount);\n\n emit WithdrawTreasuryToken(tokenAddress, actualWithdrawAmount, withdrawAddress);\n }\n\n /**\n * @notice Withdraw Treasury Native, Only owner call it\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n * @custom:error ZeroAddressNotAllowed thrown when withdrawAddress is zero.\n */\n function withdrawTreasuryNative(\n uint256 withdrawAmount,\n address payable withdrawAddress\n ) external payable onlyOwner nonReentrant {\n ensureNonzeroAddress(withdrawAddress);\n require(withdrawAmount > 0, \"withdrawAmount must not be zero\");\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury Native Balance\n uint256 nativeBalance = address(this).balance;\n\n // Check Withdraw Amount\n if (withdrawAmount > nativeBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = nativeBalance;\n }\n // Transfer the native token to withdrawAddress\n (bool sent, ) = withdrawAddress.call{ value: actualWithdrawAmount }(\"\");\n require(sent, \"Call failed\");\n emit WithdrawTreasuryNative(actualWithdrawAmount, withdrawAddress);\n }\n\n /// @notice Checks if the provided address is nonzero, reverts otherwise\n /// @param address_ Address to check\n /// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\n function ensureNonzeroAddress(address address_) internal pure {\n if (address_ == address(0)) {\n revert ZeroAddressNotAllowed();\n }\n }\n}\n" }, + "contracts/hardhat-dependency-compiler/hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport 'hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol';\n" + }, + "contracts/hardhat-dependency-compiler/hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport 'hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol';\n" + }, + "contracts/InterestRateModels/InterestRateModelV8.sol": { + "content": "pragma solidity 0.8.25;\n\n/**\n * @title Venus's InterestRateModelV8 Interface\n * @author Venus\n */\nabstract contract InterestRateModelV8 {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) external view virtual returns (uint256);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) external view virtual returns (uint256);\n}\n" + }, + "contracts/InterestRateModels/TwoKinksInterestRateModel.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { InterestRateModelV8 } from \"./InterestRateModelV8.sol\";\n\n/**\n * @title TwoKinksInterestRateModel\n * @author Venus\n * @notice An interest rate model with two different slope increase or decrease each after a certain utilization threshold called **kink** is reached.\n */\ncontract TwoKinksInterestRateModel is InterestRateModelV8 {\n int256 public constant BLOCKS_PER_YEAR = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\n\n ////////////////////// SLOPE 1 //////////////////////\n\n /**\n * @notice The multiplier of utilization rate per block that gives the slope 1 of the interest rate scaled by EXP_SCALE\n */\n int256 public immutable MULTIPLIER_PER_BLOCK;\n\n /**\n * @notice The base interest rate per block which is the y-intercept when utilization rate is 0 scaled by EXP_SCALE\n */\n int256 public immutable BASE_RATE_PER_BLOCK;\n\n ////////////////////// SLOPE 2 //////////////////////\n\n /**\n * @notice The utilization point at which the multiplier2 is applied\n */\n int256 public immutable KINK_1;\n\n /**\n * @notice The multiplier of utilization rate per block that gives the slope 2 of the interest rate scaled by EXP_SCALE\n */\n int256 public immutable MULTIPLIER_2_PER_BLOCK;\n\n /**\n * @notice The base interest rate per block which is the y-intercept when utilization rate hits KINK_1 scaled by EXP_SCALE\n */\n int256 public immutable BASE_RATE_2_PER_BLOCK;\n\n /**\n * @notice The maximum kink interest rate scaled by EXP_SCALE\n */\n int256 public immutable RATE_1;\n\n ////////////////////// SLOPE 3 //////////////////////\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n int256 public immutable KINK_2;\n\n /**\n * @notice The multiplier of utilization rate per block that gives the slope 3 of interest rate scaled by EXP_SCALE\n */\n int256 public immutable JUMP_MULTIPLIER_PER_BLOCK;\n\n /**\n * @notice The maximum kink interest rate scaled by EXP_SCALE\n */\n int256 public immutable RATE_2;\n\n /// @notice Base unit for computations, usually used in scaling (multiplications, divisions)\n uint256 internal constant EXP_SCALE = 1e18;\n\n /**\n * @notice Thrown when a negative value is not allowed\n */\n error NegativeValueNotAllowed();\n\n /**\n * @notice Thrown when the kink points are not in the correct order\n */\n error InvalidKink();\n\n /**\n * @notice Construct an interest rate model\n * @param baseRatePerYear_ The approximate target base APR, as a mantissa (scaled by EXP_SCALE)\n * @param multiplierPerYear_ The rate of increase or decrease in interest rate wrt utilization (scaled by EXP_SCALE)\n * @param kink1_ The utilization point at which the multiplier2 is applied\n * @param multiplier2PerYear_ The rate of increase or decrease in interest rate wrt utilization after hitting KINK_1 (scaled by EXP_SCALE)\n * @param baseRate2PerYear_ The additional base APR after hitting KINK_1, as a mantissa (scaled by EXP_SCALE)\n * @param kink2_ The utilization point at which the jump multiplier is applied\n * @param jumpMultiplierPerYear_ The multiplier after hitting KINK_2\n */\n constructor(\n int256 baseRatePerYear_,\n int256 multiplierPerYear_,\n int256 kink1_,\n int256 multiplier2PerYear_,\n int256 baseRate2PerYear_,\n int256 kink2_,\n int256 jumpMultiplierPerYear_\n ) {\n if (baseRatePerYear_ < 0 || baseRate2PerYear_ < 0) {\n revert NegativeValueNotAllowed();\n }\n\n if (kink2_ <= kink1_ || kink1_ <= 0) {\n revert InvalidKink();\n }\n\n BASE_RATE_PER_BLOCK = baseRatePerYear_ / BLOCKS_PER_YEAR;\n MULTIPLIER_PER_BLOCK = multiplierPerYear_ / BLOCKS_PER_YEAR;\n KINK_1 = kink1_;\n MULTIPLIER_2_PER_BLOCK = multiplier2PerYear_ / BLOCKS_PER_YEAR;\n BASE_RATE_2_PER_BLOCK = baseRate2PerYear_ / BLOCKS_PER_YEAR;\n KINK_2 = kink2_;\n JUMP_MULTIPLIER_PER_BLOCK = jumpMultiplierPerYear_ / BLOCKS_PER_YEAR;\n\n int256 expScale = int256(EXP_SCALE);\n RATE_1 = (((KINK_1 * MULTIPLIER_PER_BLOCK) / expScale) + BASE_RATE_PER_BLOCK);\n\n int256 slope2Util;\n unchecked {\n slope2Util = KINK_2 - KINK_1;\n }\n RATE_2 = ((slope2Util * MULTIPLIER_2_PER_BLOCK) / expScale) + BASE_RATE_2_PER_BLOCK;\n }\n\n /**\n * @notice Calculates the current borrow rate per slot (block)\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per slot (block) as a mantissa (scaled by EXP_SCALE)\n */\n function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) external view override returns (uint256) {\n return _getBorrowRate(cash, borrows, reserves);\n }\n\n /**\n * @notice Calculates the current supply rate per slot (block)\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per slot (block) as a mantissa (scaled by EXP_SCALE)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual override returns (uint256) {\n uint256 oneMinusReserveFactor = EXP_SCALE - reserveFactorMantissa;\n uint256 borrowRate = _getBorrowRate(cash, borrows, reserves);\n uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / EXP_SCALE;\n return (utilizationRate(cash, borrows, reserves) * rateToPool) / EXP_SCALE;\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The utilization rate as a mantissa between [0, EXP_SCALE]\n */\n function utilizationRate(uint256 cash, uint256 borrows, uint256 reserves) public pure returns (uint256) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n uint256 rate = (borrows * EXP_SCALE) / (cash + borrows - reserves);\n\n if (rate > EXP_SCALE) {\n rate = EXP_SCALE;\n }\n\n return rate;\n }\n\n /**\n * @notice Calculates the current borrow rate per slot (block), with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per slot (block) as a mantissa (scaled by EXP_SCALE)\n */\n function _getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) internal view returns (uint256) {\n int256 util = int256(utilizationRate(cash, borrows, reserves));\n int256 expScale = int256(EXP_SCALE);\n\n if (util < KINK_1) {\n return _minCap(((util * MULTIPLIER_PER_BLOCK) / expScale) + BASE_RATE_PER_BLOCK);\n } else if (util < KINK_2) {\n int256 slope2Util;\n unchecked {\n slope2Util = util - KINK_1;\n }\n int256 rate2 = ((slope2Util * MULTIPLIER_2_PER_BLOCK) / expScale) + BASE_RATE_2_PER_BLOCK;\n\n return _minCap(RATE_1 + rate2);\n } else {\n int256 slope3Util;\n unchecked {\n slope3Util = util - KINK_2;\n }\n int256 rate3 = ((slope3Util * JUMP_MULTIPLIER_PER_BLOCK) / expScale);\n\n return _minCap(RATE_1 + RATE_2 + rate3);\n }\n }\n\n /**\n * @notice Returns 0 if number is less than 0, otherwise returns the input\n * @param number The first number\n * @return The maximum of 0 and input number\n */\n function _minCap(int256 number) internal pure returns (uint256) {\n int256 zero;\n return uint256(number > zero ? number : zero);\n }\n}\n" + }, "contracts/InterfacesV8.sol": { - "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\n\ninterface IVToken is IERC20Upgradeable {\n function accrueInterest() external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrowBalanceCurrent(address borrower) external returns (uint256);\n\n function balanceOfUnderlying(address owner) external returns (uint256);\n\n function comptroller() external view returns (IComptroller);\n\n function borrowBalanceStored(address account) external view returns (uint256);\n}\n\ninterface IVBep20 is IVToken {\n function borrowBehalf(address borrower, uint256 borrowAmount) external returns (uint256);\n\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\n\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external returns (uint256);\n\n function underlying() external view returns (address);\n}\n\ninterface IVBNB is IVToken {\n function repayBorrowBehalf(address borrower) external payable;\n\n function liquidateBorrow(address borrower, IVToken vTokenCollateral) external payable;\n}\n\ninterface IVAIController {\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external returns (uint256, uint256);\n\n function getVAIAddress() external view returns (address);\n\n function getVAIRepayAmount(address borrower) external view returns (uint256);\n}\n\ninterface IComptroller {\n enum Action {\n MINT,\n REDEEM,\n BORROW,\n REPAY,\n SEIZE,\n LIQUIDATE,\n TRANSFER,\n ENTER_MARKET,\n EXIT_MARKET\n }\n\n function _setActionsPaused(address[] calldata markets_, Action[] calldata actions_, bool paused_) external;\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function vaiController() external view returns (IVAIController);\n\n function liquidatorContract() external view returns (address);\n\n function oracle() external view returns (ResilientOracleInterface);\n\n function actionPaused(address market, Action action) external view returns (bool);\n\n function markets(address) external view returns (bool, uint256, bool);\n\n function isForcedLiquidationEnabled(address) external view returns (bool);\n}\n\ninterface ILiquidator {\n function restrictLiquidation(address borrower) external;\n\n function unrestrictLiquidation(address borrower) external;\n\n function addToAllowlist(address borrower, address liquidator) external;\n\n function removeFromAllowlist(address borrower, address liquidator) external;\n\n function liquidateBorrow(\n address vToken,\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external payable;\n\n function setTreasuryPercent(uint256 newTreasuryPercentMantissa) external;\n\n function treasuryPercentMantissa() external view returns (uint256);\n}\n\ninterface IProtocolShareReserve {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType kind) external;\n}\n\ninterface IWBNB is IERC20Upgradeable {\n function deposit() external payable;\n}\n" + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\n\ninterface IVToken is IERC20Upgradeable {\n function accrueInterest() external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrowBalanceCurrent(address borrower) external returns (uint256);\n\n function balanceOfUnderlying(address owner) external returns (uint256);\n\n function comptroller() external view returns (IComptroller);\n\n function borrowBalanceStored(address account) external view returns (uint256);\n}\n\ninterface IVBep20 is IVToken {\n function borrowBehalf(address borrower, uint256 borrowAmount) external returns (uint256);\n\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\n\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external returns (uint256);\n\n function underlying() external view returns (address);\n}\n\ninterface IVBNB is IVToken {\n function repayBorrowBehalf(address borrower) external payable;\n\n function liquidateBorrow(address borrower, IVToken vTokenCollateral) external payable;\n}\n\ninterface IVAIController {\n function accrueVAIInterest() external;\n\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external returns (uint256, uint256);\n\n function repayVAIBehalf(address borrower, uint256 amount) external returns (uint256, uint256);\n\n function getVAIAddress() external view returns (address);\n\n function getVAIRepayAmount(address borrower) external view returns (uint256);\n}\n\ninterface IComptroller {\n enum Action {\n MINT,\n REDEEM,\n BORROW,\n REPAY,\n SEIZE,\n LIQUIDATE,\n TRANSFER,\n ENTER_MARKET,\n EXIT_MARKET\n }\n\n function _setActionsPaused(address[] calldata markets_, Action[] calldata actions_, bool paused_) external;\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function vaiController() external view returns (IVAIController);\n\n function liquidatorContract() external view returns (address);\n\n function oracle() external view returns (ResilientOracleInterface);\n\n function actionPaused(address market, Action action) external view returns (bool);\n\n function markets(address) external view returns (bool, uint256, bool);\n\n function isForcedLiquidationEnabled(address) external view returns (bool);\n}\n\ninterface ILiquidator {\n function restrictLiquidation(address borrower) external;\n\n function unrestrictLiquidation(address borrower) external;\n\n function addToAllowlist(address borrower, address liquidator) external;\n\n function removeFromAllowlist(address borrower, address liquidator) external;\n\n function liquidateBorrow(\n address vToken,\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external payable;\n\n function setTreasuryPercent(uint256 newTreasuryPercentMantissa) external;\n\n function treasuryPercentMantissa() external view returns (uint256);\n}\n\ninterface IProtocolShareReserve {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType kind) external;\n}\n\ninterface IWBNB is IERC20Upgradeable {\n function deposit() external payable;\n}\n" }, "contracts/lib/approveOrRevert.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.25;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\n/// @notice Thrown if a contract is unable to approve a transfer\nerror ApproveFailed();\n\n/// @notice Approves a transfer, ensuring that it is successful. This function supports non-compliant\n/// tokens like the ones that don't return a boolean value on success. Thus, such approve call supports\n/// three different kinds of tokens:\n/// * Compliant tokens that revert on failure\n/// * Compliant tokens that return false on failure\n/// * Non-compliant tokens that don't return a value\n/// @param token The contract address of the token which will be transferred\n/// @param spender The spender contract address\n/// @param amount The value of the transfer\nfunction approveOrRevert(IERC20Upgradeable token, address spender, uint256 amount) {\n bytes memory callData = abi.encodeCall(token.approve, (spender, amount));\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory result) = address(token).call(callData);\n\n if (!success || (result.length != 0 && !abi.decode(result, (bool)))) {\n revert ApproveFailed();\n }\n}\n" @@ -252,6 +264,42 @@ }, "contracts/Tokens/Prime/PrimeStorage.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\n\n/**\n * @title PrimeStorageV1\n * @author Venus\n * @notice Storage for Prime Token\n */\ncontract PrimeStorageV1 {\n struct Token {\n bool exists;\n bool isIrrevocable;\n }\n\n struct Market {\n uint256 supplyMultiplier;\n uint256 borrowMultiplier;\n uint256 rewardIndex;\n uint256 sumOfMembersScore;\n bool exists;\n }\n\n struct Interest {\n uint256 accrued;\n uint256 score;\n uint256 rewardIndex;\n }\n\n struct PendingReward {\n address vToken;\n address rewardToken;\n uint256 amount;\n }\n\n /// @notice Base unit for computations, usually used in scaling (multiplications, divisions)\n uint256 internal constant EXP_SCALE = 1e18;\n\n /// @notice maximum BPS = 100%\n uint256 internal constant MAXIMUM_BPS = 1e4;\n\n /// @notice Mapping to get prime token's metadata\n mapping(address => Token) public tokens;\n\n /// @notice Tracks total irrevocable tokens minted\n uint256 public totalIrrevocable;\n\n /// @notice Tracks total revocable tokens minted\n uint256 public totalRevocable;\n\n /// @notice Indicates maximum revocable tokens that can be minted\n uint256 public revocableLimit;\n\n /// @notice Indicates maximum irrevocable tokens that can be minted\n uint256 public irrevocableLimit;\n\n /// @notice Tracks when prime token eligible users started staking for claiming prime token\n mapping(address => uint256) public stakedAt;\n\n /// @notice vToken to market configuration\n mapping(address => Market) public markets;\n\n /// @notice vToken to user to user index\n mapping(address => mapping(address => Interest)) public interests;\n\n /// @notice A list of boosted markets\n address[] internal _allMarkets;\n\n /// @notice numerator of alpha. Ex: if alpha is 0.5 then this will be 1\n uint128 public alphaNumerator;\n\n /// @notice denominator of alpha. Ex: if alpha is 0.5 then this will be 2\n uint128 public alphaDenominator;\n\n /// @notice address of XVS vault\n address public xvsVault;\n\n /// @notice address of XVS vault reward token\n address public xvsVaultRewardToken;\n\n /// @notice address of XVS vault pool id\n uint256 public xvsVaultPoolId;\n\n /// @notice mapping to check if a account's score was updated in the round\n mapping(uint256 => mapping(address => bool)) public isScoreUpdated;\n\n /// @notice unique id for next round\n uint256 public nextScoreUpdateRoundId;\n\n /// @notice total number of accounts whose score needs to be updated\n uint256 public totalScoreUpdatesRequired;\n\n /// @notice total number of accounts whose score is yet to be updated\n uint256 public pendingScoreUpdates;\n\n /// @notice mapping used to find if an asset is part of prime markets\n mapping(address => address) public vTokenForAsset;\n\n /// @notice Address of core pool comptroller contract\n address internal corePoolComptroller;\n\n /// @notice unreleased income from PLP that's already distributed to prime holders\n /// @dev mapping of asset address => amount\n mapping(address => uint256) public unreleasedPLPIncome;\n\n /// @notice The address of PLP contract\n address public primeLiquidityProvider;\n\n /// @notice The address of ResilientOracle contract\n ResilientOracleInterface public oracle;\n\n /// @notice The address of PoolRegistry contract\n address public poolRegistry;\n\n /// @dev This empty reserved space is put in place to allow future versions to add new\n /// variables without shifting down storage in the inheritance chain.\n uint256[26] private __gap;\n}\n" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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 (address initialOwner) {\n _transferOwnership(initialOwner);\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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \"ERC1967: beacon implementation is not a contract\");\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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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 constructor (address initialOwner) Ownable(initialOwner) {}\n\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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\n address internal immutable _ADMIN;\n\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 _ADMIN = admin_;\n\n // still store it to work with EIP-1967\n bytes32 slot = _ADMIN_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, admin_)\n }\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\n return _ADMIN;\n }\n}\n" } }, "settings": { diff --git a/deployments/opmainnet/solcInputs/a2594572bdae270af6749f50c8019b6c.json b/deployments/opmainnet/solcInputs/a2594572bdae270af6749f50c8019b6c.json new file mode 100644 index 000000000..9b8c5e750 --- /dev/null +++ b/deployments/opmainnet/solcInputs/a2594572bdae270af6749f50c8019b6c.json @@ -0,0 +1,366 @@ +{ + "language": "Solidity", + "sources": { + "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\nimport \"./IAccessControlManagerV5.sol\";\n\n/**\n * @title AccessControlledV5\n * @author Venus\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.5.16)\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\n */\ncontract AccessControlledV5 {\n /// @notice Access control manager contract\n IAccessControlManagerV5 private _accessControlManager;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when access control manager contract address is changed\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n /**\n * @notice Returns the address of the access control manager contract\n */\n function accessControlManager() external view returns (IAccessControlManagerV5) {\n return _accessControlManager;\n }\n\n /**\n * @dev Internal function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n */\n function _setAccessControlManager(address accessControlManager_) internal {\n require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n address oldAccessControlManager = address(_accessControlManager);\n _accessControlManager = IAccessControlManagerV5(accessControlManager_);\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n }\n\n /**\n * @notice Reverts if the call is not allowed by AccessControlManager\n * @param signature Method signature\n */\n function _checkAccessAllowed(string memory signature) internal view {\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n if (!isAllowedToCall) {\n revert(\"Unauthorized\");\n }\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"./GovernorBravoInterfaces.sol\";\n\n/**\n * @title GovernorBravoDelegate\n * @notice Venus Governance latest on chain governance includes several new features including variable proposal routes and fine grained pause control.\n * Variable routes for proposals allows for governance paramaters such as voting threshold and timelocks to be customized based on the risk level and\n * impact of the proposal. Added granularity to the pause control mechanism allows governance to pause individual actions on specific markets,\n * which reduces impact on the protocol as a whole. This is particularly useful when applied to isolated pools.\n *\n * The goal of **Governance** is to increase governance efficiency, while mitigating and eliminating malicious or erroneous proposals.\n *\n * ## Details\n *\n * Governance has **3 main contracts**: **GovernanceBravoDelegate, XVSVault, XVS** token.\n *\n * - XVS token is the protocol token used for protocol users to cast their vote on submitted proposals.\n * - XVSVault is the main staking contract for XVS. Users first stake their XVS in the vault and receive voting power proportional to their staked\n * tokens that they can use to vote on proposals. Users also can choose to delegate their voting power to other users.\n *\n * # Governor Bravo\n *\n * `GovernanceBravoDelegate` is main Venus Governance contract. Users interact with it to:\n * - Submit new proposal\n * - Vote on a proposal\n * - Cancel a proposal\n * - Queue a proposal for execution with a timelock executor contract.\n * `GovernanceBravoDelegate` uses the XVSVault to get restrict certain actions based on a user's voting power. The governance rules it inforces are:\n * - A user's voting power must be greater than the `proposalThreshold` to submit a proposal\n * - If a user's voting power drops below certain amount, anyone can cancel the the proposal. The governance guardian and proposal creator can also\n * cancel a proposal at anytime before it is queued for execution.\n *\n * ## Venus Improvement Proposal\n *\n * Venus Governance allows for Venus Improvement Proposals (VIPs) to be categorized based on their impact and risk levels. This allows for optimizing proposals\n * execution to allow for things such as expediting interest rate changes and quickly updating risk parameters, while moving slower on other types of proposals\n * that can prevent a larger risk to the protocol and are not urgent. There are three different types of VIPs with different proposal paramters:\n *\n * - `NORMAL`\n * - `FASTTRACK`\n * - `CRITICAL`\n *\n * When initializing the `GovernorBravo` contract, the parameters for the three routes are set. The parameters are:\n *\n * - `votingDelay`: The delay in blocks between submitting a proposal and when voting begins\n * - `votingPeriod`: The number of blocks where voting will be open\n * - `proposalThreshold`: The number of votes required in order submit a proposal\n *\n * There is also a separate timelock executor contract for each route, which is used to dispatch the VIP for execution, giving even more control over the\n * flow of each type of VIP.\n *\n * ## Voting\n *\n * After a VIP is proposed, voting is opened after the `votingDelay` has passed. For example, if `votingDelay = 0`, then voting will begin in the next block\n * after the proposal has been submitted. After the delay, the proposal state is `ACTIVE` and users can cast their vote `for`, `against`, or `abstain`,\n * weighted by their total voting power (tokens + delegated voting power). Abstaining from a voting allows for a vote to be cast and optionally include a\n * comment, without the incrementing for or against vote count. The total voting power for the user is obtained by calling XVSVault's `getPriorVotes`.\n *\n * `GovernorBravoDelegate` also accepts [EIP-712](https://eips.ethereum.org/EIPS/eip-712) signatures for voting on proposals via the external function\n * `castVoteBySig`.\n *\n * ## Delegating\n *\n * A users voting power includes the amount of staked XVS the have staked as well as the votes delegate to them. Delegating is the process of a user loaning\n * their voting power to another, so that the latter has the combined voting power of both users. This is an important feature because it allows for a user\n * to let another user who they trust propose or vote in their place.\n *\n * The delegation of votes happens through the `XVSVault` contract by calling the `delegate` or `delegateBySig` functions. These same functions can revert\n * vote delegation by calling the same function with a value of `0`.\n */\ncontract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoEvents {\n /// @notice The name of this contract\n string public constant name = \"Venus Governor Bravo\";\n\n /// @notice The minimum setable proposal threshold\n uint public constant MIN_PROPOSAL_THRESHOLD = 150000e18; // 150,000 Xvs\n\n /// @notice The maximum setable proposal threshold\n uint public constant MAX_PROPOSAL_THRESHOLD = 300000e18; //300,000 Xvs\n\n /// @notice The minimum setable voting period\n uint public constant MIN_VOTING_PERIOD = 20 * 60 * 3; // About 3 hours, 3 secs per block\n\n /// @notice The max setable voting period\n uint public constant MAX_VOTING_PERIOD = 20 * 60 * 24 * 14; // About 2 weeks, 3 secs per block\n\n /// @notice The min setable voting delay\n uint public constant MIN_VOTING_DELAY = 1;\n\n /// @notice The max setable voting delay\n uint public constant MAX_VOTING_DELAY = 20 * 60 * 24 * 7; // About 1 week, 3 secs per block\n\n /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed\n uint public constant quorumVotes = 600000e18; // 600,000 = 2% of Xvs\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the ballot struct used by the contract\n bytes32 public constant BALLOT_TYPEHASH = keccak256(\"Ballot(uint256 proposalId,uint8 support)\");\n\n /**\n * @notice Used to initialize the contract during delegator contructor\n * @param xvsVault_ The address of the XvsVault\n * @param proposalConfigs_ Governance configs for each governance route\n * @param timelocks Timelock addresses for each governance route\n */\n function initialize(\n address xvsVault_,\n ProposalConfig[] memory proposalConfigs_,\n TimelockInterface[] memory timelocks,\n address guardian_\n ) public {\n require(address(proposalTimelocks[0]) == address(0), \"GovernorBravo::initialize: cannot initialize twice\");\n require(msg.sender == admin, \"GovernorBravo::initialize: admin only\");\n require(xvsVault_ != address(0), \"GovernorBravo::initialize: invalid xvs address\");\n require(guardian_ != address(0), \"GovernorBravo::initialize: invalid guardian\");\n require(\n timelocks.length == uint8(ProposalType.CRITICAL) + 1,\n \"GovernorBravo::initialize:number of timelocks should match number of governance routes\"\n );\n require(\n proposalConfigs_.length == uint8(ProposalType.CRITICAL) + 1,\n \"GovernorBravo::initialize:number of proposal configs should match number of governance routes\"\n );\n\n xvsVault = XvsVaultInterface(xvsVault_);\n proposalMaxOperations = 10;\n guardian = guardian_;\n\n //Set parameters for each Governance Route\n uint256 arrLength = proposalConfigs_.length;\n for (uint256 i; i < arrLength; ++i) {\n require(\n proposalConfigs_[i].votingPeriod >= MIN_VOTING_PERIOD,\n \"GovernorBravo::initialize: invalid min voting period\"\n );\n require(\n proposalConfigs_[i].votingPeriod <= MAX_VOTING_PERIOD,\n \"GovernorBravo::initialize: invalid max voting period\"\n );\n require(\n proposalConfigs_[i].votingDelay >= MIN_VOTING_DELAY,\n \"GovernorBravo::initialize: invalid min voting delay\"\n );\n require(\n proposalConfigs_[i].votingDelay <= MAX_VOTING_DELAY,\n \"GovernorBravo::initialize: invalid max voting delay\"\n );\n require(\n proposalConfigs_[i].proposalThreshold >= MIN_PROPOSAL_THRESHOLD,\n \"GovernorBravo::initialize: invalid min proposal threshold\"\n );\n require(\n proposalConfigs_[i].proposalThreshold <= MAX_PROPOSAL_THRESHOLD,\n \"GovernorBravo::initialize: invalid max proposal threshold\"\n );\n require(address(timelocks[i]) != address(0), \"GovernorBravo::initialize:invalid timelock address\");\n\n proposalConfigs[i] = proposalConfigs_[i];\n proposalTimelocks[i] = timelocks[i];\n }\n }\n\n /**\n * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold.\n * targets, values, signatures, and calldatas must be of equal length\n * @dev NOTE: Proposals with duplicate set of actions can not be queued for execution. If the proposals consists\n * of duplicate actions, it's recommended to split those actions into separate proposals\n * @param targets Target addresses for proposal calls\n * @param values BNB values for proposal calls\n * @param signatures Function signatures for proposal calls\n * @param calldatas Calldatas for proposal calls\n * @param description String description of the proposal\n * @param proposalType the type of the proposal (e.g NORMAL, FASTTRACK, CRITICAL)\n * @return Proposal id of new proposal\n */\n function propose(\n address[] memory targets,\n uint[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n ProposalType proposalType\n ) public returns (uint) {\n // Reject proposals before initiating as Governor\n require(initialProposalId != 0, \"GovernorBravo::propose: Governor Bravo not active\");\n require(\n xvsVault.getPriorVotes(msg.sender, sub256(block.number, 1)) >=\n proposalConfigs[uint8(proposalType)].proposalThreshold,\n \"GovernorBravo::propose: proposer votes below proposal threshold\"\n );\n require(\n targets.length == values.length &&\n targets.length == signatures.length &&\n targets.length == calldatas.length,\n \"GovernorBravo::propose: proposal function information arity mismatch\"\n );\n require(targets.length != 0, \"GovernorBravo::propose: must provide actions\");\n require(targets.length <= proposalMaxOperations, \"GovernorBravo::propose: too many actions\");\n\n uint latestProposalId = latestProposalIds[msg.sender];\n if (latestProposalId != 0) {\n ProposalState proposersLatestProposalState = state(latestProposalId);\n require(\n proposersLatestProposalState != ProposalState.Active,\n \"GovernorBravo::propose: one live proposal per proposer, found an already active proposal\"\n );\n require(\n proposersLatestProposalState != ProposalState.Pending,\n \"GovernorBravo::propose: one live proposal per proposer, found an already pending proposal\"\n );\n }\n\n uint startBlock = add256(block.number, proposalConfigs[uint8(proposalType)].votingDelay);\n uint endBlock = add256(startBlock, proposalConfigs[uint8(proposalType)].votingPeriod);\n\n proposalCount++;\n Proposal memory newProposal = Proposal({\n id: proposalCount,\n proposer: msg.sender,\n eta: 0,\n targets: targets,\n values: values,\n signatures: signatures,\n calldatas: calldatas,\n startBlock: startBlock,\n endBlock: endBlock,\n forVotes: 0,\n againstVotes: 0,\n abstainVotes: 0,\n canceled: false,\n executed: false,\n proposalType: uint8(proposalType)\n });\n\n proposals[newProposal.id] = newProposal;\n latestProposalIds[newProposal.proposer] = newProposal.id;\n\n emit ProposalCreated(\n newProposal.id,\n msg.sender,\n targets,\n values,\n signatures,\n calldatas,\n startBlock,\n endBlock,\n description,\n uint8(proposalType)\n );\n return newProposal.id;\n }\n\n /**\n * @notice Queues a proposal of state succeeded\n * @param proposalId The id of the proposal to queue\n */\n function queue(uint proposalId) external {\n require(\n state(proposalId) == ProposalState.Succeeded,\n \"GovernorBravo::queue: proposal can only be queued if it is succeeded\"\n );\n Proposal storage proposal = proposals[proposalId];\n uint eta = add256(block.timestamp, proposalTimelocks[uint8(proposal.proposalType)].delay());\n for (uint i; i < proposal.targets.length; ++i) {\n queueOrRevertInternal(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n eta,\n uint8(proposal.proposalType)\n );\n }\n proposal.eta = eta;\n emit ProposalQueued(proposalId, eta);\n }\n\n function queueOrRevertInternal(\n address target,\n uint value,\n string memory signature,\n bytes memory data,\n uint eta,\n uint8 proposalType\n ) internal {\n require(\n !proposalTimelocks[proposalType].queuedTransactions(\n keccak256(abi.encode(target, value, signature, data, eta))\n ),\n \"GovernorBravo::queueOrRevertInternal: identical proposal action already queued at eta\"\n );\n proposalTimelocks[proposalType].queueTransaction(target, value, signature, data, eta);\n }\n\n /**\n * @notice Executes a queued proposal if eta has passed\n * @param proposalId The id of the proposal to execute\n */\n function execute(uint proposalId) external {\n require(\n state(proposalId) == ProposalState.Queued,\n \"GovernorBravo::execute: proposal can only be executed if it is queued\"\n );\n Proposal storage proposal = proposals[proposalId];\n proposal.executed = true;\n for (uint i; i < proposal.targets.length; ++i) {\n proposalTimelocks[uint8(proposal.proposalType)].executeTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n emit ProposalExecuted(proposalId);\n }\n\n /**\n * @notice Cancels a proposal only if sender is the proposer, or proposer delegates dropped below proposal threshold\n * @param proposalId The id of the proposal to cancel\n */\n function cancel(uint proposalId) external {\n require(state(proposalId) != ProposalState.Executed, \"GovernorBravo::cancel: cannot cancel executed proposal\");\n\n Proposal storage proposal = proposals[proposalId];\n require(\n msg.sender == guardian ||\n msg.sender == proposal.proposer ||\n xvsVault.getPriorVotes(proposal.proposer, sub256(block.number, 1)) <\n proposalConfigs[proposal.proposalType].proposalThreshold,\n \"GovernorBravo::cancel: proposer above threshold\"\n );\n\n proposal.canceled = true;\n for (uint i = 0; i < proposal.targets.length; i++) {\n proposalTimelocks[proposal.proposalType].cancelTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n\n emit ProposalCanceled(proposalId);\n }\n\n /**\n * @notice Gets actions of a proposal\n * @param proposalId the id of the proposal\n * @return targets, values, signatures, and calldatas of the proposal actions\n */\n function getActions(\n uint proposalId\n )\n external\n view\n returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas)\n {\n Proposal storage p = proposals[proposalId];\n return (p.targets, p.values, p.signatures, p.calldatas);\n }\n\n /**\n * @notice Gets the receipt for a voter on a given proposal\n * @param proposalId the id of proposal\n * @param voter The address of the voter\n * @return The voting receipt\n */\n function getReceipt(uint proposalId, address voter) external view returns (Receipt memory) {\n return proposals[proposalId].receipts[voter];\n }\n\n /**\n * @notice Gets the state of a proposal\n * @param proposalId The id of the proposal\n * @return Proposal state\n */\n function state(uint proposalId) public view returns (ProposalState) {\n require(\n proposalCount >= proposalId && proposalId > initialProposalId,\n \"GovernorBravo::state: invalid proposal id\"\n );\n Proposal storage proposal = proposals[proposalId];\n if (proposal.canceled) {\n return ProposalState.Canceled;\n } else if (block.number <= proposal.startBlock) {\n return ProposalState.Pending;\n } else if (block.number <= proposal.endBlock) {\n return ProposalState.Active;\n } else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes) {\n return ProposalState.Defeated;\n } else if (proposal.eta == 0) {\n return ProposalState.Succeeded;\n } else if (proposal.executed) {\n return ProposalState.Executed;\n } else if (\n block.timestamp >= add256(proposal.eta, proposalTimelocks[uint8(proposal.proposalType)].GRACE_PERIOD())\n ) {\n return ProposalState.Expired;\n } else {\n return ProposalState.Queued;\n }\n }\n\n /**\n * @notice Cast a vote for a proposal\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n */\n function castVote(uint proposalId, uint8 support) external {\n emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), \"\");\n }\n\n /**\n * @notice Cast a vote for a proposal with a reason\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param reason The reason given for the vote by the voter\n */\n function castVoteWithReason(uint proposalId, uint8 support, string calldata reason) external {\n emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), reason);\n }\n\n /**\n * @notice Cast a vote for a proposal by signature\n * @dev External function that accepts EIP-712 signatures for voting on proposals.\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param v recovery id of ECDSA signature\n * @param r part of the ECDSA sig output\n * @param s part of the ECDSA sig output\n */\n function castVoteBySig(uint proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s) external {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"GovernorBravo::castVoteBySig: invalid signature\");\n emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), \"\");\n }\n\n /**\n * @notice Internal function that caries out voting logic\n * @param voter The voter that is casting their vote\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @return The number of votes cast\n */\n function castVoteInternal(address voter, uint proposalId, uint8 support) internal returns (uint96) {\n require(state(proposalId) == ProposalState.Active, \"GovernorBravo::castVoteInternal: voting is closed\");\n require(support <= 2, \"GovernorBravo::castVoteInternal: invalid vote type\");\n Proposal storage proposal = proposals[proposalId];\n Receipt storage receipt = proposal.receipts[voter];\n require(receipt.hasVoted == false, \"GovernorBravo::castVoteInternal: voter already voted\");\n uint96 votes = xvsVault.getPriorVotes(voter, proposal.startBlock);\n\n if (support == 0) {\n proposal.againstVotes = add256(proposal.againstVotes, votes);\n } else if (support == 1) {\n proposal.forVotes = add256(proposal.forVotes, votes);\n } else if (support == 2) {\n proposal.abstainVotes = add256(proposal.abstainVotes, votes);\n }\n\n receipt.hasVoted = true;\n receipt.support = support;\n receipt.votes = votes;\n\n return votes;\n }\n\n /**\n * @notice Sets the new governance guardian\n * @param newGuardian the address of the new guardian\n */\n function _setGuardian(address newGuardian) external {\n require(msg.sender == guardian || msg.sender == admin, \"GovernorBravo::_setGuardian: admin or guardian only\");\n require(newGuardian != address(0), \"GovernorBravo::_setGuardian: cannot live without a guardian\");\n address oldGuardian = guardian;\n guardian = newGuardian;\n\n emit NewGuardian(oldGuardian, newGuardian);\n }\n\n /**\n * @notice Initiate the GovernorBravo contract\n * @dev Admin only. Sets initial proposal id which initiates the contract, ensuring a continuous proposal id count\n * @param governorAlpha The address for the Governor to continue the proposal id count from\n */\n function _initiate(address governorAlpha) external {\n require(msg.sender == admin, \"GovernorBravo::_initiate: admin only\");\n require(initialProposalId == 0, \"GovernorBravo::_initiate: can only initiate once\");\n proposalCount = GovernorAlphaInterface(governorAlpha).proposalCount();\n initialProposalId = proposalCount;\n for (uint256 i; i < uint8(ProposalType.CRITICAL) + 1; ++i) {\n proposalTimelocks[i].acceptAdmin();\n }\n }\n\n /**\n * @notice Set max proposal operations\n * @dev Admin only.\n * @param proposalMaxOperations_ Max proposal operations\n */\n function _setProposalMaxOperations(uint proposalMaxOperations_) external {\n require(msg.sender == admin, \"GovernorBravo::_setProposalMaxOperations: admin only\");\n uint oldProposalMaxOperations = proposalMaxOperations;\n proposalMaxOperations = proposalMaxOperations_;\n\n emit ProposalMaxOperationsUpdated(oldProposalMaxOperations, proposalMaxOperations_);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) external {\n // Check caller = admin\n require(msg.sender == admin, \"GovernorBravo:_setPendingAdmin: admin only\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n */\n function _acceptAdmin() external {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n require(\n msg.sender == pendingAdmin && msg.sender != address(0),\n \"GovernorBravo:_acceptAdmin: pending admin only\"\n );\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n function add256(uint256 a, uint256 b) internal pure returns (uint) {\n uint c = a + b;\n require(c >= a, \"addition overflow\");\n return c;\n }\n\n function sub256(uint256 a, uint256 b) internal pure returns (uint) {\n require(b <= a, \"subtraction underflow\");\n return a - b;\n }\n\n function getChainIdInternal() internal pure returns (uint) {\n uint chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoInterfaces.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\n/**\n * @title GovernorBravoEvents\n * @author Venus\n * @notice Set of events emitted by the GovernorBravo contracts.\n */\ncontract GovernorBravoEvents {\n /// @notice An event emitted when a new proposal is created\n event ProposalCreated(\n uint id,\n address proposer,\n address[] targets,\n uint[] values,\n string[] signatures,\n bytes[] calldatas,\n uint startBlock,\n uint endBlock,\n string description,\n uint8 proposalType\n );\n\n /// @notice An event emitted when a vote has been cast on a proposal\n /// @param voter The address which casted a vote\n /// @param proposalId The proposal id which was voted on\n /// @param support Support value for the vote. 0=against, 1=for, 2=abstain\n /// @param votes Number of votes which were cast by the voter\n /// @param reason The reason given for the vote by the voter\n event VoteCast(address indexed voter, uint proposalId, uint8 support, uint votes, string reason);\n\n /// @notice An event emitted when a proposal has been canceled\n event ProposalCanceled(uint id);\n\n /// @notice An event emitted when a proposal has been queued in the Timelock\n event ProposalQueued(uint id, uint eta);\n\n /// @notice An event emitted when a proposal has been executed in the Timelock\n event ProposalExecuted(uint id);\n\n /// @notice An event emitted when the voting delay is set\n event VotingDelaySet(uint oldVotingDelay, uint newVotingDelay);\n\n /// @notice An event emitted when the voting period is set\n event VotingPeriodSet(uint oldVotingPeriod, uint newVotingPeriod);\n\n /// @notice Emitted when implementation is changed\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /// @notice Emitted when proposal threshold is set\n event ProposalThresholdSet(uint oldProposalThreshold, uint newProposalThreshold);\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Emitted when pendingAdmin is accepted, which means admin is updated\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /// @notice Emitted when the new guardian address is set\n event NewGuardian(address oldGuardian, address newGuardian);\n\n /// @notice Emitted when the maximum number of operations in one proposal is updated\n event ProposalMaxOperationsUpdated(uint oldMaxOperations, uint newMaxOperations);\n}\n\n/**\n * @title GovernorBravoDelegatorStorage\n * @author Venus\n * @notice Storage layout of the `GovernorBravoDelegator` contract\n */\ncontract GovernorBravoDelegatorStorage {\n /// @notice Administrator for this contract\n address public admin;\n\n /// @notice Pending administrator for this contract\n address public pendingAdmin;\n\n /// @notice Active brains of Governor\n address public implementation;\n}\n\n/**\n * @title GovernorBravoDelegateStorageV1\n * @dev For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a new\n * contract which implements GovernorBravoDelegateStorageV1 and following the naming convention\n * GovernorBravoDelegateStorageVX.\n */\ncontract GovernorBravoDelegateStorageV1 is GovernorBravoDelegatorStorage {\n /// @notice DEPRECATED The delay before voting on a proposal may take place, once proposed, in blocks\n uint public votingDelay;\n\n /// @notice DEPRECATED The duration of voting on a proposal, in blocks\n uint public votingPeriod;\n\n /// @notice DEPRECATED The number of votes required in order for a voter to become a proposer\n uint public proposalThreshold;\n\n /// @notice Initial proposal id set at become\n uint public initialProposalId;\n\n /// @notice The total number of proposals\n uint public proposalCount;\n\n /// @notice The address of the Venus Protocol Timelock\n TimelockInterface public timelock;\n\n /// @notice The address of the Venus governance token\n XvsVaultInterface public xvsVault;\n\n /// @notice The official record of all proposals ever proposed\n mapping(uint => Proposal) public proposals;\n\n /// @notice The latest proposal for each proposer\n mapping(address => uint) public latestProposalIds;\n\n struct Proposal {\n /// @notice Unique id for looking up a proposal\n uint id;\n /// @notice Creator of the proposal\n address proposer;\n /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds\n uint eta;\n /// @notice the ordered list of target addresses for calls to be made\n address[] targets;\n /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made\n uint[] values;\n /// @notice The ordered list of function signatures to be called\n string[] signatures;\n /// @notice The ordered list of calldata to be passed to each call\n bytes[] calldatas;\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\n uint startBlock;\n /// @notice The block at which voting ends: votes must be cast prior to this block\n uint endBlock;\n /// @notice Current number of votes in favor of this proposal\n uint forVotes;\n /// @notice Current number of votes in opposition to this proposal\n uint againstVotes;\n /// @notice Current number of votes for abstaining for this proposal\n uint abstainVotes;\n /// @notice Flag marking whether the proposal has been canceled\n bool canceled;\n /// @notice Flag marking whether the proposal has been executed\n bool executed;\n /// @notice Receipts of ballots for the entire set of voters\n mapping(address => Receipt) receipts;\n /// @notice The type of the proposal\n uint8 proposalType;\n }\n\n /// @notice Ballot receipt record for a voter\n struct Receipt {\n /// @notice Whether or not a vote has been cast\n bool hasVoted;\n /// @notice Whether or not the voter supports the proposal or abstains\n uint8 support;\n /// @notice The number of votes the voter had, which were cast\n uint96 votes;\n }\n\n /// @notice Possible states that a proposal may be in\n enum ProposalState {\n Pending,\n Active,\n Canceled,\n Defeated,\n Succeeded,\n Queued,\n Expired,\n Executed\n }\n\n /// @notice The maximum number of actions that can be included in a proposal\n uint public proposalMaxOperations;\n\n /// @notice A privileged role that can cancel any proposal\n address public guardian;\n}\n\n/**\n * @title GovernorBravoDelegateStorageV2\n * @dev For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a new\n * contract which implements GovernorBravoDelegateStorageV2 and following the naming convention\n * GovernorBravoDelegateStorageVX.\n */\ncontract GovernorBravoDelegateStorageV2 is GovernorBravoDelegateStorageV1 {\n enum ProposalType {\n NORMAL,\n FASTTRACK,\n CRITICAL\n }\n\n struct ProposalConfig {\n /// @notice The delay before voting on a proposal may take place, once proposed, in blocks\n uint256 votingDelay;\n /// @notice The duration of voting on a proposal, in blocks\n uint256 votingPeriod;\n /// @notice The number of votes required in order for a voter to become a proposer\n uint256 proposalThreshold;\n }\n\n /// @notice mapping containing configuration for each proposal type\n mapping(uint => ProposalConfig) public proposalConfigs;\n\n /// @notice mapping containing Timelock addresses for each proposal type\n mapping(uint => TimelockInterface) public proposalTimelocks;\n}\n\n/**\n * @title TimelockInterface\n * @author Venus\n * @notice Interface implemented by the Timelock contract.\n */\ninterface TimelockInterface {\n function delay() external view returns (uint);\n\n function GRACE_PERIOD() external view returns (uint);\n\n function acceptAdmin() external;\n\n function queuedTransactions(bytes32 hash) external view returns (bool);\n\n function queueTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external returns (bytes32);\n\n function cancelTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external;\n\n function executeTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external payable returns (bytes memory);\n}\n\ninterface XvsVaultInterface {\n function getPriorVotes(address account, uint blockNumber) external view returns (uint96);\n}\n\ninterface GovernorAlphaInterface {\n /// @notice The total number of proposals\n function proposalCount() external returns (uint);\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\n/**\n * @title IAccessControlManagerV5\n * @author Venus\n * @notice Interface implemented by the `AccessControlManagerV5` contract.\n */\ninterface IAccessControlManagerV5 {\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 */\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 /**\n * @notice Gives a function call permission to one single account\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * \t\tMay emit a {RoleGranted} event.\n * @param contractAddress address of contract for which call permissions will be granted\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n */\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n /**\n * @notice Revokes an account's permission to a particular function call\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * \t\tMay emit a {RoleRevoked} event.\n * @param contractAddress address of contract for which call permissions will be revoked\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n */\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) external;\n\n /**\n * @notice Verifies if the given account can call a praticular contract's function\n * @dev Since the contract is calling itself this function, we can get contracts address with msg.sender\n * @param account address (eoa or contract) for which call permissions will be checked\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n * @return false if the user account cannot call the particular contract function\n *\n */\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) external view returns (bool);\n}\n" + }, + "@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\ncontract TimeManagerV5 {\n /// @dev The approximate number of seconds per year\n uint256 public constant SECONDS_PER_YEAR = 31_536_000;\n\n /// @notice Number of blocks per year or seconds per year\n uint256 public blocksOrSecondsPerYear;\n\n /// @dev Sets true when block timestamp is used\n bool public isTimeBased;\n\n /// @dev Sets true when contract is initialized\n bool private isInitialized;\n\n /// @notice Deprecated slot for _getCurrentSlot function pointer\n bytes8 private __deprecatedSlot1;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[48] private __gap;\n\n /**\n * @dev Function to simply retrieve block number or block timestamp\n * @return Current block number or block timestamp\n */\n function getBlockNumberOrTimestamp() public view returns (uint256) {\n return isTimeBased ? _getBlockTimestamp() : _getBlockNumber();\n }\n\n /**\n * @dev Initializes the contract to use either blocks or seconds\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\n * @param blocksPerYear_ The number of blocks per year\n */\n function _initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) internal {\n if (isInitialized) revert(\"Already initialized TimeManager\");\n\n if (!timeBased_ && blocksPerYear_ == 0) {\n revert(\"Invalid blocks per year\");\n }\n if (timeBased_ && blocksPerYear_ != 0) {\n revert(\"Invalid time based configuration\");\n }\n\n isTimeBased = timeBased_;\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\n isInitialized = true;\n }\n\n /**\n * @dev Returns the current timestamp in seconds\n * @return The current timestamp\n */\n function _getBlockTimestamp() private view returns (uint256) {\n return block.timestamp;\n }\n\n /**\n * @dev Returns the current block number\n * @return The current block number\n */\n function _getBlockNumber() private view returns (uint256) {\n return block.number;\n }\n}\n" + }, + "contracts/Comptroller/ComptrollerInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerTypes } from \"./ComptrollerStorage.sol\";\n\ncontract ComptrollerInterface {\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n bool public constant isComptroller = true;\n\n /*** Assets You Are In ***/\n\n function enterMarkets(address[] calldata vTokens) external returns (uint[] memory);\n\n function exitMarket(address vToken) external returns (uint);\n\n /*** Policy Hooks ***/\n\n function mintAllowed(address vToken, address minter, uint mintAmount) external returns (uint);\n\n function mintVerify(address vToken, address minter, uint mintAmount, uint mintTokens) external;\n\n function redeemAllowed(address vToken, address redeemer, uint redeemTokens) external returns (uint);\n\n function redeemVerify(address vToken, address redeemer, uint redeemAmount, uint redeemTokens) external;\n\n function borrowAllowed(address vToken, address borrower, uint borrowAmount) external returns (uint);\n\n function borrowVerify(address vToken, address borrower, uint borrowAmount) external;\n\n function repayBorrowAllowed(\n address vToken,\n address payer,\n address borrower,\n uint repayAmount\n ) external returns (uint);\n\n function repayBorrowVerify(\n address vToken,\n address payer,\n address borrower,\n uint repayAmount,\n uint borrowerIndex\n ) external;\n\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint repayAmount\n ) external returns (uint);\n\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint repayAmount,\n uint seizeTokens\n ) external;\n\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) external returns (uint);\n\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) external;\n\n function transferAllowed(address vToken, address src, address dst, uint transferTokens) external returns (uint);\n\n function transferVerify(address vToken, address src, address dst, uint transferTokens) external;\n\n /*** Liquidity/Liquidation Calculations ***/\n\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint repayAmount\n ) external view returns (uint, uint);\n\n function setMintedVAIOf(address owner, uint amount) external returns (uint);\n\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint repayAmount\n ) external view returns (uint, uint);\n\n function getXVSAddress() public view returns (address);\n\n function markets(address) external view returns (bool, uint);\n\n function oracle() external view returns (PriceOracle);\n\n function getAccountLiquidity(address) external view returns (uint, uint, uint);\n\n function getAssetsIn(address) external view returns (VToken[] memory);\n\n function claimVenus(address) external;\n\n function venusAccrued(address) external view returns (uint);\n\n function venusSupplySpeeds(address) external view returns (uint);\n\n function venusBorrowSpeeds(address) external view returns (uint);\n\n function getAllMarkets() external view returns (VToken[] memory);\n\n function venusSupplierIndex(address, address) external view returns (uint);\n\n function venusInitialIndex() external view returns (uint224);\n\n function venusBorrowerIndex(address, address) external view returns (uint);\n\n function venusBorrowState(address) external view returns (uint224, uint32);\n\n function venusSupplyState(address) external view returns (uint224, uint32);\n\n function approvedDelegates(address borrower, address delegate) external view returns (bool);\n\n function vaiController() external view returns (VAIControllerInterface);\n\n function liquidationIncentiveMantissa() external view returns (uint);\n\n function protocolPaused() external view returns (bool);\n\n function actionPaused(address market, ComptrollerTypes.Action action) public view returns (bool);\n\n function mintedVAIs(address user) external view returns (uint);\n\n function vaiMintRate() external view returns (uint);\n}\n\ninterface IVAIVault {\n function updatePendingRewards() external;\n}\n\ninterface IComptroller {\n function liquidationIncentiveMantissa() external view returns (uint);\n\n /*** Treasury Data ***/\n function treasuryAddress() external view returns (address);\n\n function treasuryPercent() external view returns (uint);\n}\n" + }, + "contracts/Comptroller/ComptrollerLensInterface.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\ninterface ComptrollerLensInterface {\n function liquidateCalculateSeizeTokens(\n address comptroller,\n address vTokenBorrowed,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint);\n\n function liquidateVAICalculateSeizeTokens(\n address comptroller,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint);\n\n function getHypotheticalAccountLiquidity(\n address comptroller,\n address account,\n VToken vTokenModify,\n uint redeemTokens,\n uint borrowAmount\n ) external view returns (uint, uint, uint);\n}\n" + }, + "contracts/Comptroller/ComptrollerStorage.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity ^0.5.16;\n\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { PriceOracle } from \"../Oracle/PriceOracle.sol\";\nimport { VAIControllerInterface } from \"../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerLensInterface } from \"./ComptrollerLensInterface.sol\";\nimport { IPrime } from \"../Tokens/Prime/IPrime.sol\";\n\ninterface ComptrollerTypes {\n enum Action {\n MINT,\n REDEEM,\n BORROW,\n REPAY,\n SEIZE,\n LIQUIDATE,\n TRANSFER,\n ENTER_MARKET,\n EXIT_MARKET\n }\n}\n\ncontract UnitrollerAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of Unitroller\n */\n address public comptrollerImplementation;\n\n /**\n * @notice Pending brains of Unitroller\n */\n address public pendingComptrollerImplementation;\n}\n\ncontract ComptrollerV1Storage is ComptrollerTypes, UnitrollerAdminStorage {\n /**\n * @notice Oracle which gives the price of any given asset\n */\n PriceOracle public oracle;\n\n /**\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\n */\n uint256 public closeFactorMantissa;\n\n /**\n * @notice Multiplier representing the discount on collateral that a liquidator receives\n */\n uint256 public liquidationIncentiveMantissa;\n\n /**\n * @notice Max number of assets a single account can participate in (borrow or use as collateral)\n */\n uint256 public maxAssets;\n\n /**\n * @notice Per-account mapping of \"assets you are in\", capped by maxAssets\n */\n mapping(address => VToken[]) public accountAssets;\n\n struct Market {\n /// @notice Whether or not this market is listed\n bool isListed;\n /**\n * @notice Multiplier representing the most one can borrow against their collateral in this market.\n * For instance, 0.9 to allow borrowing 90% of collateral value.\n * Must be between 0 and 1, and stored as a mantissa.\n */\n uint256 collateralFactorMantissa;\n /// @notice Per-market mapping of \"accounts in this asset\"\n mapping(address => bool) accountMembership;\n /// @notice Whether or not this market receives XVS\n bool isVenus;\n }\n\n /**\n * @notice Official mapping of vTokens -> Market metadata\n * @dev Used e.g. to determine if a market is supported\n */\n mapping(address => Market) public markets;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n */\n address public pauseGuardian;\n\n /// @notice Whether minting is paused (deprecated, superseded by actionPaused)\n bool private _mintGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool private _borrowGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool internal transferGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool internal seizeGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n mapping(address => bool) internal mintGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n mapping(address => bool) internal borrowGuardianPaused;\n\n struct VenusMarketState {\n /// @notice The market's last updated venusBorrowIndex or venusSupplyIndex\n uint224 index;\n /// @notice The block number the index was last updated at\n uint32 block;\n }\n\n /// @notice A list of all markets\n VToken[] public allMarkets;\n\n /// @notice The rate at which the flywheel distributes XVS, per block\n uint256 internal venusRate;\n\n /// @notice The portion of venusRate that each market currently receives\n mapping(address => uint256) internal venusSpeeds;\n\n /// @notice The Venus market supply state for each market\n mapping(address => VenusMarketState) public venusSupplyState;\n\n /// @notice The Venus market borrow state for each market\n mapping(address => VenusMarketState) public venusBorrowState;\n\n /// @notice The Venus supply index for each market for each supplier as of the last time they accrued XVS\n mapping(address => mapping(address => uint256)) public venusSupplierIndex;\n\n /// @notice The Venus borrow index for each market for each borrower as of the last time they accrued XVS\n mapping(address => mapping(address => uint256)) public venusBorrowerIndex;\n\n /// @notice The XVS accrued but not yet transferred to each user\n mapping(address => uint256) public venusAccrued;\n\n /// @notice The Address of VAIController\n VAIControllerInterface public vaiController;\n\n /// @notice The minted VAI amount to each user\n mapping(address => uint256) public mintedVAIs;\n\n /// @notice VAI Mint Rate as a percentage\n uint256 public vaiMintRate;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n */\n bool public mintVAIGuardianPaused;\n bool public repayVAIGuardianPaused;\n\n /**\n * @notice Pause/Unpause whole protocol actions\n */\n bool public protocolPaused;\n\n /// @notice The rate at which the flywheel distributes XVS to VAI Minters, per block (deprecated)\n uint256 private venusVAIRate;\n}\n\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\n /// @notice The rate at which the flywheel distributes XVS to VAI Vault, per block\n uint256 public venusVAIVaultRate;\n\n // address of VAI Vault\n address public vaiVaultAddress;\n\n // start block of release to VAI Vault\n uint256 public releaseStartBlock;\n\n // minimum release amount to VAI Vault\n uint256 public minReleaseAmount;\n}\n\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\n address public borrowCapGuardian;\n\n /// @notice Borrow caps enforced by borrowAllowed for each vToken address.\n mapping(address => uint256) public borrowCaps;\n}\n\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\n /// @notice Treasury Guardian address\n address public treasuryGuardian;\n\n /// @notice Treasury address\n address public treasuryAddress;\n\n /// @notice Fee percent of accrued interest with decimal 18\n uint256 public treasuryPercent;\n}\n\ncontract ComptrollerV5Storage is ComptrollerV4Storage {\n /// @notice The portion of XVS that each contributor receives per block (deprecated)\n mapping(address => uint256) private venusContributorSpeeds;\n\n /// @notice Last block at which a contributor's XVS rewards have been allocated (deprecated)\n mapping(address => uint256) private lastContributorBlock;\n}\n\ncontract ComptrollerV6Storage is ComptrollerV5Storage {\n address public liquidatorContract;\n}\n\ncontract ComptrollerV7Storage is ComptrollerV6Storage {\n ComptrollerLensInterface public comptrollerLens;\n}\n\ncontract ComptrollerV8Storage is ComptrollerV7Storage {\n /// @notice Supply caps enforced by mintAllowed for each vToken address. Defaults to zero which corresponds to minting notAllowed\n mapping(address => uint256) public supplyCaps;\n}\n\ncontract ComptrollerV9Storage is ComptrollerV8Storage {\n /// @notice AccessControlManager address\n address internal accessControl;\n\n /// @notice True if a certain action is paused on a certain market\n mapping(address => mapping(uint256 => bool)) internal _actionPaused;\n}\n\ncontract ComptrollerV10Storage is ComptrollerV9Storage {\n /// @notice The rate at which venus is distributed to the corresponding borrow market (per block)\n mapping(address => uint256) public venusBorrowSpeeds;\n\n /// @notice The rate at which venus is distributed to the corresponding supply market (per block)\n mapping(address => uint256) public venusSupplySpeeds;\n}\n\ncontract ComptrollerV11Storage is ComptrollerV10Storage {\n /// @notice Whether the delegate is allowed to borrow or redeem on behalf of the user\n //mapping(address user => mapping (address delegate => bool approved)) public approvedDelegates;\n mapping(address => mapping(address => bool)) public approvedDelegates;\n}\n\ncontract ComptrollerV12Storage is ComptrollerV11Storage {\n /// @notice Whether forced liquidation is enabled for all users borrowing in a certain market\n mapping(address => bool) public isForcedLiquidationEnabled;\n}\n\ncontract ComptrollerV13Storage is ComptrollerV12Storage {\n struct FacetAddressAndPosition {\n address facetAddress;\n uint96 functionSelectorPosition; // position in _facetFunctionSelectors.functionSelectors array\n }\n\n struct FacetFunctionSelectors {\n bytes4[] functionSelectors;\n uint256 facetAddressPosition; // position of facetAddress in _facetAddresses array\n }\n\n mapping(bytes4 => FacetAddressAndPosition) internal _selectorToFacetAndPosition;\n // maps facet addresses to function selectors\n mapping(address => FacetFunctionSelectors) internal _facetFunctionSelectors;\n // facet addresses\n address[] internal _facetAddresses;\n}\n\ncontract ComptrollerV14Storage is ComptrollerV13Storage {\n /// @notice Prime token address\n IPrime public prime;\n}\n\ncontract ComptrollerV15Storage is ComptrollerV14Storage {\n /// @notice Whether forced liquidation is enabled for the borrows of a user in a market\n mapping(address /* user */ => mapping(address /* market */ => bool)) public isForcedLiquidationEnabledForUser;\n}\n\ncontract ComptrollerV16Storage is ComptrollerV15Storage {\n /// @notice The XVS token contract address\n address internal xvs;\n\n /// @notice The XVS vToken contract address\n address internal xvsVToken;\n}\n" + }, + "contracts/Comptroller/Diamond/Diamond.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\nimport { IDiamondCut } from \"./interfaces/IDiamondCut.sol\";\nimport { Unitroller, ComptrollerV16Storage } from \"../Unitroller.sol\";\n\n/**\n * @title Diamond\n * @author Venus\n * @notice This contract contains functions related to facets\n */\ncontract Diamond is IDiamondCut, ComptrollerV16Storage {\n /// @notice Emitted when functions are added, replaced or removed to facets\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut);\n\n struct Facet {\n address facetAddress;\n bytes4[] functionSelectors;\n }\n\n /**\n * @notice Call _acceptImplementation to accept the diamond proxy as new implementaion\n * @param unitroller Address of the unitroller\n */\n function _become(Unitroller unitroller) public {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can\");\n require(unitroller._acceptImplementation() == 0, \"not authorized\");\n }\n\n /**\n * @notice To add function selectors to the facet's mapping\n * @dev Allows the contract admin to add function selectors\n * @param diamondCut_ IDiamondCut contains facets address, action and function selectors\n */\n function diamondCut(IDiamondCut.FacetCut[] memory diamondCut_) public {\n require(msg.sender == admin, \"only unitroller admin can\");\n libDiamondCut(diamondCut_);\n }\n\n /**\n * @notice Get all function selectors mapped to the facet address\n * @param facet Address of the facet\n * @return selectors Array of function selectors\n */\n function facetFunctionSelectors(address facet) external view returns (bytes4[] memory) {\n return _facetFunctionSelectors[facet].functionSelectors;\n }\n\n /**\n * @notice Get facet position in the _facetFunctionSelectors through facet address\n * @param facet Address of the facet\n * @return Position of the facet\n */\n function facetPosition(address facet) external view returns (uint256) {\n return _facetFunctionSelectors[facet].facetAddressPosition;\n }\n\n /**\n * @notice Get all facet addresses\n * @return facetAddresses Array of facet addresses\n */\n function facetAddresses() external view returns (address[] memory) {\n return _facetAddresses;\n }\n\n /**\n * @notice Get facet address and position through function selector\n * @param functionSelector function selector\n * @return FacetAddressAndPosition facet address and position\n */\n function facetAddress(\n bytes4 functionSelector\n ) external view returns (ComptrollerV16Storage.FacetAddressAndPosition memory) {\n return _selectorToFacetAndPosition[functionSelector];\n }\n\n /**\n * @notice Get all facets address and their function selector\n * @return facets_ Array of Facet\n */\n function facets() external view returns (Facet[] memory) {\n uint256 facetsLength = _facetAddresses.length;\n Facet[] memory facets_ = new Facet[](facetsLength);\n for (uint256 i; i < facetsLength; ++i) {\n address facet = _facetAddresses[i];\n facets_[i].facetAddress = facet;\n facets_[i].functionSelectors = _facetFunctionSelectors[facet].functionSelectors;\n }\n return facets_;\n }\n\n /**\n * @notice To add function selectors to the facets' mapping\n * @param diamondCut_ IDiamondCut contains facets address, action and function selectors\n */\n function libDiamondCut(IDiamondCut.FacetCut[] memory diamondCut_) internal {\n uint256 diamondCutLength = diamondCut_.length;\n for (uint256 facetIndex; facetIndex < diamondCutLength; ++facetIndex) {\n IDiamondCut.FacetCutAction action = diamondCut_[facetIndex].action;\n if (action == IDiamondCut.FacetCutAction.Add) {\n addFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else if (action == IDiamondCut.FacetCutAction.Replace) {\n replaceFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else if (action == IDiamondCut.FacetCutAction.Remove) {\n removeFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else {\n revert(\"LibDiamondCut: Incorrect FacetCutAction\");\n }\n }\n emit DiamondCut(diamondCut_);\n }\n\n /**\n * @notice Add function selectors to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to add in the mapping\n */\n function addFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n require(functionSelectors.length != 0, \"LibDiamondCut: No selectors in facet to cut\");\n require(facetAddress != address(0), \"LibDiamondCut: Add facet can't be address(0)\");\n uint96 selectorPosition = uint96(_facetFunctionSelectors[facetAddress].functionSelectors.length);\n // add new facet address if it does not exist\n if (selectorPosition == 0) {\n addFacet(facetAddress);\n }\n uint256 functionSelectorsLength = functionSelectors.length;\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n require(oldFacetAddress == address(0), \"LibDiamondCut: Can't add function that already exists\");\n addFunction(selector, selectorPosition, facetAddress);\n ++selectorPosition;\n }\n }\n\n /**\n * @notice Replace facet's address mapping for function selectors i.e selectors already associate to any other existing facet\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to replace in the mapping\n */\n function replaceFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n require(functionSelectors.length != 0, \"LibDiamondCut: No selectors in facet to cut\");\n require(facetAddress != address(0), \"LibDiamondCut: Add facet can't be address(0)\");\n uint96 selectorPosition = uint96(_facetFunctionSelectors[facetAddress].functionSelectors.length);\n // add new facet address if it does not exist\n if (selectorPosition == 0) {\n addFacet(facetAddress);\n }\n uint256 functionSelectorsLength = functionSelectors.length;\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n require(oldFacetAddress != facetAddress, \"LibDiamondCut: Can't replace function with same function\");\n removeFunction(oldFacetAddress, selector);\n addFunction(selector, selectorPosition, facetAddress);\n ++selectorPosition;\n }\n }\n\n /**\n * @notice Remove function selectors to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to remove in the mapping\n */\n function removeFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n uint256 functionSelectorsLength = functionSelectors.length;\n require(functionSelectorsLength != 0, \"LibDiamondCut: No selectors in facet to cut\");\n // if function does not exist then do nothing and revert\n require(facetAddress == address(0), \"LibDiamondCut: Remove facet address must be address(0)\");\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n removeFunction(oldFacetAddress, selector);\n }\n }\n\n /**\n * @notice Add new facet to the proxy\n * @param facetAddress Address of the facet\n */\n function addFacet(address facetAddress) internal {\n enforceHasContractCode(facetAddress, \"Diamond: New facet has no code\");\n _facetFunctionSelectors[facetAddress].facetAddressPosition = _facetAddresses.length;\n _facetAddresses.push(facetAddress);\n }\n\n /**\n * @notice Add function selector to the facet's address mapping\n * @param selector funciton selector need to be added\n * @param selectorPosition funciton selector position\n * @param facetAddress Address of the facet\n */\n function addFunction(bytes4 selector, uint96 selectorPosition, address facetAddress) internal {\n _selectorToFacetAndPosition[selector].functionSelectorPosition = selectorPosition;\n _facetFunctionSelectors[facetAddress].functionSelectors.push(selector);\n _selectorToFacetAndPosition[selector].facetAddress = facetAddress;\n }\n\n /**\n * @notice Remove function selector to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param selector function selectors need to remove in the mapping\n */\n function removeFunction(address facetAddress, bytes4 selector) internal {\n require(facetAddress != address(0), \"LibDiamondCut: Can't remove function that doesn't exist\");\n\n // replace selector with last selector, then delete last selector\n uint256 selectorPosition = _selectorToFacetAndPosition[selector].functionSelectorPosition;\n uint256 lastSelectorPosition = _facetFunctionSelectors[facetAddress].functionSelectors.length - 1;\n // if not the same then replace selector with lastSelector\n if (selectorPosition != lastSelectorPosition) {\n bytes4 lastSelector = _facetFunctionSelectors[facetAddress].functionSelectors[lastSelectorPosition];\n _facetFunctionSelectors[facetAddress].functionSelectors[selectorPosition] = lastSelector;\n _selectorToFacetAndPosition[lastSelector].functionSelectorPosition = uint96(selectorPosition);\n }\n // delete the last selector\n _facetFunctionSelectors[facetAddress].functionSelectors.pop();\n delete _selectorToFacetAndPosition[selector];\n\n // if no more selectors for facet address then delete the facet address\n if (lastSelectorPosition == 0) {\n // replace facet address with last facet address and delete last facet address\n uint256 lastFacetAddressPosition = _facetAddresses.length - 1;\n uint256 facetAddressPosition = _facetFunctionSelectors[facetAddress].facetAddressPosition;\n if (facetAddressPosition != lastFacetAddressPosition) {\n address lastFacetAddress = _facetAddresses[lastFacetAddressPosition];\n _facetAddresses[facetAddressPosition] = lastFacetAddress;\n _facetFunctionSelectors[lastFacetAddress].facetAddressPosition = facetAddressPosition;\n }\n _facetAddresses.pop();\n delete _facetFunctionSelectors[facetAddress];\n }\n }\n\n /**\n * @dev Ensure that the given address has contract code deployed\n * @param _contract The address to check for contract code\n * @param _errorMessage The error message to display if the contract code is not deployed\n */\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\n uint256 contractSize;\n assembly {\n contractSize := extcodesize(_contract)\n }\n require(contractSize != 0, _errorMessage);\n }\n\n // Find facet for function that is called and execute the\n // function if a facet is found and return any value.\n function() external payable {\n address facet = _selectorToFacetAndPosition[msg.sig].facetAddress;\n require(facet != address(0), \"Diamond: Function does not exist\");\n // Execute public function from facet using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the facet\n let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" + }, + "contracts/Comptroller/Diamond/DiamondConsolidated.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"./facets/MarketFacet.sol\";\nimport \"./facets/PolicyFacet.sol\";\nimport \"./facets/RewardFacet.sol\";\nimport \"./facets/SetterFacet.sol\";\nimport \"./Diamond.sol\";\n\n/**\n * @title DiamondConsolidated\n * @author Venus\n * @notice This contract contains the functions defined in the different facets of the Diamond, plus the getters to the public variables.\n * This contract cannot be deployed, due to its size. Its main purpose is to allow the easy generation of an ABI and the typechain to interact with the\n * Unitroller contract in a simple way\n */\ncontract DiamondConsolidated is Diamond, MarketFacet, PolicyFacet, RewardFacet, SetterFacet {}\n" + }, + "contracts/Comptroller/Diamond/facets/FacetBase.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken, ComptrollerErrorReporter, ExponentialNoError } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IVAIVault } from \"../../../Comptroller/ComptrollerInterface.sol\";\nimport { ComptrollerV16Storage } from \"../../../Comptroller/ComptrollerStorage.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\n\nimport { SafeBEP20, IBEP20 } from \"../../../Utils/SafeBEP20.sol\";\n\n/**\n * @title FacetBase\n * @author Venus\n * @notice This facet contract contains functions related to access and checks\n */\ncontract FacetBase is ComptrollerV16Storage, ExponentialNoError, ComptrollerErrorReporter {\n using SafeBEP20 for IBEP20;\n\n /// @notice The initial Venus index for a market\n uint224 public constant venusInitialIndex = 1e36;\n // closeFactorMantissa must be strictly greater than this value\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\n // closeFactorMantissa must not exceed this value\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\n // No collateralFactorMantissa may exceed this value\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\n\n /// @notice Emitted when an account enters a market\n event MarketEntered(VToken indexed vToken, address indexed account);\n\n /// @notice Emitted when XVS is distributed to VAI Vault\n event DistributedVAIVaultVenus(uint256 amount);\n\n /// @notice Reverts if the protocol is paused\n function checkProtocolPauseState() internal view {\n require(!protocolPaused, \"protocol is paused\");\n }\n\n /// @notice Reverts if a certain action is paused on a market\n function checkActionPauseState(address market, Action action) internal view {\n require(!actionPaused(market, action), \"action is paused\");\n }\n\n /// @notice Reverts if the caller is not admin\n function ensureAdmin() internal view {\n require(msg.sender == admin, \"only admin can\");\n }\n\n /// @notice Checks the passed address is nonzero\n function ensureNonzeroAddress(address someone) internal pure {\n require(someone != address(0), \"can't be zero address\");\n }\n\n /// @notice Reverts if the market is not listed\n function ensureListed(Market storage market) internal view {\n require(market.isListed, \"market not listed\");\n }\n\n /// @notice Reverts if the caller is neither admin nor the passed address\n function ensureAdminOr(address privilegedAddress) internal view {\n require(msg.sender == admin || msg.sender == privilegedAddress, \"access denied\");\n }\n\n /// @notice Checks the caller is allowed to call the specified fuction\n function ensureAllowed(string memory functionSig) internal view {\n require(IAccessControlManagerV5(accessControl).isAllowedToCall(msg.sender, functionSig), \"access denied\");\n }\n\n /**\n * @notice Checks if a certain action is paused on a market\n * @param action Action id\n * @param market vToken address\n */\n function actionPaused(address market, Action action) public view returns (bool) {\n return _actionPaused[market][uint256(action)];\n }\n\n /**\n * @notice Get the latest block number\n */\n function getBlockNumber() internal view returns (uint256) {\n return block.number;\n }\n\n /**\n * @notice Get the latest block number with the safe32 check\n */\n function getBlockNumberAsUint32() internal view returns (uint32) {\n return safe32(getBlockNumber(), \"block # > 32 bits\");\n }\n\n /**\n * @notice Transfer XVS to VAI Vault\n */\n function releaseToVault() internal {\n if (releaseStartBlock == 0 || getBlockNumber() < releaseStartBlock) {\n return;\n }\n\n IBEP20 xvs_ = IBEP20(xvs);\n\n uint256 xvsBalance = xvs_.balanceOf(address(this));\n if (xvsBalance == 0) {\n return;\n }\n\n uint256 actualAmount;\n uint256 deltaBlocks = sub_(getBlockNumber(), releaseStartBlock);\n // releaseAmount = venusVAIVaultRate * deltaBlocks\n uint256 releaseAmount_ = mul_(venusVAIVaultRate, deltaBlocks);\n\n if (xvsBalance >= releaseAmount_) {\n actualAmount = releaseAmount_;\n } else {\n actualAmount = xvsBalance;\n }\n\n if (actualAmount < minReleaseAmount) {\n return;\n }\n\n releaseStartBlock = getBlockNumber();\n\n xvs_.safeTransfer(vaiVaultAddress, actualAmount);\n emit DistributedVAIVaultVenus(actualAmount);\n\n IVAIVault(vaiVaultAddress).updatePendingRewards();\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param vTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @dev Note that we calculate the exchangeRateStored for each collateral vToken using stored data,\n * without calculating accumulated interest.\n * @return (possible error code,\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidityInternal(\n address account,\n VToken vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) internal view returns (Error, uint256, uint256) {\n (uint256 err, uint256 liquidity, uint256 shortfall) = comptrollerLens.getHypotheticalAccountLiquidity(\n address(this),\n account,\n vTokenModify,\n redeemTokens,\n borrowAmount\n );\n return (Error(err), liquidity, shortfall);\n }\n\n /**\n * @notice Add the market to the borrower's \"assets in\" for liquidity calculations\n * @param vToken The market to enter\n * @param borrower The address of the account to modify\n * @return Success indicator for whether the market was entered\n */\n function addToMarketInternal(VToken vToken, address borrower) internal returns (Error) {\n checkActionPauseState(address(vToken), Action.ENTER_MARKET);\n Market storage marketToJoin = markets[address(vToken)];\n ensureListed(marketToJoin);\n if (marketToJoin.accountMembership[borrower]) {\n // already joined\n return Error.NO_ERROR;\n }\n // survived the gauntlet, add to list\n // NOTE: we store these somewhat redundantly as a significant optimization\n // this avoids having to iterate through the list for the most common use cases\n // that is, only when we need to perform liquidity checks\n // and not whenever we want to check if an account is in a particular market\n marketToJoin.accountMembership[borrower] = true;\n accountAssets[borrower].push(vToken);\n\n emit MarketEntered(vToken, borrower);\n\n return Error.NO_ERROR;\n }\n\n /**\n * @notice Checks for the user is allowed to redeem tokens\n * @param vToken Address of the market\n * @param redeemer Address of the user\n * @param redeemTokens Amount of tokens to redeem\n * @return Success indicator for redeem is allowed or not\n */\n function redeemAllowedInternal(\n address vToken,\n address redeemer,\n uint256 redeemTokens\n ) internal view returns (uint256) {\n ensureListed(markets[vToken]);\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\n if (!markets[vToken].accountMembership[redeemer]) {\n return uint256(Error.NO_ERROR);\n }\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n redeemer,\n VToken(vToken),\n redeemTokens,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall != 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the XVS address\n * @return The address of XVS token\n */\n function getXVSAddress() external view returns (address) {\n return xvs;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/MarketFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { IMarketFacet } from \"../interfaces/IMarketFacet.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title MarketFacet\n * @author Venus\n * @dev This facet contains all the methods related to the market's management in the pool\n * @notice This facet contract contains functions regarding markets\n */\ncontract MarketFacet is IMarketFacet, FacetBase {\n /// @notice Emitted when an admin supports a market\n event MarketListed(VToken indexed vToken);\n\n /// @notice Emitted when an account exits a market\n event MarketExited(VToken indexed vToken, address indexed account);\n\n /// @notice Emitted when the borrowing or redeeming delegate rights are updated for an account\n event DelegateUpdated(address indexed approver, address indexed delegate, bool approved);\n\n /// @notice Emitted when an admin unlists a market\n event MarketUnlisted(address indexed vToken);\n\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n function isComptroller() public pure returns (bool) {\n return true;\n }\n\n /**\n * @notice Returns the assets an account has entered\n * @param account The address of the account to pull assets for\n * @return A dynamic list with the assets the account has entered\n */\n function getAssetsIn(address account) external view returns (VToken[] memory) {\n uint256 len;\n VToken[] memory _accountAssets = accountAssets[account];\n uint256 _accountAssetsLength = _accountAssets.length;\n\n VToken[] memory assetsIn = new VToken[](_accountAssetsLength);\n\n for (uint256 i; i < _accountAssetsLength; ++i) {\n Market memory market = markets[address(_accountAssets[i])];\n if (market.isListed) {\n assetsIn[len] = _accountAssets[i];\n ++len;\n }\n }\n\n assembly {\n mstore(assetsIn, len)\n }\n\n return assetsIn;\n }\n\n /**\n * @notice Return all of the markets\n * @dev The automatic getter may be used to access an individual market\n * @return The list of market addresses\n */\n function getAllMarkets() external view returns (VToken[] memory) {\n return allMarkets;\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in vToken.liquidateBorrowFresh)\n * @param vTokenBorrowed The address of the borrowed vToken\n * @param vTokenCollateral The address of the collateral vToken\n * @param actualRepayAmount The amount of vTokenBorrowed underlying to convert into vTokenCollateral tokens\n * @return (errorCode, number of vTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256) {\n (uint256 err, uint256 seizeTokens) = comptrollerLens.liquidateCalculateSeizeTokens(\n address(this),\n vTokenBorrowed,\n vTokenCollateral,\n actualRepayAmount\n );\n return (err, seizeTokens);\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in vToken.liquidateBorrowFresh)\n * @param vTokenCollateral The address of the collateral vToken\n * @param actualRepayAmount The amount of vTokenBorrowed underlying to convert into vTokenCollateral tokens\n * @return (errorCode, number of vTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256) {\n (uint256 err, uint256 seizeTokens) = comptrollerLens.liquidateVAICalculateSeizeTokens(\n address(this),\n vTokenCollateral,\n actualRepayAmount\n );\n return (err, seizeTokens);\n }\n\n /**\n * @notice Returns whether the given account is entered in the given asset\n * @param account The address of the account to check\n * @param vToken The vToken to check\n * @return True if the account is in the asset, otherwise false\n */\n function checkMembership(address account, VToken vToken) external view returns (bool) {\n return markets[address(vToken)].accountMembership[account];\n }\n\n /**\n * @notice Add assets to be included in account liquidity calculation\n * @param vTokens The list of addresses of the vToken markets to be enabled\n * @return Success indicator for whether each corresponding market was entered\n */\n function enterMarkets(address[] calldata vTokens) external returns (uint256[] memory) {\n uint256 len = vTokens.length;\n\n uint256[] memory results = new uint256[](len);\n for (uint256 i; i < len; ++i) {\n results[i] = uint256(addToMarketInternal(VToken(vTokens[i]), msg.sender));\n }\n\n return results;\n }\n\n /**\n * @notice Unlist a market by setting isListed to false\n * @dev Checks if market actions are paused and borrowCap/supplyCap/CF are set to 0\n * @param market The address of the market (vToken) to unlist\n * @return uint256 0=success, otherwise a failure. (See enum Error for details)\n */\n function unlistMarket(address market) external returns (uint256) {\n ensureAllowed(\"unlistMarket(address)\");\n\n Market storage _market = markets[market];\n\n if (!_market.isListed) {\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.UNLIST_MARKET_NOT_LISTED);\n }\n\n require(actionPaused(market, Action.BORROW), \"borrow action is not paused\");\n require(actionPaused(market, Action.MINT), \"mint action is not paused\");\n require(actionPaused(market, Action.REDEEM), \"redeem action is not paused\");\n require(actionPaused(market, Action.REPAY), \"repay action is not paused\");\n require(actionPaused(market, Action.ENTER_MARKET), \"enter market action is not paused\");\n require(actionPaused(market, Action.LIQUIDATE), \"liquidate action is not paused\");\n require(actionPaused(market, Action.SEIZE), \"seize action is not paused\");\n require(actionPaused(market, Action.TRANSFER), \"transfer action is not paused\");\n require(actionPaused(market, Action.EXIT_MARKET), \"exit market action is not paused\");\n\n require(borrowCaps[market] == 0, \"borrow cap is not 0\");\n require(supplyCaps[market] == 0, \"supply cap is not 0\");\n\n require(_market.collateralFactorMantissa == 0, \"collateral factor is not 0\");\n\n _market.isListed = false;\n emit MarketUnlisted(market);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Removes asset from sender's account liquidity calculation\n * @dev Sender must not have an outstanding borrow balance in the asset,\n * or be providing necessary collateral for an outstanding borrow\n * @param vTokenAddress The address of the asset to be removed\n * @return Whether or not the account successfully exited the market\n */\n function exitMarket(address vTokenAddress) external returns (uint256) {\n checkActionPauseState(vTokenAddress, Action.EXIT_MARKET);\n\n VToken vToken = VToken(vTokenAddress);\n /* Get sender tokensHeld and amountOwed underlying from the vToken */\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = vToken.getAccountSnapshot(msg.sender);\n require(oErr == 0, \"getAccountSnapshot failed\"); // semi-opaque error code\n\n /* Fail if the sender has a borrow balance */\n if (amountOwed != 0) {\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\n }\n\n /* Fail if the sender is not permitted to redeem all of their tokens */\n uint256 allowed = redeemAllowedInternal(vTokenAddress, msg.sender, tokensHeld);\n if (allowed != 0) {\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\n }\n\n Market storage marketToExit = markets[address(vToken)];\n\n /* Return true if the sender is not already ‘in’ the market */\n if (!marketToExit.accountMembership[msg.sender]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Set vToken account membership to false */\n delete marketToExit.accountMembership[msg.sender];\n\n /* Delete vToken from the account’s list of assets */\n // In order to delete vToken, copy last item in list to location of item to be removed, reduce length by 1\n VToken[] storage userAssetList = accountAssets[msg.sender];\n uint256 len = userAssetList.length;\n uint256 i;\n for (; i < len; ++i) {\n if (userAssetList[i] == vToken) {\n userAssetList[i] = userAssetList[len - 1];\n userAssetList.length--;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(i < len);\n\n emit MarketExited(vToken, msg.sender);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Add the market to the markets mapping and set it as listed\n * @dev Allows a privileged role to add and list markets to the Comptroller\n * @param vToken The address of the market (token) to list\n * @return uint256 0=success, otherwise a failure. (See enum Error for details)\n */\n function _supportMarket(VToken vToken) external returns (uint256) {\n ensureAllowed(\"_supportMarket(address)\");\n\n if (markets[address(vToken)].isListed) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n vToken.isVToken(); // Sanity check to make sure its really a VToken\n\n // Note that isVenus is not in active use anymore\n Market storage newMarket = markets[address(vToken)];\n newMarket.isListed = true;\n newMarket.isVenus = false;\n newMarket.collateralFactorMantissa = 0;\n\n _addMarketInternal(vToken);\n _initializeMarket(address(vToken));\n\n emit MarketListed(vToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Grants or revokes the borrowing or redeeming delegate rights to / from an account\n * If allowed, the delegate will be able to borrow funds on behalf of the sender\n * Upon a delegated borrow, the delegate will receive the funds, and the borrower\n * will see the debt on their account\n * Upon a delegated redeem, the delegate will receive the redeemed amount and the approver\n * will see a deduction in his vToken balance\n * @param delegate The address to update the rights for\n * @param approved Whether to grant (true) or revoke (false) the borrowing or redeeming rights\n */\n function updateDelegate(address delegate, bool approved) external {\n ensureNonzeroAddress(delegate);\n require(approvedDelegates[msg.sender][delegate] != approved, \"Delegation status unchanged\");\n\n _updateDelegate(msg.sender, delegate, approved);\n }\n\n function _updateDelegate(address approver, address delegate, bool approved) internal {\n approvedDelegates[approver][delegate] = approved;\n emit DelegateUpdated(approver, delegate, approved);\n }\n\n function _addMarketInternal(VToken vToken) internal {\n uint256 allMarketsLength = allMarkets.length;\n for (uint256 i; i < allMarketsLength; ++i) {\n require(allMarkets[i] != vToken, \"already added\");\n }\n allMarkets.push(vToken);\n }\n\n function _initializeMarket(address vToken) internal {\n uint32 blockNumber = getBlockNumberAsUint32();\n\n VenusMarketState storage supplyState = venusSupplyState[vToken];\n VenusMarketState storage borrowState = venusBorrowState[vToken];\n\n /*\n * Update market state indices\n */\n if (supplyState.index == 0) {\n // Initialize supply state index with default value\n supplyState.index = venusInitialIndex;\n }\n\n if (borrowState.index == 0) {\n // Initialize borrow state index with default value\n borrowState.index = venusInitialIndex;\n }\n\n /*\n * Update market state block numbers\n */\n supplyState.block = borrowState.block = blockNumber;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/PolicyFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IPolicyFacet } from \"../interfaces/IPolicyFacet.sol\";\n\nimport { XVSRewardsHelper } from \"./XVSRewardsHelper.sol\";\n\n/**\n * @title PolicyFacet\n * @author Venus\n * @dev This facet contains all the hooks used while transferring the assets\n * @notice This facet contract contains all the external pre-hook functions related to vToken\n */\ncontract PolicyFacet is IPolicyFacet, XVSRewardsHelper {\n /// @notice Emitted when a new borrow-side XVS speed is calculated for a market\n event VenusBorrowSpeedUpdated(VToken indexed vToken, uint256 newSpeed);\n\n /// @notice Emitted when a new supply-side XVS speed is calculated for a market\n event VenusSupplySpeedUpdated(VToken indexed vToken, uint256 newSpeed);\n\n /**\n * @notice Checks if the account should be allowed to mint tokens in the given market\n * @param vToken The market to verify the mint against\n * @param minter The account which would get the minted tokens\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function mintAllowed(address vToken, address minter, uint256 mintAmount) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.MINT);\n ensureListed(markets[vToken]);\n\n uint256 supplyCap = supplyCaps[vToken];\n require(supplyCap != 0, \"market supply cap is 0\");\n\n uint256 vTokenSupply = VToken(vToken).totalSupply();\n Exp memory exchangeRate = Exp({ mantissa: VToken(vToken).exchangeRateStored() });\n uint256 nextTotalSupply = mul_ScalarTruncateAddUInt(exchangeRate, vTokenSupply, mintAmount);\n require(nextTotalSupply <= supplyCap, \"market supply cap reached\");\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, minter);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates mint, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being minted\n * @param minter The address minting the tokens\n * @param actualMintAmount The amount of the underlying asset being minted\n * @param mintTokens The number of tokens being minted\n */\n // solhint-disable-next-line no-unused-vars\n function mintVerify(address vToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(minter, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to redeem tokens in the given market\n * @param vToken The market to verify the redeem against\n * @param redeemer The account which would redeem the tokens\n * @param redeemTokens The number of vTokens to exchange for the underlying asset in the market\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function redeemAllowed(address vToken, address redeemer, uint256 redeemTokens) external returns (uint256) {\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.REDEEM);\n\n uint256 allowed = redeemAllowedInternal(vToken, redeemer, redeemTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, redeemer);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates redeem, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being redeemed\n * @param redeemer The address redeeming the tokens\n * @param redeemAmount The amount of the underlying asset being redeemed\n * @param redeemTokens The number of tokens being redeemed\n */\n function redeemVerify(address vToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external {\n require(redeemTokens != 0 || redeemAmount == 0, \"redeemTokens zero\");\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(redeemer, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param vToken The market to verify the borrow against\n * @param borrower The account which would borrow the asset\n * @param borrowAmount The amount of underlying the account would borrow\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function borrowAllowed(address vToken, address borrower, uint256 borrowAmount) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.BORROW);\n ensureListed(markets[vToken]);\n\n uint256 borrowCap = borrowCaps[vToken];\n require(borrowCap != 0, \"market borrow cap is 0\");\n\n if (!markets[vToken].accountMembership[borrower]) {\n // only vTokens may call borrowAllowed if borrower not in market\n require(msg.sender == vToken, \"sender must be vToken\");\n\n // attempt to add borrower to the market\n Error err = addToMarketInternal(VToken(vToken), borrower);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n }\n\n if (oracle.getUnderlyingPrice(VToken(vToken)) == 0) {\n return uint256(Error.PRICE_ERROR);\n }\n\n uint256 nextTotalBorrows = add_(VToken(vToken).totalBorrows(), borrowAmount);\n require(nextTotalBorrows <= borrowCap, \"market borrow cap reached\");\n\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n borrower,\n VToken(vToken),\n 0,\n borrowAmount\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall != 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n // Keep the flywheel moving\n Exp memory borrowIndex = Exp({ mantissa: VToken(vToken).borrowIndex() });\n updateVenusBorrowIndex(vToken, borrowIndex);\n distributeBorrowerVenus(vToken, borrower, borrowIndex);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates borrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset whose underlying is being borrowed\n * @param borrower The address borrowing the underlying\n * @param borrowAmount The amount of the underlying asset requested to borrow\n */\n // solhint-disable-next-line no-unused-vars\n function borrowVerify(address vToken, address borrower, uint256 borrowAmount) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to repay a borrow in the given market\n * @param vToken The market to verify the repay against\n * @param payer The account which would repay the asset\n * @param borrower The account which borrowed the asset\n * @param repayAmount The amount of the underlying asset the account would repay\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function repayBorrowAllowed(\n address vToken,\n address payer, // solhint-disable-line no-unused-vars\n address borrower,\n uint256 repayAmount // solhint-disable-line no-unused-vars\n ) external returns (uint256) {\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.REPAY);\n ensureListed(markets[vToken]);\n\n // Keep the flywheel moving\n Exp memory borrowIndex = Exp({ mantissa: VToken(vToken).borrowIndex() });\n updateVenusBorrowIndex(vToken, borrowIndex);\n distributeBorrowerVenus(vToken, borrower, borrowIndex);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates repayBorrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being repaid\n * @param payer The address repaying the borrow\n * @param borrower The address of the borrower\n * @param actualRepayAmount The amount of underlying being repaid\n */\n function repayBorrowVerify(\n address vToken,\n address payer, // solhint-disable-line no-unused-vars\n address borrower,\n uint256 actualRepayAmount, // solhint-disable-line no-unused-vars\n uint256 borrowerIndex // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vToken);\n }\n }\n\n /**\n * @notice Checks if the liquidation should be allowed to occur\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param repayAmount The amount of underlying being repaid\n */\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external view returns (uint256) {\n checkProtocolPauseState();\n\n // if we want to pause liquidating to vTokenCollateral, we should pause seizing\n checkActionPauseState(vTokenBorrowed, Action.LIQUIDATE);\n\n if (liquidatorContract != address(0) && liquidator != liquidatorContract) {\n return uint256(Error.UNAUTHORIZED);\n }\n\n ensureListed(markets[vTokenCollateral]);\n\n uint256 borrowBalance;\n if (address(vTokenBorrowed) != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n borrowBalance = VToken(vTokenBorrowed).borrowBalanceStored(borrower);\n } else {\n borrowBalance = vaiController.getVAIRepayAmount(borrower);\n }\n\n if (isForcedLiquidationEnabled[vTokenBorrowed] || isForcedLiquidationEnabledForUser[borrower][vTokenBorrowed]) {\n if (repayAmount > borrowBalance) {\n return uint(Error.TOO_MUCH_REPAY);\n }\n return uint(Error.NO_ERROR);\n }\n\n /* The borrower must have shortfall in order to be liquidatable */\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(borrower, VToken(address(0)), 0, 0);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall == 0) {\n return uint256(Error.INSUFFICIENT_SHORTFALL);\n }\n\n // The liquidator may not repay more than what is allowed by the closeFactor\n //-- maxClose = multipy of closeFactorMantissa and borrowBalance\n if (repayAmount > mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance)) {\n return uint256(Error.TOO_MUCH_REPAY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates liquidateBorrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param actualRepayAmount The amount of underlying being repaid\n * @param seizeTokens The amount of collateral token that will be seized\n */\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral, // solhint-disable-line no-unused-vars\n address liquidator,\n address borrower,\n uint256 actualRepayAmount, // solhint-disable-line no-unused-vars\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vTokenBorrowed);\n prime.accrueInterestAndUpdateScore(liquidator, vTokenBorrowed);\n }\n }\n\n /**\n * @notice Checks if the seizing of assets should be allowed to occur\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vTokenCollateral, Action.SEIZE);\n\n Market storage market = markets[vTokenCollateral];\n\n // We've added VAIController as a borrowed token list check for seize\n ensureListed(market);\n\n if (!market.accountMembership[borrower]) {\n return uint256(Error.MARKET_NOT_COLLATERAL);\n }\n\n if (address(vTokenBorrowed) != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n\n if (VToken(vTokenCollateral).comptroller() != VToken(vTokenBorrowed).comptroller()) {\n return uint256(Error.COMPTROLLER_MISMATCH);\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vTokenCollateral);\n distributeSupplierVenus(vTokenCollateral, borrower);\n distributeSupplierVenus(vTokenCollateral, liquidator);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates seize, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed, // solhint-disable-line no-unused-vars\n address liquidator,\n address borrower,\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vTokenCollateral);\n prime.accrueInterestAndUpdateScore(liquidator, vTokenCollateral);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to transfer tokens in the given market\n * @param vToken The market to verify the transfer against\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of vTokens to transfer\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function transferAllowed(\n address vToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.TRANSFER);\n\n // Currently the only consideration is whether or not\n // the src is allowed to redeem this many tokens\n uint256 allowed = redeemAllowedInternal(vToken, src, transferTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, src);\n distributeSupplierVenus(vToken, dst);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates transfer, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being transferred\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of vTokens to transfer\n */\n // solhint-disable-next-line no-unused-vars\n function transferVerify(address vToken, address src, address dst, uint256 transferTokens) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(src, vToken);\n prime.accrueInterestAndUpdateScore(dst, vToken);\n }\n }\n\n /**\n * @notice Determine the current account liquidity wrt collateral requirements\n * @return (possible error code (semi-opaque),\n account liquidity in excess of collateral requirements,\n * account shortfall below collateral requirements)\n */\n function getAccountLiquidity(address account) external view returns (uint256, uint256, uint256) {\n (Error err, uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n VToken(address(0)),\n 0,\n 0\n );\n\n return (uint256(err), liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param vTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code (semi-opaque),\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidity(\n address account,\n address vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) external view returns (uint256, uint256, uint256) {\n (Error err, uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n VToken(vTokenModify),\n redeemTokens,\n borrowAmount\n );\n return (uint256(err), liquidity, shortfall);\n }\n\n // setter functionality\n /**\n * @notice Set XVS speed for a single market\n * @dev Allows the contract admin to set XVS speed for a market\n * @param vTokens The market whose XVS speed to update\n * @param supplySpeeds New XVS speed for supply\n * @param borrowSpeeds New XVS speed for borrow\n */\n function _setVenusSpeeds(\n VToken[] calldata vTokens,\n uint256[] calldata supplySpeeds,\n uint256[] calldata borrowSpeeds\n ) external {\n ensureAdmin();\n\n uint256 numTokens = vTokens.length;\n require(numTokens == supplySpeeds.length && numTokens == borrowSpeeds.length, \"invalid input\");\n\n for (uint256 i; i < numTokens; ++i) {\n ensureNonzeroAddress(address(vTokens[i]));\n setVenusSpeedInternal(vTokens[i], supplySpeeds[i], borrowSpeeds[i]);\n }\n }\n\n function setVenusSpeedInternal(VToken vToken, uint256 supplySpeed, uint256 borrowSpeed) internal {\n ensureListed(markets[address(vToken)]);\n\n if (venusSupplySpeeds[address(vToken)] != supplySpeed) {\n // Supply speed updated so let's update supply state to ensure that\n // 1. XVS accrued properly for the old speed, and\n // 2. XVS accrued at the new speed starts after this block.\n\n updateVenusSupplyIndex(address(vToken));\n // Update speed and emit event\n venusSupplySpeeds[address(vToken)] = supplySpeed;\n emit VenusSupplySpeedUpdated(vToken, supplySpeed);\n }\n\n if (venusBorrowSpeeds[address(vToken)] != borrowSpeed) {\n // Borrow speed updated so let's update borrow state to ensure that\n // 1. XVS accrued properly for the old speed, and\n // 2. XVS accrued at the new speed starts after this block.\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n\n // Update speed and emit event\n venusBorrowSpeeds[address(vToken)] = borrowSpeed;\n emit VenusBorrowSpeedUpdated(vToken, borrowSpeed);\n }\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/RewardFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IRewardFacet } from \"../interfaces/IRewardFacet.sol\";\nimport { XVSRewardsHelper } from \"./XVSRewardsHelper.sol\";\nimport { SafeBEP20, IBEP20 } from \"../../../Utils/SafeBEP20.sol\";\nimport { VBep20Interface } from \"../../../Tokens/VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title RewardFacet\n * @author Venus\n * @dev This facet contains all the methods related to the reward functionality\n * @notice This facet contract provides the external functions related to all claims and rewards of the protocol\n */\ncontract RewardFacet is IRewardFacet, XVSRewardsHelper {\n /// @notice Emitted when Venus is granted by admin\n event VenusGranted(address indexed recipient, uint256 amount);\n\n /// @notice Emitted when XVS are seized for the holder\n event VenusSeized(address indexed holder, uint256 amount);\n\n using SafeBEP20 for IBEP20;\n\n /**\n * @notice Claim all the xvs accrued by holder in all markets and VAI\n * @param holder The address to claim XVS for\n */\n function claimVenus(address holder) public {\n return claimVenus(holder, allMarkets);\n }\n\n /**\n * @notice Claim all the xvs accrued by holder in the specified markets\n * @param holder The address to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n */\n function claimVenus(address holder, VToken[] memory vTokens) public {\n address[] memory holders = new address[](1);\n holders[0] = holder;\n claimVenus(holders, vTokens, true, true);\n }\n\n /**\n * @notice Claim all xvs accrued by the holders\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n */\n function claimVenus(address[] memory holders, VToken[] memory vTokens, bool borrowers, bool suppliers) public {\n claimVenus(holders, vTokens, borrowers, suppliers, false);\n }\n\n /**\n * @notice Claim all the xvs accrued by holder in all markets, a shorthand for `claimVenus` with collateral set to `true`\n * @param holder The address to claim XVS for\n */\n function claimVenusAsCollateral(address holder) external {\n address[] memory holders = new address[](1);\n holders[0] = holder;\n claimVenus(holders, allMarkets, true, true, true);\n }\n\n /**\n * @notice Transfer XVS to the user with user's shortfall considered\n * @dev Note: If there is not enough XVS, we do not perform the transfer all\n * @param user The address of the user to transfer XVS to\n * @param amount The amount of XVS to (possibly) transfer\n * @param shortfall The shortfall of the user\n * @param collateral Whether or not we will use user's venus reward as collateral to pay off the debt\n * @return The amount of XVS which was NOT transferred to the user\n */\n function grantXVSInternal(\n address user,\n uint256 amount,\n uint256 shortfall,\n bool collateral\n ) internal returns (uint256) {\n // If the user is blacklisted, they can't get XVS rewards\n require(\n user != 0xEF044206Db68E40520BfA82D45419d498b4bc7Bf &&\n user != 0x7589dD3355DAE848FDbF75044A3495351655cB1A &&\n user != 0x33df7a7F6D44307E1e5F3B15975b47515e5524c0 &&\n user != 0x24e77E5b74B30b026E9996e4bc3329c881e24968,\n \"Blacklisted\"\n );\n\n IBEP20 xvs_ = IBEP20(xvs);\n\n if (amount == 0 || amount > xvs_.balanceOf(address(this))) {\n return amount;\n }\n\n if (shortfall == 0) {\n xvs_.safeTransfer(user, amount);\n return 0;\n }\n // If user's bankrupt and doesn't use pending xvs as collateral, don't grant\n // anything, otherwise, we will transfer the pending xvs as collateral to\n // vXVS token and mint vXVS for the user\n //\n // If mintBehalf failed, don't grant any xvs\n require(collateral, \"bankrupt\");\n\n address xvsVToken_ = xvsVToken;\n\n xvs_.safeApprove(xvsVToken_, 0);\n xvs_.safeApprove(xvsVToken_, amount);\n require(VBep20Interface(xvsVToken_).mintBehalf(user, amount) == uint256(Error.NO_ERROR), \"mint behalf error\");\n\n // set venusAccrued[user] to 0\n return 0;\n }\n\n /*** Venus Distribution Admin ***/\n\n /**\n * @notice Transfer XVS to the recipient\n * @dev Allows the contract admin to transfer XVS to any recipient based on the recipient's shortfall\n * Note: If there is not enough XVS, we do not perform the transfer all\n * @param recipient The address of the recipient to transfer XVS to\n * @param amount The amount of XVS to (possibly) transfer\n */\n function _grantXVS(address recipient, uint256 amount) external {\n ensureAdmin();\n uint256 amountLeft = grantXVSInternal(recipient, amount, 0, false);\n require(amountLeft == 0, \"no xvs\");\n emit VenusGranted(recipient, amount);\n }\n\n /**\n * @dev Seize XVS tokens from the specified holders and transfer to recipient\n * @notice Seize XVS rewards allocated to holders\n * @param holders Addresses of the XVS holders\n * @param recipient Address of the XVS token recipient\n * @return The total amount of XVS tokens seized and transferred to recipient\n */\n function seizeVenus(address[] calldata holders, address recipient) external returns (uint256) {\n ensureAllowed(\"seizeVenus(address[],address)\");\n\n uint256 holdersLength = holders.length;\n uint256 totalHoldings;\n\n updateAndDistributeRewardsInternal(holders, allMarkets, true, true);\n for (uint256 j; j < holdersLength; ++j) {\n address holder = holders[j];\n uint256 userHolding = venusAccrued[holder];\n\n if (userHolding != 0) {\n totalHoldings += userHolding;\n delete venusAccrued[holder];\n }\n\n emit VenusSeized(holder, userHolding);\n }\n\n if (totalHoldings != 0) {\n IBEP20(xvs).safeTransfer(recipient, totalHoldings);\n emit VenusGranted(recipient, totalHoldings);\n }\n\n return totalHoldings;\n }\n\n /**\n * @notice Claim all xvs accrued by the holders\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n * @param collateral Whether or not to use XVS earned as collateral, only takes effect when the holder has a shortfall\n */\n function claimVenus(\n address[] memory holders,\n VToken[] memory vTokens,\n bool borrowers,\n bool suppliers,\n bool collateral\n ) public {\n uint256 holdersLength = holders.length;\n\n updateAndDistributeRewardsInternal(holders, vTokens, borrowers, suppliers);\n for (uint256 j; j < holdersLength; ++j) {\n address holder = holders[j];\n\n // If there is a positive shortfall, the XVS reward is accrued,\n // but won't be granted to this holder\n (, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(holder, VToken(address(0)), 0, 0);\n\n uint256 value = venusAccrued[holder];\n delete venusAccrued[holder];\n\n uint256 returnAmount = grantXVSInternal(holder, value, shortfall, collateral);\n\n // returnAmount can only be positive if balance of xvsAddress is less than grant amount(venusAccrued[holder])\n if (returnAmount != 0) {\n venusAccrued[holder] = returnAmount;\n }\n }\n }\n\n /**\n * @notice Update and distribute tokens\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n */\n function updateAndDistributeRewardsInternal(\n address[] memory holders,\n VToken[] memory vTokens,\n bool borrowers,\n bool suppliers\n ) internal {\n uint256 j;\n uint256 holdersLength = holders.length;\n uint256 vTokensLength = vTokens.length;\n\n for (uint256 i; i < vTokensLength; ++i) {\n VToken vToken = vTokens[i];\n ensureListed(markets[address(vToken)]);\n if (borrowers) {\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n for (j = 0; j < holdersLength; ++j) {\n distributeBorrowerVenus(address(vToken), holders[j], borrowIndex);\n }\n }\n\n if (suppliers) {\n updateVenusSupplyIndex(address(vToken));\n for (j = 0; j < holdersLength; ++j) {\n distributeSupplierVenus(address(vToken), holders[j]);\n }\n }\n }\n }\n\n /**\n * @notice Returns the XVS vToken address\n * @return The address of XVS vToken\n */\n function getXVSVTokenAddress() external view returns (address) {\n return xvsVToken;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/SetterFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ISetterFacet } from \"../interfaces/ISetterFacet.sol\";\nimport { PriceOracle } from \"../../../Oracle/PriceOracle.sol\";\nimport { ComptrollerLensInterface } from \"../../ComptrollerLensInterface.sol\";\nimport { VAIControllerInterface } from \"../../../Tokens/VAI/VAIControllerInterface.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\nimport { IPrime } from \"../../../Tokens/Prime/IPrime.sol\";\n\n/**\n * @title SetterFacet\n * @author Venus\n * @dev This facet contains all the setters for the states\n * @notice This facet contract contains all the configurational setter functions\n */\ncontract SetterFacet is ISetterFacet, FacetBase {\n /// @notice Emitted when close factor is changed by admin\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\n\n /// @notice Emitted when a collateral factor is changed by admin\n event NewCollateralFactor(\n VToken indexed vToken,\n uint256 oldCollateralFactorMantissa,\n uint256 newCollateralFactorMantissa\n );\n\n /// @notice Emitted when liquidation incentive is changed by admin\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\n\n /// @notice Emitted when price oracle is changed\n event NewPriceOracle(PriceOracle oldPriceOracle, PriceOracle newPriceOracle);\n\n /// @notice Emitted when borrow cap for a vToken is changed\n event NewBorrowCap(VToken indexed vToken, uint256 newBorrowCap);\n\n /// @notice Emitted when VAIController is changed\n event NewVAIController(VAIControllerInterface oldVAIController, VAIControllerInterface newVAIController);\n\n /// @notice Emitted when VAI mint rate is changed by admin\n event NewVAIMintRate(uint256 oldVAIMintRate, uint256 newVAIMintRate);\n\n /// @notice Emitted when protocol state is changed by admin\n event ActionProtocolPaused(bool state);\n\n /// @notice Emitted when treasury guardian is changed\n event NewTreasuryGuardian(address oldTreasuryGuardian, address newTreasuryGuardian);\n\n /// @notice Emitted when treasury address is changed\n event NewTreasuryAddress(address oldTreasuryAddress, address newTreasuryAddress);\n\n /// @notice Emitted when treasury percent is changed\n event NewTreasuryPercent(uint256 oldTreasuryPercent, uint256 newTreasuryPercent);\n\n /// @notice Emitted when liquidator adress is changed\n event NewLiquidatorContract(address oldLiquidatorContract, address newLiquidatorContract);\n\n /// @notice Emitted when ComptrollerLens address is changed\n event NewComptrollerLens(address oldComptrollerLens, address newComptrollerLens);\n\n /// @notice Emitted when supply cap for a vToken is changed\n event NewSupplyCap(VToken indexed vToken, uint256 newSupplyCap);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControl(address oldAccessControlAddress, address newAccessControlAddress);\n\n /// @notice Emitted when pause guardian is changed\n event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);\n\n /// @notice Emitted when an action is paused on a market\n event ActionPausedMarket(VToken indexed vToken, Action indexed action, bool pauseState);\n\n /// @notice Emitted when VAI Vault info is changed\n event NewVAIVaultInfo(address indexed vault_, uint256 releaseStartBlock_, uint256 releaseInterval_);\n\n /// @notice Emitted when Venus VAI Vault rate is changed\n event NewVenusVAIVaultRate(uint256 oldVenusVAIVaultRate, uint256 newVenusVAIVaultRate);\n\n /// @notice Emitted when prime token contract address is changed\n event NewPrimeToken(IPrime oldPrimeToken, IPrime newPrimeToken);\n\n /// @notice Emitted when forced liquidation is enabled or disabled for all users in a market\n event IsForcedLiquidationEnabledUpdated(address indexed vToken, bool enable);\n\n /// @notice Emitted when forced liquidation is enabled or disabled for a user borrowing in a market\n event IsForcedLiquidationEnabledForUserUpdated(address indexed borrower, address indexed vToken, bool enable);\n\n /// @notice Emitted when XVS token address is changed\n event NewXVSToken(address indexed oldXVS, address indexed newXVS);\n\n /// @notice Emitted when XVS vToken address is changed\n event NewXVSVToken(address indexed oldXVSVToken, address indexed newXVSVToken);\n\n /**\n * @notice Compare two addresses to ensure they are different\n * @param oldAddress The original address to compare\n * @param newAddress The new address to compare\n */\n modifier compareAddress(address oldAddress, address newAddress) {\n require(oldAddress != newAddress, \"old address is same as new address\");\n _;\n }\n\n /**\n * @notice Compare two values to ensure they are different\n * @param oldValue The original value to compare\n * @param newValue The new value to compare\n */\n modifier compareValue(uint256 oldValue, uint256 newValue) {\n require(oldValue != newValue, \"old value is same as new value\");\n _;\n }\n\n /**\n * @notice Sets a new price oracle for the comptroller\n * @dev Allows the contract admin to set a new price oracle used by the Comptroller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPriceOracle(\n PriceOracle newOracle\n ) external compareAddress(address(oracle), address(newOracle)) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(address(newOracle));\n\n // Track the old oracle for the comptroller\n PriceOracle oldOracle = oracle;\n\n // Set comptroller's oracle to newOracle\n oracle = newOracle;\n\n // Emit NewPriceOracle(oldOracle, newOracle)\n emit NewPriceOracle(oldOracle, newOracle);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the closeFactor used when liquidating borrows\n * @dev Allows the contract admin to set the closeFactor used to liquidate borrows\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\n * @return uint256 0=success, otherwise will revert\n */\n function _setCloseFactor(\n uint256 newCloseFactorMantissa\n ) external compareValue(closeFactorMantissa, newCloseFactorMantissa) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\n\n //-- Check close factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\n //-- Check close factor >= 0.05\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\n\n if (lessThanExp(highLimit, newCloseFactorExp) || greaterThanExp(lowLimit, newCloseFactorExp)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\n closeFactorMantissa = newCloseFactorMantissa;\n emit NewCloseFactor(oldCloseFactorMantissa, newCloseFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Allows the contract admin to set the address of access control of this contract\n * @param newAccessControlAddress New address for the access control\n * @return uint256 0=success, otherwise will revert\n */\n function _setAccessControl(\n address newAccessControlAddress\n ) external compareAddress(accessControl, newAccessControlAddress) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(newAccessControlAddress);\n\n address oldAccessControlAddress = accessControl;\n\n accessControl = newAccessControlAddress;\n emit NewAccessControl(oldAccessControlAddress, newAccessControlAddress);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the collateralFactor for a market\n * @dev Allows a privileged role to set the collateralFactorMantissa\n * @param vToken The market to set the factor on\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\n * @return uint256 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCollateralFactor(\n VToken vToken,\n uint256 newCollateralFactorMantissa\n )\n external\n compareValue(markets[address(vToken)].collateralFactorMantissa, newCollateralFactorMantissa)\n returns (uint256)\n {\n // Check caller is allowed by access control manager\n ensureAllowed(\"_setCollateralFactor(address,uint256)\");\n ensureNonzeroAddress(address(vToken));\n\n // Verify market is listed\n Market storage market = markets[address(vToken)];\n ensureListed(market);\n\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\n\n //-- Check collateral factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\n }\n\n // If collateral factor != 0, fail if price == 0\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(vToken) == 0) {\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\n }\n\n // Set market's collateral factor to new collateral factor, remember old value\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\n market.collateralFactorMantissa = newCollateralFactorMantissa;\n\n // Emit event with asset, old collateral factor, and new collateral factor\n emit NewCollateralFactor(vToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets liquidationIncentive\n * @dev Allows a privileged role to set the liquidationIncentiveMantissa\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\n * @return uint256 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setLiquidationIncentive(\n uint256 newLiquidationIncentiveMantissa\n ) external compareValue(liquidationIncentiveMantissa, newLiquidationIncentiveMantissa) returns (uint256) {\n ensureAllowed(\"_setLiquidationIncentive(uint256)\");\n\n require(newLiquidationIncentiveMantissa >= 1e18, \"incentive < 1e18\");\n\n // Save current value for use in log\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\n // Set liquidation incentive to new incentive\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\n\n // Emit event with old incentive, new incentive\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Update the address of the liquidator contract\n * @dev Allows the contract admin to update the address of liquidator contract\n * @param newLiquidatorContract_ The new address of the liquidator contract\n */\n function _setLiquidatorContract(\n address newLiquidatorContract_\n ) external compareAddress(liquidatorContract, newLiquidatorContract_) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(newLiquidatorContract_);\n address oldLiquidatorContract = liquidatorContract;\n liquidatorContract = newLiquidatorContract_;\n emit NewLiquidatorContract(oldLiquidatorContract, newLiquidatorContract_);\n }\n\n /**\n * @notice Admin function to change the Pause Guardian\n * @dev Allows the contract admin to change the Pause Guardian\n * @param newPauseGuardian The address of the new Pause Guardian\n * @return uint256 0=success, otherwise a failure. (See enum Error for details)\n */\n function _setPauseGuardian(\n address newPauseGuardian\n ) external compareAddress(pauseGuardian, newPauseGuardian) returns (uint256) {\n ensureAdmin();\n ensureNonzeroAddress(newPauseGuardian);\n\n // Save current value for inclusion in log\n address oldPauseGuardian = pauseGuardian;\n // Store pauseGuardian with value newPauseGuardian\n pauseGuardian = newPauseGuardian;\n\n // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)\n emit NewPauseGuardian(oldPauseGuardian, newPauseGuardian);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the given borrow caps for the given vToken market Borrowing that brings total borrows to or above borrow cap will revert\n * @dev Allows a privileged role to set the borrowing cap for a vToken market. A borrow cap of 0 corresponds to Borrow not allowed\n * @param vTokens The addresses of the markets (tokens) to change the borrow caps for\n * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to Borrow not allowed\n */\n function _setMarketBorrowCaps(VToken[] calldata vTokens, uint256[] calldata newBorrowCaps) external {\n ensureAllowed(\"_setMarketBorrowCaps(address[],uint256[])\");\n\n uint256 numMarkets = vTokens.length;\n uint256 numBorrowCaps = newBorrowCaps.length;\n\n require(numMarkets != 0 && numMarkets == numBorrowCaps, \"invalid input\");\n\n for (uint256 i; i < numMarkets; ++i) {\n borrowCaps[address(vTokens[i])] = newBorrowCaps[i];\n emit NewBorrowCap(vTokens[i], newBorrowCaps[i]);\n }\n }\n\n /**\n * @notice Set the given supply caps for the given vToken market Supply that brings total Supply to or above supply cap will revert\n * @dev Allows a privileged role to set the supply cap for a vToken. A supply cap of 0 corresponds to Minting NotAllowed\n * @param vTokens The addresses of the markets (tokens) to change the supply caps for\n * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to Minting NotAllowed\n */\n function _setMarketSupplyCaps(VToken[] calldata vTokens, uint256[] calldata newSupplyCaps) external {\n ensureAllowed(\"_setMarketSupplyCaps(address[],uint256[])\");\n\n uint256 numMarkets = vTokens.length;\n uint256 numSupplyCaps = newSupplyCaps.length;\n\n require(numMarkets != 0 && numMarkets == numSupplyCaps, \"invalid input\");\n\n for (uint256 i; i < numMarkets; ++i) {\n supplyCaps[address(vTokens[i])] = newSupplyCaps[i];\n emit NewSupplyCap(vTokens[i], newSupplyCaps[i]);\n }\n }\n\n /**\n * @notice Set whole protocol pause/unpause state\n * @dev Allows a privileged role to pause/unpause protocol\n * @param state The new state (true=paused, false=unpaused)\n * @return bool The updated state of the protocol\n */\n function _setProtocolPaused(bool state) external returns (bool) {\n ensureAllowed(\"_setProtocolPaused(bool)\");\n\n protocolPaused = state;\n emit ActionProtocolPaused(state);\n return state;\n }\n\n /**\n * @notice Pause/unpause certain actions\n * @dev Allows a privileged role to pause/unpause the protocol action state\n * @param markets_ Markets to pause/unpause the actions on\n * @param actions_ List of action ids to pause/unpause\n * @param paused_ The new paused state (true=paused, false=unpaused)\n */\n function _setActionsPaused(address[] calldata markets_, Action[] calldata actions_, bool paused_) external {\n ensureAllowed(\"_setActionsPaused(address[],uint8[],bool)\");\n\n uint256 numMarkets = markets_.length;\n uint256 numActions = actions_.length;\n for (uint256 marketIdx; marketIdx < numMarkets; ++marketIdx) {\n for (uint256 actionIdx; actionIdx < numActions; ++actionIdx) {\n setActionPausedInternal(markets_[marketIdx], actions_[actionIdx], paused_);\n }\n }\n }\n\n /**\n * @dev Pause/unpause an action on a market\n * @param market Market to pause/unpause the action on\n * @param action Action id to pause/unpause\n * @param paused The new paused state (true=paused, false=unpaused)\n */\n function setActionPausedInternal(address market, Action action, bool paused) internal {\n ensureListed(markets[market]);\n _actionPaused[market][uint256(action)] = paused;\n emit ActionPausedMarket(VToken(market), action, paused);\n }\n\n /**\n * @notice Sets a new VAI controller\n * @dev Admin function to set a new VAI controller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setVAIController(\n VAIControllerInterface vaiController_\n ) external compareAddress(address(vaiController), address(vaiController_)) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(address(vaiController_));\n\n VAIControllerInterface oldVaiController = vaiController;\n vaiController = vaiController_;\n emit NewVAIController(oldVaiController, vaiController_);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the VAI mint rate\n * @param newVAIMintRate The new VAI mint rate to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setVAIMintRate(\n uint256 newVAIMintRate\n ) external compareValue(vaiMintRate, newVAIMintRate) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n uint256 oldVAIMintRate = vaiMintRate;\n vaiMintRate = newVAIMintRate;\n emit NewVAIMintRate(oldVAIMintRate, newVAIMintRate);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the minted VAI amount of the `owner`\n * @param owner The address of the account to set\n * @param amount The amount of VAI to set to the account\n * @return The number of minted VAI by `owner`\n */\n function setMintedVAIOf(address owner, uint256 amount) external returns (uint256) {\n checkProtocolPauseState();\n\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!mintVAIGuardianPaused && !repayVAIGuardianPaused, \"VAI is paused\");\n // Check caller is vaiController\n if (msg.sender != address(vaiController)) {\n return fail(Error.REJECTION, FailureInfo.SET_MINTED_VAI_REJECTION);\n }\n mintedVAIs[owner] = amount;\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the treasury data.\n * @param newTreasuryGuardian The new address of the treasury guardian to be set\n * @param newTreasuryAddress The new address of the treasury to be set\n * @param newTreasuryPercent The new treasury percent to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256) {\n // Check caller is admin\n ensureAdminOr(treasuryGuardian);\n\n require(newTreasuryPercent < 1e18, \"percent >= 100%\");\n ensureNonzeroAddress(newTreasuryGuardian);\n ensureNonzeroAddress(newTreasuryAddress);\n\n address oldTreasuryGuardian = treasuryGuardian;\n address oldTreasuryAddress = treasuryAddress;\n uint256 oldTreasuryPercent = treasuryPercent;\n\n treasuryGuardian = newTreasuryGuardian;\n treasuryAddress = newTreasuryAddress;\n treasuryPercent = newTreasuryPercent;\n\n emit NewTreasuryGuardian(oldTreasuryGuardian, newTreasuryGuardian);\n emit NewTreasuryAddress(oldTreasuryAddress, newTreasuryAddress);\n emit NewTreasuryPercent(oldTreasuryPercent, newTreasuryPercent);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Venus Distribution ***/\n\n /**\n * @dev Set ComptrollerLens contract address\n * @param comptrollerLens_ The new ComptrollerLens contract address to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptrollerLens(\n ComptrollerLensInterface comptrollerLens_\n ) external compareAddress(address(comptrollerLens), address(comptrollerLens_)) returns (uint256) {\n ensureAdmin();\n ensureNonzeroAddress(address(comptrollerLens_));\n address oldComptrollerLens = address(comptrollerLens);\n comptrollerLens = comptrollerLens_;\n emit NewComptrollerLens(oldComptrollerLens, address(comptrollerLens));\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the amount of XVS distributed per block to VAI Vault\n * @param venusVAIVaultRate_ The amount of XVS wei per block to distribute to VAI Vault\n */\n function _setVenusVAIVaultRate(\n uint256 venusVAIVaultRate_\n ) external compareValue(venusVAIVaultRate, venusVAIVaultRate_) {\n ensureAdmin();\n if (vaiVaultAddress != address(0)) {\n releaseToVault();\n }\n uint256 oldVenusVAIVaultRate = venusVAIVaultRate;\n venusVAIVaultRate = venusVAIVaultRate_;\n emit NewVenusVAIVaultRate(oldVenusVAIVaultRate, venusVAIVaultRate_);\n }\n\n /**\n * @notice Set the VAI Vault infos\n * @param vault_ The address of the VAI Vault\n * @param releaseStartBlock_ The start block of release to VAI Vault\n * @param minReleaseAmount_ The minimum release amount to VAI Vault\n */\n function _setVAIVaultInfo(\n address vault_,\n uint256 releaseStartBlock_,\n uint256 minReleaseAmount_\n ) external compareAddress(vaiVaultAddress, vault_) {\n ensureAdmin();\n ensureNonzeroAddress(vault_);\n if (vaiVaultAddress != address(0)) {\n releaseToVault();\n }\n\n vaiVaultAddress = vault_;\n releaseStartBlock = releaseStartBlock_;\n minReleaseAmount = minReleaseAmount_;\n emit NewVAIVaultInfo(vault_, releaseStartBlock_, minReleaseAmount_);\n }\n\n /**\n * @notice Sets the prime token contract for the comptroller\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPrimeToken(IPrime _prime) external returns (uint) {\n ensureAdmin();\n ensureNonzeroAddress(address(_prime));\n\n IPrime oldPrime = prime;\n prime = _prime;\n emit NewPrimeToken(oldPrime, _prime);\n\n return uint(Error.NO_ERROR);\n }\n\n /** @notice Enables forced liquidations for a market. If forced liquidation is enabled,\n * borrows in the market may be liquidated regardless of the account liquidity\n * @dev Allows a privileged role to set enable/disable forced liquidations\n * @param vTokenBorrowed Borrowed vToken\n * @param enable Whether to enable forced liquidations\n */\n function _setForcedLiquidation(address vTokenBorrowed, bool enable) external {\n ensureAllowed(\"_setForcedLiquidation(address,bool)\");\n if (vTokenBorrowed != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n isForcedLiquidationEnabled[vTokenBorrowed] = enable;\n emit IsForcedLiquidationEnabledUpdated(vTokenBorrowed, enable);\n }\n\n /**\n * @notice Enables forced liquidations for user's borrows in a certain market. If forced\n * liquidation is enabled, user's borrows in the market may be liquidated regardless of\n * the account liquidity. Forced liquidation may be enabled for a user even if it is not\n * enabled for the entire market.\n * @param borrower The address of the borrower\n * @param vTokenBorrowed Borrowed vToken\n * @param enable Whether to enable forced liquidations\n */\n function _setForcedLiquidationForUser(address borrower, address vTokenBorrowed, bool enable) external {\n ensureAllowed(\"_setForcedLiquidationForUser(address,address,bool)\");\n if (vTokenBorrowed != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n isForcedLiquidationEnabledForUser[borrower][vTokenBorrowed] = enable;\n emit IsForcedLiquidationEnabledForUserUpdated(borrower, vTokenBorrowed, enable);\n }\n\n /**\n * @notice Set the address of the XVS token\n * @param xvs_ The address of the XVS token\n */\n function _setXVSToken(address xvs_) external {\n ensureAdmin();\n ensureNonzeroAddress(xvs_);\n\n emit NewXVSToken(xvs, xvs_);\n xvs = xvs_;\n }\n\n /**\n * @notice Set the address of the XVS vToken\n * @param xvsVToken_ The address of the XVS vToken\n */\n function _setXVSVToken(address xvsVToken_) external {\n ensureAdmin();\n ensureNonzeroAddress(xvsVToken_);\n\n address underlying = VToken(xvsVToken_).underlying();\n require(underlying == xvs, \"invalid xvs vtoken address\");\n\n emit NewXVSVToken(xvsVToken, xvsVToken_);\n xvsVToken = xvsVToken_;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/XVSRewardsHelper.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\n\n/**\n * @title XVSRewardsHelper\n * @author Venus\n * @dev This contract contains internal functions used in RewardFacet and PolicyFacet\n * @notice This facet contract contains the shared functions used by the RewardFacet and PolicyFacet\n */\ncontract XVSRewardsHelper is FacetBase {\n /// @notice Emitted when XVS is distributed to a borrower\n event DistributedBorrowerVenus(\n VToken indexed vToken,\n address indexed borrower,\n uint256 venusDelta,\n uint256 venusBorrowIndex\n );\n\n /// @notice Emitted when XVS is distributed to a supplier\n event DistributedSupplierVenus(\n VToken indexed vToken,\n address indexed supplier,\n uint256 venusDelta,\n uint256 venusSupplyIndex\n );\n\n /**\n * @notice Accrue XVS to the market by updating the borrow index\n * @param vToken The market whose borrow index to update\n */\n function updateVenusBorrowIndex(address vToken, Exp memory marketBorrowIndex) internal {\n VenusMarketState storage borrowState = venusBorrowState[vToken];\n uint256 borrowSpeed = venusBorrowSpeeds[vToken];\n uint32 blockNumber = getBlockNumberAsUint32();\n uint256 deltaBlocks = sub_(blockNumber, borrowState.block);\n if (deltaBlocks != 0 && borrowSpeed != 0) {\n uint256 borrowAmount = div_(VToken(vToken).totalBorrows(), marketBorrowIndex);\n uint256 accruedVenus = mul_(deltaBlocks, borrowSpeed);\n Double memory ratio = borrowAmount != 0 ? fraction(accruedVenus, borrowAmount) : Double({ mantissa: 0 });\n borrowState.index = safe224(add_(Double({ mantissa: borrowState.index }), ratio).mantissa, \"224\");\n borrowState.block = blockNumber;\n } else if (deltaBlocks != 0) {\n borrowState.block = blockNumber;\n }\n }\n\n /**\n * @notice Accrue XVS to the market by updating the supply index\n * @param vToken The market whose supply index to update\n */\n function updateVenusSupplyIndex(address vToken) internal {\n VenusMarketState storage supplyState = venusSupplyState[vToken];\n uint256 supplySpeed = venusSupplySpeeds[vToken];\n uint32 blockNumber = getBlockNumberAsUint32();\n\n uint256 deltaBlocks = sub_(blockNumber, supplyState.block);\n if (deltaBlocks != 0 && supplySpeed != 0) {\n uint256 supplyTokens = VToken(vToken).totalSupply();\n uint256 accruedVenus = mul_(deltaBlocks, supplySpeed);\n Double memory ratio = supplyTokens != 0 ? fraction(accruedVenus, supplyTokens) : Double({ mantissa: 0 });\n supplyState.index = safe224(add_(Double({ mantissa: supplyState.index }), ratio).mantissa, \"224\");\n supplyState.block = blockNumber;\n } else if (deltaBlocks != 0) {\n supplyState.block = blockNumber;\n }\n }\n\n /**\n * @notice Calculate XVS accrued by a supplier and possibly transfer it to them\n * @param vToken The market in which the supplier is interacting\n * @param supplier The address of the supplier to distribute XVS to\n */\n function distributeSupplierVenus(address vToken, address supplier) internal {\n if (address(vaiVaultAddress) != address(0)) {\n releaseToVault();\n }\n uint256 supplyIndex = venusSupplyState[vToken].index;\n uint256 supplierIndex = venusSupplierIndex[vToken][supplier];\n // Update supplier's index to the current index since we are distributing accrued XVS\n venusSupplierIndex[vToken][supplier] = supplyIndex;\n if (supplierIndex == 0 && supplyIndex >= venusInitialIndex) {\n // Covers the case where users supplied tokens before the market's supply state index was set.\n // Rewards the user with XVS accrued from the start of when supplier rewards were first\n // set for the market.\n supplierIndex = venusInitialIndex;\n }\n // Calculate change in the cumulative sum of the XVS per vToken accrued\n Double memory deltaIndex = Double({ mantissa: sub_(supplyIndex, supplierIndex) });\n // Multiply of supplierTokens and supplierDelta\n uint256 supplierDelta = mul_(VToken(vToken).balanceOf(supplier), deltaIndex);\n // Addition of supplierAccrued and supplierDelta\n venusAccrued[supplier] = add_(venusAccrued[supplier], supplierDelta);\n emit DistributedSupplierVenus(VToken(vToken), supplier, supplierDelta, supplyIndex);\n }\n\n /**\n * @notice Calculate XVS accrued by a borrower and possibly transfer it to them\n * @dev Borrowers will not begin to accrue until after the first interaction with the protocol\n * @param vToken The market in which the borrower is interacting\n * @param borrower The address of the borrower to distribute XVS to\n */\n function distributeBorrowerVenus(address vToken, address borrower, Exp memory marketBorrowIndex) internal {\n if (address(vaiVaultAddress) != address(0)) {\n releaseToVault();\n }\n uint256 borrowIndex = venusBorrowState[vToken].index;\n uint256 borrowerIndex = venusBorrowerIndex[vToken][borrower];\n // Update borrowers's index to the current index since we are distributing accrued XVS\n venusBorrowerIndex[vToken][borrower] = borrowIndex;\n if (borrowerIndex == 0 && borrowIndex >= venusInitialIndex) {\n // Covers the case where users borrowed tokens before the market's borrow state index was set.\n // Rewards the user with XVS accrued from the start of when borrower rewards were first\n // set for the market.\n borrowerIndex = venusInitialIndex;\n }\n // Calculate change in the cumulative sum of the XVS per borrowed unit accrued\n Double memory deltaIndex = Double({ mantissa: sub_(borrowIndex, borrowerIndex) });\n uint256 borrowerDelta = mul_(div_(VToken(vToken).borrowBalanceStored(borrower), marketBorrowIndex), deltaIndex);\n venusAccrued[borrower] = add_(venusAccrued[borrower], borrowerDelta);\n emit DistributedBorrowerVenus(VToken(vToken), borrower, borrowerDelta, borrowIndex);\n }\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IDiamondCut.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\ninterface IDiamondCut {\n enum FacetCutAction {\n Add,\n Replace,\n Remove\n }\n // Add=0, Replace=1, Remove=2\n\n struct FacetCut {\n address facetAddress;\n FacetCutAction action;\n bytes4[] functionSelectors;\n }\n\n /// @notice Add/replace/remove any number of functions and optionally execute\n /// a function with delegatecall\n /// @param _diamondCut Contains the facet addresses and function selectors\n function diamondCut(FacetCut[] calldata _diamondCut) external;\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IMarketFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\ninterface IMarketFacet {\n function isComptroller() external pure returns (bool);\n\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256);\n\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256);\n\n function checkMembership(address account, VToken vToken) external view returns (bool);\n\n function enterMarkets(address[] calldata vTokens) external returns (uint256[] memory);\n\n function exitMarket(address vToken) external returns (uint256);\n\n function _supportMarket(VToken vToken) external returns (uint256);\n\n function getAssetsIn(address account) external view returns (VToken[] memory);\n\n function getAllMarkets() external view returns (VToken[] memory);\n\n function updateDelegate(address delegate, bool allowBorrows) external;\n\n function unlistMarket(address market) external returns (uint256);\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IPolicyFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\ninterface IPolicyFacet {\n function mintAllowed(address vToken, address minter, uint256 mintAmount) external returns (uint256);\n\n function mintVerify(address vToken, address minter, uint256 mintAmount, uint256 mintTokens) external;\n\n function redeemAllowed(address vToken, address redeemer, uint256 redeemTokens) external returns (uint256);\n\n function redeemVerify(address vToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\n\n function borrowAllowed(address vToken, address borrower, uint256 borrowAmount) external returns (uint256);\n\n function borrowVerify(address vToken, address borrower, uint256 borrowAmount) external;\n\n function repayBorrowAllowed(\n address vToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function repayBorrowVerify(\n address vToken,\n address payer,\n address borrower,\n uint256 repayAmount,\n uint256 borrowerIndex\n ) external;\n\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external view returns (uint256);\n\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount,\n uint256 seizeTokens\n ) external;\n\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external;\n\n function transferAllowed(\n address vToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external returns (uint256);\n\n function transferVerify(address vToken, address src, address dst, uint256 transferTokens) external;\n\n function getAccountLiquidity(address account) external view returns (uint256, uint256, uint256);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) external view returns (uint256, uint256, uint256);\n\n function _setVenusSpeeds(\n VToken[] calldata vTokens,\n uint256[] calldata supplySpeeds,\n uint256[] calldata borrowSpeeds\n ) external;\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IRewardFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ComptrollerTypes } from \"../../ComptrollerStorage.sol\";\n\ninterface IRewardFacet {\n function claimVenus(address holder) external;\n\n function claimVenus(address holder, VToken[] calldata vTokens) external;\n\n function claimVenus(address[] calldata holders, VToken[] calldata vTokens, bool borrowers, bool suppliers) external;\n\n function claimVenusAsCollateral(address holder) external;\n\n function _grantXVS(address recipient, uint256 amount) external;\n\n function getXVSAddress() external view returns (address);\n\n function getXVSVTokenAddress() external view returns (address);\n\n function actionPaused(address market, ComptrollerTypes.Action action) external view returns (bool);\n\n function claimVenus(\n address[] calldata holders,\n VToken[] calldata vTokens,\n bool borrowers,\n bool suppliers,\n bool collateral\n ) external;\n function seizeVenus(address[] calldata holders, address recipient) external returns (uint256);\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/ISetterFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { PriceOracle } from \"../../../Oracle/PriceOracle.sol\";\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ComptrollerTypes } from \"../../ComptrollerStorage.sol\";\nimport { VAIControllerInterface } from \"../../../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerLensInterface } from \"../../../Comptroller/ComptrollerLensInterface.sol\";\nimport { IPrime } from \"../../../Tokens/Prime/IPrime.sol\";\n\ninterface ISetterFacet {\n function _setPriceOracle(PriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setAccessControl(address newAccessControlAddress) external returns (uint256);\n\n function _setCollateralFactor(VToken vToken, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _setLiquidatorContract(address newLiquidatorContract_) external;\n\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\n\n function _setMarketBorrowCaps(VToken[] calldata vTokens, uint256[] calldata newBorrowCaps) external;\n\n function _setMarketSupplyCaps(VToken[] calldata vTokens, uint256[] calldata newSupplyCaps) external;\n\n function _setProtocolPaused(bool state) external returns (bool);\n\n function _setActionsPaused(\n address[] calldata markets,\n ComptrollerTypes.Action[] calldata actions,\n bool paused\n ) external;\n\n function _setVAIController(VAIControllerInterface vaiController_) external returns (uint256);\n\n function _setVAIMintRate(uint256 newVAIMintRate) external returns (uint256);\n\n function setMintedVAIOf(address owner, uint256 amount) external returns (uint256);\n\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256);\n\n function _setComptrollerLens(ComptrollerLensInterface comptrollerLens_) external returns (uint256);\n\n function _setVenusVAIVaultRate(uint256 venusVAIVaultRate_) external;\n\n function _setVAIVaultInfo(address vault_, uint256 releaseStartBlock_, uint256 minReleaseAmount_) external;\n\n function _setForcedLiquidation(address vToken, bool enable) external;\n\n function _setPrimeToken(IPrime _prime) external returns (uint);\n\n function _setForcedLiquidationForUser(address borrower, address vTokenBorrowed, bool enable) external;\n\n function _setXVSToken(address xvs_) external;\n\n function _setXVSVToken(address xvsVToken_) external;\n}\n" + }, + "contracts/Comptroller/Unitroller.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerStorage.sol\";\nimport \"../Utils/ErrorReporter.sol\";\n\n/**\n * @title ComptrollerCore\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\n * VTokens should reference this contract as their comptroller.\n */\ncontract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {\n /**\n * @notice Emitted when pendingComptrollerImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingComptrollerImplementation;\n\n pendingComptrollerImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation and pendingImplementation ≠ address(0)\n if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = comptrollerImplementation;\n address oldPendingImplementation = pendingComptrollerImplementation;\n\n comptrollerImplementation = pendingComptrollerImplementation;\n\n pendingComptrollerImplementation = address(0);\n\n emit NewImplementation(oldImplementation, comptrollerImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = comptrollerImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Governance/VTreasury.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/IBEP20.sol\";\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/Ownable.sol\";\n\n/**\n * @title VTreasury\n * @author Venus\n * @notice Protocol treasury that holds tokens owned by Venus\n */\ncontract VTreasury is Ownable {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n // WithdrawTreasuryBEP20 Event\n event WithdrawTreasuryBEP20(address tokenAddress, uint256 withdrawAmount, address withdrawAddress);\n\n // WithdrawTreasuryBNB Event\n event WithdrawTreasuryBNB(uint256 withdrawAmount, address withdrawAddress);\n\n /**\n * @notice To receive BNB\n */\n function() external payable {}\n\n /**\n * @notice Withdraw Treasury BEP20 Tokens, Only owner call it\n * @param tokenAddress The address of treasury token\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n */\n function withdrawTreasuryBEP20(\n address tokenAddress,\n uint256 withdrawAmount,\n address withdrawAddress\n ) external onlyOwner {\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury Token Balance\n uint256 treasuryBalance = IBEP20(tokenAddress).balanceOf(address(this));\n\n // Check Withdraw Amount\n if (withdrawAmount > treasuryBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = treasuryBalance;\n }\n\n // Transfer BEP20 Token to withdrawAddress\n IBEP20(tokenAddress).safeTransfer(withdrawAddress, actualWithdrawAmount);\n\n emit WithdrawTreasuryBEP20(tokenAddress, actualWithdrawAmount, withdrawAddress);\n }\n\n /**\n * @notice Withdraw Treasury BNB, Only owner call it\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n */\n function withdrawTreasuryBNB(uint256 withdrawAmount, address payable withdrawAddress) external payable onlyOwner {\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury BNB Balance\n uint256 bnbBalance = address(this).balance;\n\n // Check Withdraw Amount\n if (withdrawAmount > bnbBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = bnbBalance;\n }\n // Transfer BNB to withdrawAddress\n withdrawAddress.transfer(actualWithdrawAmount);\n\n emit WithdrawTreasuryBNB(actualWithdrawAmount, withdrawAddress);\n }\n}\n" + }, + "contracts/InterestRateModels/InterestRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Venus's InterestRateModel Interface\n * @author Venus\n */\ncontract InterestRateModel {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) external view returns (uint);\n}\n" + }, + "contracts/InterestRateModels/JumpRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Venus's JumpRateModel Contract\n * @author Venus\n */\ncontract JumpRateModel is InterestRateModel {\n using SafeMath for uint;\n\n event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock, uint jumpMultiplierPerBlock, uint kink);\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint public constant blocksPerYear = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint public baseRatePerBlock;\n\n /**\n * @notice The multiplierPerBlock after hitting a specified utilization point\n */\n uint public jumpMultiplierPerBlock;\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n uint public kink;\n\n /**\n * @notice Construct an interest rate model\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\n * @param kink_ The utilization point at which the jump multiplier is applied\n */\n constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) public {\n baseRatePerBlock = baseRatePerYear.div(blocksPerYear);\n multiplierPerBlock = multiplierPerYear.div(blocksPerYear);\n jumpMultiplierPerBlock = jumpMultiplierPerYear.div(blocksPerYear);\n kink = kink_;\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {\n uint util = utilizationRate(cash, borrows, reserves);\n\n if (util <= kink) {\n return util.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n } else {\n uint normalRate = kink.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n uint excessUtil = util.sub(kink);\n return excessUtil.mul(jumpMultiplierPerBlock).div(1e18).add(normalRate);\n }\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) public view returns (uint) {\n uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);\n uint borrowRate = getBorrowRate(cash, borrows, reserves);\n uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);\n return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);\n }\n}\n" + }, + "contracts/InterestRateModels/WhitePaperInterestRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Venus's WhitePaperInterestRateModel Contract\n * @author Venus\n * @notice The parameterized model described in section 2.4 of the original Venus Protocol whitepaper\n */\ncontract WhitePaperInterestRateModel is InterestRateModel {\n using SafeMath for uint;\n\n event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock);\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint public constant blocksPerYear = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint public baseRatePerBlock;\n\n /**\n * @notice Construct an interest rate model\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n */\n constructor(uint baseRatePerYear, uint multiplierPerYear) public {\n baseRatePerBlock = baseRatePerYear.div(blocksPerYear);\n multiplierPerBlock = multiplierPerYear.div(blocksPerYear);\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {\n uint ur = utilizationRate(cash, borrows, reserves);\n return ur.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) public view returns (uint) {\n uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);\n uint borrowRate = getBorrowRate(cash, borrows, reserves);\n uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);\n return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);\n }\n}\n" + }, + "contracts/Lens/ComptrollerLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VBep20.sol\";\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { ExponentialNoError } from \"../Utils/ExponentialNoError.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Utils/ErrorReporter.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Comptroller/ComptrollerLensInterface.sol\";\nimport \"../Tokens/VAI/VAIControllerInterface.sol\";\n\n/**\n * @title ComptrollerLens Contract\n * @author Venus\n * @notice The ComptrollerLens contract has functions to get the number of tokens that\n * can be seized through liquidation, hypothetical account liquidity and shortfall of an account.\n */\ncontract ComptrollerLens is ComptrollerLensInterface, ComptrollerErrorReporter, ExponentialNoError {\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountLiquidityLocalVars {\n uint sumCollateral;\n uint sumBorrowPlusEffects;\n uint vTokenBalance;\n uint borrowBalance;\n uint exchangeRateMantissa;\n uint oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n }\n\n /**\n * @notice Computes the number of collateral tokens to be seized in a liquidation event\n * @param comptroller Address of comptroller\n * @param vTokenBorrowed Address of the borrowed vToken\n * @param vTokenCollateral Address of collateral for the borrow\n * @param actualRepayAmount Repayment amount i.e amount to be repaid of total borrowed amount\n * @return A tuple of error code, and tokens to seize\n */\n function liquidateCalculateSeizeTokens(\n address comptroller,\n address vTokenBorrowed,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint) {\n /* Read oracle prices for borrowed and collateral markets */\n uint priceBorrowedMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenBorrowed)\n );\n uint priceCollateralMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenCollateral)\n );\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n uint exchangeRateMantissa = VToken(vTokenCollateral).exchangeRateStored(); // Note: reverts on error\n uint seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n numerator = mul_(\n Exp({ mantissa: ComptrollerInterface(comptroller).liquidationIncentiveMantissa() }),\n Exp({ mantissa: priceBorrowedMantissa })\n );\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n\n return (uint(Error.NO_ERROR), seizeTokens);\n }\n\n /**\n * @notice Computes the number of VAI tokens to be seized in a liquidation event\n * @param comptroller Address of comptroller\n * @param vTokenCollateral Address of collateral for vToken\n * @param actualRepayAmount Repayment amount i.e amount to be repaid of the total borrowed amount\n * @return A tuple of error code, and tokens to seize\n */\n function liquidateVAICalculateSeizeTokens(\n address comptroller,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint) {\n /* Read oracle prices for borrowed and collateral markets */\n uint priceBorrowedMantissa = 1e18; // Note: this is VAI\n uint priceCollateralMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenCollateral)\n );\n if (priceCollateralMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n uint exchangeRateMantissa = VToken(vTokenCollateral).exchangeRateStored(); // Note: reverts on error\n uint seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n numerator = mul_(\n Exp({ mantissa: ComptrollerInterface(comptroller).liquidationIncentiveMantissa() }),\n Exp({ mantissa: priceBorrowedMantissa })\n );\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n\n return (uint(Error.NO_ERROR), seizeTokens);\n }\n\n /**\n * @notice Computes the hypothetical liquidity and shortfall of an account given a hypothetical borrow\n * A snapshot of the account is taken and the total borrow amount of the account is calculated\n * @param comptroller Address of comptroller\n * @param account Address of the borrowed vToken\n * @param vTokenModify Address of collateral for vToken\n * @param redeemTokens Number of vTokens being redeemed\n * @param borrowAmount Amount borrowed\n * @return Returns a tuple of error code, liquidity, and shortfall\n */\n function getHypotheticalAccountLiquidity(\n address comptroller,\n address account,\n VToken vTokenModify,\n uint redeemTokens,\n uint borrowAmount\n ) external view returns (uint, uint, uint) {\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\n uint oErr;\n\n // For each asset the account is in\n VToken[] memory assets = ComptrollerInterface(comptroller).getAssetsIn(account);\n uint assetsCount = assets.length;\n for (uint i = 0; i < assetsCount; ++i) {\n VToken asset = assets[i];\n\n // Read the balances and exchange rate from the vToken\n (oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = asset.getAccountSnapshot(\n account\n );\n if (oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (uint(Error.SNAPSHOT_ERROR), 0, 0);\n }\n (, uint collateralFactorMantissa) = ComptrollerInterface(comptroller).markets(address(asset));\n vars.collateralFactor = Exp({ mantissa: collateralFactorMantissa });\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(asset);\n if (vars.oraclePriceMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0, 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> bnb (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n\n // sumCollateral += tokensToDenom * vTokenBalance\n vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.vTokenBalance, vars.sumCollateral);\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n\n // Calculate effects of interacting with vTokenModify\n if (asset == vTokenModify) {\n // redeem effect\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.tokensToDenom,\n redeemTokens,\n vars.sumBorrowPlusEffects\n );\n\n // borrow effect\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n borrowAmount,\n vars.sumBorrowPlusEffects\n );\n }\n }\n\n VAIControllerInterface vaiController = ComptrollerInterface(comptroller).vaiController();\n\n if (address(vaiController) != address(0)) {\n vars.sumBorrowPlusEffects = add_(vars.sumBorrowPlusEffects, vaiController.getVAIRepayAmount(account));\n }\n\n // These are safe, as the underflow condition is checked first\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\n return (uint(Error.NO_ERROR), vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\n } else {\n return (uint(Error.NO_ERROR), 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\n }\n }\n}\n" + }, + "contracts/Lens/SnapshotLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { ExponentialNoError } from \"../Utils/ExponentialNoError.sol\";\nimport \"../Utils/SafeMath.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Tokens/VTokens/VBep20.sol\";\n\ncontract SnapshotLens is ExponentialNoError {\n using SafeMath for uint256;\n\n struct AccountSnapshot {\n address account;\n string assetName;\n address vTokenAddress;\n address underlyingAssetAddress;\n uint256 supply;\n uint256 supplyInUsd;\n uint256 collateral;\n uint256 borrows;\n uint256 borrowsInUsd;\n uint256 assetPrice;\n uint256 accruedInterest;\n uint vTokenDecimals;\n uint underlyingDecimals;\n uint exchangeRate;\n bool isACollateral;\n }\n\n /** Snapshot calculation **/\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account snapshot.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountSnapshotLocalVars {\n uint collateral;\n uint vTokenBalance;\n uint borrowBalance;\n uint borrowsInUsd;\n uint balanceOfUnderlying;\n uint supplyInUsd;\n uint exchangeRateMantissa;\n uint oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n bool isACollateral;\n }\n\n function getAccountSnapshot(\n address payable account,\n address comptrollerAddress\n ) public returns (AccountSnapshot[] memory) {\n // For each asset the account is in\n VToken[] memory assets = ComptrollerInterface(comptrollerAddress).getAllMarkets();\n AccountSnapshot[] memory accountSnapshots = new AccountSnapshot[](assets.length);\n for (uint256 i = 0; i < assets.length; ++i) {\n accountSnapshots[i] = getAccountSnapshot(account, comptrollerAddress, assets[i]);\n }\n return accountSnapshots;\n }\n\n function isACollateral(address account, address asset, address comptrollerAddress) public view returns (bool) {\n VToken[] memory assetsAsCollateral = ComptrollerInterface(comptrollerAddress).getAssetsIn(account);\n for (uint256 j = 0; j < assetsAsCollateral.length; ++j) {\n if (address(assetsAsCollateral[j]) == asset) {\n return true;\n }\n }\n\n return false;\n }\n\n function getAccountSnapshot(\n address payable account,\n address comptrollerAddress,\n VToken vToken\n ) public returns (AccountSnapshot memory) {\n AccountSnapshotLocalVars memory vars; // Holds all our calculation results\n uint oErr;\n\n // Read the balances and exchange rate from the vToken\n (oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vToken.getAccountSnapshot(account);\n require(oErr == 0, \"Snapshot Error\");\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n (, uint collateralFactorMantissa) = ComptrollerInterface(comptrollerAddress).markets(address(vToken));\n vars.collateralFactor = Exp({ mantissa: collateralFactorMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = ComptrollerInterface(comptrollerAddress).oracle().getUnderlyingPrice(vToken);\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> bnb (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n\n //Collateral = tokensToDenom * vTokenBalance\n vars.collateral = mul_ScalarTruncate(vars.tokensToDenom, vars.vTokenBalance);\n\n vars.balanceOfUnderlying = vToken.balanceOfUnderlying(account);\n vars.supplyInUsd = mul_ScalarTruncate(vars.oraclePrice, vars.balanceOfUnderlying);\n\n vars.borrowsInUsd = mul_ScalarTruncate(vars.oraclePrice, vars.borrowBalance);\n\n address underlyingAssetAddress;\n uint underlyingDecimals;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n underlyingAssetAddress = address(0);\n underlyingDecimals = 18;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n underlyingAssetAddress = vBep20.underlying();\n underlyingDecimals = EIP20Interface(vBep20.underlying()).decimals();\n }\n\n vars.isACollateral = isACollateral(account, address(vToken), comptrollerAddress);\n\n return\n AccountSnapshot({\n account: account,\n assetName: vToken.name(),\n vTokenAddress: address(vToken),\n underlyingAssetAddress: underlyingAssetAddress,\n supply: vars.balanceOfUnderlying,\n supplyInUsd: vars.supplyInUsd,\n collateral: vars.collateral,\n borrows: vars.borrowBalance,\n borrowsInUsd: vars.borrowsInUsd,\n assetPrice: vars.oraclePriceMantissa,\n accruedInterest: vToken.borrowIndex(),\n vTokenDecimals: vToken.decimals(),\n underlyingDecimals: underlyingDecimals,\n exchangeRate: vToken.exchangeRateCurrent(),\n isACollateral: vars.isACollateral\n });\n }\n\n // utilities\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/Lens/VenusLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VBep20.sol\";\nimport \"../Tokens/VTokens/VToken.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Tokens/XVS/XVS.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Utils/SafeMath.sol\";\nimport { ComptrollerTypes } from \"../Comptroller/ComptrollerStorage.sol\";\n\ncontract VenusLens is ExponentialNoError {\n using SafeMath for uint;\n\n /// @notice Blocks Per Day\n uint public constant BLOCKS_PER_DAY = 28800;\n\n /// @notice Total actions available on VToken\n uint public constant VTOKEN_ACTIONS = 8;\n\n struct VenusMarketState {\n uint224 index;\n uint32 block;\n }\n\n struct VTokenMetadata {\n address vToken;\n uint exchangeRateCurrent;\n uint supplyRatePerBlock;\n uint borrowRatePerBlock;\n uint reserveFactorMantissa;\n uint totalBorrows;\n uint totalReserves;\n uint totalSupply;\n uint totalCash;\n bool isListed;\n uint collateralFactorMantissa;\n address underlyingAssetAddress;\n uint vTokenDecimals;\n uint underlyingDecimals;\n uint venusSupplySpeed;\n uint venusBorrowSpeed;\n uint dailySupplyXvs;\n uint dailyBorrowXvs;\n uint pausedActions;\n }\n\n struct VTokenBalances {\n address vToken;\n uint balanceOf;\n uint borrowBalanceCurrent;\n uint balanceOfUnderlying;\n uint tokenBalance;\n uint tokenAllowance;\n }\n\n struct VTokenUnderlyingPrice {\n address vToken;\n uint underlyingPrice;\n }\n\n struct AccountLimits {\n VToken[] markets;\n uint liquidity;\n uint shortfall;\n }\n\n struct XVSBalanceMetadata {\n uint balance;\n uint votes;\n address delegate;\n }\n\n struct XVSBalanceMetadataExt {\n uint balance;\n uint votes;\n address delegate;\n uint allocated;\n }\n\n struct VenusVotes {\n uint blockNumber;\n uint votes;\n }\n\n struct ClaimVenusLocalVariables {\n uint totalRewards;\n uint224 borrowIndex;\n uint32 borrowBlock;\n uint224 supplyIndex;\n uint32 supplyBlock;\n }\n\n /**\n * @dev Struct for Pending Rewards for per market\n */\n struct PendingReward {\n address vTokenAddress;\n uint256 amount;\n }\n\n /**\n * @dev Struct for Reward of a single reward token.\n */\n struct RewardSummary {\n address distributorAddress;\n address rewardTokenAddress;\n uint256 totalRewards;\n PendingReward[] pendingRewards;\n }\n\n /**\n * @notice Query the metadata of a vToken by its address\n * @param vToken The address of the vToken to fetch VTokenMetadata\n * @return VTokenMetadata struct with vToken supply and borrow information.\n */\n function vTokenMetadata(VToken vToken) public returns (VTokenMetadata memory) {\n uint exchangeRateCurrent = vToken.exchangeRateCurrent();\n address comptrollerAddress = address(vToken.comptroller());\n ComptrollerInterface comptroller = ComptrollerInterface(comptrollerAddress);\n (bool isListed, uint collateralFactorMantissa) = comptroller.markets(address(vToken));\n address underlyingAssetAddress;\n uint underlyingDecimals;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n underlyingAssetAddress = address(0);\n underlyingDecimals = 18;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n underlyingAssetAddress = vBep20.underlying();\n underlyingDecimals = EIP20Interface(vBep20.underlying()).decimals();\n }\n\n uint venusSupplySpeedPerBlock = comptroller.venusSupplySpeeds(address(vToken));\n uint venusBorrowSpeedPerBlock = comptroller.venusBorrowSpeeds(address(vToken));\n\n uint256 pausedActions;\n\n for (uint8 i; i <= VTOKEN_ACTIONS; ++i) {\n uint256 paused = comptroller.actionPaused(address(vToken), ComptrollerTypes.Action(i)) ? 1 : 0;\n pausedActions |= paused << i;\n }\n\n return\n VTokenMetadata({\n vToken: address(vToken),\n exchangeRateCurrent: exchangeRateCurrent,\n supplyRatePerBlock: vToken.supplyRatePerBlock(),\n borrowRatePerBlock: vToken.borrowRatePerBlock(),\n reserveFactorMantissa: vToken.reserveFactorMantissa(),\n totalBorrows: vToken.totalBorrows(),\n totalReserves: vToken.totalReserves(),\n totalSupply: vToken.totalSupply(),\n totalCash: vToken.getCash(),\n isListed: isListed,\n collateralFactorMantissa: collateralFactorMantissa,\n underlyingAssetAddress: underlyingAssetAddress,\n vTokenDecimals: vToken.decimals(),\n underlyingDecimals: underlyingDecimals,\n venusSupplySpeed: venusSupplySpeedPerBlock,\n venusBorrowSpeed: venusBorrowSpeedPerBlock,\n dailySupplyXvs: venusSupplySpeedPerBlock.mul(BLOCKS_PER_DAY),\n dailyBorrowXvs: venusBorrowSpeedPerBlock.mul(BLOCKS_PER_DAY),\n pausedActions: pausedActions\n });\n }\n\n /**\n * @notice Get VTokenMetadata for an array of vToken addresses\n * @param vTokens Array of vToken addresses to fetch VTokenMetadata\n * @return Array of structs with vToken supply and borrow information.\n */\n function vTokenMetadataAll(VToken[] calldata vTokens) external returns (VTokenMetadata[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenMetadata[] memory res = new VTokenMetadata[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenMetadata(vTokens[i]);\n }\n return res;\n }\n\n /**\n * @notice Get amount of XVS distributed daily to an account\n * @param account Address of account to fetch the daily XVS distribution\n * @param comptrollerAddress Address of the comptroller proxy\n * @return Amount of XVS distributed daily to an account\n */\n function getDailyXVS(address payable account, address comptrollerAddress) external returns (uint) {\n ComptrollerInterface comptrollerInstance = ComptrollerInterface(comptrollerAddress);\n VToken[] memory vTokens = comptrollerInstance.getAllMarkets();\n uint dailyXvsPerAccount = 0;\n\n for (uint i = 0; i < vTokens.length; i++) {\n VToken vToken = vTokens[i];\n if (!compareStrings(vToken.symbol(), \"vUST\") && !compareStrings(vToken.symbol(), \"vLUNA\")) {\n VTokenMetadata memory metaDataItem = vTokenMetadata(vToken);\n\n //get balanceOfUnderlying and borrowBalanceCurrent from vTokenBalance\n VTokenBalances memory vTokenBalanceInfo = vTokenBalances(vToken, account);\n\n VTokenUnderlyingPrice memory underlyingPriceResponse = vTokenUnderlyingPrice(vToken);\n uint underlyingPrice = underlyingPriceResponse.underlyingPrice;\n Exp memory underlyingPriceMantissa = Exp({ mantissa: underlyingPrice });\n\n //get dailyXvsSupplyMarket\n uint dailyXvsSupplyMarket = 0;\n uint supplyInUsd = mul_ScalarTruncate(underlyingPriceMantissa, vTokenBalanceInfo.balanceOfUnderlying);\n uint marketTotalSupply = (metaDataItem.totalSupply.mul(metaDataItem.exchangeRateCurrent)).div(1e18);\n uint marketTotalSupplyInUsd = mul_ScalarTruncate(underlyingPriceMantissa, marketTotalSupply);\n\n if (marketTotalSupplyInUsd > 0) {\n dailyXvsSupplyMarket = (metaDataItem.dailySupplyXvs.mul(supplyInUsd)).div(marketTotalSupplyInUsd);\n }\n\n //get dailyXvsBorrowMarket\n uint dailyXvsBorrowMarket = 0;\n uint borrowsInUsd = mul_ScalarTruncate(underlyingPriceMantissa, vTokenBalanceInfo.borrowBalanceCurrent);\n uint marketTotalBorrowsInUsd = mul_ScalarTruncate(underlyingPriceMantissa, metaDataItem.totalBorrows);\n\n if (marketTotalBorrowsInUsd > 0) {\n dailyXvsBorrowMarket = (metaDataItem.dailyBorrowXvs.mul(borrowsInUsd)).div(marketTotalBorrowsInUsd);\n }\n\n dailyXvsPerAccount += dailyXvsSupplyMarket + dailyXvsBorrowMarket;\n }\n }\n\n return dailyXvsPerAccount;\n }\n\n /**\n * @notice Get the current vToken balance (outstanding borrows) for an account\n * @param vToken Address of the token to check the balance of\n * @param account Account address to fetch the balance of\n * @return VTokenBalances with token balance information\n */\n function vTokenBalances(VToken vToken, address payable account) public returns (VTokenBalances memory) {\n uint balanceOf = vToken.balanceOf(account);\n uint borrowBalanceCurrent = vToken.borrowBalanceCurrent(account);\n uint balanceOfUnderlying = vToken.balanceOfUnderlying(account);\n uint tokenBalance;\n uint tokenAllowance;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n tokenBalance = account.balance;\n tokenAllowance = account.balance;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n EIP20Interface underlying = EIP20Interface(vBep20.underlying());\n tokenBalance = underlying.balanceOf(account);\n tokenAllowance = underlying.allowance(account, address(vToken));\n }\n\n return\n VTokenBalances({\n vToken: address(vToken),\n balanceOf: balanceOf,\n borrowBalanceCurrent: borrowBalanceCurrent,\n balanceOfUnderlying: balanceOfUnderlying,\n tokenBalance: tokenBalance,\n tokenAllowance: tokenAllowance\n });\n }\n\n /**\n * @notice Get the current vToken balances (outstanding borrows) for all vTokens on an account\n * @param vTokens Addresses of the tokens to check the balance of\n * @param account Account address to fetch the balance of\n * @return VTokenBalances Array with token balance information\n */\n function vTokenBalancesAll(\n VToken[] calldata vTokens,\n address payable account\n ) external returns (VTokenBalances[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenBalances[] memory res = new VTokenBalances[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenBalances(vTokens[i], account);\n }\n return res;\n }\n\n /**\n * @notice Get the price for the underlying asset of a vToken\n * @param vToken address of the vToken\n * @return response struct with underlyingPrice info of vToken\n */\n function vTokenUnderlyingPrice(VToken vToken) public view returns (VTokenUnderlyingPrice memory) {\n ComptrollerInterface comptroller = ComptrollerInterface(address(vToken.comptroller()));\n PriceOracle priceOracle = comptroller.oracle();\n\n return\n VTokenUnderlyingPrice({ vToken: address(vToken), underlyingPrice: priceOracle.getUnderlyingPrice(vToken) });\n }\n\n /**\n * @notice Query the underlyingPrice of an array of vTokens\n * @param vTokens Array of vToken addresses\n * @return array of response structs with underlying price information of vTokens\n */\n function vTokenUnderlyingPriceAll(\n VToken[] calldata vTokens\n ) external view returns (VTokenUnderlyingPrice[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenUnderlyingPrice[] memory res = new VTokenUnderlyingPrice[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenUnderlyingPrice(vTokens[i]);\n }\n return res;\n }\n\n /**\n * @notice Query the account liquidity and shortfall of an account\n * @param comptroller Address of comptroller proxy\n * @param account Address of the account to query\n * @return Struct with markets user has entered, liquidity, and shortfall of the account\n */\n function getAccountLimits(\n ComptrollerInterface comptroller,\n address account\n ) public view returns (AccountLimits memory) {\n (uint errorCode, uint liquidity, uint shortfall) = comptroller.getAccountLiquidity(account);\n require(errorCode == 0, \"account liquidity error\");\n\n return AccountLimits({ markets: comptroller.getAssetsIn(account), liquidity: liquidity, shortfall: shortfall });\n }\n\n /**\n * @notice Query the XVSBalance info of an account\n * @param xvs XVS contract address\n * @param account Account address\n * @return Struct with XVS balance and voter details\n */\n function getXVSBalanceMetadata(XVS xvs, address account) external view returns (XVSBalanceMetadata memory) {\n return\n XVSBalanceMetadata({\n balance: xvs.balanceOf(account),\n votes: uint256(xvs.getCurrentVotes(account)),\n delegate: xvs.delegates(account)\n });\n }\n\n /**\n * @notice Query the XVSBalance extended info of an account\n * @param xvs XVS contract address\n * @param comptroller Comptroller proxy contract address\n * @param account Account address\n * @return Struct with XVS balance and voter details and XVS allocation\n */\n function getXVSBalanceMetadataExt(\n XVS xvs,\n ComptrollerInterface comptroller,\n address account\n ) external returns (XVSBalanceMetadataExt memory) {\n uint balance = xvs.balanceOf(account);\n comptroller.claimVenus(account);\n uint newBalance = xvs.balanceOf(account);\n uint accrued = comptroller.venusAccrued(account);\n uint total = add_(accrued, newBalance, \"sum xvs total\");\n uint allocated = sub_(total, balance, \"sub allocated\");\n\n return\n XVSBalanceMetadataExt({\n balance: balance,\n votes: uint256(xvs.getCurrentVotes(account)),\n delegate: xvs.delegates(account),\n allocated: allocated\n });\n }\n\n /**\n * @notice Query the voting power for an account at a specific list of block numbers\n * @param xvs XVS contract address\n * @param account Address of the account\n * @param blockNumbers Array of blocks to query\n * @return Array of VenusVotes structs with block number and vote count\n */\n function getVenusVotes(\n XVS xvs,\n address account,\n uint32[] calldata blockNumbers\n ) external view returns (VenusVotes[] memory) {\n VenusVotes[] memory res = new VenusVotes[](blockNumbers.length);\n for (uint i = 0; i < blockNumbers.length; i++) {\n res[i] = VenusVotes({\n blockNumber: uint256(blockNumbers[i]),\n votes: uint256(xvs.getPriorVotes(account, blockNumbers[i]))\n });\n }\n return res;\n }\n\n /**\n * @dev Queries the current supply to calculate rewards for an account\n * @param supplyState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param comptroller Address of the comptroller proxy\n */\n function updateVenusSupplyIndex(\n VenusMarketState memory supplyState,\n address vToken,\n ComptrollerInterface comptroller\n ) internal view {\n uint supplySpeed = comptroller.venusSupplySpeeds(vToken);\n uint blockNumber = block.number;\n uint deltaBlocks = sub_(blockNumber, uint(supplyState.block));\n if (deltaBlocks > 0 && supplySpeed > 0) {\n uint supplyTokens = VToken(vToken).totalSupply();\n uint venusAccrued = mul_(deltaBlocks, supplySpeed);\n Double memory ratio = supplyTokens > 0 ? fraction(venusAccrued, supplyTokens) : Double({ mantissa: 0 });\n Double memory index = add_(Double({ mantissa: supplyState.index }), ratio);\n supplyState.index = safe224(index.mantissa, \"new index overflows\");\n supplyState.block = safe32(blockNumber, \"block number overflows\");\n } else if (deltaBlocks > 0) {\n supplyState.block = safe32(blockNumber, \"block number overflows\");\n }\n }\n\n /**\n * @dev Queries the current borrow to calculate rewards for an account\n * @param borrowState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param comptroller Address of the comptroller proxy\n */\n function updateVenusBorrowIndex(\n VenusMarketState memory borrowState,\n address vToken,\n Exp memory marketBorrowIndex,\n ComptrollerInterface comptroller\n ) internal view {\n uint borrowSpeed = comptroller.venusBorrowSpeeds(vToken);\n uint blockNumber = block.number;\n uint deltaBlocks = sub_(blockNumber, uint(borrowState.block));\n if (deltaBlocks > 0 && borrowSpeed > 0) {\n uint borrowAmount = div_(VToken(vToken).totalBorrows(), marketBorrowIndex);\n uint venusAccrued = mul_(deltaBlocks, borrowSpeed);\n Double memory ratio = borrowAmount > 0 ? fraction(venusAccrued, borrowAmount) : Double({ mantissa: 0 });\n Double memory index = add_(Double({ mantissa: borrowState.index }), ratio);\n borrowState.index = safe224(index.mantissa, \"new index overflows\");\n borrowState.block = safe32(blockNumber, \"block number overflows\");\n } else if (deltaBlocks > 0) {\n borrowState.block = safe32(blockNumber, \"block number overflows\");\n }\n }\n\n /**\n * @dev Calculate available rewards for an account's supply\n * @param supplyState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param supplier Address of the account supplying\n * @param comptroller Address of the comptroller proxy\n * @return Undistributed earned XVS from supplies\n */\n function distributeSupplierVenus(\n VenusMarketState memory supplyState,\n address vToken,\n address supplier,\n ComptrollerInterface comptroller\n ) internal view returns (uint) {\n Double memory supplyIndex = Double({ mantissa: supplyState.index });\n Double memory supplierIndex = Double({ mantissa: comptroller.venusSupplierIndex(vToken, supplier) });\n if (supplierIndex.mantissa == 0 && supplyIndex.mantissa > 0) {\n supplierIndex.mantissa = comptroller.venusInitialIndex();\n }\n\n Double memory deltaIndex = sub_(supplyIndex, supplierIndex);\n uint supplierTokens = VToken(vToken).balanceOf(supplier);\n uint supplierDelta = mul_(supplierTokens, deltaIndex);\n return supplierDelta;\n }\n\n /**\n * @dev Calculate available rewards for an account's borrows\n * @param borrowState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param borrower Address of the account borrowing\n * @param marketBorrowIndex vToken Borrow index\n * @param comptroller Address of the comptroller proxy\n * @return Undistributed earned XVS from borrows\n */\n function distributeBorrowerVenus(\n VenusMarketState memory borrowState,\n address vToken,\n address borrower,\n Exp memory marketBorrowIndex,\n ComptrollerInterface comptroller\n ) internal view returns (uint) {\n Double memory borrowIndex = Double({ mantissa: borrowState.index });\n Double memory borrowerIndex = Double({ mantissa: comptroller.venusBorrowerIndex(vToken, borrower) });\n if (borrowerIndex.mantissa > 0) {\n Double memory deltaIndex = sub_(borrowIndex, borrowerIndex);\n uint borrowerAmount = div_(VToken(vToken).borrowBalanceStored(borrower), marketBorrowIndex);\n uint borrowerDelta = mul_(borrowerAmount, deltaIndex);\n return borrowerDelta;\n }\n return 0;\n }\n\n /**\n * @notice Calculate the total XVS tokens pending and accrued by a user account\n * @param holder Account to query pending XVS\n * @param comptroller Address of the comptroller\n * @return Reward object contraining the totalRewards and pending rewards for each market\n */\n function pendingRewards(\n address holder,\n ComptrollerInterface comptroller\n ) external view returns (RewardSummary memory) {\n VToken[] memory vTokens = comptroller.getAllMarkets();\n ClaimVenusLocalVariables memory vars;\n RewardSummary memory rewardSummary;\n rewardSummary.distributorAddress = address(comptroller);\n rewardSummary.rewardTokenAddress = comptroller.getXVSAddress();\n rewardSummary.totalRewards = comptroller.venusAccrued(holder);\n rewardSummary.pendingRewards = new PendingReward[](vTokens.length);\n for (uint i; i < vTokens.length; ++i) {\n (vars.borrowIndex, vars.borrowBlock) = comptroller.venusBorrowState(address(vTokens[i]));\n VenusMarketState memory borrowState = VenusMarketState({\n index: vars.borrowIndex,\n block: vars.borrowBlock\n });\n\n (vars.supplyIndex, vars.supplyBlock) = comptroller.venusSupplyState(address(vTokens[i]));\n VenusMarketState memory supplyState = VenusMarketState({\n index: vars.supplyIndex,\n block: vars.supplyBlock\n });\n\n Exp memory borrowIndex = Exp({ mantissa: vTokens[i].borrowIndex() });\n\n PendingReward memory marketReward;\n marketReward.vTokenAddress = address(vTokens[i]);\n\n updateVenusBorrowIndex(borrowState, address(vTokens[i]), borrowIndex, comptroller);\n uint256 borrowReward = distributeBorrowerVenus(\n borrowState,\n address(vTokens[i]),\n holder,\n borrowIndex,\n comptroller\n );\n\n updateVenusSupplyIndex(supplyState, address(vTokens[i]), comptroller);\n uint256 supplyReward = distributeSupplierVenus(supplyState, address(vTokens[i]), holder, comptroller);\n\n marketReward.amount = add_(borrowReward, supplyReward);\n rewardSummary.pendingRewards[i] = marketReward;\n }\n return rewardSummary;\n }\n\n // utilities\n /**\n * @notice Compares if two strings are equal\n * @param a First string to compare\n * @param b Second string to compare\n * @return Boolean depending on if the strings are equal\n */\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/Oracle/PriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\ncontract PriceOracle {\n /// @notice Indicator that this is a PriceOracle contract (for inspection)\n bool public constant isPriceOracle = true;\n\n /**\n * @notice Get the underlying price of a vToken asset\n * @param vToken The vToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(VToken vToken) external view returns (uint);\n}\n" + }, + "contracts/test/BEP20.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\n\n// Mock import\nimport { GovernorBravoDelegate } from \"@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol\";\n\ninterface BEP20Base {\n event Approval(address indexed owner, address indexed spender, uint256 value);\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function totalSupply() external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function balanceOf(address who) external view returns (uint256);\n}\n\ncontract BEP20 is BEP20Base {\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n\ncontract BEP20NS is BEP20Base {\n function transfer(address to, uint256 value) external;\n\n function transferFrom(address from, address to, uint256 value) external;\n}\n\n/**\n * @title Standard BEP20 token\n * @dev Implementation of the basic standard token.\n * See https://github.com/ethereum/EIPs/issues/20\n */\ncontract StandardToken is BEP20 {\n using SafeMath for uint256;\n\n string public name;\n string public symbol;\n uint8 public decimals;\n uint256 public totalSupply;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public balanceOf;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public {\n totalSupply = _initialAmount;\n balanceOf[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool) {\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n return true;\n }\n\n function approve(address _spender, uint256 amount) external returns (bool) {\n allowance[msg.sender][_spender] = amount;\n emit Approval(msg.sender, _spender, amount);\n return true;\n }\n}\n\n/**\n * @title Non-Standard BEP20 token\n * @dev Version of BEP20 with no return values for `transfer` and `transferFrom`\n * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\ncontract NonStandardToken is BEP20NS {\n using SafeMath for uint256;\n\n string public name;\n uint8 public decimals;\n string public symbol;\n uint256 public totalSupply;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public balanceOf;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public {\n totalSupply = _initialAmount;\n balanceOf[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n }\n\n function transfer(address dst, uint256 amount) external {\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n }\n\n function transferFrom(address src, address dst, uint256 amount) external {\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n }\n\n function approve(address _spender, uint256 amount) external returns (bool) {\n allowance[msg.sender][_spender] = amount;\n emit Approval(msg.sender, _spender, amount);\n return true;\n }\n}\n\ncontract BEP20Harness is StandardToken {\n // To support testing, we can specify addresses for which transferFrom should fail and return false\n mapping(address => bool) public failTransferFromAddresses;\n\n // To support testing, we allow the contract to always fail `transfer`.\n mapping(address => bool) public failTransferToAddresses;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public StandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function harnessSetFailTransferFromAddress(address src, bool _fail) public {\n failTransferFromAddresses[src] = _fail;\n }\n\n function harnessSetFailTransferToAddress(address dst, bool _fail) public {\n failTransferToAddresses[dst] = _fail;\n }\n\n function harnessSetBalance(address _account, uint _amount) public {\n balanceOf[_account] = _amount;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool success) {\n // Added for testing purposes\n if (failTransferToAddresses[dst]) {\n return false;\n }\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool success) {\n // Added for testing purposes\n if (failTransferFromAddresses[src]) {\n return false;\n }\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/ComptrollerHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerMock.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Comptroller/Unitroller.sol\";\n\ncontract ComptrollerHarness is ComptrollerMock {\n address internal xvsAddress;\n address internal vXVSAddress;\n uint public blockNumber;\n\n constructor() public ComptrollerMock() {}\n\n function setVenusSupplyState(address vToken, uint224 index, uint32 blockNumber_) public {\n venusSupplyState[vToken].index = index;\n venusSupplyState[vToken].block = blockNumber_;\n }\n\n function setVenusBorrowState(address vToken, uint224 index, uint32 blockNumber_) public {\n venusBorrowState[vToken].index = index;\n venusBorrowState[vToken].block = blockNumber_;\n }\n\n function setVenusAccrued(address user, uint userAccrued) public {\n venusAccrued[user] = userAccrued;\n }\n\n function setXVSAddress(address xvsAddress_) public {\n xvsAddress = xvsAddress_;\n }\n\n function setXVSVTokenAddress(address vXVSAddress_) public {\n vXVSAddress = vXVSAddress_;\n }\n\n /**\n * @notice Set the amount of XVS distributed per block\n * @param venusRate_ The amount of XVS wei per block to distribute\n */\n function harnessSetVenusRate(uint venusRate_) public {\n venusRate = venusRate_;\n }\n\n /**\n * @notice Recalculate and update XVS speeds for all XVS markets\n */\n function harnessRefreshVenusSpeeds() public {\n VToken[] memory allMarkets_ = allMarkets;\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusSupplyIndex(address(vToken));\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n }\n\n Exp memory totalUtility = Exp({ mantissa: 0 });\n Exp[] memory utilities = new Exp[](allMarkets_.length);\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n if (venusSpeeds[address(vToken)] > 0) {\n Exp memory assetPrice = Exp({ mantissa: oracle.getUnderlyingPrice(vToken) });\n Exp memory utility = mul_(assetPrice, vToken.totalBorrows());\n utilities[i] = utility;\n totalUtility = add_(totalUtility, utility);\n }\n }\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets[i];\n uint newSpeed = totalUtility.mantissa > 0 ? mul_(venusRate, div_(utilities[i], totalUtility)) : 0;\n setVenusSpeedInternal(vToken, newSpeed, newSpeed);\n }\n }\n\n function setVenusBorrowerIndex(address vToken, address borrower, uint index) public {\n venusBorrowerIndex[vToken][borrower] = index;\n }\n\n function setVenusSupplierIndex(address vToken, address supplier, uint index) public {\n venusSupplierIndex[vToken][supplier] = index;\n }\n\n function harnessDistributeAllBorrowerVenus(\n address vToken,\n address borrower,\n uint marketBorrowIndexMantissa\n ) public {\n distributeBorrowerVenus(vToken, borrower, Exp({ mantissa: marketBorrowIndexMantissa }));\n venusAccrued[borrower] = grantXVSInternal(borrower, venusAccrued[borrower], 0, false);\n }\n\n function harnessDistributeAllSupplierVenus(address vToken, address supplier) public {\n distributeSupplierVenus(vToken, supplier);\n venusAccrued[supplier] = grantXVSInternal(supplier, venusAccrued[supplier], 0, false);\n }\n\n function harnessUpdateVenusBorrowIndex(address vToken, uint marketBorrowIndexMantissa) public {\n updateVenusBorrowIndex(vToken, Exp({ mantissa: marketBorrowIndexMantissa }));\n }\n\n function harnessUpdateVenusSupplyIndex(address vToken) public {\n updateVenusSupplyIndex(vToken);\n }\n\n function harnessDistributeBorrowerVenus(address vToken, address borrower, uint marketBorrowIndexMantissa) public {\n distributeBorrowerVenus(vToken, borrower, Exp({ mantissa: marketBorrowIndexMantissa }));\n }\n\n function harnessDistributeSupplierVenus(address vToken, address supplier) public {\n distributeSupplierVenus(vToken, supplier);\n }\n\n function harnessTransferVenus(address user, uint userAccrued, uint threshold) public returns (uint) {\n if (userAccrued > 0 && userAccrued >= threshold) {\n return grantXVSInternal(user, userAccrued, 0, false);\n }\n return userAccrued;\n }\n\n function harnessAddVenusMarkets(address[] memory vTokens) public {\n for (uint i = 0; i < vTokens.length; i++) {\n // temporarily set venusSpeed to 1 (will be fixed by `harnessRefreshVenusSpeeds`)\n setVenusSpeedInternal(VToken(vTokens[i]), 1, 1);\n }\n }\n\n function harnessSetMintedVAIs(address user, uint amount) public {\n mintedVAIs[user] = amount;\n }\n\n function harnessFastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getVenusMarkets() public view returns (address[] memory) {\n uint m = allMarkets.length;\n uint n = 0;\n for (uint i = 0; i < m; i++) {\n if (venusSpeeds[address(allMarkets[i])] > 0) {\n n++;\n }\n }\n\n address[] memory venusMarkets = new address[](n);\n uint k = 0;\n for (uint i = 0; i < m; i++) {\n if (venusSpeeds[address(allMarkets[i])] > 0) {\n venusMarkets[k++] = address(allMarkets[i]);\n }\n }\n return venusMarkets;\n }\n\n function harnessSetReleaseStartBlock(uint startBlock) external {\n releaseStartBlock = startBlock;\n }\n\n function harnessAddVtoken(address vToken) external {\n markets[vToken] = Market({ isListed: true, isVenus: false, collateralFactorMantissa: 0 });\n }\n}\n\ncontract EchoTypesComptroller is UnitrollerAdminStorage {\n function stringy(string memory s) public pure returns (string memory) {\n return s;\n }\n\n function addresses(address a) public pure returns (address) {\n return a;\n }\n\n function booly(bool b) public pure returns (bool) {\n return b;\n }\n\n function listOInts(uint[] memory u) public pure returns (uint[] memory) {\n return u;\n }\n\n function reverty() public pure {\n require(false, \"gotcha sucka\");\n }\n\n function becomeBrains(address payable unitroller) public {\n Unitroller(unitroller)._acceptImplementation();\n }\n}\n" + }, + "contracts/test/ComptrollerMock.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Comptroller/Diamond/facets/MarketFacet.sol\";\nimport \"../Comptroller/Diamond/facets/PolicyFacet.sol\";\nimport \"../Comptroller/Diamond/facets/RewardFacet.sol\";\nimport \"../Comptroller/Diamond/facets/SetterFacet.sol\";\nimport \"../Comptroller/Unitroller.sol\";\n\n// This contract contains all methods of Comptroller implementation in different facets at one place for testing purpose\n// This contract does not have diamond functionality(i.e delegate call to facets methods)\ncontract ComptrollerMock is MarketFacet, PolicyFacet, RewardFacet, SetterFacet {\n constructor() public {\n admin = msg.sender;\n }\n\n function _become(Unitroller unitroller) public {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can\");\n require(unitroller._acceptImplementation() == 0, \"not authorized\");\n }\n\n function _setComptrollerLens(ComptrollerLensInterface comptrollerLens_) external returns (uint) {\n ensureAdmin();\n ensureNonzeroAddress(address(comptrollerLens_));\n address oldComptrollerLens = address(comptrollerLens);\n comptrollerLens = comptrollerLens_;\n emit NewComptrollerLens(oldComptrollerLens, address(comptrollerLens));\n\n return uint(Error.NO_ERROR);\n }\n}\n" + }, + "contracts/test/ComptrollerMockR1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Comptroller/Diamond/facets/MarketFacet.sol\";\nimport \"../Comptroller/Diamond/facets/PolicyFacet.sol\";\nimport \"../Comptroller/Diamond/facets/RewardFacet.sol\";\nimport \"../Comptroller/Diamond/facets/SetterFacet.sol\";\nimport \"../Comptroller/Unitroller.sol\";\n\n// This contract contains all methods of Comptroller implementation in different facets at one place for testing purpose\n// This contract does not have diamond functionality(i.e delegate call to facets methods)\ncontract ComptrollerMockR1 is MarketFacet, PolicyFacet, RewardFacet, SetterFacet {\n event MarketListed(address vToken);\n event NewCollateralFactor(address vToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\n event MarketEntered(address vToken, address account);\n event MarketExited(address vToken, address account);\n\n constructor() public {\n admin = msg.sender;\n }\n\n function _become(Unitroller unitroller) public {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can\");\n require(unitroller._acceptImplementation() == 0, \"not authorized\");\n }\n\n function _setComptrollerLens(ComptrollerLensInterface comptrollerLens_) external returns (uint) {\n ensureAdmin();\n ensureNonzeroAddress(address(comptrollerLens_));\n address oldComptrollerLens = address(comptrollerLens);\n comptrollerLens = comptrollerLens_;\n emit NewComptrollerLens(oldComptrollerLens, address(comptrollerLens));\n\n return uint(Error.NO_ERROR);\n }\n}\n" + }, + "contracts/test/ComptrollerScenario.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerMock.sol\";\n\ncontract ComptrollerScenario is ComptrollerMock {\n uint public blockNumber;\n address public xvsAddress;\n address public vaiAddress;\n\n constructor() public ComptrollerMock() {}\n\n function setXVSAddress(address xvsAddress_) public {\n xvsAddress = xvsAddress_;\n }\n\n // function getXVSAddress() public view returns (address) {\n // return xvsAddress;\n // }\n\n function setVAIAddress(address vaiAddress_) public {\n vaiAddress = vaiAddress_;\n }\n\n function getVAIAddress() public view returns (address) {\n return vaiAddress;\n }\n\n function membershipLength(VToken vToken) public view returns (uint) {\n return accountAssets[address(vToken)].length;\n }\n\n function fastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n\n return blockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getVenusMarkets() public view returns (address[] memory) {\n uint m = allMarkets.length;\n uint n = 0;\n for (uint i = 0; i < m; i++) {\n if (markets[address(allMarkets[i])].isVenus) {\n n++;\n }\n }\n\n address[] memory venusMarkets = new address[](n);\n uint k = 0;\n for (uint i = 0; i < m; i++) {\n if (markets[address(allMarkets[i])].isVenus) {\n venusMarkets[k++] = address(allMarkets[i]);\n }\n }\n return venusMarkets;\n }\n\n function unlist(VToken vToken) public {\n markets[address(vToken)].isListed = false;\n }\n\n /**\n * @notice Recalculate and update XVS speeds for all XVS markets\n */\n function refreshVenusSpeeds() public {\n VToken[] memory allMarkets_ = allMarkets;\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusSupplyIndex(address(vToken));\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n }\n\n Exp memory totalUtility = Exp({ mantissa: 0 });\n Exp[] memory utilities = new Exp[](allMarkets_.length);\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n if (venusSpeeds[address(vToken)] > 0) {\n Exp memory assetPrice = Exp({ mantissa: oracle.getUnderlyingPrice(vToken) });\n Exp memory utility = mul_(assetPrice, vToken.totalBorrows());\n utilities[i] = utility;\n totalUtility = add_(totalUtility, utility);\n }\n }\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets[i];\n uint newSpeed = totalUtility.mantissa > 0 ? mul_(venusRate, div_(utilities[i], totalUtility)) : 0;\n setVenusSpeedInternal(vToken, newSpeed, newSpeed);\n }\n }\n}\n" + }, + "contracts/test/DiamondHarness.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Comptroller/Diamond/Diamond.sol\";\n\ncontract DiamondHarness is Diamond {\n function getFacetAddress(bytes4 sig) public view returns (address) {\n address facet = _selectorToFacetAndPosition[sig].facetAddress;\n require(facet != address(0), \"Diamond: Function does not exist\");\n return facet;\n }\n}\n" + }, + "contracts/test/EvilToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./FaucetToken.sol\";\n\n/**\n * @title The Venus Evil Test Token\n * @author Venus\n * @notice A simple test token that fails certain operations\n */\ncontract EvilToken is FaucetToken {\n bool public fail;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public FaucetToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {\n fail = true;\n }\n\n function setFail(bool _fail) external {\n fail = _fail;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool) {\n if (fail) {\n return false;\n }\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(amount);\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n if (fail) {\n return false;\n }\n balanceOf[src] = balanceOf[src].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(amount);\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount);\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/EvilXDelegator.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegator Contract\n * @notice VTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Venus\n */\ncontract EvilXDelegator is VTokenInterface, VBep20Interface, VDelegatorInterface {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n * @param implementation_ The address of the implementation the contract delegates to\n * @param becomeImplementationData The encoded args for becomeImplementation\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint256 initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,address,uint256,string,string,uint8)\",\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n )\n );\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_, false, becomeImplementationData);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public {\n require(msg.sender == admin, \"VBep20Delegator::_setImplementation: Caller must be admin\");\n\n if (allowResign) {\n delegateToImplementation(abi.encodeWithSignature(\"_resignImplementation()\"));\n }\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n delegateToImplementation(abi.encodeWithSignature(\"_becomeImplementation(bytes)\", becomeImplementationData));\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint256 mintAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"mint(uint256)\", mintAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mintBehalf(address receiver, uint256 mintAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"mintBehalf(address,uint256)\", receiver, mintAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint256 redeemTokens) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"redeem(uint256)\", redeemTokens));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"redeemUnderlying(uint256)\", redeemAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint256 borrowAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrow(uint256)\", borrowAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint256 repayAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"repayBorrow(uint256)\", repayAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"repayBorrowBehalf(address,uint256)\", borrower, repayAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"liquidateBorrow(address,uint256,address)\", borrower, repayAmount, vTokenCollateral)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"transfer(address,uint256)\", dst, amount));\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", src, dst, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"approve(address,uint256)\", spender, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"allowance(address,address)\", owner, spender)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"balanceOf(address)\", owner));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"balanceOfUnderlying(address)\", owner));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint256, uint256, uint256, uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"getAccountSnapshot(address)\", account)\n );\n return abi.decode(data, (uint256, uint256, uint256, uint256));\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"borrowRatePerBlock()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"supplyRatePerBlock()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"totalBorrowsCurrent()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrowBalanceCurrent(address)\", account));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"borrowBalanceStored(address)\", account)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"exchangeRateCurrent()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"exchangeRateStored()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"getCash()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves.\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"accrueInterest()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seize(address liquidator, address borrower, uint256 seizeTokens) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"seize(address,address,uint256)\", liquidator, borrower, seizeTokens)\n );\n return abi.decode(data, (uint256));\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setPendingAdmin(address)\", newPendingAdmin)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setComptroller(address)\", newComptroller)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setReserveFactor(uint256)\", newReserveFactorMantissa)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_acceptAdmin()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from admin\n * @param addAmount Amount of reserves to add\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addReserves(uint256 addAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_addReserves(uint256)\", addAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _reduceReserves(uint256 reduceAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_reduceReserves(uint256)\", reduceAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setInterestRateModel(address)\", newInterestRateModel)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /**\n * @notice Delegates execution to the implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToImplementation(bytes memory data) public returns (bytes memory) {\n return delegateTo(implementation, data);\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {\n (bool success, bytes memory returnData) = address(this).staticcall(\n abi.encodeWithSignature(\"delegateToImplementation(bytes)\", data)\n );\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return abi.decode(returnData, (bytes));\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n */\n function() external payable {\n require(msg.value == 0, \"VBep20Delegator:fallback: cannot send value to fallback\");\n\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/test/EvilXToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VBep20Immutable.sol\";\nimport \"../Tokens/VTokens/VBep20Delegator.sol\";\nimport \"../Tokens/VTokens/VBep20Delegate.sol\";\nimport \"./ComptrollerScenario.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\n\ncontract VBep20Scenario is VBep20Immutable {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\n// doTransferOut method of this token supposed to be compromised and contians malicious code which\n// can be used by attacker to compromise the protocol working.\ncontract EvilXToken is VBep20Delegate {\n event Log(string x, address y);\n event Log(string x, uint y);\n event LogLiquidity(uint liquidity);\n\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n address public comptrollerAddress;\n\n mapping(address => bool) public failTransferToAddresses;\n\n function setComptrollerAddress(address _comptrollerAddress) external {\n comptrollerAddress = _comptrollerAddress;\n }\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n super.doTransferOut(to, amount);\n\n // Checking the Liquidity of the user after the tranfer.\n // solhint-disable-next-line no-unused-vars\n (uint errorCode, uint liquidity, uint shortfall) = ComptrollerInterface(comptrollerAddress).getAccountLiquidity(\n msg.sender\n );\n emit LogLiquidity(liquidity);\n return;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessIncrementTotalBorrows(uint addtlBorrow_) public {\n totalBorrows = totalBorrows + addtlBorrow_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n" + }, + "contracts/test/Fauceteer.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/EIP20NonStandardInterface.sol\";\n\n/**\n * @title Fauceteer\n * @author Venus\n * @notice First computer program to be part of The Giving Pledge\n */\ncontract Fauceteer {\n /**\n * @notice Drips some tokens to caller\n * @dev We send 0.01% of our tokens to the caller. Over time, the amount will tend toward and eventually reach zero.\n * @param token The token to drip. Note: if we have no balance in this token, function will revert.\n */\n function drip(EIP20NonStandardInterface token) public {\n uint tokenBalance = token.balanceOf(address(this));\n require(tokenBalance > 0, \"Fauceteer is empty\");\n token.transfer(msg.sender, tokenBalance / 10000); // 0.01%\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n\n require(success, \"Transfer returned false.\");\n }\n}\n" + }, + "contracts/test/FaucetToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./BEP20.sol\";\n\n/**\n * @title The Venus Faucet Test Token\n * @author Venus\n * @notice A simple test token that lets anyone get more of it.\n */\ncontract FaucetToken is StandardToken {\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public StandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n\n/**\n * @title The Venus Faucet Test Token (non-standard)\n * @author Venus\n * @notice A simple test token that lets anyone get more of it.\n */\ncontract FaucetNonStandardToken is NonStandardToken {\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public NonStandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n\n/**\n * @title The Venus Faucet Re-Entrant Test Token\n * @author Venus\n * @notice A test token that is malicious and tries to re-enter callers\n */\ncontract FaucetTokenReEntrantHarness {\n using SafeMath for uint256;\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n string public name;\n string public symbol;\n uint8 public decimals;\n uint256 internal totalSupply_;\n mapping(address => mapping(address => uint256)) internal allowance_;\n mapping(address => uint256) internal balanceOf_;\n\n bytes public reEntryCallData;\n string public reEntryFun;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol,\n bytes memory _reEntryCallData,\n string memory _reEntryFun\n ) public {\n totalSupply_ = _initialAmount;\n balanceOf_[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n reEntryCallData = _reEntryCallData;\n reEntryFun = _reEntryFun;\n }\n\n modifier reEnter(string memory funName) {\n string memory _reEntryFun = reEntryFun;\n if (compareStrings(_reEntryFun, funName)) {\n reEntryFun = \"\"; // Clear re-entry fun\n (bool success, bytes memory returndata) = msg.sender.call(reEntryCallData);\n assembly {\n if eq(success, 0) {\n revert(add(returndata, 0x20), returndatasize())\n }\n }\n }\n\n _;\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)));\n }\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf_[_owner] += value;\n totalSupply_ += value;\n emit Transfer(address(this), _owner, value);\n }\n\n function totalSupply() public reEnter(\"totalSupply\") returns (uint256) {\n return totalSupply_;\n }\n\n function allowance(address owner, address spender) public reEnter(\"allowance\") returns (uint256 remaining) {\n return allowance_[owner][spender];\n }\n\n function approve(address spender, uint256 amount) public reEnter(\"approve\") returns (bool success) {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n function balanceOf(address owner) public reEnter(\"balanceOf\") returns (uint256 balance) {\n return balanceOf_[owner];\n }\n\n function transfer(address dst, uint256 amount) public reEnter(\"transfer\") returns (bool success) {\n _transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) public reEnter(\"transferFrom\") returns (bool success) {\n _transfer(src, dst, amount);\n _approve(src, msg.sender, allowance_[src][msg.sender].sub(amount));\n return true;\n }\n\n function _approve(address owner, address spender, uint256 amount) internal {\n require(spender != address(0), \"sender should be valid address\");\n require(owner != address(0), \"owner should be valid address\");\n allowance_[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n function _transfer(address src, address dst, uint256 amount) internal {\n require(dst != address(0), \"dst should be valid address\");\n balanceOf_[src] = balanceOf_[src].sub(amount);\n balanceOf_[dst] = balanceOf_[dst].add(amount);\n emit Transfer(src, dst, amount);\n }\n}\n" + }, + "contracts/test/FeeToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./FaucetToken.sol\";\n\n/**\n * @title Fee Token\n * @author Venus\n * @notice A simple test token that charges fees on transfer. Used to mock USDT.\n */\ncontract FeeToken is FaucetToken {\n uint public basisPointFee;\n address public owner;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol,\n uint _basisPointFee,\n address _owner\n ) public FaucetToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {\n basisPointFee = _basisPointFee;\n owner = _owner;\n }\n\n function transfer(address dst, uint amount) public returns (bool) {\n uint fee = amount.mul(basisPointFee).div(10000);\n uint net = amount.sub(fee);\n balanceOf[owner] = balanceOf[owner].add(fee);\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(net);\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint amount) public returns (bool) {\n uint fee = amount.mul(basisPointFee).div(10000);\n uint net = amount.sub(fee);\n balanceOf[owner] = balanceOf[owner].add(fee);\n balanceOf[src] = balanceOf[src].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(net);\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount);\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/FixedPriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Oracle/PriceOracle.sol\";\n\ncontract FixedPriceOracle is PriceOracle {\n uint public price;\n\n constructor(uint _price) public {\n price = _price;\n }\n\n function getUnderlyingPrice(VToken vToken) public view returns (uint) {\n vToken;\n return price;\n }\n\n function assetPrices(address asset) public view returns (uint) {\n asset;\n return price;\n }\n}\n" + }, + "contracts/test/InterestRateModelHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../InterestRateModels/InterestRateModel.sol\";\n\n/**\n * @title An Interest Rate Model for tests that can be instructed to return a failure instead of doing a calculation\n * @author Venus\n */\ncontract InterestRateModelHarness is InterestRateModel {\n uint public constant opaqueBorrowFailureCode = 20;\n bool public failBorrowRate;\n uint public borrowRate;\n\n constructor(uint borrowRate_) public {\n borrowRate = borrowRate_;\n }\n\n function setFailBorrowRate(bool failBorrowRate_) public {\n failBorrowRate = failBorrowRate_;\n }\n\n function setBorrowRate(uint borrowRate_) public {\n borrowRate = borrowRate_;\n }\n\n function getBorrowRate(uint _cash, uint _borrows, uint _reserves) public view returns (uint) {\n _cash; // unused\n _borrows; // unused\n _reserves; // unused\n require(!failBorrowRate, \"INTEREST_RATE_MODEL_ERROR\");\n return borrowRate;\n }\n\n function getSupplyRate(\n uint _cash,\n uint _borrows,\n uint _reserves,\n uint _reserveFactor\n ) external view returns (uint) {\n _cash; // unused\n _borrows; // unused\n _reserves; // unused\n return borrowRate * (1 - _reserveFactor);\n }\n}\n" + }, + "contracts/test/MockDeflationaryToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\n\ncontract DeflatingERC20 {\n using SafeMath for uint;\n\n string public constant name = \"Deflating Test Token\";\n string public constant symbol = \"DTT\";\n uint8 public constant decimals = 18;\n uint public totalSupply;\n mapping(address => uint) public balanceOf;\n mapping(address => mapping(address => uint)) public allowance;\n\n bytes32 public DOMAIN_SEPARATOR;\n // keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;\n mapping(address => uint) public nonces;\n\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n constructor(uint _totalSupply) public {\n uint chainId;\n assembly {\n chainId := chainid()\n }\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n chainId,\n address(this)\n )\n );\n _mint(msg.sender, _totalSupply);\n }\n\n function _mint(address to, uint value) internal {\n totalSupply = totalSupply.add(value);\n balanceOf[to] = balanceOf[to].add(value);\n emit Transfer(address(0), to, value);\n }\n\n function _burn(address from, uint value) internal {\n balanceOf[from] = balanceOf[from].sub(value);\n totalSupply = totalSupply.sub(value);\n emit Transfer(from, address(0), value);\n }\n\n function _approve(address owner, address spender, uint value) private {\n allowance[owner][spender] = value;\n emit Approval(owner, spender, value);\n }\n\n function _transfer(address from, address to, uint value) private {\n uint burnAmount = value / 100;\n _burn(from, burnAmount);\n uint transferAmount = value.sub(burnAmount);\n balanceOf[from] = balanceOf[from].sub(transferAmount);\n balanceOf[to] = balanceOf[to].add(transferAmount);\n emit Transfer(from, to, transferAmount);\n }\n\n function approve(address spender, uint value) external returns (bool) {\n _approve(msg.sender, spender, value);\n return true;\n }\n\n function transfer(address to, uint value) external returns (bool) {\n _transfer(msg.sender, to, value);\n return true;\n }\n\n function transferFrom(address from, address to, uint value) external returns (bool) {\n if (allowance[from][msg.sender] != uint(-1)) {\n allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);\n }\n _transfer(from, to, value);\n return true;\n }\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {\n require(deadline >= block.timestamp, \"EXPIRED\");\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))\n )\n );\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNATURE\");\n _approve(owner, spender, value);\n }\n}\n" + }, + "contracts/test/MockVBNB.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title Venus's vBNB Contract\n * @notice vToken which wraps BNB\n * @author Venus\n */\ncontract MockVBNB is VToken {\n /**\n * @notice Construct a new vBNB money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Send BNB to VBNB to mint\n */\n function() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Reverts upon any failure\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @dev Reverts upon any failure\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow() external payable {\n (uint err, ) = repayBorrowInternal(msg.value);\n requireNoError(err, \"repayBorrow failed\");\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @dev Reverts upon any failure\n * @param borrower The account with the debt being payed off\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower) external payable {\n (uint err, ) = repayBorrowBehalfInternal(borrower, msg.value);\n requireNoError(err, \"repayBorrowBehalf failed\");\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @dev Reverts upon any failure\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(address borrower, VToken vTokenCollateral) external payable {\n (uint err, ) = liquidateBorrowInternal(borrower, msg.value, vTokenCollateral);\n requireNoError(err, \"liquidateBorrow failed\");\n }\n\n function setTotalReserves(uint totalReserves_) external payable {\n totalReserves = totalReserves_;\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Perform the actual transfer in, which is a no-op\n * @param from Address sending the BNB\n * @param amount Amount of BNB being sent\n * @return The actual amount of BNB transferred\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n // Sanity checks\n require(msg.sender == from, \"sender mismatch\");\n require(msg.value == amount, \"value mismatch\");\n return amount;\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n /* Send the BNB, with minimal gas and revert on failure */\n to.transfer(amount);\n }\n\n /**\n * @notice Gets balance of this contract in terms of BNB, before this message\n * @dev This excludes the value of the current message, if any\n * @return The quantity of BNB owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n (MathError err, uint startingBalance) = subUInt(address(this).balance, msg.value);\n require(err == MathError.NO_ERROR, \"cash prior math error\");\n return startingBalance;\n }\n\n function requireNoError(uint errCode, string memory message) internal pure {\n if (errCode == uint(Error.NO_ERROR)) {\n return;\n }\n\n bytes memory fullMessage = new bytes(bytes(message).length + 5);\n uint i;\n\n for (i = 0; i < bytes(message).length; i++) {\n fullMessage[i] = bytes(message)[i];\n }\n\n fullMessage[i + 0] = bytes1(uint8(32));\n fullMessage[i + 1] = bytes1(uint8(40));\n fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10)));\n fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10)));\n fullMessage[i + 4] = bytes1(uint8(41));\n\n require(errCode == uint(Error.NO_ERROR), string(fullMessage));\n }\n\n /**\n * @dev Function to simply retrieve block number\n * This exists mainly for inheriting test contracts to stub this result.\n */\n function getBlockNumber() internal view returns (uint) {\n return block.number;\n }\n\n /**\n * @notice Reduces reserves by transferring to admin\n * @dev Requires fresh interest accrual\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReservesFresh(uint reduceAmount) internal returns (uint) {\n // totalReserves - reduceAmount\n uint totalReservesNew;\n\n // Check caller is admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK);\n }\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != getBlockNumber()) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashPrior() < reduceAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);\n }\n\n // Check reduceAmount ≤ reserves[n] (totalReserves)\n if (reduceAmount > totalReserves) {\n return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n totalReservesNew = totalReserves - reduceAmount;\n\n // Store reserves[n+1] = reserves[n] - reduceAmount\n totalReserves = totalReservesNew;\n\n // // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(admin, reduceAmount);\n\n emit ReservesReduced(admin, reduceAmount, totalReservesNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesReduced event\n function _reduceReserves(uint reduceAmount) external nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.\n return _reduceReservesFresh(reduceAmount);\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n // @custom:event Emits AccrueInterest event\n function accrueInterest() public returns (uint) {\n /* Remember the initial block number */\n uint currentBlockNumber = getBlockNumber();\n uint accrualBlockNumberPrior = accrualBlockNumber;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumberPrior == currentBlockNumber) {\n return uint(Error.NO_ERROR);\n }\n\n /* Read the previous values out of storage */\n uint cashPrior = getCashPrior();\n uint borrowsPrior = totalBorrows;\n uint reservesPrior = totalReserves;\n uint borrowIndexPrior = borrowIndex;\n\n /* Calculate the current borrow interest rate */\n uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior);\n require(borrowRateMantissa <= borrowRateMaxMantissa, \"borrow rate is absurdly high\");\n\n /* Calculate the number of blocks elapsed since the last accrual */\n (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);\n require(mathErr == MathError.NO_ERROR, \"could not calculate block delta\");\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n Exp memory simpleInterestFactor;\n uint interestAccumulated;\n uint totalBorrowsNew;\n uint totalReservesNew;\n uint borrowIndexNew;\n\n (mathErr, simpleInterestFactor) = mulScalar(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n interestAccumulated,\n reservesPrior\n );\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = borrowIndexNew;\n totalBorrows = totalBorrowsNew;\n totalReserves = totalReservesNew;\n\n /* We emit an AccrueInterest event */\n emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);\n\n return uint(Error.NO_ERROR);\n }\n}\n" + }, + "contracts/test/SimplePriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/VTokens/VBep20.sol\";\n\ncontract SimplePriceOracle is PriceOracle {\n mapping(address => uint) internal prices;\n event PricePosted(address asset, uint previousPriceMantissa, uint requestedPriceMantissa, uint newPriceMantissa);\n\n function getUnderlyingPrice(VToken vToken) public view returns (uint) {\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n return 1e18;\n } else if (compareStrings(vToken.symbol(), \"VAI\")) {\n return prices[address(vToken)];\n } else {\n return prices[address(VBep20(address(vToken)).underlying())];\n }\n }\n\n function setUnderlyingPrice(VToken vToken, uint underlyingPriceMantissa) public {\n address asset = address(VBep20(address(vToken)).underlying());\n emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);\n prices[asset] = underlyingPriceMantissa;\n }\n\n function setDirectPrice(address asset, uint price) public {\n emit PricePosted(asset, prices[asset], price, price);\n prices[asset] = price;\n }\n\n // v1 price oracle interface for use as backing of proxy\n function assetPrices(address asset) external view returns (uint) {\n return prices[asset];\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/test/VAIControllerHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VAI/VAIController.sol\";\n\ncontract VAIControllerHarness is VAIController {\n uint public blockNumber;\n uint public blocksPerYear;\n\n constructor() public VAIController() {\n admin = msg.sender;\n }\n\n function setVenusVAIState(uint224 index, uint32 blockNumber_) public {\n venusVAIState.index = index;\n venusVAIState.block = blockNumber_;\n }\n\n function setVAIAddress(address vaiAddress_) public {\n vai = vaiAddress_;\n }\n\n function getVAIAddress() public view returns (address) {\n return vai;\n }\n\n function harnessRepayVAIFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayVAIFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateVAIFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateVAIFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessFastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function setBlocksPerYear(uint number) public {\n blocksPerYear = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBlocksPerYear() public view returns (uint) {\n return blocksPerYear;\n }\n}\n" + }, + "contracts/test/VAIHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VAI/VAI.sol\";\n\ncontract VAIScenario is VAI {\n uint internal blockNumber = 100000;\n\n constructor(uint chainId) public VAI(chainId) {}\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetTotalSupply(uint _totalSupply) public {\n totalSupply = _totalSupply;\n }\n\n function harnessIncrementTotalSupply(uint addtlSupply_) public {\n totalSupply = totalSupply + addtlSupply_;\n }\n\n function harnessSetBalanceOf(address account, uint _amount) public {\n balanceOf[account] = _amount;\n }\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n" + }, + "contracts/test/VBep20Harness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VBep20Immutable.sol\";\nimport \"../Tokens/VTokens/VBep20Delegator.sol\";\nimport \"../Tokens/VTokens/VBep20Delegate.sol\";\nimport \"./ComptrollerScenario.sol\";\n\ncontract VBep20Harness is VBep20Immutable {\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n mapping(address => bool) public failTransferToAddresses;\n\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n return super.doTransferOut(to, amount);\n }\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n\ncontract VBep20Scenario is VBep20Immutable {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\ncontract VEvil is VBep20Scenario {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Scenario(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function evilSeize(VToken treasure, address liquidator, address borrower, uint seizeTokens) public returns (uint) {\n return treasure.seize(liquidator, borrower, seizeTokens);\n }\n}\n\ncontract VBep20DelegatorScenario is VBep20Delegator {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n )\n public\n VBep20Delegator(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_,\n implementation_,\n becomeImplementationData\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n}\n\ncontract VBep20DelegateHarness is VBep20Delegate {\n event Log(string x, address y);\n event Log(string x, uint y);\n\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n mapping(address => bool) public failTransferToAddresses;\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n return super.doTransferOut(to, amount);\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessIncrementTotalBorrows(uint addtlBorrow_) public {\n totalBorrows = totalBorrows + addtlBorrow_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n\ncontract VBep20DelegateScenario is VBep20Delegate {\n constructor() public {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\ncontract VBep20DelegateScenarioExtra is VBep20DelegateScenario {\n function iHaveSpoken() public pure returns (string memory) {\n return \"i have spoken\";\n }\n\n function itIsTheWay() public {\n admin = address(1); // make a change to test effect\n }\n\n function babyYoda() public pure {\n revert(\"protect the baby\");\n }\n}\n" + }, + "contracts/test/VBep20MockDelegate.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title Venus's VBep20 Contract\n * @notice VTokens which wrap an EIP-20 underlying\n * @author Venus\n */\ncontract VBep20MockDelegate is VToken, VBep20Interface {\n address public implementation;\n uint internal blockNumber = 100000;\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n */\n function initialize(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n // VToken initialize does the bulk of the work\n super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public {\n // Shh -- currently unused\n data;\n\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _becomeImplementation\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public {\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _resignImplementation\");\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint mintAmount) external returns (uint) {\n (uint err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver the account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n (uint err, ) = mintBehalfInternal(receiver, mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n (uint err, ) = liquidateBorrowInternal(borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n /**\n * @notice The sender adds to reserves.\n * @param addAmount The amount fo underlying token to add as reserves\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addReserves(uint addAmount) external returns (uint) {\n return _addReservesInternal(addAmount);\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n EIP20Interface token = EIP20Interface(underlying);\n return token.balanceOf(address(this));\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);\n uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n token.transferFrom(from, address(this), amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_IN_FAILED\");\n\n // Calculate the amount that was *actually* transferred\n uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address payable to, uint amount) internal {\n EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);\n token.transfer(to, amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a complaint BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_OUT_FAILED\");\n }\n}\n" + }, + "contracts/test/VRTConverterHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/Tokens/VRT/VRTConverter.sol\";\n\ncontract VRTConverterHarness is VRTConverter {\n constructor() public VRTConverter() {\n admin = msg.sender;\n }\n\n function balanceOfUser() public view returns (uint256, address) {\n uint256 vrtBalanceOfUser = vrt.balanceOf(msg.sender);\n return (vrtBalanceOfUser, msg.sender);\n }\n\n function setConversionRatio(uint256 _conversionRatio) public onlyAdmin {\n conversionRatio = _conversionRatio;\n }\n\n function setConversionTimeline(uint256 _conversionStartTime, uint256 _conversionPeriod) public onlyAdmin {\n conversionStartTime = _conversionStartTime;\n conversionPeriod = _conversionPeriod;\n conversionEndTime = conversionStartTime.add(conversionPeriod);\n }\n\n function getXVSRedeemedAmount(uint256 vrtAmount) public view returns (uint256) {\n return vrtAmount.mul(conversionRatio).mul(xvsDecimalsMultiplier).div(1e18).div(vrtDecimalsMultiplier);\n }\n}\n" + }, + "contracts/test/VRTVaultHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/VRTVault/VRTVault.sol\";\n\ncontract VRTVaultHarness is VRTVault {\n uint public blockNumber;\n\n constructor() public VRTVault() {}\n\n function overrideInterestRatePerBlock(uint256 _interestRatePerBlock) public {\n interestRatePerBlock = _interestRatePerBlock;\n }\n\n function balanceOfUser() public view returns (uint256, address) {\n uint256 vrtBalanceOfUser = vrt.balanceOf(msg.sender);\n return (vrtBalanceOfUser, msg.sender);\n }\n\n function harnessFastForward(uint256 blocks) public returns (uint256) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function setBlockNumber(uint256 number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() public view returns (uint256) {\n return blockNumber;\n }\n}\n" + }, + "contracts/test/XVSHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/XVS/XVS.sol\";\n\ncontract XVSScenario is XVS {\n constructor(address account) public XVS(account) {}\n\n function transferScenario(address[] calldata destinations, uint256 amount) external returns (bool) {\n for (uint i = 0; i < destinations.length; i++) {\n address dst = destinations[i];\n _transferTokens(msg.sender, dst, uint96(amount));\n }\n return true;\n }\n\n function transferFromScenario(address[] calldata froms, uint256 amount) external returns (bool) {\n for (uint i = 0; i < froms.length; i++) {\n address from = froms[i];\n _transferTokens(from, msg.sender, uint96(amount));\n }\n return true;\n }\n\n function generateCheckpoints(uint count, uint offset) external {\n for (uint i = 1 + offset; i <= count + offset; i++) {\n checkpoints[msg.sender][numCheckpoints[msg.sender]++] = Checkpoint(uint32(i), uint96(i));\n }\n }\n}\n" + }, + "contracts/test/XVSVaultScenario.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../XVSVault/XVSVault.sol\";\n\ncontract XVSVaultScenario is XVSVault {\n using SafeMath for uint256;\n\n constructor() public {\n admin = msg.sender;\n }\n\n function pushOldWithdrawalRequest(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests,\n uint _amount,\n uint _lockedUntil\n ) internal {\n uint i = _requests.length;\n _requests.push(WithdrawalRequest(0, 0, 0));\n // Keep it sorted so that the first to get unlocked request is always at the end\n for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) {\n _requests[i] = _requests[i - 1];\n }\n _requests[i] = WithdrawalRequest(_amount, uint128(_lockedUntil), 0);\n _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount);\n }\n\n function requestOldWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant {\n _ensureValidPool(_rewardToken, _pid);\n require(_amount > 0, \"requested amount cannot be zero\");\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n require(user.amount >= user.pendingWithdrawals.add(_amount), \"requested amount is invalid\");\n\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n uint lockedUntil = pool.lockPeriod.add(block.timestamp);\n\n pushOldWithdrawalRequest(user, requests, _amount, lockedUntil);\n\n // Update Delegate Amount\n if (_rewardToken == address(xvsAddress)) {\n _moveDelegates(delegates[msg.sender], address(0), uint96(_amount));\n }\n\n emit RequestedWithdrawal(msg.sender, _rewardToken, _pid, _amount);\n }\n\n function transferReward(address rewardToken, address user, uint256 amount) external {\n _transferReward(rewardToken, user, amount);\n }\n}\n" + }, + "contracts/test/XVSVestingHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/Tokens/XVS/XVSVesting.sol\";\n\ncontract XVSVestingHarness is XVSVesting {\n address public constant ZERO_ADDRESS = 0x0000000000000000000000000000000000000000;\n\n constructor() public XVSVesting() {\n admin = msg.sender;\n }\n\n uint public blockNumber;\n\n function recoverXVS(address recoveryAddress) public payable {\n uint256 xvsBalance = xvs.balanceOf(address(this));\n xvs.safeTransferFrom(address(this), recoveryAddress, xvsBalance);\n }\n\n function overWriteVRTConversionAddress() public {\n vrtConversionAddress = ZERO_ADDRESS;\n }\n\n function computeWithdrawableAmount(\n uint256 amount,\n uint256 vestingStartTime,\n uint256 withdrawnAmount\n ) public view returns (uint256 vestedAmount, uint256 toWithdraw) {\n (vestedAmount, toWithdraw) = super.calculateWithdrawableAmount(amount, vestingStartTime, withdrawnAmount);\n return (vestedAmount, toWithdraw);\n }\n\n function computeVestedAmount(\n uint256 vestingAmount,\n uint256 vestingStartTime,\n uint256 currentTime\n ) public view returns (uint256) {\n return super.calculateVestedAmount(vestingAmount, vestingStartTime, currentTime);\n }\n\n function getVestingCount(address beneficiary) public view returns (uint256) {\n return vestings[beneficiary].length;\n }\n\n function getVestedAmount(address recipient) public view nonZeroAddress(recipient) returns (uint256) {\n VestingRecord[] memory vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n uint256 totalVestedAmount = 0;\n uint256 currentTime = getCurrentTime();\n\n for (uint i = 0; i < vestingCount; i++) {\n VestingRecord memory vesting = vestingsOfRecipient[i];\n uint256 vestedAmount = calculateVestedAmount(vesting.amount, vesting.startTime, currentTime);\n totalVestedAmount = totalVestedAmount.add(vestedAmount);\n }\n\n return totalVestedAmount;\n }\n}\n" + }, + "contracts/Tokens/EIP20Interface.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title BEP 20 Token Standard Interface\n * https://eips.ethereum.org/EIPS/eip-20\n */\ninterface EIP20Interface {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n /**\n * @notice Get the total number of tokens in circulation\n * @return The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return success whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining The number of tokens allowed to be spent\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/Tokens/EIP20NonStandardInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title EIP20NonStandardInterface\n * @dev Version of BEP20 with no return values for `transfer` and `transferFrom`\n * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\ninterface EIP20NonStandardInterface {\n /**\n * @notice Get the total number of tokens in circulation\n * @return The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance of the owner\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n ///\n /// !!!!!!!!!!!!!!\n /// !!! NOTICE !!! `transfer` does not return a value, in violation of the BEP-20 specification\n /// !!!!!!!!!!!!!!\n ///\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n */\n function transfer(address dst, uint256 amount) external;\n\n ///\n /// !!!!!!!!!!!!!!\n /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the BEP-20 specification\n /// !!!!!!!!!!!!!!\n ///\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n */\n function transferFrom(address src, address dst, uint256 amount) external;\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved\n * @return success Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining The number of tokens allowed to be spent\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/Tokens/Prime/IPrime.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\n/**\n * @title IPrime\n * @author Venus\n * @notice Interface for Prime Token\n */\ninterface IPrime {\n /**\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\n * @param user the account address whose balance was updated\n */\n function xvsUpdated(address user) external;\n\n /**\n * @notice accrues interest and updates score for an user for a specific market\n * @param user the account address for which to accrue interest and update score\n * @param market the market for which to accrue interest and update score\n */\n function accrueInterestAndUpdateScore(address user, address market) external;\n\n /**\n * @notice Distributes income from market since last distribution\n * @param vToken the market for which to distribute the income\n */\n function accrueInterest(address vToken) external;\n\n /**\n * @notice Returns if user is a prime holder\n * @param isPrimeHolder returns if the user is a prime holder\n */\n function isUserPrimeHolder(address user) external view returns (bool isPrimeHolder);\n}\n" + }, + "contracts/Tokens/VAI/lib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.5.16;\n\ncontract LibNote {\n event LogNote(\n bytes4 indexed sig,\n address indexed usr,\n bytes32 indexed arg1,\n bytes32 indexed arg2,\n bytes data\n ) anonymous;\n\n modifier note() {\n _;\n assembly {\n // log an 'anonymous' event with a constant 6 words of calldata\n // and four indexed topics: selector, caller, arg1 and arg2\n let mark := msize() // end of memory ensures zero\n mstore(0x40, add(mark, 288)) // update free memory pointer\n mstore(mark, 0x20) // bytes type data offset\n mstore(add(mark, 0x20), 224) // bytes size (padded)\n calldatacopy(add(mark, 0x40), 0, 224) // bytes payload\n log4(\n mark,\n 288, // calldata\n shl(224, shr(224, calldataload(0))), // msg.sig\n caller(), // msg.sender\n calldataload(4), // arg1\n calldataload(36) // arg2\n )\n }\n }\n}\n" + }, + "contracts/Tokens/VAI/VAI.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n// Copyright (C) 2017, 2018, 2019 dbrock, rain, mrchico\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.5.16;\n\nimport \"./lib.sol\";\n\ncontract VAI is LibNote {\n // --- Auth ---\n mapping(address => uint256) public wards;\n\n function rely(address guy) external note auth {\n wards[guy] = 1;\n }\n\n function deny(address guy) external note auth {\n wards[guy] = 0;\n }\n\n modifier auth() {\n require(wards[msg.sender] == 1, \"VAI/not-authorized\");\n _;\n }\n\n // --- BEP20 Data ---\n string public constant name = \"VAI Stablecoin\";\n string public constant symbol = \"VAI\";\n string public constant version = \"1\";\n uint8 public constant decimals = 18;\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public nonces;\n\n event Approval(address indexed src, address indexed guy, uint256 wad);\n event Transfer(address indexed src, address indexed dst, uint256 wad);\n\n // --- Math ---\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x + y) >= x, \"VAI math error\");\n }\n\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x - y) <= x, \"VAI math error\");\n }\n\n // --- EIP712 niceties ---\n bytes32 public DOMAIN_SEPARATOR;\n // bytes32 public constant PERMIT_TYPEHASH = keccak256(\"Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)\");\n bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;\n\n constructor(uint256 chainId_) public {\n wards[msg.sender] = 1;\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(version)),\n chainId_,\n address(this)\n )\n );\n }\n\n // --- Token ---\n function transfer(address dst, uint256 wad) external returns (bool) {\n return transferFrom(msg.sender, dst, wad);\n }\n\n function transferFrom(address src, address dst, uint256 wad) public returns (bool) {\n require(balanceOf[src] >= wad, \"VAI/insufficient-balance\");\n if (src != msg.sender && allowance[src][msg.sender] != uint256(-1)) {\n require(allowance[src][msg.sender] >= wad, \"VAI/insufficient-allowance\");\n allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);\n }\n balanceOf[src] = sub(balanceOf[src], wad);\n balanceOf[dst] = add(balanceOf[dst], wad);\n emit Transfer(src, dst, wad);\n return true;\n }\n\n function mint(address usr, uint256 wad) external auth {\n balanceOf[usr] = add(balanceOf[usr], wad);\n totalSupply = add(totalSupply, wad);\n emit Transfer(address(0), usr, wad);\n }\n\n function burn(address usr, uint256 wad) external {\n require(balanceOf[usr] >= wad, \"VAI/insufficient-balance\");\n if (usr != msg.sender && allowance[usr][msg.sender] != uint256(-1)) {\n require(allowance[usr][msg.sender] >= wad, \"VAI/insufficient-allowance\");\n allowance[usr][msg.sender] = sub(allowance[usr][msg.sender], wad);\n }\n balanceOf[usr] = sub(balanceOf[usr], wad);\n totalSupply = sub(totalSupply, wad);\n emit Transfer(usr, address(0), wad);\n }\n\n function approve(address usr, uint256 wad) external returns (bool) {\n allowance[msg.sender][usr] = wad;\n emit Approval(msg.sender, usr, wad);\n return true;\n }\n\n // --- Alias ---\n function push(address usr, uint256 wad) external {\n transferFrom(msg.sender, usr, wad);\n }\n\n function pull(address usr, uint256 wad) external {\n transferFrom(usr, msg.sender, wad);\n }\n\n function move(address src, address dst, uint256 wad) external {\n transferFrom(src, dst, wad);\n }\n\n // --- Approve by signature ---\n function permit(\n address holder,\n address spender,\n uint256 nonce,\n uint256 expiry,\n bool allowed,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(abi.encode(PERMIT_TYPEHASH, holder, spender, nonce, expiry, allowed))\n )\n );\n\n require(holder != address(0), \"VAI/invalid-address-0\");\n require(holder == ecrecover(digest, v, r, s), \"VAI/invalid-permit\");\n require(expiry == 0 || now <= expiry, \"VAI/permit-expired\");\n require(nonce == nonces[holder]++, \"VAI/invalid-nonce\");\n uint256 wad = allowed ? uint256(-1) : 0;\n allowance[holder][spender] = wad;\n emit Approval(holder, spender, wad);\n }\n}\n" + }, + "contracts/Tokens/VAI/VAIController.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.5.16;\n\nimport { PriceOracle } from \"../../Oracle/PriceOracle.sol\";\nimport { VAIControllerErrorReporter } from \"../../Utils/ErrorReporter.sol\";\nimport { Exponential } from \"../../Utils/Exponential.sol\";\nimport { ComptrollerInterface } from \"../../Comptroller/ComptrollerInterface.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\nimport { VToken, EIP20Interface } from \"../VTokens/VToken.sol\";\nimport { VAIUnitroller, VAIControllerStorageG4 } from \"./VAIUnitroller.sol\";\nimport { VAIControllerInterface } from \"./VAIControllerInterface.sol\";\nimport { VAI } from \"./VAI.sol\";\nimport { IPrime } from \"../Prime/IPrime.sol\";\nimport { VTokenInterface } from \"../VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title VAI Comptroller\n * @author Venus\n * @notice This is the implementation contract for the VAIUnitroller proxy\n */\ncontract VAIController is VAIControllerInterface, VAIControllerStorageG4, VAIControllerErrorReporter, Exponential {\n /// @notice Initial index used in interest computations\n uint256 public constant INITIAL_VAI_MINT_INDEX = 1e18;\n\n /// @notice Emitted when Comptroller is changed\n event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);\n\n /// @notice Emitted when mint for prime holder is changed\n event MintOnlyForPrimeHolder(bool previousMintEnabledOnlyForPrimeHolder, bool newMintEnabledOnlyForPrimeHolder);\n\n /// @notice Emitted when Prime is changed\n event NewPrime(address oldPrime, address newPrime);\n\n /// @notice Event emitted when VAI is minted\n event MintVAI(address minter, uint256 mintVAIAmount);\n\n /// @notice Event emitted when VAI is repaid\n event RepayVAI(address payer, address borrower, uint256 repayVAIAmount);\n\n /// @notice Event emitted when a borrow is liquidated\n event LiquidateVAI(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address vTokenCollateral,\n uint256 seizeTokens\n );\n\n /// @notice Emitted when treasury guardian is changed\n event NewTreasuryGuardian(address oldTreasuryGuardian, address newTreasuryGuardian);\n\n /// @notice Emitted when treasury address is changed\n event NewTreasuryAddress(address oldTreasuryAddress, address newTreasuryAddress);\n\n /// @notice Emitted when treasury percent is changed\n event NewTreasuryPercent(uint256 oldTreasuryPercent, uint256 newTreasuryPercent);\n\n /// @notice Event emitted when VAIs are minted and fee are transferred\n event MintFee(address minter, uint256 feeAmount);\n\n /// @notice Emiitted when VAI base rate is changed\n event NewVAIBaseRate(uint256 oldBaseRateMantissa, uint256 newBaseRateMantissa);\n\n /// @notice Emiitted when VAI float rate is changed\n event NewVAIFloatRate(uint256 oldFloatRateMantissa, uint256 newFlatRateMantissa);\n\n /// @notice Emiitted when VAI receiver address is changed\n event NewVAIReceiver(address oldReceiver, address newReceiver);\n\n /// @notice Emiitted when VAI mint cap is changed\n event NewVAIMintCap(uint256 oldMintCap, uint256 newMintCap);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControl(address oldAccessControlAddress, address newAccessControlAddress);\n\n /// @notice Emitted when VAI token address is changed by admin\n event NewVaiToken(address oldVaiToken, address newVaiToken);\n\n function initialize() external onlyAdmin {\n require(vaiMintIndex == 0, \"already initialized\");\n\n vaiMintIndex = INITIAL_VAI_MINT_INDEX;\n accrualBlockNumber = getBlockNumber();\n mintCap = uint256(-1);\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n function _become(VAIUnitroller unitroller) external {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can change brains\");\n require(unitroller._acceptImplementation() == 0, \"change not authorized\");\n }\n\n /**\n * @notice The mintVAI function mints and transfers VAI from the protocol to the user, and adds a borrow balance.\n * The amount minted must be less than the user's Account Liquidity and the mint vai limit.\n * @dev If the Comptroller address is not set, minting is a no-op and the function returns the success code.\n * @param mintVAIAmount The amount of the VAI to be minted.\n * @return 0 on success, otherwise an error code\n */\n // solhint-disable-next-line code-complexity\n function mintVAI(uint256 mintVAIAmount) external nonReentrant returns (uint256) {\n if (address(comptroller) == address(0)) {\n return uint256(Error.NO_ERROR);\n }\n\n _ensureNonzeroAmount(mintVAIAmount);\n _ensureNotPaused();\n accrueVAIInterest();\n\n uint256 err;\n address minter = msg.sender;\n address _vai = vai;\n uint256 vaiTotalSupply = EIP20Interface(_vai).totalSupply();\n\n uint256 vaiNewTotalSupply = add_(vaiTotalSupply, mintVAIAmount);\n require(vaiNewTotalSupply <= mintCap, \"mint cap reached\");\n\n uint256 accountMintableVAI;\n (err, accountMintableVAI) = getMintableVAI(minter);\n require(err == uint256(Error.NO_ERROR), \"could not compute mintable amount\");\n\n // check that user have sufficient mintableVAI balance\n require(mintVAIAmount <= accountMintableVAI, \"minting more than allowed\");\n\n // Calculate the minted balance based on interest index\n uint256 totalMintedVAI = comptroller.mintedVAIs(minter);\n\n if (totalMintedVAI > 0) {\n uint256 repayAmount = getVAIRepayAmount(minter);\n uint256 remainedAmount = sub_(repayAmount, totalMintedVAI);\n pastVAIInterest[minter] = add_(pastVAIInterest[minter], remainedAmount);\n totalMintedVAI = repayAmount;\n }\n\n uint256 accountMintVAINew = add_(totalMintedVAI, mintVAIAmount);\n err = comptroller.setMintedVAIOf(minter, accountMintVAINew);\n require(err == uint256(Error.NO_ERROR), \"comptroller rejection\");\n\n uint256 remainedAmount;\n if (treasuryPercent != 0) {\n uint256 feeAmount = div_(mul_(mintVAIAmount, treasuryPercent), 1e18);\n remainedAmount = sub_(mintVAIAmount, feeAmount);\n VAI(_vai).mint(treasuryAddress, feeAmount);\n\n emit MintFee(minter, feeAmount);\n } else {\n remainedAmount = mintVAIAmount;\n }\n\n VAI(_vai).mint(minter, remainedAmount);\n vaiMinterInterestIndex[minter] = vaiMintIndex;\n\n emit MintVAI(minter, remainedAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice The repay function transfers VAI interest into the protocol and burns the rest,\n * reducing the borrower's borrow balance. Before repaying VAI, users must first approve\n * VAIController to access their VAI balance.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAI(uint256 amount) external nonReentrant returns (uint256, uint256) {\n return _repayVAI(msg.sender, amount);\n }\n\n /**\n * @notice The repay on behalf function transfers VAI interest into the protocol and burns the rest,\n * reducing the borrower's borrow balance. Borrowed VAIs are repaid by another user (possibly the borrower).\n * Before repaying VAI, the payer must first approve VAIController to access their VAI balance.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param borrower The account to repay the debt for.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAIBehalf(address borrower, uint256 amount) external nonReentrant returns (uint256, uint256) {\n _ensureNonzeroAddress(borrower);\n return _repayVAI(borrower, amount);\n }\n\n /**\n * @dev Checks the parameters and the protocol state, accrues interest, and invokes repayVAIFresh.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param borrower The account to repay the debt for.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function _repayVAI(address borrower, uint256 amount) internal returns (uint256, uint256) {\n if (address(comptroller) == address(0)) {\n return (0, 0);\n }\n _ensureNonzeroAmount(amount);\n _ensureNotPaused();\n\n accrueVAIInterest();\n return repayVAIFresh(msg.sender, borrower, amount);\n }\n\n /**\n * @dev Repay VAI, expecting interest to be accrued\n * @dev Borrowed VAIs are repaid by another user (possibly the borrower).\n * @param payer the account paying off the VAI\n * @param borrower the account with the debt being payed off\n * @param repayAmount the amount of VAI being repaid\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAIFresh(address payer, address borrower, uint256 repayAmount) internal returns (uint256, uint256) {\n (uint256 burn, uint256 partOfCurrentInterest, uint256 partOfPastInterest) = getVAICalculateRepayAmount(\n borrower,\n repayAmount\n );\n\n VAI _vai = VAI(vai);\n _vai.burn(payer, burn);\n bool success = _vai.transferFrom(payer, receiver, partOfCurrentInterest);\n require(success == true, \"failed to transfer VAI fee\");\n\n uint256 vaiBalanceBorrower = comptroller.mintedVAIs(borrower);\n\n uint256 accountVAINew = sub_(sub_(vaiBalanceBorrower, burn), partOfPastInterest);\n pastVAIInterest[borrower] = sub_(pastVAIInterest[borrower], partOfPastInterest);\n\n uint256 error = comptroller.setMintedVAIOf(borrower, accountVAINew);\n // We have to revert upon error since side-effects already happened at this point\n require(error == uint256(Error.NO_ERROR), \"comptroller rejection\");\n\n uint256 repaidAmount = add_(burn, partOfCurrentInterest);\n emit RepayVAI(payer, borrower, repaidAmount);\n\n return (uint256(Error.NO_ERROR), repaidAmount);\n }\n\n /**\n * @notice The sender liquidates the vai minters collateral. The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of vai to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external nonReentrant returns (uint256, uint256) {\n _ensureNotPaused();\n\n uint256 error = vTokenCollateral.accrueInterest();\n if (error != uint256(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.VAI_LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0);\n }\n\n // liquidateVAIFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateVAIFresh(msg.sender, borrower, repayAmount, vTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral by repay borrowers VAI.\n * The collateral seized is transferred to the liquidator.\n * @dev If the Comptroller address is not set, liquidation is a no-op and the function returns the success code.\n * @param liquidator The address repaying the VAI and seizing collateral\n * @param borrower The borrower of this VAI to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the VAI to repay\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function liquidateVAIFresh(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) internal returns (uint256, uint256) {\n if (address(comptroller) != address(0)) {\n accrueVAIInterest();\n\n /* Fail if liquidate not allowed */\n uint256 allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify vTokenCollateral market's block number equals current block number */\n //if (vTokenCollateral.accrualBlockNumber() != accrualBlockNumber) {\n if (vTokenCollateral.accrualBlockNumber() != getBlockNumber()) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == uint256(-1)) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayVAI fails */\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayVAIFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.VAI_LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateVAICalculateSeizeTokens(\n address(vTokenCollateral),\n actualRepayAmount\n );\n require(\n amountSeizeError == uint256(Error.NO_ERROR),\n \"VAI_LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\"\n );\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(vTokenCollateral.balanceOf(borrower) >= seizeTokens, \"VAI_LIQUIDATE_SEIZE_TOO_MUCH\");\n\n uint256 seizeError;\n seizeError = vTokenCollateral.seize(liquidator, borrower, seizeTokens);\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint256(Error.NO_ERROR), \"token seizure failed\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateVAI(liquidator, borrower, actualRepayAmount, address(vTokenCollateral), seizeTokens);\n\n /* We call the defense hook */\n comptroller.liquidateBorrowVerify(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n actualRepayAmount,\n seizeTokens\n );\n\n return (uint256(Error.NO_ERROR), actualRepayAmount);\n }\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Sets a new comptroller\n * @dev Admin function to set a new comptroller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptroller(ComptrollerInterface comptroller_) external returns (uint256) {\n // Check caller is admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK);\n }\n\n ComptrollerInterface oldComptroller = comptroller;\n comptroller = comptroller_;\n emit NewComptroller(oldComptroller, comptroller_);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the prime token contract address\n * @param prime_ The new address of the prime token contract\n */\n function setPrimeToken(address prime_) external onlyAdmin {\n emit NewPrime(prime, prime_);\n prime = prime_;\n }\n\n /**\n * @notice Set the VAI token contract address\n * @param vai_ The new address of the VAI token contract\n */\n function setVAIToken(address vai_) external onlyAdmin {\n emit NewVaiToken(vai, vai_);\n vai = vai_;\n }\n\n /**\n * @notice Toggle mint only for prime holder\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function toggleOnlyPrimeHolderMint() external returns (uint256) {\n _ensureAllowed(\"toggleOnlyPrimeHolderMint()\");\n\n if (!mintEnabledOnlyForPrimeHolder && prime == address(0)) {\n return uint256(Error.REJECTION);\n }\n\n emit MintOnlyForPrimeHolder(mintEnabledOnlyForPrimeHolder, !mintEnabledOnlyForPrimeHolder);\n mintEnabledOnlyForPrimeHolder = !mintEnabledOnlyForPrimeHolder;\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account total supply balance.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountAmountLocalVars {\n uint256 oErr;\n MathError mErr;\n uint256 sumSupply;\n uint256 marketSupply;\n uint256 sumBorrowPlusEffects;\n uint256 vTokenBalance;\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n uint256 oraclePriceMantissa;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n }\n\n /**\n * @notice Function that returns the amount of VAI a user can mint based on their account liquidy and the VAI mint rate\n * If mintEnabledOnlyForPrimeHolder is true, only Prime holders are able to mint VAI\n * @param minter The account to check mintable VAI\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol for details)\n * @return Mintable amount (with 18 decimals)\n */\n // solhint-disable-next-line code-complexity\n function getMintableVAI(address minter) public view returns (uint256, uint256) {\n if (mintEnabledOnlyForPrimeHolder && !IPrime(prime).isUserPrimeHolder(minter)) {\n return (uint256(Error.REJECTION), 0);\n }\n\n PriceOracle oracle = comptroller.oracle();\n VToken[] memory enteredMarkets = comptroller.getAssetsIn(minter);\n\n AccountAmountLocalVars memory vars; // Holds all our calculation results\n\n uint256 accountMintableVAI;\n uint256 i;\n\n /**\n * We use this formula to calculate mintable VAI amount.\n * totalSupplyAmount * VAIMintRate - (totalBorrowAmount + mintedVAIOf)\n */\n uint256 marketsCount = enteredMarkets.length;\n for (i = 0; i < marketsCount; i++) {\n (vars.oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = enteredMarkets[i]\n .getAccountSnapshot(minter);\n if (vars.oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (uint256(Error.SNAPSHOT_ERROR), 0);\n }\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(enteredMarkets[i]);\n if (vars.oraclePriceMantissa == 0) {\n return (uint256(Error.PRICE_ERROR), 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n (vars.mErr, vars.tokensToDenom) = mulExp(vars.exchangeRate, vars.oraclePrice);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n // marketSupply = tokensToDenom * vTokenBalance\n (vars.mErr, vars.marketSupply) = mulScalarTruncate(vars.tokensToDenom, vars.vTokenBalance);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (, uint256 collateralFactorMantissa) = comptroller.markets(address(enteredMarkets[i]));\n (vars.mErr, vars.marketSupply) = mulUInt(vars.marketSupply, collateralFactorMantissa);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, vars.marketSupply) = divUInt(vars.marketSupply, 1e18);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, vars.sumSupply) = addUInt(vars.sumSupply, vars.marketSupply);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n (vars.mErr, vars.sumBorrowPlusEffects) = mulScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n }\n\n uint256 totalMintedVAI = comptroller.mintedVAIs(minter);\n uint256 repayAmount = 0;\n\n if (totalMintedVAI > 0) {\n repayAmount = getVAIRepayAmount(minter);\n }\n\n (vars.mErr, vars.sumBorrowPlusEffects) = addUInt(vars.sumBorrowPlusEffects, repayAmount);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, accountMintableVAI) = mulUInt(vars.sumSupply, comptroller.vaiMintRate());\n require(vars.mErr == MathError.NO_ERROR, \"VAI_MINT_AMOUNT_CALCULATION_FAILED\");\n\n (vars.mErr, accountMintableVAI) = divUInt(accountMintableVAI, 10000);\n require(vars.mErr == MathError.NO_ERROR, \"VAI_MINT_AMOUNT_CALCULATION_FAILED\");\n\n (vars.mErr, accountMintableVAI) = subUInt(accountMintableVAI, vars.sumBorrowPlusEffects);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.REJECTION), 0);\n }\n\n return (uint256(Error.NO_ERROR), accountMintableVAI);\n }\n\n /**\n * @notice Update treasury data\n * @param newTreasuryGuardian New Treasury Guardian address\n * @param newTreasuryAddress New Treasury Address\n * @param newTreasuryPercent New fee percentage for minting VAI that is sent to the treasury\n */\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256) {\n // Check caller is admin\n if (!(msg.sender == admin || msg.sender == treasuryGuardian)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_TREASURY_OWNER_CHECK);\n }\n\n require(newTreasuryPercent < 1e18, \"treasury percent cap overflow\");\n\n address oldTreasuryGuardian = treasuryGuardian;\n address oldTreasuryAddress = treasuryAddress;\n uint256 oldTreasuryPercent = treasuryPercent;\n\n treasuryGuardian = newTreasuryGuardian;\n treasuryAddress = newTreasuryAddress;\n treasuryPercent = newTreasuryPercent;\n\n emit NewTreasuryGuardian(oldTreasuryGuardian, newTreasuryGuardian);\n emit NewTreasuryAddress(oldTreasuryAddress, newTreasuryAddress);\n emit NewTreasuryPercent(oldTreasuryPercent, newTreasuryPercent);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Gets yearly VAI interest rate based on the VAI price\n * @return uint256 Yearly VAI interest rate\n */\n function getVAIRepayRate() public view returns (uint256) {\n PriceOracle oracle = comptroller.oracle();\n MathError mErr;\n\n if (baseRateMantissa > 0) {\n if (floatRateMantissa > 0) {\n uint256 oraclePrice = oracle.getUnderlyingPrice(VToken(getVAIAddress()));\n if (1e18 > oraclePrice) {\n uint256 delta;\n uint256 rate;\n\n (mErr, delta) = subUInt(1e18, oraclePrice);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, delta) = mulUInt(delta, floatRateMantissa);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, delta) = divUInt(delta, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, rate) = addUInt(delta, baseRateMantissa);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n return rate;\n } else {\n return baseRateMantissa;\n }\n } else {\n return baseRateMantissa;\n }\n } else {\n return 0;\n }\n }\n\n /**\n * @notice Get interest rate per block\n * @return uint256 Interest rate per bock\n */\n function getVAIRepayRatePerBlock() public view returns (uint256) {\n uint256 yearlyRate = getVAIRepayRate();\n\n MathError mErr;\n uint256 rate;\n\n (mErr, rate) = divUInt(yearlyRate, getBlocksPerYear());\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n return rate;\n }\n\n /**\n * @notice Get the last updated interest index for a VAI Minter\n * @param minter Address of VAI minter\n * @return uint256 Returns the interest rate index for a minter\n */\n function getVAIMinterInterestIndex(address minter) public view returns (uint256) {\n uint256 storedIndex = vaiMinterInterestIndex[minter];\n // If the user minted VAI before the stability fee was introduced, accrue\n // starting from stability fee launch\n if (storedIndex == 0) {\n return INITIAL_VAI_MINT_INDEX;\n }\n return storedIndex;\n }\n\n /**\n * @notice Get the current total VAI a user needs to repay\n * @param account The address of the VAI borrower\n * @return (uint256) The total amount of VAI the user needs to repay\n */\n function getVAIRepayAmount(address account) public view returns (uint256) {\n MathError mErr;\n uint256 delta;\n\n uint256 amount = comptroller.mintedVAIs(account);\n uint256 interest = pastVAIInterest[account];\n uint256 totalMintedVAI;\n uint256 newInterest;\n\n (mErr, totalMintedVAI) = subUInt(amount, interest);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, delta) = subUInt(vaiMintIndex, getVAIMinterInterestIndex(account));\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, newInterest) = mulUInt(delta, totalMintedVAI);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, newInterest) = divUInt(newInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, amount) = addUInt(amount, newInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n return amount;\n }\n\n /**\n * @notice Calculate how much VAI the user needs to repay\n * @param borrower The address of the VAI borrower\n * @param repayAmount The amount of VAI being returned\n * @return Amount of VAI to be burned\n * @return Amount of VAI the user needs to pay in current interest\n * @return Amount of VAI the user needs to pay in past interest\n */\n function getVAICalculateRepayAmount(\n address borrower,\n uint256 repayAmount\n ) public view returns (uint256, uint256, uint256) {\n MathError mErr;\n uint256 totalRepayAmount = getVAIRepayAmount(borrower);\n uint256 currentInterest;\n\n (mErr, currentInterest) = subUInt(totalRepayAmount, comptroller.mintedVAIs(borrower));\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, currentInterest) = addUInt(pastVAIInterest[borrower], currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n uint256 burn;\n uint256 partOfCurrentInterest = currentInterest;\n uint256 partOfPastInterest = pastVAIInterest[borrower];\n\n if (repayAmount >= totalRepayAmount) {\n (mErr, burn) = subUInt(totalRepayAmount, currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n } else {\n uint256 delta;\n\n (mErr, delta) = mulUInt(repayAmount, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_PART_CALCULATION_FAILED\");\n\n (mErr, delta) = divUInt(delta, totalRepayAmount);\n require(mErr == MathError.NO_ERROR, \"VAI_PART_CALCULATION_FAILED\");\n\n uint256 totalMintedAmount;\n (mErr, totalMintedAmount) = subUInt(totalRepayAmount, currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_MINTED_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, burn) = mulUInt(totalMintedAmount, delta);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, burn) = divUInt(burn, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfCurrentInterest) = mulUInt(currentInterest, delta);\n require(mErr == MathError.NO_ERROR, \"VAI_CURRENT_INTEREST_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfCurrentInterest) = divUInt(partOfCurrentInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_CURRENT_INTEREST_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfPastInterest) = mulUInt(pastVAIInterest[borrower], delta);\n require(mErr == MathError.NO_ERROR, \"VAI_PAST_INTEREST_CALCULATION_FAILED\");\n\n (mErr, partOfPastInterest) = divUInt(partOfPastInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_PAST_INTEREST_CALCULATION_FAILED\");\n }\n\n return (burn, partOfCurrentInterest, partOfPastInterest);\n }\n\n /**\n * @notice Accrue interest on outstanding minted VAI\n */\n function accrueVAIInterest() public {\n MathError mErr;\n uint256 delta;\n\n (mErr, delta) = mulUInt(getVAIRepayRatePerBlock(), getBlockNumber() - accrualBlockNumber);\n require(mErr == MathError.NO_ERROR, \"VAI_INTEREST_ACCRUE_FAILED\");\n\n (mErr, delta) = addUInt(delta, vaiMintIndex);\n require(mErr == MathError.NO_ERROR, \"VAI_INTEREST_ACCRUE_FAILED\");\n\n vaiMintIndex = delta;\n accrualBlockNumber = getBlockNumber();\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _ensureNonzeroAddress(newAccessControlAddress);\n\n address oldAccessControlAddress = accessControl;\n accessControl = newAccessControlAddress;\n emit NewAccessControl(oldAccessControlAddress, accessControl);\n }\n\n /**\n * @notice Set VAI borrow base rate\n * @param newBaseRateMantissa the base rate multiplied by 10**18\n */\n function setBaseRate(uint256 newBaseRateMantissa) external {\n _ensureAllowed(\"setBaseRate(uint256)\");\n\n uint256 old = baseRateMantissa;\n baseRateMantissa = newBaseRateMantissa;\n emit NewVAIBaseRate(old, baseRateMantissa);\n }\n\n /**\n * @notice Set VAI borrow float rate\n * @param newFloatRateMantissa the VAI float rate multiplied by 10**18\n */\n function setFloatRate(uint256 newFloatRateMantissa) external {\n _ensureAllowed(\"setFloatRate(uint256)\");\n\n uint256 old = floatRateMantissa;\n floatRateMantissa = newFloatRateMantissa;\n emit NewVAIFloatRate(old, floatRateMantissa);\n }\n\n /**\n * @notice Set VAI stability fee receiver address\n * @param newReceiver the address of the VAI fee receiver\n */\n function setReceiver(address newReceiver) external onlyAdmin {\n _ensureNonzeroAddress(newReceiver);\n\n address old = receiver;\n receiver = newReceiver;\n emit NewVAIReceiver(old, newReceiver);\n }\n\n /**\n * @notice Set VAI mint cap\n * @param _mintCap the amount of VAI that can be minted\n */\n function setMintCap(uint256 _mintCap) external {\n _ensureAllowed(\"setMintCap(uint256)\");\n\n uint256 old = mintCap;\n mintCap = _mintCap;\n emit NewVAIMintCap(old, _mintCap);\n }\n\n function getBlockNumber() internal view returns (uint256) {\n return block.number;\n }\n\n function getBlocksPerYear() public view returns (uint256) {\n return 10512000; //(24 * 60 * 60 * 365) / 3;\n }\n\n /**\n * @notice Return the address of the VAI token\n * @return The address of VAI\n */\n function getVAIAddress() public view returns (address) {\n return vai;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n function _ensureAllowed(string memory functionSig) private view {\n require(IAccessControlManagerV5(accessControl).isAllowedToCall(msg.sender, functionSig), \"access denied\");\n }\n\n /// @dev Reverts if the protocol is paused\n function _ensureNotPaused() private view {\n require(!comptroller.protocolPaused(), \"protocol is paused\");\n }\n\n /// @dev Reverts if the passed address is zero\n function _ensureNonzeroAddress(address someone) private pure {\n require(someone != address(0), \"can't be zero address\");\n }\n\n /// @dev Reverts if the passed amount is zero\n function _ensureNonzeroAmount(uint256 amount) private pure {\n require(amount > 0, \"amount can't be zero\");\n }\n}\n" + }, + "contracts/Tokens/VAI/VAIControllerInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VTokenInterface } from \"../VTokens/VTokenInterfaces.sol\";\n\ncontract VAIControllerInterface {\n function mintVAI(uint256 mintVAIAmount) external returns (uint256);\n\n function repayVAI(uint256 amount) external returns (uint256, uint256);\n\n function repayVAIBehalf(address borrower, uint256 amount) external returns (uint256, uint256);\n\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint256, uint256);\n\n function getMintableVAI(address minter) external view returns (uint256, uint256);\n\n function getVAIAddress() external view returns (address);\n\n function getVAIRepayAmount(address account) external view returns (uint256);\n}\n" + }, + "contracts/Tokens/VAI/VAIControllerStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { ComptrollerInterface } from \"../../Comptroller/ComptrollerInterface.sol\";\n\ncontract VAIUnitrollerAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of Unitroller\n */\n address public vaiControllerImplementation;\n\n /**\n * @notice Pending brains of Unitroller\n */\n address public pendingVAIControllerImplementation;\n}\n\ncontract VAIControllerStorageG1 is VAIUnitrollerAdminStorage {\n ComptrollerInterface public comptroller;\n\n struct VenusVAIState {\n /// @notice The last updated venusVAIMintIndex\n uint224 index;\n /// @notice The block number the index was last updated at\n uint32 block;\n }\n\n /// @notice The Venus VAI state\n VenusVAIState public venusVAIState;\n\n /// @notice The Venus VAI state initialized\n bool public isVenusVAIInitialized;\n\n /// @notice The Venus VAI minter index as of the last time they accrued XVS\n mapping(address => uint256) public venusVAIMinterIndex;\n}\n\ncontract VAIControllerStorageG2 is VAIControllerStorageG1 {\n /// @notice Treasury Guardian address\n address public treasuryGuardian;\n\n /// @notice Treasury address\n address public treasuryAddress;\n\n /// @notice Fee percent of accrued interest with decimal 18\n uint256 public treasuryPercent;\n\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice The base rate for stability fee\n uint256 public baseRateMantissa;\n\n /// @notice The float rate for stability fee\n uint256 public floatRateMantissa;\n\n /// @notice The address for VAI interest receiver\n address public receiver;\n\n /// @notice Accumulator of the total earned interest rate since the opening of the market. For example: 0.6 (60%)\n uint256 public vaiMintIndex;\n\n /// @notice Block number that interest was last accrued at\n uint256 internal accrualBlockNumber;\n\n /// @notice Global vaiMintIndex as of the most recent balance-changing action for user\n mapping(address => uint256) internal vaiMinterInterestIndex;\n\n /// @notice Tracks the amount of mintedVAI of a user that represents the accrued interest\n mapping(address => uint256) public pastVAIInterest;\n\n /// @notice VAI mint cap\n uint256 public mintCap;\n\n /// @notice Access control manager address\n address public accessControl;\n}\n\ncontract VAIControllerStorageG3 is VAIControllerStorageG2 {\n /// @notice The address of the prime contract. It can be a ZERO address\n address public prime;\n\n /// @notice Tracks if minting is enabled only for prime token holders. Only used if prime is set\n bool public mintEnabledOnlyForPrimeHolder;\n}\n\ncontract VAIControllerStorageG4 is VAIControllerStorageG3 {\n /// @notice The address of the VAI token\n address internal vai;\n}\n" + }, + "contracts/Tokens/VAI/VAIUnitroller.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/ErrorReporter.sol\";\nimport \"./VAIControllerStorage.sol\";\n\n/**\n * @title VAI Unitroller\n * @author Venus\n * @notice This is the proxy contract for the VAIComptroller\n */\ncontract VAIUnitroller is VAIUnitrollerAdminStorage, VAIControllerErrorReporter {\n /**\n * @notice Emitted when pendingVAIControllerImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingVAIControllerImplementation is accepted, which means comptroller implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint256) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingVAIControllerImplementation;\n\n pendingVAIControllerImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIControllerImplementation);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint256) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingVAIControllerImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = vaiControllerImplementation;\n address oldPendingImplementation = pendingVAIControllerImplementation;\n\n vaiControllerImplementation = pendingVAIControllerImplementation;\n\n pendingVAIControllerImplementation = address(0);\n\n emit NewImplementation(oldImplementation, vaiControllerImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIControllerImplementation);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint256) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = vaiControllerImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/VRT/VRT.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/Tokenlock.sol\";\n\ncontract VRT is Tokenlock {\n /// @notice BEP-20 token name for this token\n string public constant name = \"Venus Reward Token\";\n\n /// @notice BEP-20 token symbol for this token\n string public constant symbol = \"VRT\";\n\n /// @notice BEP-20 token decimals for this token\n uint8 public constant decimals = 18;\n\n /// @notice Total number of tokens in circulation\n uint public constant totalSupply = 30000000000e18; // 30 billion VRT\n\n /// @notice Allowance amounts on behalf of others\n mapping(address => mapping(address => uint96)) internal allowances;\n\n /// @notice Official record of token balances for each account\n mapping(address => uint96) internal balances;\n\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A checkpoint for marking number of votes from a given block\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice The standard BEP-20 transfer event\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /// @notice The standard BEP-20 approval event\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Construct a new VRT token\n * @param account The initial account to grant all the tokens\n */\n constructor(address account) public {\n balances[account] = uint96(totalSupply);\n emit Transfer(address(0), account, totalSupply);\n }\n\n /**\n * @notice Get the number of tokens `spender` is approved to spend on behalf of `account`\n * @param account The address of the account holding the funds\n * @param spender The address of the account spending the funds\n * @return The number of tokens approved\n */\n function allowance(address account, address spender) external view returns (uint) {\n return allowances[account][spender];\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param rawAmount The number of tokens that are approved (2^256-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint rawAmount) external validLock returns (bool) {\n uint96 amount;\n if (rawAmount == uint(-1)) {\n amount = uint96(-1);\n } else {\n amount = safe96(rawAmount, \"VRT::approve: amount exceeds 96 bits\");\n }\n\n allowances[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the number of tokens held by the `account`\n * @param account The address of the account to get the balance of\n * @return The number of tokens held\n */\n function balanceOf(address account) external view returns (uint) {\n return balances[account];\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint rawAmount) external validLock returns (bool) {\n uint96 amount = safe96(rawAmount, \"VRT::transfer: amount exceeds 96 bits\");\n _transferTokens(msg.sender, dst, amount);\n return true;\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint rawAmount) external validLock returns (bool) {\n address spender = msg.sender;\n uint96 spenderAllowance = allowances[src][spender];\n uint96 amount = safe96(rawAmount, \"VRT::approve: amount exceeds 96 bits\");\n\n if (spender != src && spenderAllowance != uint96(-1)) {\n uint96 newAllowance = sub96(\n spenderAllowance,\n amount,\n \"VRT::transferFrom: transfer amount exceeds spender allowance\"\n );\n allowances[src][spender] = newAllowance;\n\n emit Approval(src, spender, newAllowance);\n }\n\n _transferTokens(src, dst, amount);\n return true;\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) public validLock {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public validLock {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"VRT::delegateBySig: invalid signature\");\n require(nonce == nonces[signatory]++, \"VRT::delegateBySig: invalid nonce\");\n require(now <= expiry, \"VRT::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n /**\n * @notice Determine the prior number of votes for an account as of a block number\n * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n * @param account The address of the account to check\n * @param blockNumber The block number to get the vote balance at\n * @return The number of votes the account had as of the given block\n */\n function getPriorVotes(address account, uint blockNumber) public view returns (uint96) {\n require(blockNumber < block.number, \"VRT::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlock > blockNumber) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlock == blockNumber) {\n return cp.votes;\n } else if (cp.fromBlock < blockNumber) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = balances[delegator];\n delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _transferTokens(address src, address dst, uint96 amount) internal {\n require(src != address(0), \"VRT::_transferTokens: cannot transfer from the zero address\");\n require(dst != address(0), \"VRT::_transferTokens: cannot transfer to the zero address\");\n\n balances[src] = sub96(balances[src], amount, \"VRT::_transferTokens: transfer amount exceeds balance\");\n balances[dst] = add96(balances[dst], amount, \"VRT::_transferTokens: transfer amount overflows\");\n emit Transfer(src, dst, amount);\n\n _moveDelegates(delegates[src], delegates[dst], amount);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"VRT::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"VRT::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumber = safe32(block.number, \"VRT::_writeCheckpoint: block number exceeds 32 bits\");\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChanged(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverter.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/IBEP20.sol\";\nimport \"../../Utils/SafeBEP20.sol\";\nimport \"../XVS/IXVSVesting.sol\";\nimport \"./VRTConverterStorage.sol\";\nimport \"./VRTConverterProxy.sol\";\n\n/**\n * @title Venus's VRTConversion Contract\n * @author Venus\n */\ncontract VRTConverter is VRTConverterStorage {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n address public constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;\n\n /// @notice decimal precision for VRT\n uint256 public constant vrtDecimalsMultiplier = 1e18;\n\n /// @notice decimal precision for XVS\n uint256 public constant xvsDecimalsMultiplier = 1e18;\n\n /// @notice Emitted when an admin set conversion info\n event ConversionInfoSet(\n uint256 conversionRatio,\n uint256 conversionStartTime,\n uint256 conversionPeriod,\n uint256 conversionEndTime\n );\n\n /// @notice Emitted when token conversion is done\n event TokenConverted(\n address reedeemer,\n address vrtAddress,\n uint256 vrtAmount,\n address xvsAddress,\n uint256 xvsAmount\n );\n\n /// @notice Emitted when an admin withdraw converted token\n event TokenWithdraw(address token, address to, uint256 amount);\n\n /// @notice Emitted when XVSVestingAddress is set\n event XVSVestingSet(address xvsVestingAddress);\n\n constructor() public {}\n\n function initialize(\n address _vrtAddress,\n address _xvsAddress,\n uint256 _conversionRatio,\n uint256 _conversionStartTime,\n uint256 _conversionPeriod\n ) public {\n require(msg.sender == admin, \"only admin may initialize the VRTConverter\");\n require(initialized == false, \"VRTConverter is already initialized\");\n\n require(_vrtAddress != address(0), \"vrtAddress cannot be Zero\");\n vrt = IBEP20(_vrtAddress);\n\n require(_xvsAddress != address(0), \"xvsAddress cannot be Zero\");\n xvs = IBEP20(_xvsAddress);\n\n require(_conversionRatio > 0, \"conversionRatio cannot be Zero\");\n conversionRatio = _conversionRatio;\n\n require(_conversionStartTime >= block.timestamp, \"conversionStartTime must be time in the future\");\n require(_conversionPeriod > 0, \"_conversionPeriod is invalid\");\n\n conversionStartTime = _conversionStartTime;\n conversionPeriod = _conversionPeriod;\n conversionEndTime = conversionStartTime.add(conversionPeriod);\n emit ConversionInfoSet(conversionRatio, conversionStartTime, conversionPeriod, conversionEndTime);\n\n totalVrtConverted = 0;\n _notEntered = true;\n initialized = true;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @notice sets XVSVestingProxy Address\n * @dev Note: If XVSVestingProxy is not set, then Conversion is not allowed\n * @param _xvsVestingAddress The XVSVestingProxy Address\n */\n function setXVSVesting(address _xvsVestingAddress) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_xvsVestingAddress != address(0), \"xvsVestingAddress cannot be Zero\");\n xvsVesting = IXVSVesting(_xvsVestingAddress);\n emit XVSVestingSet(_xvsVestingAddress);\n }\n\n modifier isInitialized() {\n require(initialized == true, \"VRTConverter is not initialized\");\n _;\n }\n\n function isConversionActive() public view returns (bool) {\n uint256 currentTime = block.timestamp;\n if (currentTime >= conversionStartTime && currentTime <= conversionEndTime) {\n return true;\n }\n return false;\n }\n\n modifier checkForActiveConversionPeriod() {\n uint256 currentTime = block.timestamp;\n require(currentTime >= conversionStartTime, \"Conversion did not start yet\");\n require(currentTime <= conversionEndTime, \"Conversion Period Ended\");\n _;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Transfer VRT and redeem XVS\n * @dev Note: If there is not enough XVS, we do not perform the conversion.\n * @param vrtAmount The amount of VRT\n */\n function convert(uint256 vrtAmount) external isInitialized checkForActiveConversionPeriod nonReentrant {\n require(\n address(xvsVesting) != address(0) && address(xvsVesting) != DEAD_ADDRESS,\n \"XVS-Vesting Address is not set\"\n );\n require(vrtAmount > 0, \"VRT amount must be non-zero\");\n totalVrtConverted = totalVrtConverted.add(vrtAmount);\n\n uint256 redeemAmount = vrtAmount.mul(conversionRatio).mul(xvsDecimalsMultiplier).div(1e18).div(\n vrtDecimalsMultiplier\n );\n\n emit TokenConverted(msg.sender, address(vrt), vrtAmount, address(xvs), redeemAmount);\n vrt.safeTransferFrom(msg.sender, DEAD_ADDRESS, vrtAmount);\n xvsVesting.deposit(msg.sender, redeemAmount);\n }\n\n /*** Admin Functions ***/\n function _become(VRTConverterProxy vrtConverterProxy) public {\n require(msg.sender == vrtConverterProxy.admin(), \"only proxy admin can change brains\");\n vrtConverterProxy._acceptImplementation();\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverterProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VRTConverterStorage.sol\";\n\ncontract VRTConverterProxy is VRTConverterAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means VRTConverter implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(\n address implementation_,\n address _vrtAddress,\n address _xvsAddress,\n uint256 _conversionRatio,\n uint256 _conversionStartTime,\n uint256 _conversionPeriod\n ) public nonZeroAddress(implementation_) nonZeroAddress(_vrtAddress) nonZeroAddress(_xvsAddress) {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,uint256,uint256,uint256)\",\n _vrtAddress,\n _xvsAddress,\n _conversionRatio,\n _conversionStartTime,\n _conversionPeriod\n )\n );\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"VRTConverterProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"VRTConverterProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal nonZeroAddress(callee) returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(\n address newPendingImplementation\n ) public nonZeroAddress(newPendingImplementation) {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRTConverter. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public nonZeroAddress(newPendingAdmin) {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n require(newPendingAdmin != pendingAdmin, \"New pendingAdmin can not be same as the previous one\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverterStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/SafeMath.sol\";\nimport \"../../Utils/IBEP20.sol\";\nimport \"../XVS/IXVSVesting.sol\";\n\ncontract VRTConverterAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VRTConverter\n */\n address public implementation;\n\n /**\n * @notice Pending brains of VRTConverter\n */\n address public pendingImplementation;\n}\n\ncontract VRTConverterStorage is VRTConverterAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice indicator to check if the contract is initialized\n bool public initialized;\n\n /// @notice The VRT TOKEN!\n IBEP20 public vrt;\n\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice XVSVesting Contract reference\n IXVSVesting public xvsVesting;\n\n /// @notice Conversion ratio from VRT to XVS with decimal 18\n uint256 public conversionRatio;\n\n /// @notice total VRT converted to XVS\n uint256 public totalVrtConverted;\n\n /// @notice Conversion Start time in EpochSeconds\n uint256 public conversionStartTime;\n\n /// @notice ConversionPeriod in Seconds\n uint256 public conversionPeriod;\n\n /// @notice Conversion End time in EpochSeconds\n uint256 public conversionEndTime;\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VBep20DelegateR1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../VTokenInterfaces.sol\";\nimport { VBep20R1 } from \"./VBep20R1.sol\";\nimport { VDelegateInterface } from \"./VTokenInterfaceR1.sol\";\n\n/**\n * @title Venus's VBep20Delegate Contract\n * @notice VTokens which wrap an EIP-20 underlying and are delegated to\n * @author Venus\n */\ncontract VBep20DelegateR1 is VBep20R1, VDelegateInterface {\n /**\n * @notice Construct an empty delegate\n */\n constructor() public {}\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public {\n // Shh -- currently unused\n data;\n\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _becomeImplementation\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public {\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _resignImplementation\");\n }\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VBep20DelegatorR1.sol": { + "content": "pragma solidity ^0.5.16;\nimport \"../VTokenInterfaces.sol\";\nimport \"./VTokenInterfaceR1.sol\";\n\n/**\n * @title Venus's VBep20Delegator Contract\n * @notice vTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Venus\n */\ncontract VBep20DelegatorR1 is VTokenInterfaceR1, VBep20Interface, VDelegatorInterface {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n * @param implementation_ The address of the implementation the contract delegates to\n * @param becomeImplementationData The encoded args for becomeImplementation\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,address,uint256,string,string,uint8)\",\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n )\n );\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_, false, becomeImplementationData);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n */\n function() external payable {\n require(msg.value == 0, \"VBep20Delegator:fallback: cannot send value to fallback\");\n\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mint(uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"mint(uint256)\", mintAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"mintBehalf(address,uint256)\", receiver, mintAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying asset\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeem(uint redeemTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"redeem(uint256)\", redeemTokens));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"redeemUnderlying(uint256)\", redeemAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrow(uint borrowAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrow(uint256)\", borrowAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrow(uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"repayBorrow(uint256)\", repayAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrower\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"repayBorrowBehalf(address,uint256)\", borrower, repayAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"liquidateBorrow(address,uint256,address)\", borrower, repayAmount, vTokenCollateral)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint amount) external returns (bool) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"transfer(address,uint256)\", dst, amount));\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", src, dst, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"approve(address,uint256)\", spender, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"balanceOfUnderlying(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"totalBorrowsCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrowBalanceCurrent(address)\", account));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * It's absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"seize(address,address,uint256)\", liquidator, borrower, seizeTokens)\n );\n return abi.decode(data, (uint));\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setPendingAdmin(address)\", newPendingAdmin)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setReserveFactor(uint256)\", newReserveFactorMantissa)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accepts transfer of admin rights. `msg.sender` must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _acceptAdmin() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_acceptAdmin()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from admin\n * @param addAmount Amount of reserves to add\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReserves(uint addAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_addReserves(uint256)\", addAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReserves(uint reduceAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_reduceReserves(uint256)\", reduceAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"getCash()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"allowance(address,address)\", owner, spender)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"balanceOf(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get a snapshot of the account's balances and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"getAccountSnapshot(address)\", account)\n );\n return abi.decode(data, (uint, uint, uint, uint));\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"borrowRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"supplyRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n // @custom:access Only callable by admin\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public {\n require(msg.sender == admin, \"VBep20Delegator::_setImplementation: Caller must be admin\");\n\n if (allowResign) {\n delegateToImplementation(abi.encodeWithSignature(\"_resignImplementation()\"));\n }\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n delegateToImplementation(abi.encodeWithSignature(\"_becomeImplementation(bytes)\", becomeImplementationData));\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"exchangeRateCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves.\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"accrueInterest()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setComptroller(address)\", newComptroller)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using `_setInterestRateModelFresh`\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setInterestRateModel(address)\", newInterestRateModel)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Delegates execution to the implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToImplementation(bytes memory data) public returns (bytes memory) {\n return delegateTo(implementation, data);\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {\n (bool success, bytes memory returnData) = address(this).staticcall(\n abi.encodeWithSignature(\"delegateToImplementation(bytes)\", data)\n );\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return abi.decode(returnData, (bytes));\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"borrowBalanceStored(address)\", account)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"exchangeRateStored()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VBep20R1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VTokenR1, VBep20Interface, ComptrollerInterface, InterestRateModel, VTokenInterface } from \"./VTokenR1.sol\";\nimport { EIP20Interface } from \"../../EIP20Interface.sol\";\nimport { EIP20NonStandardInterface } from \"../../EIP20NonStandardInterface.sol\";\n\n/**\n * @title Venus's VBep20 Contract\n * @notice vTokens which wrap an EIP-20 underlying\n * @author Venus\n */\ncontract VBep20R1 is VTokenR1, VBep20Interface {\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint(uint mintAmount) external returns (uint) {\n (uint err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits MintBehalf event\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n (uint err, ) = mintBehalfInternal(receiver, mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The user on behalf of whom to redeem\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemBehalf(address redeemer, uint redeemTokens) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemInternal(redeemer, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer, on behalf of whom to redeem\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlyingBehalf(address redeemer, uint redeemAmount) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemUnderlyingInternal(redeemer, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender borrows assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the borrower using `comptroller.updateDelegate`\n * @param borrower The borrower, on behalf of whom to borrow.\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrowBehalf(address borrower, uint borrowAmount) external returns (uint) {\n require(comptroller.approvedDelegates(borrower, msg.sender), \"not an approved delegate\");\n return borrowInternal(borrower, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow(uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n (uint err, ) = liquidateBorrowInternal(borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n /**\n * @notice The sender adds to reserves.\n * @param addAmount The amount of underlying tokens to add as reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesAdded event\n function _addReserves(uint addAmount) external returns (uint) {\n return _addReservesInternal(addAmount);\n }\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n */\n function initialize(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n // VToken initialize does the bulk of the work\n super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n EIP20NonStandardInterface(underlying).transferFrom(from, address(this), amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_IN_FAILED\");\n\n // Calculate the amount that was *actually* transferred\n uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address payable to, uint amount) internal {\n EIP20NonStandardInterface(underlying).transfer(to, amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_OUT_FAILED\");\n }\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VTokenInterfaceR1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../../InterestRateModels/InterestRateModel.sol\";\nimport \"../VTokenInterfaces.sol\";\n\ncontract VTokenInterfaceR1 is VTokenStorage {\n /**\n * @notice Indicator that this is a vToken contract (for inspection)\n */\n bool public constant isVToken = true;\n\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows);\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint mintAmount, uint mintTokens);\n\n /**\n * @notice Event emitted when tokens are minted behalf by payer to receiver\n */\n event MintBehalf(address payer, address receiver, uint mintAmount, uint mintTokens);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint redeemAmount, uint redeemTokens);\n\n /**\n * @notice Event emitted when tokens are redeemed and fee is transferred\n */\n event RedeemFee(address redeemer, uint feeAmount, uint redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint repayAmount,\n address vTokenCollateral,\n uint seizeTokens\n );\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Event emitted when pendingAdmin is accepted, which means admin has been updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @notice Event emitted when comptroller is changed\n */\n event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address protocolShareReserve, uint reduceAmount, uint newTotalReserves);\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint amount);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint amount);\n\n /**\n * @notice Event emitted when block delta for reduce reserves get updated\n */\n event NewReduceReservesBlockDelta(uint256 oldReduceReservesBlockDelta, uint256 newReduceReservesBlockDelta);\n\n /**\n * @notice Event emitted when address of ProtocolShareReserve contract get updated\n */\n event NewProtocolShareReserve(address indexed oldProtocolShareReserve, address indexed newProtocolShareReserve);\n\n /**\n * @notice Failure event\n */\n event Failure(uint error, uint info, uint detail);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControlManager(address oldAccessControlAddress, address newAccessControlAddress);\n\n /*** User Interface ***/\n\n function transfer(address dst, uint amount) external returns (bool);\n\n function transferFrom(address src, address dst, uint amount) external returns (bool);\n\n function approve(address spender, uint amount) external returns (bool);\n\n function balanceOfUnderlying(address owner) external returns (uint);\n\n function totalBorrowsCurrent() external returns (uint);\n\n function borrowBalanceCurrent(address account) external returns (uint);\n\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint);\n\n /*** Admin Function ***/\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint);\n\n /*** Admin Function ***/\n function _acceptAdmin() external returns (uint);\n\n /*** Admin Function ***/\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint);\n\n /*** Admin Function ***/\n function _reduceReserves(uint reduceAmount) external returns (uint);\n\n function balanceOf(address owner) external view returns (uint);\n\n function allowance(address owner, address spender) external view returns (uint);\n\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint);\n\n function borrowRatePerBlock() external view returns (uint);\n\n function supplyRatePerBlock() external view returns (uint);\n\n function getCash() external view returns (uint);\n\n function exchangeRateCurrent() public returns (uint);\n\n function accrueInterest() public returns (uint);\n\n /*** Admin Function ***/\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint);\n\n /*** Admin Function ***/\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint);\n\n function borrowBalanceStored(address account) public view returns (uint);\n\n function exchangeRateStored() public view returns (uint);\n}\n" + }, + "contracts/Tokens/VTokens/legacy/VTokenR1.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../../Utils/ErrorReporter.sol\";\nimport \"../../../Utils/Exponential.sol\";\nimport \"../../../Tokens/EIP20Interface.sol\";\nimport \"../../../Tokens/EIP20NonStandardInterface.sol\";\nimport \"../../../InterestRateModels/InterestRateModel.sol\";\nimport \"../VTokenInterfaces.sol\";\nimport { VTokenInterfaceR1 } from \"./VTokenInterfaceR1.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\n\n/**\n * @title Venus's vToken Contract\n * @notice Abstract base for vTokens\n * @author Venus\n */\ncontract VTokenR1 is VTokenInterfaceR1, Exponential, TokenErrorReporter {\n struct MintLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint mintTokens;\n uint totalSupplyNew;\n uint accountTokensNew;\n uint actualMintAmount;\n }\n\n struct RedeemLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint redeemTokens;\n uint redeemAmount;\n uint totalSupplyNew;\n uint accountTokensNew;\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint repayAmount;\n uint borrowerIndex;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n uint actualRepayAmount;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transfer(address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transferFrom(address src, address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n // @custom:event Emits Approval event on successful approve\n function approve(address spender, uint256 amount) external returns (bool) {\n transferAllowances[msg.sender][spender] = amount;\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n ensureNoMathError(mErr);\n return balance;\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return totalBorrows;\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return borrowBalanceStored(account);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewPendingAdmin event with old and new admin addresses\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n // Check caller = admin\n ensureAdmin(msg.sender);\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewAdmin event on successful acceptance\n // @custom:event Emits NewPendingAdmin event with null new pending admin\n function _acceptAdmin() external returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using `_setReserveFactorFresh`\n * @dev Governor function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewReserveFactor event\n function _setReserveFactor(uint newReserveFactorMantissa_) external nonReentrant returns (uint) {\n ensureAllowed(\"_setReserveFactor(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed.\n return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);\n }\n // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to.\n return _setReserveFactorFresh(newReserveFactorMantissa_);\n }\n\n /**\n * @notice Sets the address of the access control manager of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlManagerAddress New address for the access control\n * @return uint 0=success, otherwise will revert\n */\n function setAccessControlManager(address newAccessControlManagerAddress) external returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ensureNonZeroAddress(newAccessControlManagerAddress);\n\n emit NewAccessControlManager(accessControlManager, newAccessControlManagerAddress);\n accessControlManager = newAccessControlManagerAddress;\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to protocol share reserve\n * @param reduceAmount_ Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesReduced event\n function _reduceReserves(uint reduceAmount_) external nonReentrant returns (uint) {\n ensureAllowed(\"_reduceReserves(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // If reserves were reduced in accrueInterest\n if (reduceReservesBlockNumber == block.number) return (uint(Error.NO_ERROR));\n // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.\n return _reduceReservesFresh(reduceAmount_);\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint256) {\n return accountTokens[owner];\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n uint vTokenBalance = accountTokens[account];\n uint borrowBalance;\n uint exchangeRateMantissa;\n\n MathError mErr;\n\n (mErr, borrowBalance) = borrowBalanceStoredInternal(account);\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n (mErr, exchangeRateMantissa) = exchangeRateStoredInternal();\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n return (uint(Error.NO_ERROR), vTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves);\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n return getCashPrior();\n }\n\n /**\n * @notice Governance function to set new threshold of block difference after which funds will be sent to the protocol share reserve\n * @param newReduceReservesBlockDelta_ block difference value\n */\n function setReduceReservesBlockDelta(uint256 newReduceReservesBlockDelta_) external {\n require(newReduceReservesBlockDelta_ > 0, \"Invalid Input\");\n ensureAllowed(\"setReduceReservesBlockDelta(uint256)\");\n emit NewReduceReservesBlockDelta(reduceReservesBlockDelta, newReduceReservesBlockDelta_);\n reduceReservesBlockDelta = newReduceReservesBlockDelta_;\n }\n\n /**\n * @notice Sets protocol share reserve contract address\n * @param protcolShareReserve_ The address of protocol share reserve contract\n */\n function setProtocolShareReserve(address payable protcolShareReserve_) external {\n // Check caller is admin\n ensureAdmin(msg.sender);\n ensureNonZeroAddress(protcolShareReserve_);\n emit NewProtocolShareReserve(protocolShareReserve, protcolShareReserve_);\n protocolShareReserve = protcolShareReserve_;\n }\n\n /**\n * @notice Initialize the money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ EIP-20 name of this token\n * @param symbol_ EIP-20 symbol of this token\n * @param decimals_ EIP-20 decimal precision of this token\n */\n function initialize(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n ensureAdmin(msg.sender);\n require(accrualBlockNumber == 0 && borrowIndex == 0, \"market may only be initialized once\");\n\n // Set initial exchange rate\n initialExchangeRateMantissa = initialExchangeRateMantissa_;\n require(initialExchangeRateMantissa > 0, \"initial exchange rate must be greater than zero.\");\n\n // Set the comptroller\n uint err = _setComptroller(comptroller_);\n require(err == uint(Error.NO_ERROR), \"setting comptroller failed\");\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = mantissaOne;\n\n // Set the interest rate model (depends on block number / borrow index)\n err = _setInterestRateModelFresh(interestRateModel_);\n require(err == uint(Error.NO_ERROR), \"setting interest rate model failed\");\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return exchangeRateStored();\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage and\n * reduce spread reserves to protocol share reserve\n * if currentBlock - reduceReservesBlockNumber >= blockDelta\n */\n // @custom:event Emits AccrueInterest event\n function accrueInterest() public returns (uint) {\n /* Remember the initial block number */\n uint currentBlockNumber = block.number;\n uint accrualBlockNumberPrior = accrualBlockNumber;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumberPrior == currentBlockNumber) {\n return uint(Error.NO_ERROR);\n }\n\n /* Read the previous values out of storage */\n uint cashPrior = getCashPrior();\n uint borrowsPrior = totalBorrows;\n uint reservesPrior = totalReserves;\n uint borrowIndexPrior = borrowIndex;\n\n /* Calculate the current borrow interest rate */\n uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior);\n require(borrowRateMantissa <= borrowRateMaxMantissa, \"borrow rate is absurdly high\");\n\n /* Calculate the number of blocks elapsed since the last accrual */\n (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);\n ensureNoMathError(mathErr);\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n Exp memory simpleInterestFactor;\n uint interestAccumulated;\n uint totalBorrowsNew;\n uint totalReservesNew;\n uint borrowIndexNew;\n\n (mathErr, simpleInterestFactor) = mulScalar(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n interestAccumulated,\n reservesPrior\n );\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = borrowIndexNew;\n totalBorrows = totalBorrowsNew;\n totalReserves = totalReservesNew;\n\n (mathErr, blockDelta) = subUInt(currentBlockNumber, reduceReservesBlockNumber);\n ensureNoMathError(mathErr);\n if (blockDelta >= reduceReservesBlockDelta) {\n reduceReservesBlockNumber = currentBlockNumber;\n if (cashPrior < totalReservesNew) {\n _reduceReservesFresh(cashPrior);\n } else {\n _reduceReservesFresh(totalReservesNew);\n }\n }\n\n /* We emit an AccrueInterest event */\n emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewComptroller event\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ComptrollerInterface oldComptroller = comptroller;\n // Ensure invoke comptroller.isComptroller() returns true\n require(newComptroller.isComptroller(), \"marker method returned false\");\n\n // Set market's comptroller to newComptroller\n comptroller = newComptroller;\n\n // Emit NewComptroller(oldComptroller, newComptroller)\n emit NewComptroller(oldComptroller, newComptroller);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Governance function to accrue interest and update the interest rate model\n * @param newInterestRateModel_ The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel_) public returns (uint) {\n ensureAllowed(\"_setInterestRateModel(address)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed\n return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);\n }\n // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.\n return _setInterestRateModelFresh(newInterestRateModel_);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n (MathError err, uint result) = exchangeRateStoredInternal();\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n (MathError err, uint result) = borrowBalanceStoredInternal(account);\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Transfers `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) {\n /* Fail if transfer not allowed */\n uint allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint startingAllowance = 0;\n if (spender == src) {\n startingAllowance = uint(-1);\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint allowanceNew;\n uint srvTokensNew;\n uint dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srvTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srvTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != uint(-1)) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mint failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n /**\n * @notice User supplies assets into the market and receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) {\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The address of the account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfInternal(address receiver, uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mintBehalf failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintBelahfFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintBehalfFresh(msg.sender, receiver, mintAmount);\n }\n\n /**\n * @notice Payer supplies assets into the market and receiver receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param payer The address of the account which is paying the underlying token\n * @param receiver The address of the account which is receiving vToken\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfFresh(address payer, address receiver, uint mintAmount) internal returns (uint, uint) {\n ensureNonZeroAddress(receiver);\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), receiver, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the payer and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(payer, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and receiver token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[receiver] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[receiver], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[receiver] = vars.accountTokensNew;\n\n /* We emit a MintBehalf event, and a Transfer event */\n emit MintBehalf(payer, receiver, vars.actualMintAmount, vars.mintTokens);\n emit Transfer(address(this), receiver, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), receiver, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemInternal(\n address redeemer,\n address payable receiver,\n uint redeemTokens\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens, if called by a delegate\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlyingInternal(\n address redeemer,\n address payable receiver,\n uint redeemAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, 0, redeemAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokensIn The number of vTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming vTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // solhint-disable-next-line code-complexity\n function redeemFresh(\n address redeemer,\n address payable receiver,\n uint redeemTokensIn,\n uint redeemAmountIn\n ) internal returns (uint) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"one of redeemTokensIn or redeemAmountIn must be zero\");\n\n RedeemLocalVars memory vars;\n\n /* exchangeRate = invoke Exchange Rate Stored() */\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n ensureNoMathError(vars.mathErr);\n\n /* If redeemTokensIn > 0: */\n if (redeemTokensIn > 0) {\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n ensureNoMathError(vars.mathErr);\n } else {\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(\n redeemAmountIn,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashPrior() < vars.redeemAmount) {\n revert(\"math error\");\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the receiver and the redeemAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n\n uint feeAmount;\n uint remainedAmount;\n if (IComptroller(address(comptroller)).treasuryPercent() != 0) {\n (vars.mathErr, feeAmount) = mulUInt(\n vars.redeemAmount,\n IComptroller(address(comptroller)).treasuryPercent()\n );\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, feeAmount) = divUInt(feeAmount, 1e18);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, remainedAmount) = subUInt(vars.redeemAmount, feeAmount);\n ensureNoMathError(vars.mathErr);\n\n doTransferOut(address(uint160(IComptroller(address(comptroller)).treasuryAddress())), feeAmount);\n\n emit RedeemFee(redeemer, feeAmount, vars.redeemTokens);\n } else {\n remainedAmount = vars.redeemAmount;\n }\n\n doTransferOut(receiver, remainedAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, remainedAmount, vars.redeemTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrowInternal(\n address borrower,\n address payable receiver,\n uint borrowAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED);\n }\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(borrower, receiver, borrowAmount);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @dev Before calling this function, ensure that the interest has been accrued\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise revert (see ErrorReporter.sol for details).\n */\n function borrowFresh(address borrower, address payable receiver, uint borrowAmount) internal returns (uint) {\n /* Revert if borrow not allowed */\n uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /* Revert if protocol has insufficient underlying cash */\n if (getCashPrior() < borrowAmount) {\n revert(\"math error\");\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the receiver and the borrowAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(receiver, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer The account paying off the borrow\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) {\n /* Fail if repayBorrow not allowed */\n uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (\n failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed),\n 0\n );\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n if (vars.mathErr != MathError.NO_ERROR) {\n return (\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n uint(vars.mathErr)\n ),\n 0\n );\n }\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == uint(-1)) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0);\n }\n\n error = vTokenCollateral.accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0);\n }\n\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, vTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n // solhint-disable-next-line code-complexity\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal returns (uint, uint) {\n /* Fail if liquidate not allowed */\n uint allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify vTokenCollateral market's block number equals current block number */\n if (vTokenCollateral.accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == uint(-1)) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n address(vTokenCollateral),\n actualRepayAmount\n );\n require(amountSeizeError == uint(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(vTokenCollateral.balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint seizeError;\n if (address(vTokenCollateral) == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = vTokenCollateral.seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint(Error.NO_ERROR), \"token seizure failed\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(vTokenCollateral), seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.liquidateBorrowVerify(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n actualRepayAmount,\n seizeTokens\n );\n\n return (uint(Error.NO_ERROR), actualRepayAmount);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another vToken.\n * Its absolutely critical to use msg.sender as the seizer vToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed vToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) internal returns (uint) {\n /* Fail if seize not allowed */\n uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n MathError mathErr;\n uint borrowerTokensNew;\n uint liquidatorTokensNew;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr));\n }\n\n (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountTokens[borrower] = borrowerTokensNew;\n accountTokens[liquidator] = liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new reserve factor for the protocol (requires fresh interest accrual)\n * @dev Governance function to set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) {\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa > reserveFactorMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from `msg.sender`\n * @param addAmount Amount of addition to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to.\n (error, ) = _addReservesFresh(addAmount);\n return error;\n }\n\n /**\n * @notice Add reserves by transferring from caller\n * @dev Requires fresh interest accrual\n * @param addAmount Amount of addition to reserves\n * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees\n */\n function _addReservesFresh(uint addAmount) internal returns (uint, uint) {\n // totalReserves + actualAddAmount\n uint totalReservesNew;\n uint actualAddAmount;\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the caller and the addAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional addAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n\n actualAddAmount = doTransferIn(msg.sender, addAmount);\n\n totalReservesNew = totalReserves + actualAddAmount;\n\n /* Revert on overflow */\n require(totalReservesNew >= totalReserves, \"add reserves unexpected overflow\");\n\n // Store reserves[n+1] = reserves[n] + actualAddAmount\n totalReserves = totalReservesNew;\n\n /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */\n emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew);\n\n /* Return (NO_ERROR, actualAddAmount) */\n return (uint(Error.NO_ERROR), actualAddAmount);\n }\n\n /**\n * @notice Reduces reserves by transferring to protocol share reserve contract\n * @dev Requires fresh interest accrual\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReservesFresh(uint reduceAmount) internal returns (uint) {\n if (reduceAmount == 0) {\n return uint(Error.NO_ERROR);\n }\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashPrior() < reduceAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);\n }\n\n // Check reduceAmount ≤ reserves[n] (totalReserves)\n if (reduceAmount > totalReserves) {\n return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n // totalReserves - reduceAmount\n uint totalReservesNew = totalReserves - reduceAmount;\n\n // Store reserves[n+1] = reserves[n] - reduceAmount\n totalReserves = totalReservesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(protocolShareReserve, reduceAmount);\n\n IProtocolShareReserveV5(protocolShareReserve).updateAssetsState(\n address(comptroller),\n underlying,\n IProtocolShareReserveV5.IncomeType.SPREAD\n );\n\n emit ReservesReduced(protocolShareReserve, reduceAmount, totalReservesNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice updates the interest rate model (requires fresh interest accrual)\n * @dev Governance function to update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) {\n // Used to store old model for use in the event that is emitted on success\n InterestRateModel oldInterestRateModel;\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n // Track the market's current interest rate model\n oldInterestRateModel = interestRateModel;\n\n // Ensure invoke newInterestRateModel.isInterestRateModel() returns true\n require(newInterestRateModel.isInterestRateModel(), \"marker method returned false\");\n\n // Set the interest rate model to newInterestRateModel\n interestRateModel = newInterestRateModel;\n\n // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel)\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee.\n * This may revert due to insufficient balance or insufficient allowance.\n */\n function doTransferIn(address from, uint amount) internal returns (uint);\n\n /**\n * @dev Performs a transfer out, ideally returning an explanatory error code upon failure rather than reverting.\n * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract.\n * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions.\n */\n function doTransferOut(address payable to, uint amount) internal;\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return Tuple of error code and the calculated balance or 0 if error code is non-zero\n */\n function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint) {\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint principalTimesIndex;\n uint result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, borrowIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, result);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the vToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Tuple of error code and calculated exchange rate scaled by 1e18\n */\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n uint _totalSupply = totalSupply;\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return (MathError.NO_ERROR, initialExchangeRateMantissa);\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply\n */\n uint totalCash = getCashPrior();\n uint cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(totalCash, totalBorrows, totalReserves);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, exchangeRate.mantissa);\n }\n }\n\n function ensureAllowed(string memory functionSig) private view {\n require(\n IAccessControlManagerV5(accessControlManager).isAllowedToCall(msg.sender, functionSig),\n \"access denied\"\n );\n }\n\n function ensureAdmin(address caller_) private view {\n require(caller_ == admin, \"Unauthorized\");\n }\n\n function ensureNoMathError(MathError mErr) private pure {\n require(mErr == MathError.NO_ERROR, \"math error\");\n }\n\n function ensureNonZeroAddress(address address_) private pure {\n require(address_ != address(0), \"zero address\");\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying owned by this contract\n */\n function getCashPrior() internal view returns (uint);\n}\n" + }, + "contracts/Tokens/VTokens/VBep20.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VToken, VBep20Interface, ComptrollerInterface, InterestRateModel, VTokenInterface } from \"./VToken.sol\";\nimport { EIP20Interface } from \"../EIP20Interface.sol\";\nimport { EIP20NonStandardInterface } from \"../EIP20NonStandardInterface.sol\";\n\n/**\n * @title Venus's VBep20 Contract\n * @notice vTokens which wrap an EIP-20 underlying\n * @author Venus\n */\ncontract VBep20 is VToken, VBep20Interface {\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint(uint mintAmount) external returns (uint) {\n (uint err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits MintBehalf event\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n (uint err, ) = mintBehalfInternal(receiver, mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The user on behalf of whom to redeem\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemBehalf(address redeemer, uint redeemTokens) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemInternal(redeemer, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer, on behalf of whom to redeem\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlyingBehalf(address redeemer, uint redeemAmount) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemUnderlyingInternal(redeemer, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender borrows assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the borrower using `comptroller.updateDelegate`\n * @param borrower The borrower, on behalf of whom to borrow.\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrowBehalf(address borrower, uint borrowAmount) external returns (uint) {\n require(comptroller.approvedDelegates(borrower, msg.sender), \"not an approved delegate\");\n return borrowInternal(borrower, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow(uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n (uint err, ) = liquidateBorrowInternal(borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n /**\n * @notice The sender adds to reserves.\n * @param addAmount The amount of underlying tokens to add as reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesAdded event\n function _addReserves(uint addAmount) external returns (uint) {\n return _addReservesInternal(addAmount);\n }\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n */\n function initialize(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n // VToken initialize does the bulk of the work\n super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n EIP20NonStandardInterface(underlying).transferFrom(from, address(this), amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_IN_FAILED\");\n\n // Calculate the amount that was *actually* transferred\n uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address payable to, uint amount) internal {\n EIP20NonStandardInterface(underlying).transfer(to, amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_OUT_FAILED\");\n }\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Delegate.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VBep20 } from \"./VBep20.sol\";\nimport { VDelegateInterface } from \"./VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegate Contract\n * @notice VTokens which wrap an EIP-20 underlying and are delegated to\n * @author Venus\n */\ncontract VBep20Delegate is VBep20, VDelegateInterface {\n /**\n * @notice Construct an empty delegate\n */\n constructor() public {}\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public {\n // Shh -- currently unused\n data;\n\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _becomeImplementation\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public {\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _resignImplementation\");\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Delegator.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegator Contract\n * @notice vTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Venus\n */\ncontract VBep20Delegator is VTokenInterface, VBep20Interface, VDelegatorInterface {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n * @param implementation_ The address of the implementation the contract delegates to\n * @param becomeImplementationData The encoded args for becomeImplementation\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,address,uint256,string,string,uint8)\",\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n )\n );\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_, false, becomeImplementationData);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n */\n function() external payable {\n require(msg.value == 0, \"VBep20Delegator:fallback: cannot send value to fallback\");\n\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mint(uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"mint(uint256)\", mintAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"mintBehalf(address,uint256)\", receiver, mintAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying asset\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeem(uint redeemTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"redeem(uint256)\", redeemTokens));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"redeemUnderlying(uint256)\", redeemAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrow(uint borrowAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrow(uint256)\", borrowAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrow(uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"repayBorrow(uint256)\", repayAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrower\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"repayBorrowBehalf(address,uint256)\", borrower, repayAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"liquidateBorrow(address,uint256,address)\", borrower, repayAmount, vTokenCollateral)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint amount) external returns (bool) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"transfer(address,uint256)\", dst, amount));\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", src, dst, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"approve(address,uint256)\", spender, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"balanceOfUnderlying(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"totalBorrowsCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrowBalanceCurrent(address)\", account));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * It's absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"seize(address,address,uint256)\", liquidator, borrower, seizeTokens)\n );\n return abi.decode(data, (uint));\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setPendingAdmin(address)\", newPendingAdmin)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setReserveFactor(uint256)\", newReserveFactorMantissa)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accepts transfer of admin rights. `msg.sender` must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _acceptAdmin() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_acceptAdmin()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from admin\n * @param addAmount Amount of reserves to add\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReserves(uint addAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_addReserves(uint256)\", addAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReserves(uint reduceAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_reduceReserves(uint256)\", reduceAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"getCash()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"allowance(address,address)\", owner, spender)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"balanceOf(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get a snapshot of the account's balances and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"getAccountSnapshot(address)\", account)\n );\n return abi.decode(data, (uint, uint, uint, uint));\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"borrowRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"supplyRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n // @custom:access Only callable by admin\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public {\n require(msg.sender == admin, \"VBep20Delegator::_setImplementation: Caller must be admin\");\n\n if (allowResign) {\n delegateToImplementation(abi.encodeWithSignature(\"_resignImplementation()\"));\n }\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n delegateToImplementation(abi.encodeWithSignature(\"_becomeImplementation(bytes)\", becomeImplementationData));\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"exchangeRateCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves.\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"accrueInterest()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setComptroller(address)\", newComptroller)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using `_setInterestRateModelFresh`\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setInterestRateModel(address)\", newInterestRateModel)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Delegates execution to the implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToImplementation(bytes memory data) public returns (bytes memory) {\n return delegateTo(implementation, data);\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {\n (bool success, bytes memory returnData) = address(this).staticcall(\n abi.encodeWithSignature(\"delegateToImplementation(bytes)\", data)\n );\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return abi.decode(returnData, (bytes));\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"borrowBalanceStored(address)\", account)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"exchangeRateStored()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Immutable.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VBep20.sol\";\n\n/**\n * @title Venus's VBep20Immutable Contract\n * @notice VTokens which wrap an EIP-20 underlying and are immutable\n * @author Venus\n */\ncontract VBep20Immutable is VBep20 {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // Initialize the market\n initialize(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n );\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBNB.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VToken.sol\";\n\n/**\n * @title Venus's vBNB Contract\n * @notice vToken which wraps BNB\n * @author Venus\n */\ncontract VBNB is VToken {\n /**\n * @notice Construct a new vBNB money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Send BNB to VBNB to mint\n */\n function() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Reverts upon any failure\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @dev Reverts upon any failure\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow() external payable {\n (uint err, ) = repayBorrowInternal(msg.value);\n requireNoError(err, \"repayBorrow failed\");\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @dev Reverts upon any failure\n * @param borrower The account with the debt being payed off\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower) external payable {\n (uint err, ) = repayBorrowBehalfInternal(borrower, msg.value);\n requireNoError(err, \"repayBorrowBehalf failed\");\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @dev Reverts upon any failure\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(address borrower, VToken vTokenCollateral) external payable {\n (uint err, ) = liquidateBorrowInternal(borrower, msg.value, vTokenCollateral);\n requireNoError(err, \"liquidateBorrow failed\");\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Perform the actual transfer in, which is a no-op\n * @param from Address sending the BNB\n * @param amount Amount of BNB being sent\n * @return The actual amount of BNB transferred\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n // Sanity checks\n require(msg.sender == from, \"sender mismatch\");\n require(msg.value == amount, \"value mismatch\");\n return amount;\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n /* Send the BNB, with minimal gas and revert on failure */\n to.transfer(amount);\n }\n\n /**\n * @notice Gets balance of this contract in terms of BNB, before this message\n * @dev This excludes the value of the current message, if any\n * @return The quantity of BNB owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n (MathError err, uint startingBalance) = subUInt(address(this).balance, msg.value);\n require(err == MathError.NO_ERROR, \"cash prior math error\");\n return startingBalance;\n }\n\n function requireNoError(uint errCode, string memory message) internal pure {\n if (errCode == uint(Error.NO_ERROR)) {\n return;\n }\n\n bytes memory fullMessage = new bytes(bytes(message).length + 5);\n uint i;\n\n for (i = 0; i < bytes(message).length; i++) {\n fullMessage[i] = bytes(message)[i];\n }\n\n fullMessage[i + 0] = bytes1(uint8(32));\n fullMessage[i + 1] = bytes1(uint8(40));\n fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10)));\n fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10)));\n fullMessage[i + 4] = bytes1(uint8(41));\n\n require(errCode == uint(Error.NO_ERROR), string(fullMessage));\n }\n}\n" + }, + "contracts/Tokens/VTokens/VToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../Utils/ErrorReporter.sol\";\nimport \"../../Utils/Exponential.sol\";\nimport \"../../Tokens/EIP20Interface.sol\";\nimport \"../../Tokens/EIP20NonStandardInterface.sol\";\nimport \"../../InterestRateModels/InterestRateModel.sol\";\nimport \"./VTokenInterfaces.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\n\n/**\n * @title Venus's vToken Contract\n * @notice Abstract base for vTokens\n * @author Venus\n */\ncontract VToken is VTokenInterface, Exponential, TokenErrorReporter {\n struct MintLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint mintTokens;\n uint totalSupplyNew;\n uint accountTokensNew;\n uint actualMintAmount;\n }\n\n struct RedeemLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint redeemTokens;\n uint redeemAmount;\n uint totalSupplyNew;\n uint accountTokensNew;\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint repayAmount;\n uint borrowerIndex;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n uint actualRepayAmount;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transfer(address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transferFrom(address src, address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n // @custom:event Emits Approval event on successful approve\n function approve(address spender, uint256 amount) external returns (bool) {\n transferAllowances[msg.sender][spender] = amount;\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n ensureNoMathError(mErr);\n return balance;\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return totalBorrows;\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return borrowBalanceStored(account);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewPendingAdmin event with old and new admin addresses\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n // Check caller = admin\n ensureAdmin(msg.sender);\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewAdmin event on successful acceptance\n // @custom:event Emits NewPendingAdmin event with null new pending admin\n function _acceptAdmin() external returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using `_setReserveFactorFresh`\n * @dev Governor function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewReserveFactor event\n function _setReserveFactor(uint newReserveFactorMantissa_) external nonReentrant returns (uint) {\n ensureAllowed(\"_setReserveFactor(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed.\n return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);\n }\n // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to.\n return _setReserveFactorFresh(newReserveFactorMantissa_);\n }\n\n /**\n * @notice Sets the address of the access control manager of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlManagerAddress New address for the access control\n * @return uint 0=success, otherwise will revert\n */\n function setAccessControlManager(address newAccessControlManagerAddress) external returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ensureNonZeroAddress(newAccessControlManagerAddress);\n\n emit NewAccessControlManager(accessControlManager, newAccessControlManagerAddress);\n accessControlManager = newAccessControlManagerAddress;\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to protocol share reserve\n * @param reduceAmount_ Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesReduced event\n function _reduceReserves(uint reduceAmount_) external nonReentrant returns (uint) {\n ensureAllowed(\"_reduceReserves(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // If reserves were reduced in accrueInterest\n if (reduceReservesBlockNumber == block.number) return (uint(Error.NO_ERROR));\n // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.\n return _reduceReservesFresh(reduceAmount_);\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint256) {\n return accountTokens[owner];\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n uint vTokenBalance = accountTokens[account];\n uint borrowBalance;\n uint exchangeRateMantissa;\n\n MathError mErr;\n\n (mErr, borrowBalance) = borrowBalanceStoredInternal(account);\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n (mErr, exchangeRateMantissa) = exchangeRateStoredInternal();\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n return (uint(Error.NO_ERROR), vTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves);\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n return getCashPrior();\n }\n\n /**\n * @notice Governance function to set new threshold of block difference after which funds will be sent to the protocol share reserve\n * @param newReduceReservesBlockDelta_ block difference value\n */\n function setReduceReservesBlockDelta(uint256 newReduceReservesBlockDelta_) external {\n require(newReduceReservesBlockDelta_ > 0, \"Invalid Input\");\n ensureAllowed(\"setReduceReservesBlockDelta(uint256)\");\n emit NewReduceReservesBlockDelta(reduceReservesBlockDelta, newReduceReservesBlockDelta_);\n reduceReservesBlockDelta = newReduceReservesBlockDelta_;\n }\n\n /**\n * @notice Sets protocol share reserve contract address\n * @param protcolShareReserve_ The address of protocol share reserve contract\n */\n function setProtocolShareReserve(address payable protcolShareReserve_) external {\n // Check caller is admin\n ensureAdmin(msg.sender);\n ensureNonZeroAddress(protcolShareReserve_);\n emit NewProtocolShareReserve(protocolShareReserve, protcolShareReserve_);\n protocolShareReserve = protcolShareReserve_;\n }\n\n /**\n * @notice Initialize the money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ EIP-20 name of this token\n * @param symbol_ EIP-20 symbol of this token\n * @param decimals_ EIP-20 decimal precision of this token\n */\n function initialize(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n ensureAdmin(msg.sender);\n require(accrualBlockNumber == 0 && borrowIndex == 0, \"market may only be initialized once\");\n\n // Set initial exchange rate\n initialExchangeRateMantissa = initialExchangeRateMantissa_;\n require(initialExchangeRateMantissa > 0, \"initial exchange rate must be greater than zero.\");\n\n // Set the comptroller\n uint err = _setComptroller(comptroller_);\n require(err == uint(Error.NO_ERROR), \"setting comptroller failed\");\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = mantissaOne;\n\n // Set the interest rate model (depends on block number / borrow index)\n err = _setInterestRateModelFresh(interestRateModel_);\n require(err == uint(Error.NO_ERROR), \"setting interest rate model failed\");\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return exchangeRateStored();\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage and\n * reduce spread reserves to protocol share reserve\n * if currentBlock - reduceReservesBlockNumber >= blockDelta\n */\n // @custom:event Emits AccrueInterest event\n function accrueInterest() public returns (uint) {\n /* Remember the initial block number */\n uint currentBlockNumber = block.number;\n uint accrualBlockNumberPrior = accrualBlockNumber;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumberPrior == currentBlockNumber) {\n return uint(Error.NO_ERROR);\n }\n\n /* Read the previous values out of storage */\n uint cashPrior = getCashPrior();\n uint borrowsPrior = totalBorrows;\n uint reservesPrior = totalReserves;\n uint borrowIndexPrior = borrowIndex;\n\n /* Calculate the current borrow interest rate */\n uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior);\n require(borrowRateMantissa <= borrowRateMaxMantissa, \"borrow rate is absurdly high\");\n\n /* Calculate the number of blocks elapsed since the last accrual */\n (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);\n ensureNoMathError(mathErr);\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n Exp memory simpleInterestFactor;\n uint interestAccumulated;\n uint totalBorrowsNew;\n uint totalReservesNew;\n uint borrowIndexNew;\n\n (mathErr, simpleInterestFactor) = mulScalar(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n interestAccumulated,\n reservesPrior\n );\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = borrowIndexNew;\n totalBorrows = totalBorrowsNew;\n totalReserves = totalReservesNew;\n\n (mathErr, blockDelta) = subUInt(currentBlockNumber, reduceReservesBlockNumber);\n ensureNoMathError(mathErr);\n if (blockDelta >= reduceReservesBlockDelta) {\n reduceReservesBlockNumber = currentBlockNumber;\n if (cashPrior < totalReservesNew) {\n _reduceReservesFresh(cashPrior);\n } else {\n _reduceReservesFresh(totalReservesNew);\n }\n }\n\n /* We emit an AccrueInterest event */\n emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewComptroller event\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ComptrollerInterface oldComptroller = comptroller;\n // Ensure invoke comptroller.isComptroller() returns true\n require(newComptroller.isComptroller(), \"marker method returned false\");\n\n // Set market's comptroller to newComptroller\n comptroller = newComptroller;\n\n // Emit NewComptroller(oldComptroller, newComptroller)\n emit NewComptroller(oldComptroller, newComptroller);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Governance function to accrue interest and update the interest rate model\n * @param newInterestRateModel_ The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel_) public returns (uint) {\n ensureAllowed(\"_setInterestRateModel(address)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed\n return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);\n }\n // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.\n return _setInterestRateModelFresh(newInterestRateModel_);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n (MathError err, uint result) = exchangeRateStoredInternal();\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n (MathError err, uint result) = borrowBalanceStoredInternal(account);\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Transfers `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) {\n /* Fail if transfer not allowed */\n uint allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint startingAllowance = 0;\n if (spender == src) {\n startingAllowance = uint(-1);\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint allowanceNew;\n uint srvTokensNew;\n uint dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srvTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srvTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != uint(-1)) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mint failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n /**\n * @notice User supplies assets into the market and receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) {\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens, vars.accountTokensNew);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The address of the account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfInternal(address receiver, uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mintBehalf failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintBelahfFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintBehalfFresh(msg.sender, receiver, mintAmount);\n }\n\n /**\n * @notice Payer supplies assets into the market and receiver receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param payer The address of the account which is paying the underlying token\n * @param receiver The address of the account which is receiving vToken\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfFresh(address payer, address receiver, uint mintAmount) internal returns (uint, uint) {\n ensureNonZeroAddress(receiver);\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), receiver, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the payer and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(payer, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and receiver token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[receiver] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[receiver], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[receiver] = vars.accountTokensNew;\n\n /* We emit a MintBehalf event, and a Transfer event */\n emit MintBehalf(payer, receiver, vars.actualMintAmount, vars.mintTokens, vars.accountTokensNew);\n emit Transfer(address(this), receiver, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), receiver, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemInternal(\n address redeemer,\n address payable receiver,\n uint redeemTokens\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens, if called by a delegate\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlyingInternal(\n address redeemer,\n address payable receiver,\n uint redeemAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, 0, redeemAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokensIn The number of vTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming vTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // solhint-disable-next-line code-complexity\n function redeemFresh(\n address redeemer,\n address payable receiver,\n uint redeemTokensIn,\n uint redeemAmountIn\n ) internal returns (uint) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"one of redeemTokensIn or redeemAmountIn must be zero\");\n\n RedeemLocalVars memory vars;\n\n /* exchangeRate = invoke Exchange Rate Stored() */\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n ensureNoMathError(vars.mathErr);\n\n /* If redeemTokensIn > 0: */\n if (redeemTokensIn > 0) {\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n ensureNoMathError(vars.mathErr);\n } else {\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(\n redeemAmountIn,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashPrior() < vars.redeemAmount) {\n revert(\"math error\");\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the receiver and the redeemAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n\n uint feeAmount;\n uint remainedAmount;\n if (IComptroller(address(comptroller)).treasuryPercent() != 0) {\n (vars.mathErr, feeAmount) = mulUInt(\n vars.redeemAmount,\n IComptroller(address(comptroller)).treasuryPercent()\n );\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, feeAmount) = divUInt(feeAmount, 1e18);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, remainedAmount) = subUInt(vars.redeemAmount, feeAmount);\n ensureNoMathError(vars.mathErr);\n\n doTransferOut(address(uint160(IComptroller(address(comptroller)).treasuryAddress())), feeAmount);\n\n emit RedeemFee(redeemer, feeAmount, vars.redeemTokens);\n } else {\n remainedAmount = vars.redeemAmount;\n }\n\n doTransferOut(receiver, remainedAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, remainedAmount, vars.redeemTokens, vars.accountTokensNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrowInternal(\n address borrower,\n address payable receiver,\n uint borrowAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED);\n }\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(borrower, receiver, borrowAmount);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @dev Before calling this function, ensure that the interest has been accrued\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise revert (see ErrorReporter.sol for details).\n */\n function borrowFresh(address borrower, address payable receiver, uint borrowAmount) internal returns (uint) {\n /* Revert if borrow not allowed */\n uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /* Revert if protocol has insufficient underlying cash */\n if (getCashPrior() < borrowAmount) {\n revert(\"math error\");\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the receiver and the borrowAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(receiver, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer The account paying off the borrow\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) {\n /* Fail if repayBorrow not allowed */\n uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (\n failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed),\n 0\n );\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n if (vars.mathErr != MathError.NO_ERROR) {\n return (\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n uint(vars.mathErr)\n ),\n 0\n );\n }\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == uint(-1)) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0);\n }\n\n error = vTokenCollateral.accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0);\n }\n\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, vTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n // solhint-disable-next-line code-complexity\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal returns (uint, uint) {\n /* Fail if liquidate not allowed */\n uint allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify vTokenCollateral market's block number equals current block number */\n if (vTokenCollateral.accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == uint(-1)) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n address(vTokenCollateral),\n actualRepayAmount\n );\n require(amountSeizeError == uint(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(vTokenCollateral.balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint seizeError;\n if (address(vTokenCollateral) == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = vTokenCollateral.seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint(Error.NO_ERROR), \"token seizure failed\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(vTokenCollateral), seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.liquidateBorrowVerify(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n actualRepayAmount,\n seizeTokens\n );\n\n return (uint(Error.NO_ERROR), actualRepayAmount);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another vToken.\n * Its absolutely critical to use msg.sender as the seizer vToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed vToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) internal returns (uint) {\n /* Fail if seize not allowed */\n uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n MathError mathErr;\n uint borrowerTokensNew;\n uint liquidatorTokensNew;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr));\n }\n\n (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountTokens[borrower] = borrowerTokensNew;\n accountTokens[liquidator] = liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new reserve factor for the protocol (requires fresh interest accrual)\n * @dev Governance function to set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) {\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa > reserveFactorMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from `msg.sender`\n * @param addAmount Amount of addition to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to.\n (error, ) = _addReservesFresh(addAmount);\n return error;\n }\n\n /**\n * @notice Add reserves by transferring from caller\n * @dev Requires fresh interest accrual\n * @param addAmount Amount of addition to reserves\n * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees\n */\n function _addReservesFresh(uint addAmount) internal returns (uint, uint) {\n // totalReserves + actualAddAmount\n uint totalReservesNew;\n uint actualAddAmount;\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the caller and the addAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional addAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n\n actualAddAmount = doTransferIn(msg.sender, addAmount);\n\n totalReservesNew = totalReserves + actualAddAmount;\n\n /* Revert on overflow */\n require(totalReservesNew >= totalReserves, \"add reserves unexpected overflow\");\n\n // Store reserves[n+1] = reserves[n] + actualAddAmount\n totalReserves = totalReservesNew;\n\n /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */\n emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew);\n\n /* Return (NO_ERROR, actualAddAmount) */\n return (uint(Error.NO_ERROR), actualAddAmount);\n }\n\n /**\n * @notice Reduces reserves by transferring to protocol share reserve contract\n * @dev Requires fresh interest accrual\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReservesFresh(uint reduceAmount) internal returns (uint) {\n if (reduceAmount == 0) {\n return uint(Error.NO_ERROR);\n }\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashPrior() < reduceAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);\n }\n\n // Check reduceAmount ≤ reserves[n] (totalReserves)\n if (reduceAmount > totalReserves) {\n return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n // totalReserves - reduceAmount\n uint totalReservesNew = totalReserves - reduceAmount;\n\n // Store reserves[n+1] = reserves[n] - reduceAmount\n totalReserves = totalReservesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(protocolShareReserve, reduceAmount);\n\n IProtocolShareReserveV5(protocolShareReserve).updateAssetsState(\n address(comptroller),\n underlying,\n IProtocolShareReserveV5.IncomeType.SPREAD\n );\n\n emit ReservesReduced(protocolShareReserve, reduceAmount, totalReservesNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice updates the interest rate model (requires fresh interest accrual)\n * @dev Governance function to update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) {\n // Used to store old model for use in the event that is emitted on success\n InterestRateModel oldInterestRateModel;\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n // Track the market's current interest rate model\n oldInterestRateModel = interestRateModel;\n\n // Ensure invoke newInterestRateModel.isInterestRateModel() returns true\n require(newInterestRateModel.isInterestRateModel(), \"marker method returned false\");\n\n // Set the interest rate model to newInterestRateModel\n interestRateModel = newInterestRateModel;\n\n // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel)\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee.\n * This may revert due to insufficient balance or insufficient allowance.\n */\n function doTransferIn(address from, uint amount) internal returns (uint);\n\n /**\n * @dev Performs a transfer out, ideally returning an explanatory error code upon failure rather than reverting.\n * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract.\n * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions.\n */\n function doTransferOut(address payable to, uint amount) internal;\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return Tuple of error code and the calculated balance or 0 if error code is non-zero\n */\n function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint) {\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint principalTimesIndex;\n uint result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, borrowIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, result);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the vToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Tuple of error code and calculated exchange rate scaled by 1e18\n */\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n uint _totalSupply = totalSupply;\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return (MathError.NO_ERROR, initialExchangeRateMantissa);\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply\n */\n uint totalCash = getCashPrior();\n uint cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(totalCash, totalBorrows, totalReserves);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, exchangeRate.mantissa);\n }\n }\n\n function ensureAllowed(string memory functionSig) private view {\n require(\n IAccessControlManagerV5(accessControlManager).isAllowedToCall(msg.sender, functionSig),\n \"access denied\"\n );\n }\n\n function ensureAdmin(address caller_) private view {\n require(caller_ == admin, \"Unauthorized\");\n }\n\n function ensureNoMathError(MathError mErr) private pure {\n require(mErr == MathError.NO_ERROR, \"math error\");\n }\n\n function ensureNonZeroAddress(address address_) private pure {\n require(address_ != address(0), \"zero address\");\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying owned by this contract\n */\n function getCashPrior() internal view returns (uint);\n}\n" + }, + "contracts/Tokens/VTokens/VTokenInterfaces.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../InterestRateModels/InterestRateModel.sol\";\n\ninterface IProtocolShareReserveV5 {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType kind) external;\n}\n\ncontract VTokenStorageBase {\n /**\n * @notice Container for borrow balance information\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\n */\n struct BorrowSnapshot {\n uint principal;\n uint interestIndex;\n }\n\n /**\n * @dev Guard variable for re-entrancy checks\n */\n bool internal _notEntered;\n\n /**\n * @notice EIP-20 token name for this token\n */\n string public name;\n\n /**\n * @notice EIP-20 token symbol for this token\n */\n string public symbol;\n\n /**\n * @notice EIP-20 token decimals for this token\n */\n uint8 public decimals;\n\n /**\n * @notice Maximum borrow rate that can ever be applied (.0005% / block)\n */\n\n uint internal constant borrowRateMaxMantissa = 0.0005e16;\n\n /**\n * @notice Maximum fraction of interest that can be set aside for reserves\n */\n uint internal constant reserveFactorMaxMantissa = 1e18;\n\n /**\n * @notice Administrator for this contract\n */\n address payable public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address payable public pendingAdmin;\n\n /**\n * @notice Contract which oversees inter-vToken operations\n */\n ComptrollerInterface public comptroller;\n\n /**\n * @notice Model which tells what the current interest rate should be\n */\n InterestRateModel public interestRateModel;\n\n /**\n * @notice Initial exchange rate used when minting the first VTokens (used when totalSupply = 0)\n */\n uint internal initialExchangeRateMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for reserves\n */\n uint public reserveFactorMantissa;\n\n /**\n * @notice Block number that interest was last accrued at\n */\n uint public accrualBlockNumber;\n\n /**\n * @notice Accumulator of the total earned interest rate since the opening of the market\n */\n uint public borrowIndex;\n\n /**\n * @notice Total amount of outstanding borrows of the underlying in this market\n */\n uint public totalBorrows;\n\n /**\n * @notice Total amount of reserves of the underlying held in this market\n */\n uint public totalReserves;\n\n /**\n * @notice Total number of tokens in circulation\n */\n uint public totalSupply;\n\n /**\n * @notice Official record of token balances for each account\n */\n mapping(address => uint) internal accountTokens;\n\n /**\n * @notice Approved token transfer amounts on behalf of others\n */\n mapping(address => mapping(address => uint)) internal transferAllowances;\n\n /**\n * @notice Mapping of account addresses to outstanding borrow balances\n */\n mapping(address => BorrowSnapshot) internal accountBorrows;\n\n /**\n * @notice Underlying asset for this VToken\n */\n address public underlying;\n\n /**\n * @notice Implementation address for this contract\n */\n address public implementation;\n\n /**\n * @notice delta block after which reserves will be reduced\n */\n uint public reduceReservesBlockDelta;\n\n /**\n * @notice last block number at which reserves were reduced\n */\n uint public reduceReservesBlockNumber;\n\n /**\n * @notice address of protocol share reserve contract\n */\n address payable public protocolShareReserve;\n\n /**\n * @notice address of accessControlManager\n */\n\n address public accessControlManager;\n}\n\ncontract VTokenStorage is VTokenStorageBase {\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\ncontract VTokenInterface is VTokenStorage {\n /**\n * @notice Indicator that this is a vToken contract (for inspection)\n */\n bool public constant isVToken = true;\n\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows);\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint mintAmount, uint mintTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are minted behalf by payer to receiver\n */\n event MintBehalf(address payer, address receiver, uint mintAmount, uint mintTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint redeemAmount, uint redeemTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are redeemed and fee is transferred\n */\n event RedeemFee(address redeemer, uint feeAmount, uint redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint repayAmount,\n address vTokenCollateral,\n uint seizeTokens\n );\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Event emitted when pendingAdmin is accepted, which means admin has been updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @notice Event emitted when comptroller is changed\n */\n event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address protocolShareReserve, uint reduceAmount, uint newTotalReserves);\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint amount);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint amount);\n\n /**\n * @notice Event emitted when block delta for reduce reserves get updated\n */\n event NewReduceReservesBlockDelta(uint256 oldReduceReservesBlockDelta, uint256 newReduceReservesBlockDelta);\n\n /**\n * @notice Event emitted when address of ProtocolShareReserve contract get updated\n */\n event NewProtocolShareReserve(address indexed oldProtocolShareReserve, address indexed newProtocolShareReserve);\n\n /**\n * @notice Failure event\n */\n event Failure(uint error, uint info, uint detail);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControlManager(address oldAccessControlAddress, address newAccessControlAddress);\n\n /*** User Interface ***/\n\n function transfer(address dst, uint amount) external returns (bool);\n\n function transferFrom(address src, address dst, uint amount) external returns (bool);\n\n function approve(address spender, uint amount) external returns (bool);\n\n function balanceOfUnderlying(address owner) external returns (uint);\n\n function totalBorrowsCurrent() external returns (uint);\n\n function borrowBalanceCurrent(address account) external returns (uint);\n\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint);\n\n /*** Admin Function ***/\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint);\n\n /*** Admin Function ***/\n function _acceptAdmin() external returns (uint);\n\n /*** Admin Function ***/\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint);\n\n /*** Admin Function ***/\n function _reduceReserves(uint reduceAmount) external returns (uint);\n\n function balanceOf(address owner) external view returns (uint);\n\n function allowance(address owner, address spender) external view returns (uint);\n\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint);\n\n function borrowRatePerBlock() external view returns (uint);\n\n function supplyRatePerBlock() external view returns (uint);\n\n function getCash() external view returns (uint);\n\n function exchangeRateCurrent() public returns (uint);\n\n function accrueInterest() public returns (uint);\n\n /*** Admin Function ***/\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint);\n\n /*** Admin Function ***/\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint);\n\n function borrowBalanceStored(address account) public view returns (uint);\n\n function exchangeRateStored() public view returns (uint);\n}\n\ncontract VBep20Interface {\n /*** User Interface ***/\n\n function mint(uint mintAmount) external returns (uint);\n\n function mintBehalf(address receiver, uint mintAmount) external returns (uint);\n\n function redeem(uint redeemTokens) external returns (uint);\n\n function redeemUnderlying(uint redeemAmount) external returns (uint);\n\n function borrow(uint borrowAmount) external returns (uint);\n\n function repayBorrow(uint repayAmount) external returns (uint);\n\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);\n\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint);\n\n /*** Admin Functions ***/\n\n function _addReserves(uint addAmount) external returns (uint);\n}\n\ncontract VDelegatorInterface {\n /**\n * @notice Emitted when implementation is changed\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public;\n}\n\ncontract VDelegateInterface {\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @dev Should revert if any issues arise which make it unfit for delegation\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public;\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public;\n}\n" + }, + "contracts/Tokens/XVS/IXVSVesting.sol": { + "content": "pragma solidity ^0.5.16;\n\ninterface IXVSVesting {\n /// @param _recipient Address of the Vesting. recipient entitled to claim the vested funds\n /// @param _amount Total number of tokens Vested\n function deposit(address _recipient, uint256 _amount) external;\n}\n" + }, + "contracts/Tokens/XVS/XVS.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/Tokenlock.sol\";\n\ncontract XVS is Tokenlock {\n /// @notice BEP-20 token name for this token\n string public constant name = \"Venus\";\n\n /// @notice BEP-20 token symbol for this token\n string public constant symbol = \"XVS\";\n\n /// @notice BEP-20 token decimals for this token\n uint8 public constant decimals = 18;\n\n /// @notice Total number of tokens in circulation\n uint public constant totalSupply = 30000000e18; // 30 million XVS\n\n /// @notice Allowance amounts on behalf of others\n mapping(address => mapping(address => uint96)) internal allowances;\n\n /// @notice Official record of token balances for each account\n mapping(address => uint96) internal balances;\n\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A checkpoint for marking number of votes from a given block\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice The standard BEP-20 transfer event\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /// @notice The standard BEP-20 approval event\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Construct a new XVS token\n * @param account The initial account to grant all the tokens\n */\n constructor(address account) public {\n balances[account] = uint96(totalSupply);\n emit Transfer(address(0), account, totalSupply);\n }\n\n /**\n * @notice Get the number of tokens `spender` is approved to spend on behalf of `account`\n * @param account The address of the account holding the funds\n * @param spender The address of the account spending the funds\n * @return The number of tokens approved\n */\n function allowance(address account, address spender) external view returns (uint) {\n return allowances[account][spender];\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param rawAmount The number of tokens that are approved (2^256-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint rawAmount) external validLock returns (bool) {\n uint96 amount;\n if (rawAmount == uint(-1)) {\n amount = uint96(-1);\n } else {\n amount = safe96(rawAmount, \"XVS::approve: amount exceeds 96 bits\");\n }\n\n allowances[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the number of tokens held by the `account`\n * @param account The address of the account to get the balance of\n * @return The number of tokens held\n */\n function balanceOf(address account) external view returns (uint) {\n return balances[account];\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint rawAmount) external validLock returns (bool) {\n uint96 amount = safe96(rawAmount, \"XVS::transfer: amount exceeds 96 bits\");\n _transferTokens(msg.sender, dst, amount);\n return true;\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint rawAmount) external validLock returns (bool) {\n address spender = msg.sender;\n uint96 spenderAllowance = allowances[src][spender];\n uint96 amount = safe96(rawAmount, \"XVS::approve: amount exceeds 96 bits\");\n\n if (spender != src && spenderAllowance != uint96(-1)) {\n uint96 newAllowance = sub96(\n spenderAllowance,\n amount,\n \"XVS::transferFrom: transfer amount exceeds spender allowance\"\n );\n allowances[src][spender] = newAllowance;\n\n emit Approval(src, spender, newAllowance);\n }\n\n _transferTokens(src, dst, amount);\n return true;\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) public validLock {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public validLock {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"XVS::delegateBySig: invalid signature\");\n require(nonce == nonces[signatory]++, \"XVS::delegateBySig: invalid nonce\");\n require(now <= expiry, \"XVS::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n /**\n * @notice Determine the prior number of votes for an account as of a block number\n * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n * @param account The address of the account to check\n * @param blockNumber The block number to get the vote balance at\n * @return The number of votes the account had as of the given block\n */\n function getPriorVotes(address account, uint blockNumber) public view returns (uint96) {\n require(blockNumber < block.number, \"XVS::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlock > blockNumber) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlock == blockNumber) {\n return cp.votes;\n } else if (cp.fromBlock < blockNumber) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = balances[delegator];\n delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _transferTokens(address src, address dst, uint96 amount) internal {\n require(src != address(0), \"XVS::_transferTokens: cannot transfer from the zero address\");\n require(dst != address(0), \"XVS::_transferTokens: cannot transfer to the zero address\");\n\n balances[src] = sub96(balances[src], amount, \"XVS::_transferTokens: transfer amount exceeds balance\");\n balances[dst] = add96(balances[dst], amount, \"XVS::_transferTokens: transfer amount overflows\");\n emit Transfer(src, dst, amount);\n\n _moveDelegates(delegates[src], delegates[dst], amount);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"XVS::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"XVS::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumber = safe32(block.number, \"XVS::_writeCheckpoint: block number exceeds 32 bits\");\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChanged(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVesting.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/IBEP20.sol\";\nimport \"../../Utils/SafeBEP20.sol\";\nimport \"./XVSVestingStorage.sol\";\nimport \"./XVSVestingProxy.sol\";\n\n/**\n * @title Venus's XVSVesting Contract\n * @author Venus\n */\ncontract XVSVesting is XVSVestingStorage {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice total vesting period for 1 year in seconds\n uint256 public constant TOTAL_VESTING_TIME = 365 * 24 * 60 * 60;\n\n /// @notice decimal precision for XVS\n uint256 public constant xvsDecimalsMultiplier = 1e18;\n\n /// @notice Emitted when XVSVested is claimed by recipient\n event VestedTokensClaimed(address recipient, uint256 amountClaimed);\n\n /// @notice Emitted when vrtConversionAddress is set\n event VRTConversionSet(address vrtConversionAddress);\n\n /// @notice Emitted when XVS is deposited for vesting\n event XVSVested(address indexed recipient, uint256 startTime, uint256 amount, uint256 withdrawnAmount);\n\n /// @notice Emitted when XVS is withdrawn by recipient\n event XVSWithdrawn(address recipient, uint256 amount);\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n constructor() public {}\n\n /**\n * @notice initialize XVSVestingStorage\n * @param _xvsAddress The XVSToken address\n */\n function initialize(address _xvsAddress) public {\n require(msg.sender == admin, \"only admin may initialize the XVSVesting\");\n require(initialized == false, \"XVSVesting is already initialized\");\n require(_xvsAddress != address(0), \"_xvsAddress cannot be Zero\");\n xvs = IBEP20(_xvsAddress);\n\n _notEntered = true;\n initialized = true;\n }\n\n modifier isInitialized() {\n require(initialized == true, \"XVSVesting is not initialized\");\n _;\n }\n\n /**\n * @notice sets VRTConverter Address\n * @dev Note: If VRTConverter is not set, then Vesting is not allowed\n * @param _vrtConversionAddress The VRTConverterProxy Address\n */\n function setVRTConverter(address _vrtConversionAddress) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_vrtConversionAddress != address(0), \"vrtConversionAddress cannot be Zero\");\n vrtConversionAddress = _vrtConversionAddress;\n emit VRTConversionSet(_vrtConversionAddress);\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier onlyVrtConverter() {\n require(msg.sender == vrtConversionAddress, \"only VRTConversion Address can call the function\");\n _;\n }\n\n modifier vestingExistCheck(address recipient) {\n require(vestings[recipient].length > 0, \"recipient doesnot have any vestingRecord\");\n _;\n }\n\n /**\n * @notice Deposit XVS for Vesting\n * @param recipient The vesting recipient\n * @param depositAmount XVS amount for deposit\n */\n function deposit(\n address recipient,\n uint depositAmount\n ) external isInitialized onlyVrtConverter nonZeroAddress(recipient) {\n require(depositAmount > 0, \"Deposit amount must be non-zero\");\n\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n\n VestingRecord memory vesting = VestingRecord({\n recipient: recipient,\n startTime: getCurrentTime(),\n amount: depositAmount,\n withdrawnAmount: 0\n });\n\n vestingsOfRecipient.push(vesting);\n\n emit XVSVested(recipient, vesting.startTime, vesting.amount, vesting.withdrawnAmount);\n }\n\n /**\n * @notice Withdraw Vested XVS of recipient\n */\n function withdraw() external isInitialized vestingExistCheck(msg.sender) {\n address recipient = msg.sender;\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n uint256 totalWithdrawableAmount = 0;\n\n for (uint i = 0; i < vestingCount; ++i) {\n VestingRecord storage vesting = vestingsOfRecipient[i];\n (, uint256 toWithdraw) = calculateWithdrawableAmount(\n vesting.amount,\n vesting.startTime,\n vesting.withdrawnAmount\n );\n if (toWithdraw > 0) {\n totalWithdrawableAmount = totalWithdrawableAmount.add(toWithdraw);\n vesting.withdrawnAmount = vesting.withdrawnAmount.add(toWithdraw);\n }\n }\n\n if (totalWithdrawableAmount > 0) {\n uint256 xvsBalance = xvs.balanceOf(address(this));\n require(xvsBalance >= totalWithdrawableAmount, \"Insufficient XVS for withdrawal\");\n emit XVSWithdrawn(recipient, totalWithdrawableAmount);\n xvs.safeTransfer(recipient, totalWithdrawableAmount);\n }\n }\n\n /**\n * @notice get Withdrawable XVS Amount\n * @param recipient The vesting recipient\n * @dev returns A tuple with totalWithdrawableAmount , totalVestedAmount and totalWithdrawnAmount\n */\n function getWithdrawableAmount(\n address recipient\n )\n public\n view\n isInitialized\n nonZeroAddress(recipient)\n vestingExistCheck(recipient)\n returns (uint256 totalWithdrawableAmount, uint256 totalVestedAmount, uint256 totalWithdrawnAmount)\n {\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n\n for (uint i = 0; i < vestingCount; i++) {\n VestingRecord storage vesting = vestingsOfRecipient[i];\n (uint256 vestedAmount, uint256 toWithdraw) = calculateWithdrawableAmount(\n vesting.amount,\n vesting.startTime,\n vesting.withdrawnAmount\n );\n totalVestedAmount = totalVestedAmount.add(vestedAmount);\n totalWithdrawableAmount = totalWithdrawableAmount.add(toWithdraw);\n totalWithdrawnAmount = totalWithdrawnAmount.add(vesting.withdrawnAmount);\n }\n\n return (totalWithdrawableAmount, totalVestedAmount, totalWithdrawnAmount);\n }\n\n /**\n * @notice get Withdrawable XVS Amount\n * @param amount Amount deposited for vesting\n * @param vestingStartTime time in epochSeconds at the time of vestingDeposit\n * @param withdrawnAmount XVSAmount withdrawn from VestedAmount\n * @dev returns A tuple with vestedAmount and withdrawableAmount\n */\n function calculateWithdrawableAmount(\n uint256 amount,\n uint256 vestingStartTime,\n uint256 withdrawnAmount\n ) internal view returns (uint256, uint256) {\n uint256 vestedAmount = calculateVestedAmount(amount, vestingStartTime, getCurrentTime());\n uint toWithdraw = vestedAmount.sub(withdrawnAmount);\n return (vestedAmount, toWithdraw);\n }\n\n /**\n * @notice calculate total vested amount\n * @param vestingAmount Amount deposited for vesting\n * @param vestingStartTime time in epochSeconds at the time of vestingDeposit\n * @param currentTime currentTime in epochSeconds\n * @return Total XVS amount vested\n */\n function calculateVestedAmount(\n uint256 vestingAmount,\n uint256 vestingStartTime,\n uint256 currentTime\n ) internal view returns (uint256) {\n if (currentTime < vestingStartTime) {\n return 0;\n } else if (currentTime > vestingStartTime.add(TOTAL_VESTING_TIME)) {\n return vestingAmount;\n } else {\n return (vestingAmount.mul(currentTime.sub(vestingStartTime))).div(TOTAL_VESTING_TIME);\n }\n }\n\n /**\n * @notice current block timestamp\n * @return blocktimestamp\n */\n function getCurrentTime() public view returns (uint256) {\n return block.timestamp;\n }\n\n /*** Admin Functions ***/\n function _become(XVSVestingProxy xvsVestingProxy) public {\n require(msg.sender == xvsVestingProxy.admin(), \"only proxy admin can change brains\");\n xvsVestingProxy._acceptImplementation();\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVestingProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./XVSVestingStorage.sol\";\n\ncontract XVSVestingProxy is XVSVestingAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means XVSVesting implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(\n address implementation_,\n address _xvsAddress\n ) public nonZeroAddress(implementation_) nonZeroAddress(_xvsAddress) {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(implementation_, abi.encodeWithSignature(\"initialize(address)\", _xvsAddress));\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"XVSVestingProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"XVSVestingProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal nonZeroAddress(callee) returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(\n address newPendingImplementation\n ) public nonZeroAddress(newPendingImplementation) {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRT Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) public nonZeroAddress(newPendingAdmin) {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n require(newPendingAdmin != pendingAdmin, \"New pendingAdmin can not be same as the previous one\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVestingStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/SafeMath.sol\";\nimport \"../../Utils/IBEP20.sol\";\n\ncontract XVSVestingAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of XVSVesting\n */\n address public implementation;\n\n /**\n * @notice Pending brains of XVSVesting\n */\n address public pendingImplementation;\n}\n\ncontract XVSVestingStorage is XVSVestingAdminStorage {\n struct VestingRecord {\n address recipient;\n uint256 startTime;\n uint256 amount;\n uint256 withdrawnAmount;\n }\n\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice indicator to check if the contract is initialized\n bool public initialized;\n\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice VRTConversion Contract Address\n address public vrtConversionAddress;\n\n /// @notice mapping of VestingRecord(s) for user(s)\n mapping(address => VestingRecord[]) public vestings;\n}\n" + }, + "contracts/Utils/Address.sol": { + "content": "pragma solidity ^0.5.5;\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 function isContract(address account) internal view returns (bool) {\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n // for accounts without code, i.e. `keccak256('')`\n bytes32 codehash;\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n codehash := extcodehash(account)\n }\n return (codehash != accountHash && codehash != 0x0);\n }\n\n /**\n * @dev Converts an `address` into `address payable`. Note that this is\n * simply a type cast: the actual underlying value is not changed.\n *\n * _Available since v2.4.0._\n */\n function toPayable(address account) internal pure returns (address payable) {\n return address(uint160(account));\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 * _Available since v2.4.0._\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-call-value\n // solium-disable-next-line security/no-call-value\n (bool success, ) = recipient.call.value(amount)(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n}\n" + }, + "contracts/Utils/CarefulMath.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Careful Math\n * @author Venus\n * @notice Derived from OpenZeppelin's SafeMath library\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\n */\ncontract CarefulMath {\n /**\n * @dev Possible error codes that we can return\n */\n enum MathError {\n NO_ERROR,\n DIVISION_BY_ZERO,\n INTEGER_OVERFLOW,\n INTEGER_UNDERFLOW\n }\n\n /**\n * @dev Multiplies two numbers, returns an error on overflow.\n */\n function mulUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (a == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n uint c = a * b;\n\n if (c / a != b) {\n return (MathError.INTEGER_OVERFLOW, 0);\n } else {\n return (MathError.NO_ERROR, c);\n }\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function divUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (b == 0) {\n return (MathError.DIVISION_BY_ZERO, 0);\n }\n\n return (MathError.NO_ERROR, a / b);\n }\n\n /**\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\n */\n function subUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (b <= a) {\n return (MathError.NO_ERROR, a - b);\n } else {\n return (MathError.INTEGER_UNDERFLOW, 0);\n }\n }\n\n /**\n * @dev Adds two numbers, returns an error on overflow.\n */\n function addUInt(uint a, uint b) internal pure returns (MathError, uint) {\n uint c = a + b;\n\n if (c >= a) {\n return (MathError.NO_ERROR, c);\n } else {\n return (MathError.INTEGER_OVERFLOW, 0);\n }\n }\n\n /**\n * @dev add a and b and then subtract c\n */\n function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) {\n (MathError err0, uint sum) = addUInt(a, b);\n\n if (err0 != MathError.NO_ERROR) {\n return (err0, 0);\n }\n\n return subUInt(sum, c);\n }\n}\n" + }, + "contracts/Utils/Context.sol": { + "content": "pragma solidity ^0.5.16;\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 GSN 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 */\ncontract Context {\n // Empty internal constructor, to prevent people from mistakenly deploying\n // an instance of this contract, which should be used via inheritance.\n constructor() internal {}\n\n function _msgSender() internal view returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n" + }, + "contracts/Utils/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// Adapted from OpenZeppelin Contracts v4.3.2 (utils/cryptography/ECDSA.sol)\n\n// SPDX-Copyright-Text: OpenZeppelin, 2021\n// SPDX-Copyright-Text: Venus, 2021\n\npragma solidity ^0.5.16;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\ncontract ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n}\n" + }, + "contracts/Utils/ErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract ComptrollerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n COMPTROLLER_MISMATCH,\n INSUFFICIENT_SHORTFALL,\n INSUFFICIENT_LIQUIDITY,\n INVALID_CLOSE_FACTOR,\n INVALID_COLLATERAL_FACTOR,\n INVALID_LIQUIDATION_INCENTIVE,\n MARKET_NOT_ENTERED, // no longer possible\n MARKET_NOT_LISTED,\n MARKET_ALREADY_LISTED,\n MATH_ERROR,\n NONZERO_BORROW_BALANCE,\n PRICE_ERROR,\n REJECTION,\n SNAPSHOT_ERROR,\n TOO_MANY_ASSETS,\n TOO_MUCH_REPAY,\n INSUFFICIENT_BALANCE_FOR_VAI,\n MARKET_NOT_COLLATERAL\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n EXIT_MARKET_BALANCE_OWED,\n EXIT_MARKET_REJECTION,\n SET_CLOSE_FACTOR_OWNER_CHECK,\n SET_CLOSE_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_NO_EXISTS,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\n SET_IMPLEMENTATION_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\n SET_MAX_ASSETS_OWNER_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_PRICE_ORACLE_OWNER_CHECK,\n SUPPORT_MARKET_EXISTS,\n SUPPORT_MARKET_OWNER_CHECK,\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\n SET_VAI_MINT_RATE_CHECK,\n SET_VAICONTROLLER_OWNER_CHECK,\n SET_MINTED_VAI_REJECTION,\n SET_TREASURY_OWNER_CHECK,\n UNLIST_MARKET_NOT_LISTED\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n\ncontract TokenErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n BAD_INPUT,\n COMPTROLLER_REJECTION,\n COMPTROLLER_CALCULATION_ERROR,\n INTEREST_RATE_MODEL_ERROR,\n INVALID_ACCOUNT_PAIR,\n INVALID_CLOSE_AMOUNT_REQUESTED,\n INVALID_COLLATERAL_FACTOR,\n MATH_ERROR,\n MARKET_NOT_FRESH,\n MARKET_NOT_LISTED,\n TOKEN_INSUFFICIENT_ALLOWANCE,\n TOKEN_INSUFFICIENT_BALANCE,\n TOKEN_INSUFFICIENT_CASH,\n TOKEN_TRANSFER_IN_FAILED,\n TOKEN_TRANSFER_OUT_FAILED,\n TOKEN_PRICE_ERROR\n }\n\n /*\n * Note: FailureInfo (but not Error) is kept in alphabetical order\n * This is because FailureInfo grows significantly faster, and\n * the order of Error has some meaning, while the order of FailureInfo\n * is entirely arbitrary.\n */\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n BORROW_ACCRUE_INTEREST_FAILED,\n BORROW_CASH_NOT_AVAILABLE,\n BORROW_FRESHNESS_CHECK,\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n BORROW_MARKET_NOT_LISTED,\n BORROW_COMPTROLLER_REJECTION,\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n LIQUIDATE_COMPTROLLER_REJECTION,\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n LIQUIDATE_FRESHNESS_CHECK,\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_ACCRUE_INTEREST_FAILED,\n MINT_COMPTROLLER_REJECTION,\n MINT_EXCHANGE_CALCULATION_FAILED,\n MINT_EXCHANGE_RATE_READ_FAILED,\n MINT_FRESHNESS_CHECK,\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n MINT_TRANSFER_IN_FAILED,\n MINT_TRANSFER_IN_NOT_POSSIBLE,\n REDEEM_ACCRUE_INTEREST_FAILED,\n REDEEM_COMPTROLLER_REJECTION,\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\n REDEEM_EXCHANGE_RATE_READ_FAILED,\n REDEEM_FRESHNESS_CHECK,\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\n REDUCE_RESERVES_ADMIN_CHECK,\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\n REDUCE_RESERVES_FRESH_CHECK,\n REDUCE_RESERVES_VALIDATION,\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_COMPTROLLER_REJECTION,\n REPAY_BORROW_FRESHNESS_CHECK,\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COMPTROLLER_OWNER_CHECK,\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\n SET_MAX_ASSETS_OWNER_CHECK,\n SET_ORACLE_MARKET_NOT_LISTED,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\n SET_RESERVE_FACTOR_ADMIN_CHECK,\n SET_RESERVE_FACTOR_FRESH_CHECK,\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\n TRANSFER_COMPTROLLER_REJECTION,\n TRANSFER_NOT_ALLOWED,\n TRANSFER_NOT_ENOUGH,\n TRANSFER_TOO_MUCH,\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\n ADD_RESERVES_FRESH_CHECK,\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE,\n TOKEN_GET_UNDERLYING_PRICE_ERROR,\n REPAY_VAI_COMPTROLLER_REJECTION,\n REPAY_VAI_FRESHNESS_CHECK,\n VAI_MINT_EXCHANGE_CALCULATION_FAILED,\n SFT_MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n\ncontract VAIControllerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED, // The sender is not authorized to perform this action.\n REJECTION, // The action would violate the comptroller, vaicontroller policy.\n SNAPSHOT_ERROR, // The comptroller could not get the account borrows and exchange rate from the market.\n PRICE_ERROR, // The comptroller could not obtain a required price of an asset.\n MATH_ERROR, // A math calculation error occurred.\n INSUFFICIENT_BALANCE_FOR_VAI // Caller does not have sufficient balance to mint VAI.\n }\n\n enum FailureInfo {\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_COMPTROLLER_OWNER_CHECK,\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n VAI_MINT_REJECTION,\n VAI_BURN_REJECTION,\n VAI_LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n VAI_LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n VAI_LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n VAI_LIQUIDATE_COMPTROLLER_REJECTION,\n VAI_LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n VAI_LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n VAI_LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n VAI_LIQUIDATE_FRESHNESS_CHECK,\n VAI_LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n VAI_LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n VAI_LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n VAI_LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n VAI_LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n VAI_LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n VAI_LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_FEE_CALCULATION_FAILED,\n SET_TREASURY_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/Utils/Exponential.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./CarefulMath.sol\";\nimport \"./ExponentialNoError.sol\";\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Venus\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract Exponential is CarefulMath, ExponentialNoError {\n /**\n * @dev Creates an exponential from numerator and denominator values.\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\n * or if `denom` is zero.\n */\n function getExp(uint num, uint denom) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint scaledNumerator) = mulUInt(num, expScale);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n (MathError err1, uint rational) = divUInt(scaledNumerator, denom);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\n }\n\n /**\n * @dev Adds two exponentials, returning a new exponential.\n */\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint result) = addUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Subtracts two exponentials, returning a new exponential.\n */\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint result) = subUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, returning a new Exp.\n */\n function mulScalar(Exp memory a, uint scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mulScalarTruncate(Exp memory a, uint scalar) internal pure returns (MathError, uint) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(product));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) internal pure returns (MathError, uint) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return addUInt(truncate(product), addend);\n }\n\n /**\n * @dev Divide an Exp by a scalar, returning a new Exp.\n */\n function divScalar(Exp memory a, uint scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\n }\n\n /**\n * @dev Divide a scalar by an Exp, returning a new Exp.\n */\n function divScalarByExp(uint scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\n /*\n We are doing this as:\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\n\n How it works:\n Exp = a / b;\n Scalar = s;\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\n */\n (MathError err0, uint numerator) = mulUInt(expScale, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n return getExp(numerator, divisor.mantissa);\n }\n\n /**\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\n */\n function divScalarByExpTruncate(uint scalar, Exp memory divisor) internal pure returns (MathError, uint) {\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(fraction));\n }\n\n /**\n * @dev Multiplies two exponentials, returning a new exponential.\n */\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n // We add half the scale before dividing so that we get rounding instead of truncation.\n // See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\n (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale);\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\n assert(err2 == MathError.NO_ERROR);\n\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\n }\n\n /**\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\n */\n function mulExp(uint a, uint b) internal pure returns (MathError, Exp memory) {\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\n }\n\n /**\n * @dev Multiplies three exponentials, returning a new exponential.\n */\n function mulExp3(Exp memory a, Exp memory b, Exp memory c) internal pure returns (MathError, Exp memory) {\n (MathError err, Exp memory ab) = mulExp(a, b);\n if (err != MathError.NO_ERROR) {\n return (err, ab);\n }\n return mulExp(ab, c);\n }\n\n /**\n * @dev Divides two exponentials, returning a new exponential.\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\n */\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n return getExp(a.mantissa, b.mantissa);\n }\n}\n" + }, + "contracts/Utils/ExponentialNoError.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract ExponentialNoError {\n uint internal constant expScale = 1e18;\n uint internal constant doubleScale = 1e36;\n uint internal constant halfExpScale = expScale / 2;\n uint internal constant mantissaOne = expScale;\n\n struct Exp {\n uint mantissa;\n }\n\n struct Double {\n uint mantissa;\n }\n\n /**\n * @dev Truncates the given exp to a whole number value.\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\n */\n function truncate(Exp memory exp) internal pure returns (uint) {\n // Note: We are not using careful math here as we're performing a division that cannot fail\n return exp.mantissa / expScale;\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mul_ScalarTruncate(Exp memory a, uint scalar) internal pure returns (uint) {\n Exp memory product = mul_(a, scalar);\n return truncate(product);\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mul_ScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) internal pure returns (uint) {\n Exp memory product = mul_(a, scalar);\n return add_(truncate(product), addend);\n }\n\n /**\n * @dev Checks if first Exp is less than second Exp.\n */\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa < right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp <= right Exp.\n */\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa <= right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp > right Exp.\n */\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa > right.mantissa;\n }\n\n /**\n * @dev returns true if Exp is exactly zero\n */\n function isZeroExp(Exp memory value) internal pure returns (bool) {\n return value.mantissa == 0;\n }\n\n function safe224(uint n, string memory errorMessage) internal pure returns (uint224) {\n require(n < 2 ** 224, errorMessage);\n return uint224(n);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(uint a, uint b) internal pure returns (uint) {\n return add_(a, b, \"addition overflow\");\n }\n\n function add_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n uint c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(uint a, uint b) internal pure returns (uint) {\n return sub_(a, b, \"subtraction underflow\");\n }\n\n function sub_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\n }\n\n function mul_(Exp memory a, uint b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint a, Exp memory b) internal pure returns (uint) {\n return mul_(a, b.mantissa) / expScale;\n }\n\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\n }\n\n function mul_(Double memory a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint a, Double memory b) internal pure returns (uint) {\n return mul_(a, b.mantissa) / doubleScale;\n }\n\n function mul_(uint a, uint b) internal pure returns (uint) {\n return mul_(a, b, \"multiplication overflow\");\n }\n\n function mul_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n if (a == 0 || b == 0) {\n return 0;\n }\n uint c = a * b;\n require(c / a == b, errorMessage);\n return c;\n }\n\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\n }\n\n function div_(Exp memory a, uint b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint a, Exp memory b) internal pure returns (uint) {\n return div_(mul_(a, expScale), b.mantissa);\n }\n\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\n }\n\n function div_(Double memory a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint a, Double memory b) internal pure returns (uint) {\n return div_(mul_(a, doubleScale), b.mantissa);\n }\n\n function div_(uint a, uint b) internal pure returns (uint) {\n return div_(a, b, \"divide by zero\");\n }\n\n function div_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n function fraction(uint a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\n }\n}\n" + }, + "contracts/Utils/IBEP20.sol": { + "content": "pragma solidity ^0.5.0;\n\n/**\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\n * the optional functions; to access them see {BEP20Detailed}.\n */\ninterface IBEP20 {\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 `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\n\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" + }, + "contracts/Utils/Ownable.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\ncontract 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() internal {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view 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 onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = 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 onlyOwner {\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n */\n function _transferOwnership(address newOwner) internal {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n}\n" + }, + "contracts/Utils/Owned.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract Owned {\n address public owner;\n\n event OwnershipTransferred(address indexed _from, address indexed _to);\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Should be owner\");\n _;\n }\n\n function transferOwnership(address newOwner) public onlyOwner {\n owner = newOwner;\n emit OwnershipTransferred(owner, newOwner);\n }\n}\n" + }, + "contracts/Utils/SafeBEP20.sol": { + "content": "pragma solidity ^0.5.0;\n\nimport \"./SafeMath.sol\";\nimport \"./IBEP20.sol\";\nimport \"./Address.sol\";\n\n/**\n * @title SafeBEP20\n * @dev Wrappers around BEP20 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 SafeBEP20 for BEP20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeBEP20 {\n using SafeMath for uint256;\n using Address for address;\n\n function safeTransfer(IBEP20 token, address to, uint256 value) internal {\n callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(IBEP20 token, address from, address to, uint256 value) internal {\n callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n function safeApprove(IBEP20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeBEP20: approve from non-zero to non-zero allowance\"\n );\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).sub(\n value,\n \"SafeBEP20: decreased allowance below zero\"\n );\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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(IBEP20 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.\n\n // A Solidity high level call has three parts:\n // 1. The target address is checked to verify it contains contract code\n // 2. The call itself is made, and success asserted\n // 3. The return value is decoded, which in turn checks the size of the returned data.\n // solhint-disable-next-line max-line-length\n require(address(token).isContract(), \"SafeBEP20: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = address(token).call(data);\n require(success, \"SafeBEP20: low-level call failed\");\n\n if (returndata.length > 0) {\n // Return data is optional\n // solhint-disable-next-line max-line-length\n require(abi.decode(returndata, (bool)), \"SafeBEP20: BEP20 operation did not succeed\");\n }\n }\n}\n" + }, + "contracts/Utils/SafeCast.sol": { + "content": "pragma solidity ^0.5.16;\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 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 < 2 ** 128, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(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 < 2 ** 64, \"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 < 2 ** 32, \"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 < 2 ** 16, \"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 < 2 ** 8, \"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 >= -2 ** 127 && value < 2 ** 127, \"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 >= -2 ** 63 && value < 2 ** 63, \"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 >= -2 ** 31 && value < 2 ** 31, \"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 >= -2 ** 15 && value < 2 ** 15, \"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 >= -2 ** 7 && value < 2 ** 7, \"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 require(value < 2 ** 255, \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "contracts/Utils/SafeMath.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return add(a, b, \"SafeMath: addition overflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, errorMessage);\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0, errorMessage);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return mod(a, b, \"SafeMath: modulo by zero\");\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts with custom message when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b != 0, errorMessage);\n return a % b;\n }\n}\n" + }, + "contracts/Utils/Tokenlock.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./Owned.sol\";\n\ncontract Tokenlock is Owned {\n /// @notice Indicates if token is locked\n uint8 internal isLocked = 0;\n\n event Freezed();\n event UnFreezed();\n\n modifier validLock() {\n require(isLocked == 0, \"Token is locked\");\n _;\n }\n\n function freeze() public onlyOwner {\n isLocked = 1;\n\n emit Freezed();\n }\n\n function unfreeze() public onlyOwner {\n isLocked = 0;\n\n emit UnFreezed();\n }\n}\n" + }, + "contracts/VAIVault/VAIVault.sol": { + "content": "pragma solidity 0.5.16;\n\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./VAIVaultStorage.sol\";\nimport \"./VAIVaultErrorReporter.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\nimport { VAIVaultProxy } from \"./VAIVaultProxy.sol\";\n\n/**\n * @title VAI Vault\n * @author Venus\n * @notice The VAI Vault is configured for users to stake VAI And receive XVS as a reward.\n */\ncontract VAIVault is VAIVaultStorage, AccessControlledV5 {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice Event emitted when VAI deposit\n event Deposit(address indexed user, uint256 amount);\n\n /// @notice Event emitted when VAI withrawal\n event Withdraw(address indexed user, uint256 amount);\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @dev Prevents functions to execute when vault is paused.\n */\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @notice Pause vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Deposit VAI to VAIVault for XVS allocation\n * @param _amount The amount to deposit to vault\n */\n function deposit(uint256 _amount) external nonReentrant isActive {\n UserInfo storage user = userInfo[msg.sender];\n\n updateVault();\n\n // Transfer pending tokens to user\n updateAndPayOutPending(msg.sender);\n\n // Transfer in the amounts from user\n if (_amount > 0) {\n vai.safeTransferFrom(address(msg.sender), address(this), _amount);\n user.amount = user.amount.add(_amount);\n }\n\n user.rewardDebt = user.amount.mul(accXVSPerShare).div(1e18);\n emit Deposit(msg.sender, _amount);\n }\n\n /**\n * @notice Withdraw VAI from VAIVault\n * @param _amount The amount to withdraw from vault\n */\n function withdraw(uint256 _amount) external nonReentrant isActive {\n _withdraw(msg.sender, _amount);\n }\n\n /**\n * @notice Claim XVS from VAIVault\n */\n function claim() external nonReentrant isActive {\n _withdraw(msg.sender, 0);\n }\n\n /**\n * @notice Claim XVS from VAIVault\n * @param account The account for which to claim XVS\n */\n function claim(address account) external nonReentrant isActive {\n _withdraw(account, 0);\n }\n\n /**\n * @notice Low level withdraw function\n * @param account The account to withdraw from vault\n * @param _amount The amount to withdraw from vault\n */\n function _withdraw(address account, uint256 _amount) internal {\n UserInfo storage user = userInfo[account];\n require(user.amount >= _amount, \"withdraw: not good\");\n\n updateVault();\n updateAndPayOutPending(account); // Update balances of account this is not withdrawal but claiming XVS farmed\n\n if (_amount > 0) {\n user.amount = user.amount.sub(_amount);\n vai.safeTransfer(address(account), _amount);\n }\n user.rewardDebt = user.amount.mul(accXVSPerShare).div(1e18);\n\n emit Withdraw(account, _amount);\n }\n\n /**\n * @notice View function to see pending XVS on frontend\n * @param _user The user to see pending XVS\n * @return Amount of XVS the user can claim\n */\n function pendingXVS(address _user) public view returns (uint256) {\n UserInfo storage user = userInfo[_user];\n\n return user.amount.mul(accXVSPerShare).div(1e18).sub(user.rewardDebt);\n }\n\n /**\n * @notice Update and pay out pending XVS to user\n * @param account The user to pay out\n */\n function updateAndPayOutPending(address account) internal {\n uint256 pending = pendingXVS(account);\n\n if (pending > 0) {\n safeXVSTransfer(account, pending);\n }\n }\n\n /**\n * @notice Safe XVS transfer function, just in case if rounding error causes pool to not have enough XVS\n * @param _to The address that XVS to be transfered\n * @param _amount The amount that XVS to be transfered\n */\n function safeXVSTransfer(address _to, uint256 _amount) internal {\n uint256 xvsBal = xvs.balanceOf(address(this));\n\n if (_amount > xvsBal) {\n xvs.transfer(_to, xvsBal);\n xvsBalance = xvs.balanceOf(address(this));\n } else {\n xvs.transfer(_to, _amount);\n xvsBalance = xvs.balanceOf(address(this));\n }\n }\n\n /**\n * @notice Function that updates pending rewards\n */\n function updatePendingRewards() public isActive {\n uint256 newRewards = xvs.balanceOf(address(this)).sub(xvsBalance);\n\n if (newRewards > 0) {\n xvsBalance = xvs.balanceOf(address(this)); // If there is no change the balance didn't change\n pendingRewards = pendingRewards.add(newRewards);\n }\n }\n\n /**\n * @notice Update reward variables to be up-to-date\n */\n function updateVault() internal {\n updatePendingRewards();\n\n uint256 vaiBalance = vai.balanceOf(address(this));\n if (vaiBalance == 0) {\n // avoids division by 0 errors\n return;\n }\n\n accXVSPerShare = accXVSPerShare.add(pendingRewards.mul(1e18).div(vaiBalance));\n pendingRewards = 0;\n }\n\n /*** Admin Functions ***/\n\n function _become(VAIVaultProxy vaiVaultProxy) external {\n require(msg.sender == vaiVaultProxy.admin(), \"only proxy admin can change brains\");\n require(vaiVaultProxy._acceptImplementation() == 0, \"change not authorized\");\n }\n\n function setVenusInfo(address _xvs, address _vai) external onlyAdmin {\n require(_xvs != address(0) && _vai != address(0), \"addresses must not be zero\");\n require(address(xvs) == address(0) && address(vai) == address(0), \"addresses already set\");\n xvs = IBEP20(_xvs);\n vai = IBEP20(_vai);\n\n _notEntered = true;\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract VAIVaultErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VAIVaultStorage.sol\";\nimport \"./VAIVaultErrorReporter.sol\";\n\n/**\n * @title VAI Vault Proxy\n * @author Venus\n * @notice Proxy contract for the VAI Vault\n */\ncontract VAIVaultProxy is VAIVaultAdminStorage, VAIVaultErrorReporter {\n /**\n * @notice Emitted when pendingVAIVaultImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingVAIVaultImplementation is accepted, which means VAI Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingVAIVaultImplementation;\n\n pendingVAIVaultImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of VAI Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingVAIVaultImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = vaiVaultImplementation;\n address oldPendingImplementation = pendingVAIVaultImplementation;\n\n vaiVaultImplementation = pendingVAIVaultImplementation;\n\n pendingVAIVaultImplementation = address(0);\n\n emit NewImplementation(oldImplementation, vaiVaultImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = vaiVaultImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\n\ncontract VAIVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VAI Vault\n */\n address public vaiVaultImplementation;\n\n /**\n * @notice Pending brains of VAI Vault\n */\n address public pendingVAIVaultImplementation;\n}\n\ncontract VAIVaultStorage is VAIVaultAdminStorage {\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice The VAI TOKEN!\n IBEP20 public vai;\n\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice XVS balance of vault\n uint256 public xvsBalance;\n\n /// @notice Accumulated XVS per share\n uint256 public accXVSPerShare;\n\n //// pending rewards awaiting anyone to update\n uint256 public pendingRewards;\n\n /// @notice Info of each user.\n struct UserInfo {\n uint256 amount;\n uint256 rewardDebt;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => UserInfo) public userInfo;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "contracts/VRTVault/VRTVault.sol": { + "content": "pragma solidity 0.5.16;\n\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./VRTVaultStorage.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\n\ninterface IVRTVaultProxy {\n function _acceptImplementation() external;\n\n function admin() external returns (address);\n}\n\ncontract VRTVault is VRTVaultStorage, AccessControlledV5 {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The upper bound for lastAccruingBlock. Close to year 3,000, considering 3 seconds per block. Used to avoid a value absurdly high\n uint256 public constant MAX_LAST_ACCRUING_BLOCK = 9999999999;\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n /// @notice Event emitted on VRT deposit\n event Deposit(address indexed user, uint256 amount);\n\n /// @notice Event emitted when accruedInterest and VRT PrincipalAmount is withrawn\n event Withdraw(\n address indexed user,\n uint256 withdrawnAmount,\n uint256 totalPrincipalAmount,\n uint256 accruedInterest\n );\n\n /// @notice Event emitted when Admin withdraw BEP20 token from contract\n event WithdrawToken(address indexed tokenAddress, address indexed receiver, uint256 amount);\n\n /// @notice Event emitted when accruedInterest is claimed\n event Claim(address indexed user, uint256 interestAmount);\n\n /// @notice Event emitted when lastAccruingBlock state variable changes\n event LastAccruingBlockChanged(uint256 oldLastAccruingBlock, uint256 newLastAccruingBlock);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin allowed\");\n _;\n }\n\n function initialize(address _vrtAddress, uint256 _interestRatePerBlock) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_vrtAddress != address(0), \"vrtAddress cannot be Zero\");\n require(interestRatePerBlock == 0, \"Vault may only be initialized once\");\n\n // Set initial exchange rate\n interestRatePerBlock = _interestRatePerBlock;\n require(interestRatePerBlock > 0, \"interestRate Per Block must be greater than zero.\");\n\n // Set the VRT\n vrt = IBEP20(_vrtAddress);\n _notEntered = true;\n }\n\n modifier isInitialized() {\n require(interestRatePerBlock > 0, \"Vault is not initialized\");\n _;\n }\n\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n modifier userHasPosition(address userAddress) {\n UserInfo storage user = userInfo[userAddress];\n require(user.userAddress != address(0), \"User does not have any position in the Vault.\");\n _;\n }\n\n /**\n * @notice Pause vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Deposit VRT to VRTVault for a fixed-interest-rate\n * @param depositAmount The amount to deposit to vault\n */\n function deposit(uint256 depositAmount) external nonReentrant isInitialized isActive {\n require(depositAmount > 0, \"Deposit amount must be non-zero\");\n\n address userAddress = msg.sender;\n UserInfo storage user = userInfo[userAddress];\n\n if (user.userAddress == address(0)) {\n user.userAddress = userAddress;\n user.totalPrincipalAmount = depositAmount;\n } else {\n // accrue Interest and transfer to the user\n uint256 accruedInterest = computeAccruedInterest(user.totalPrincipalAmount, user.accrualStartBlockNumber);\n\n user.totalPrincipalAmount = user.totalPrincipalAmount.add(depositAmount);\n\n if (accruedInterest > 0) {\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(\n vrtBalance >= accruedInterest,\n \"Failed to transfer accruedInterest, Insufficient VRT in Vault.\"\n );\n emit Claim(userAddress, accruedInterest);\n vrt.safeTransfer(user.userAddress, accruedInterest);\n }\n }\n\n uint256 currentBlock_ = getBlockNumber();\n if (lastAccruingBlock > currentBlock_) {\n user.accrualStartBlockNumber = currentBlock_;\n } else {\n user.accrualStartBlockNumber = lastAccruingBlock;\n }\n emit Deposit(userAddress, depositAmount);\n vrt.safeTransferFrom(userAddress, address(this), depositAmount);\n }\n\n /**\n * @notice get accruedInterest of the user's VRTDeposits in the Vault\n * @param userAddress Address of User in the the Vault\n * @return The interest accrued, in VRT\n */\n function getAccruedInterest(\n address userAddress\n ) public view nonZeroAddress(userAddress) isInitialized returns (uint256) {\n UserInfo storage user = userInfo[userAddress];\n if (user.accrualStartBlockNumber == 0) {\n return 0;\n }\n\n return computeAccruedInterest(user.totalPrincipalAmount, user.accrualStartBlockNumber);\n }\n\n /**\n * @notice get accruedInterest of the user's VRTDeposits in the Vault\n * @param totalPrincipalAmount of the User\n * @param accrualStartBlockNumber of the User\n * @return The interest accrued, in VRT\n */\n function computeAccruedInterest(\n uint256 totalPrincipalAmount,\n uint256 accrualStartBlockNumber\n ) internal view isInitialized returns (uint256) {\n uint256 blockNumber = getBlockNumber();\n uint256 _lastAccruingBlock = lastAccruingBlock;\n\n if (blockNumber > _lastAccruingBlock) {\n blockNumber = _lastAccruingBlock;\n }\n\n if (accrualStartBlockNumber == 0 || accrualStartBlockNumber >= blockNumber) {\n return 0;\n }\n\n // Number of blocks since deposit\n uint256 blockDelta = blockNumber.sub(accrualStartBlockNumber);\n uint256 accruedInterest = (totalPrincipalAmount.mul(interestRatePerBlock).mul(blockDelta)).div(1e18);\n return accruedInterest;\n }\n\n /**\n * @notice claim the accruedInterest of the user's VRTDeposits in the Vault\n */\n function claim() external nonReentrant isInitialized userHasPosition(msg.sender) isActive {\n _claim(msg.sender);\n }\n\n /**\n * @notice claim the accruedInterest of the user's VRTDeposits in the Vault\n * @param account The account for which to claim rewards\n */\n function claim(address account) external nonReentrant isInitialized userHasPosition(account) isActive {\n _claim(account);\n }\n\n /**\n * @notice Low level claim function\n * @param account The account for which to claim rewards\n */\n function _claim(address account) internal {\n uint256 accruedInterest = getAccruedInterest(account);\n if (accruedInterest > 0) {\n UserInfo storage user = userInfo[account];\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(vrtBalance >= accruedInterest, \"Failed to transfer VRT, Insufficient VRT in Vault.\");\n emit Claim(account, accruedInterest);\n uint256 currentBlock_ = getBlockNumber();\n if (lastAccruingBlock > currentBlock_) {\n user.accrualStartBlockNumber = currentBlock_;\n } else {\n user.accrualStartBlockNumber = lastAccruingBlock;\n }\n vrt.safeTransfer(user.userAddress, accruedInterest);\n }\n }\n\n /**\n * @notice withdraw accruedInterest and totalPrincipalAmount of the user's VRTDeposit in the Vault\n */\n function withdraw() external nonReentrant isInitialized userHasPosition(msg.sender) isActive {\n address userAddress = msg.sender;\n uint256 accruedInterest = getAccruedInterest(userAddress);\n\n UserInfo storage user = userInfo[userAddress];\n\n uint256 totalPrincipalAmount = user.totalPrincipalAmount;\n uint256 vrtForWithdrawal = accruedInterest.add(totalPrincipalAmount);\n user.totalPrincipalAmount = 0;\n user.accrualStartBlockNumber = getBlockNumber();\n\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(vrtBalance >= vrtForWithdrawal, \"Failed to transfer VRT, Insufficient VRT in Vault.\");\n\n emit Withdraw(userAddress, vrtForWithdrawal, totalPrincipalAmount, accruedInterest);\n vrt.safeTransfer(user.userAddress, vrtForWithdrawal);\n }\n\n /**\n * @notice withdraw BEP20 tokens from the contract to a recipient address.\n * @param tokenAddress address of the BEP20 token\n * @param receiver recipient of the BEP20 token\n * @param amount tokenAmount\n */\n function withdrawBep20(\n address tokenAddress,\n address receiver,\n uint256 amount\n ) external isInitialized nonZeroAddress(tokenAddress) nonZeroAddress(receiver) {\n _checkAccessAllowed(\"withdrawBep20(address,address,uint256)\");\n require(amount > 0, \"amount is invalid\");\n IBEP20 token = IBEP20(tokenAddress);\n require(amount <= token.balanceOf(address(this)), \"Insufficient amount in Vault\");\n emit WithdrawToken(tokenAddress, receiver, amount);\n token.safeTransfer(receiver, amount);\n }\n\n function setLastAccruingBlock(uint256 _lastAccruingBlock) external {\n _checkAccessAllowed(\"setLastAccruingBlock(uint256)\");\n require(_lastAccruingBlock < MAX_LAST_ACCRUING_BLOCK, \"_lastAccruingBlock is absurdly high\");\n\n uint256 oldLastAccruingBlock = lastAccruingBlock;\n uint256 currentBlock = getBlockNumber();\n if (oldLastAccruingBlock != 0) {\n require(currentBlock < oldLastAccruingBlock, \"Cannot change at this point\");\n }\n if (oldLastAccruingBlock == 0 || _lastAccruingBlock < oldLastAccruingBlock) {\n // Must be in future\n require(currentBlock < _lastAccruingBlock, \"Invalid _lastAccruingBlock interest have been accumulated\");\n }\n lastAccruingBlock = _lastAccruingBlock;\n emit LastAccruingBlockChanged(oldLastAccruingBlock, _lastAccruingBlock);\n }\n\n function getBlockNumber() public view returns (uint256) {\n return block.number;\n }\n\n /*** Admin Functions ***/\n\n function _become(IVRTVaultProxy vrtVaultProxy) external {\n require(msg.sender == vrtVaultProxy.admin(), \"only proxy admin can change brains\");\n vrtVaultProxy._acceptImplementation();\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n}\n" + }, + "contracts/VRTVault/VRTVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VRTVaultStorage.sol\";\n\ncontract VRTVaultProxy is VRTVaultAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means VRT Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(address implementation_, address vrtAddress_, uint256 interestRatePerBlock_) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\"initialize(address,uint256)\", vrtAddress_, interestRatePerBlock_)\n );\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"VRTVaultProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"VRTVaultProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRT Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) public {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/VRTVault/VRTVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\n\ncontract VRTVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VRT Vault\n */\n address public implementation;\n\n /**\n * @notice Pending brains of VAI Vault\n */\n address public pendingImplementation;\n}\n\ncontract VRTVaultStorage is VRTVaultAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /// @notice The VRT TOKEN!\n IBEP20 public vrt;\n\n /// @notice interestRate for accrual - per Block\n uint256 public interestRatePerBlock;\n\n /// @notice Info of each user.\n struct UserInfo {\n address userAddress;\n uint256 accrualStartBlockNumber;\n uint256 totalPrincipalAmount;\n uint256 lastWithdrawnBlockNumber;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => UserInfo) public userInfo;\n\n /// @notice block number after which no interest will be accrued\n uint256 public lastAccruingBlock;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "contracts/XVSVault/XVSStore.sol": { + "content": "pragma solidity 0.5.16;\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\n\n/**\n * @title XVS Store\n * @author Venus\n * @notice XVS Store responsible for distributing XVS rewards\n */\ncontract XVSStore {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The Admin Address\n address public admin;\n\n /// @notice The pending admin address\n address public pendingAdmin;\n\n /// @notice The Owner Address\n address public owner;\n\n /// @notice The reward tokens\n mapping(address => bool) public rewardTokens;\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Event emitted when admin changed\n event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);\n\n /// @notice Event emitted when owner changed\n event OwnerTransferred(address indexed oldOwner, address indexed newOwner);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"only owner can\");\n _;\n }\n\n /**\n * @notice Safely transfer rewards. Only active reward tokens can be sent using this function.\n * Only callable by owner\n * @dev Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\n * @param token Reward token to transfer\n * @param _to Destination address of the reward\n * @param _amount Amount to transfer\n */\n function safeRewardTransfer(address token, address _to, uint256 _amount) external onlyOwner {\n require(rewardTokens[token] == true, \"only reward token can\");\n\n if (address(token) != address(0)) {\n uint256 tokenBalance = IBEP20(token).balanceOf(address(this));\n if (_amount > tokenBalance) {\n IBEP20(token).safeTransfer(_to, tokenBalance);\n } else {\n IBEP20(token).safeTransfer(_to, _amount);\n }\n }\n }\n\n /**\n * @notice Allows the admin to propose a new admin\n * Only callable admin\n * @param _admin Propose an account as admin of the XVS store\n */\n function setPendingAdmin(address _admin) external onlyAdmin {\n address oldPendingAdmin = pendingAdmin;\n pendingAdmin = _admin;\n emit NewPendingAdmin(oldPendingAdmin, _admin);\n }\n\n /**\n * @notice Allows an account that is pending as admin to accept the role\n * nly calllable by the pending admin\n */\n function acceptAdmin() external {\n require(msg.sender == pendingAdmin, \"only pending admin\");\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n admin = pendingAdmin;\n pendingAdmin = address(0);\n\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n emit AdminTransferred(oldAdmin, admin);\n }\n\n /**\n * @notice Set the contract owner\n * @param _owner The address of the owner to set\n * Only callable admin\n */\n function setNewOwner(address _owner) external onlyAdmin {\n require(_owner != address(0), \"new owner is the zero address\");\n address oldOwner = owner;\n owner = _owner;\n emit OwnerTransferred(oldOwner, _owner);\n }\n\n /**\n * @notice Set or disable a reward token\n * @param _tokenAddress The address of a token to set as active or inactive\n * @param status Set whether a reward token is active or not\n */\n function setRewardToken(address _tokenAddress, bool status) external {\n require(msg.sender == admin || msg.sender == owner, \"only admin or owner can\");\n rewardTokens[_tokenAddress] = status;\n }\n\n /**\n * @notice Security function to allow the owner of the contract to withdraw from the contract\n * @param _tokenAddress Reward token address to withdraw\n * @param _amount Amount of token to withdraw\n */\n function emergencyRewardWithdraw(address _tokenAddress, uint256 _amount) external onlyOwner {\n IBEP20(_tokenAddress).safeTransfer(address(msg.sender), _amount);\n }\n}\n" + }, + "contracts/XVSVault/XVSVault.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Utils/ECDSA.sol\";\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./XVSVaultStorage.sol\";\nimport \"../Tokens/Prime/IPrime.sol\";\nimport \"../Utils/SafeCast.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\nimport \"@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol\";\n\nimport { XVSStore } from \"./XVSStore.sol\";\nimport { XVSVaultProxy } from \"./XVSVaultProxy.sol\";\n\n/**\n * @title XVS Vault\n * @author Venus\n * @notice The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS.\n */\ncontract XVSVault is XVSVaultStorage, ECDSA, AccessControlledV5, TimeManagerV5 {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The upper bound for the lock period in a pool, 10 years\n uint256 public constant MAX_LOCK_PERIOD = 60 * 60 * 24 * 365 * 10;\n\n /// @notice Event emitted when deposit\n event Deposit(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when execute withrawal\n event ExecutedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when request withrawal\n event RequestedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChangedV2(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChangedV2(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice An event emitted when the reward store address is updated\n event StoreUpdated(address oldXvs, address oldStore, address newXvs, address newStore);\n\n /// @notice An event emitted when the withdrawal locking period is updated for a pool\n event WithdrawalLockingPeriodUpdated(address indexed rewardToken, uint indexed pid, uint oldPeriod, uint newPeriod);\n\n /// @notice An event emitted when the reward amount per block or second is modified for a pool\n event RewardAmountUpdated(address indexed rewardToken, uint oldReward, uint newReward);\n\n /// @notice An event emitted when a new pool is added\n event PoolAdded(\n address indexed rewardToken,\n uint indexed pid,\n address indexed token,\n uint allocPoints,\n uint rewardPerBlockOrSecond,\n uint lockPeriod\n );\n\n /// @notice An event emitted when a pool allocation points are updated\n event PoolUpdated(address indexed rewardToken, uint indexed pid, uint oldAllocPoints, uint newAllocPoints);\n\n /// @notice Event emitted when reward claimed\n event Claim(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n /// @notice Event emitted when protocol logs a debt to a user due to insufficient funds for pending reward distribution\n event VaultDebtUpdated(\n address indexed rewardToken,\n address indexed userAddress,\n uint256 oldOwedAmount,\n uint256 newOwedAmount\n );\n\n /// @notice Emitted when prime token contract address is changed\n event NewPrimeToken(\n IPrime indexed oldPrimeToken,\n IPrime indexed newPrimeToken,\n address oldPrimeRewardToken,\n address newPrimeRewardToken,\n uint256 oldPrimePoolId,\n uint256 newPrimePoolId\n );\n\n /**\n * @notice XVSVault constructor\n */\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @dev Prevents functions to execute when vault is paused.\n */\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @notice Pauses vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Returns the number of pools with the specified reward token\n * @param rewardToken Reward token address\n * @return Number of pools that distribute the specified token as a reward\n */\n function poolLength(address rewardToken) external view returns (uint256) {\n return poolInfos[rewardToken].length;\n }\n\n /**\n * @notice Returns the number of reward tokens created per block or second\n * @param _rewardToken Reward token address\n * @return Number of reward tokens created per block or second\n */\n function rewardTokenAmountsPerBlock(address _rewardToken) external view returns (uint256) {\n return rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n }\n\n /**\n * @notice Add a new token pool\n * @dev This vault DOES NOT support deflationary tokens — it expects that\n * the amount of transferred tokens would equal the actually deposited\n * amount. In practice this means that this vault DOES NOT support USDT\n * and similar tokens (that do not provide these guarantees).\n * @param _rewardToken Reward token address\n * @param _allocPoint Number of allocation points assigned to this pool\n * @param _token Staked token\n * @param _rewardPerBlockOrSecond Initial reward per block or second, in terms of _rewardToken\n * @param _lockPeriod A period between withdrawal request and a moment when it's executable\n */\n function add(\n address _rewardToken,\n uint256 _allocPoint,\n IBEP20 _token,\n uint256 _rewardPerBlockOrSecond,\n uint256 _lockPeriod\n ) external {\n _checkAccessAllowed(\"add(address,uint256,address,uint256,uint256)\");\n _ensureNonzeroAddress(_rewardToken);\n _ensureNonzeroAddress(address(_token));\n require(address(xvsStore) != address(0), \"Store contract address is empty\");\n require(_allocPoint > 0, \"Alloc points must not be zero\");\n\n massUpdatePools(_rewardToken);\n\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\n\n uint256 length = poolInfo.length;\n for (uint256 pid = 0; pid < length; ++pid) {\n require(poolInfo[pid].token != _token, \"Pool already added\");\n }\n\n // We use balanceOf to get the supply amount, so shouldn't be possible to\n // configure pools with different reward token but the same staked token\n require(!isStakedToken[address(_token)], \"Token exists in other pool\");\n\n totalAllocPoints[_rewardToken] = totalAllocPoints[_rewardToken].add(_allocPoint);\n\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardPerBlockOrSecond;\n\n poolInfo.push(\n PoolInfo({\n token: _token,\n allocPoint: _allocPoint,\n lastRewardBlockOrSecond: getBlockNumberOrTimestamp(),\n accRewardPerShare: 0,\n lockPeriod: _lockPeriod\n })\n );\n isStakedToken[address(_token)] = true;\n\n XVSStore(xvsStore).setRewardToken(_rewardToken, true);\n\n emit PoolAdded(\n _rewardToken,\n poolInfo.length - 1,\n address(_token),\n _allocPoint,\n _rewardPerBlockOrSecond,\n _lockPeriod\n );\n }\n\n /**\n * @notice Update the given pool's reward allocation point\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _allocPoint Number of allocation points assigned to this pool\n */\n function set(address _rewardToken, uint256 _pid, uint256 _allocPoint) external {\n _checkAccessAllowed(\"set(address,uint256,uint256)\");\n _ensureValidPool(_rewardToken, _pid);\n\n massUpdatePools(_rewardToken);\n\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\n uint256 newTotalAllocPoints = totalAllocPoints[_rewardToken].sub(poolInfo[_pid].allocPoint).add(_allocPoint);\n require(newTotalAllocPoints > 0, \"Alloc points per reward token must not be zero\");\n\n uint256 oldAllocPoints = poolInfo[_pid].allocPoint;\n poolInfo[_pid].allocPoint = _allocPoint;\n totalAllocPoints[_rewardToken] = newTotalAllocPoints;\n\n emit PoolUpdated(_rewardToken, _pid, oldAllocPoints, _allocPoint);\n }\n\n /**\n * @notice Update the given reward token's amount per block or second\n * @param _rewardToken Reward token address\n * @param _rewardAmount Number of allocation points assigned to this pool\n */\n function setRewardAmountPerBlockOrSecond(address _rewardToken, uint256 _rewardAmount) external {\n _checkAccessAllowed(\"setRewardAmountPerBlockOrSecond(address,uint256)\");\n require(XVSStore(xvsStore).rewardTokens(_rewardToken), \"Invalid reward token\");\n massUpdatePools(_rewardToken);\n uint256 oldReward = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardAmount;\n\n emit RewardAmountUpdated(_rewardToken, oldReward, _rewardAmount);\n }\n\n /**\n * @notice Update the lock period after which a requested withdrawal can be executed\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _newPeriod New lock period\n */\n function setWithdrawalLockingPeriod(address _rewardToken, uint256 _pid, uint256 _newPeriod) external {\n _checkAccessAllowed(\"setWithdrawalLockingPeriod(address,uint256,uint256)\");\n _ensureValidPool(_rewardToken, _pid);\n require(_newPeriod > 0 && _newPeriod < MAX_LOCK_PERIOD, \"Invalid new locking period\");\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n uint256 oldPeriod = pool.lockPeriod;\n pool.lockPeriod = _newPeriod;\n\n emit WithdrawalLockingPeriodUpdated(_rewardToken, _pid, oldPeriod, _newPeriod);\n }\n\n /**\n * @notice Deposit XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _amount The amount to deposit to vault\n */\n function deposit(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n _updatePool(_rewardToken, _pid);\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, msg.sender) == 0, \"execute pending withdrawal\");\n\n if (user.amount > 0) {\n uint256 pending = _computeReward(user, pool);\n if (pending > 0) {\n _transferReward(_rewardToken, msg.sender, pending);\n emit Claim(msg.sender, _rewardToken, _pid, pending);\n }\n }\n pool.token.safeTransferFrom(msg.sender, address(this), _amount);\n user.amount = user.amount.add(_amount);\n user.rewardDebt = _cumulativeReward(user, pool);\n\n // Update Delegate Amount\n if (address(pool.token) == xvsAddress) {\n _moveDelegates(address(0), delegates[msg.sender], safe96(_amount, \"XVSVault::deposit: votes overflow\"));\n }\n\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\n primeToken.xvsUpdated(msg.sender);\n }\n\n emit Deposit(msg.sender, _rewardToken, _pid, _amount);\n }\n\n /**\n * @notice Claim rewards for pool\n * @param _account The account for which to claim rewards\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n */\n function claim(address _account, address _rewardToken, uint256 _pid) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][_account];\n _updatePool(_rewardToken, _pid);\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, _account) == 0, \"execute pending withdrawal\");\n\n if (user.amount > 0) {\n uint256 pending = _computeReward(user, pool);\n\n if (pending > 0) {\n user.rewardDebt = _cumulativeReward(user, pool);\n\n _transferReward(_rewardToken, _account, pending);\n emit Claim(_account, _rewardToken, _pid, pending);\n }\n }\n }\n\n /**\n * @notice Pushes withdrawal request to the requests array and updates\n * the pending withdrawals amount. The requests are always sorted\n * by unlock time (descending) so that the earliest to execute requests\n * are always at the end of the array.\n * @param _user The user struct storage pointer\n * @param _requests The user's requests array storage pointer\n * @param _amount The amount being requested\n */\n function pushWithdrawalRequest(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests,\n uint _amount,\n uint _lockedUntil\n ) internal {\n uint i = _requests.length;\n _requests.push(WithdrawalRequest(0, 0, 1));\n // Keep it sorted so that the first to get unlocked request is always at the end\n for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) {\n _requests[i] = _requests[i - 1];\n }\n _requests[i] = WithdrawalRequest(_amount, _lockedUntil.toUint128(), 1);\n _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount);\n }\n\n /**\n * @notice Pops the requests with unlock time < now from the requests\n * array and deducts the computed amount from the user's pending\n * withdrawals counter. Assumes that the requests array is sorted\n * by unclock time (descending).\n * @dev This function **removes** the eligible requests from the requests\n * array. If this function is called, the withdrawal should actually\n * happen (or the transaction should be reverted).\n * @param _user The user struct storage pointer\n * @param _requests The user's requests array storage pointer\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade (this amount should be\n * sent to the user, otherwise the state would be inconsistent).\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade (this amount should be\n * sent to the user, otherwise the state would be inconsistent).\n */\n function popEligibleWithdrawalRequests(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests\n ) internal returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\n // Since the requests are sorted by their unlock time, we can just\n // pop them from the array and stop at the first not-yet-eligible one\n for (uint i = _requests.length; i > 0 && isUnlocked(_requests[i - 1]); --i) {\n if (_requests[i - 1].afterUpgrade == 1) {\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n } else {\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n }\n\n _requests.pop();\n }\n _user.pendingWithdrawals = _user.pendingWithdrawals.sub(\n afterUpgradeWithdrawalAmount.add(beforeUpgradeWithdrawalAmount)\n );\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\n }\n\n /**\n * @notice Checks if the request is eligible for withdrawal.\n * @param _request The request struct storage pointer\n * @return True if the request is eligible for withdrawal, false otherwise\n */\n function isUnlocked(WithdrawalRequest storage _request) private view returns (bool) {\n return _request.lockedUntil <= block.timestamp;\n }\n\n /**\n * @notice Execute withdrawal to XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n */\n function executeWithdrawal(address _rewardToken, uint256 _pid) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n\n uint256 beforeUpgradeWithdrawalAmount;\n uint256 afterUpgradeWithdrawalAmount;\n\n (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount) = popEligibleWithdrawalRequests(user, requests);\n require(beforeUpgradeWithdrawalAmount > 0 || afterUpgradeWithdrawalAmount > 0, \"nothing to withdraw\");\n\n // Having both old-style and new-style requests is not allowed and shouldn't be possible\n require(beforeUpgradeWithdrawalAmount == 0 || afterUpgradeWithdrawalAmount == 0, \"inconsistent state\");\n\n if (beforeUpgradeWithdrawalAmount > 0) {\n _updatePool(_rewardToken, _pid);\n uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub(user.rewardDebt);\n XVSStore(xvsStore).safeRewardTransfer(_rewardToken, msg.sender, pending);\n user.amount = user.amount.sub(beforeUpgradeWithdrawalAmount);\n user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);\n pool.token.safeTransfer(address(msg.sender), beforeUpgradeWithdrawalAmount);\n } else {\n user.amount = user.amount.sub(afterUpgradeWithdrawalAmount);\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].sub(\n afterUpgradeWithdrawalAmount\n );\n pool.token.safeTransfer(address(msg.sender), afterUpgradeWithdrawalAmount);\n }\n\n emit ExecutedWithdrawal(\n msg.sender,\n _rewardToken,\n _pid,\n beforeUpgradeWithdrawalAmount.add(afterUpgradeWithdrawalAmount)\n );\n }\n\n /**\n * @notice Returns before and after upgrade pending withdrawal amount\n * @param _requests The user's requests array storage pointer\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade\n */\n function getRequestedWithdrawalAmount(\n WithdrawalRequest[] storage _requests\n ) internal view returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\n for (uint i = _requests.length; i > 0; --i) {\n if (_requests[i - 1].afterUpgrade == 1) {\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n } else {\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n }\n }\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\n }\n\n /**\n * @notice Request withdrawal to XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _amount The amount to withdraw from the vault\n */\n function requestWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n require(_amount > 0, \"requested amount cannot be zero\");\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n require(user.amount >= user.pendingWithdrawals.add(_amount), \"requested amount is invalid\");\n\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n\n uint beforeUpgradeWithdrawalAmount;\n\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\n require(beforeUpgradeWithdrawalAmount == 0, \"execute pending withdrawal\");\n\n _updatePool(_rewardToken, _pid);\n uint256 pending = _computeReward(user, pool);\n _transferReward(_rewardToken, msg.sender, pending);\n\n uint lockedUntil = pool.lockPeriod.add(block.timestamp);\n\n pushWithdrawalRequest(user, requests, _amount, lockedUntil);\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].add(_amount);\n user.rewardDebt = _cumulativeReward(user, pool);\n\n // Update Delegate Amount\n if (address(pool.token) == xvsAddress) {\n _moveDelegates(\n delegates[msg.sender],\n address(0),\n safe96(_amount, \"XVSVault::requestWithdrawal: votes overflow\")\n );\n }\n\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\n primeToken.xvsUpdated(msg.sender);\n }\n\n emit Claim(msg.sender, _rewardToken, _pid, pending);\n emit RequestedWithdrawal(msg.sender, _rewardToken, _pid, _amount);\n }\n\n /**\n * @notice Get unlocked withdrawal amount\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return withdrawalAmount Amount that the user can withdraw\n */\n function getEligibleWithdrawalAmount(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (uint withdrawalAmount) {\n _ensureValidPool(_rewardToken, _pid);\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n // Since the requests are sorted by their unlock time, we can take\n // the entries from the end of the array and stop at the first\n // not-yet-eligible one\n for (uint i = requests.length; i > 0 && isUnlocked(requests[i - 1]); --i) {\n withdrawalAmount = withdrawalAmount.add(requests[i - 1].amount);\n }\n return withdrawalAmount;\n }\n\n /**\n * @notice Get requested amount\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return Total amount of requested but not yet executed withdrawals (including both executable and locked ones)\n */\n function getRequestedAmount(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\n _ensureValidPool(_rewardToken, _pid);\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n return user.pendingWithdrawals;\n }\n\n /**\n * @notice Returns the array of withdrawal requests that have not been executed yet\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return An array of withdrawal requests\n */\n function getWithdrawalRequests(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (WithdrawalRequest[] memory) {\n _ensureValidPool(_rewardToken, _pid);\n return withdrawalRequests[_rewardToken][_pid][_user];\n }\n\n /**\n * @notice View function to see pending XVSs on frontend\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _user User address\n * @return Reward the user is eligible for in this pool, in terms of _rewardToken\n */\n function pendingReward(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n uint256 accRewardPerShare = pool.accRewardPerShare;\n uint256 supply = pool.token.balanceOf(address(this)).sub(totalPendingWithdrawals[_rewardToken][_pid]);\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\n uint256 rewardTokenPerBlockOrSecond = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n if (curBlockNumberOrSecond > pool.lastRewardBlockOrSecond && supply != 0) {\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\n uint256 reward = multiplier.mul(rewardTokenPerBlockOrSecond).mul(pool.allocPoint).div(\n totalAllocPoints[_rewardToken]\n );\n accRewardPerShare = accRewardPerShare.add(reward.mul(1e12).div(supply));\n }\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n (, uint256 afterUpgradeWithdrawalAmount) = getRequestedWithdrawalAmount(requests);\n return user.amount.sub(afterUpgradeWithdrawalAmount).mul(accRewardPerShare).div(1e12).sub(user.rewardDebt);\n }\n\n // Update reward variables for all pools. Be careful of gas spending!\n function massUpdatePools(address _rewardToken) internal {\n uint256 length = poolInfos[_rewardToken].length;\n for (uint256 pid = 0; pid < length; ++pid) {\n _updatePool(_rewardToken, pid);\n }\n }\n\n /**\n * @notice Update reward variables of the given pool to be up-to-date\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n */\n function updatePool(address _rewardToken, uint256 _pid) external isActive {\n _ensureValidPool(_rewardToken, _pid);\n _updatePool(_rewardToken, _pid);\n }\n\n // Update reward variables of the given pool to be up-to-date.\n function _updatePool(address _rewardToken, uint256 _pid) internal {\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n if (getBlockNumberOrTimestamp() <= pool.lastRewardBlockOrSecond) {\n return;\n }\n uint256 supply = pool.token.balanceOf(address(this));\n supply = supply.sub(totalPendingWithdrawals[_rewardToken][_pid]);\n if (supply == 0) {\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\n return;\n }\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\n uint256 reward = multiplier.mul(rewardTokenAmountsPerBlockOrSecond[_rewardToken]).mul(pool.allocPoint).div(\n totalAllocPoints[_rewardToken]\n );\n pool.accRewardPerShare = pool.accRewardPerShare.add(reward.mul(1e12).div(supply));\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\n }\n\n function _ensureValidPool(address rewardToken, uint256 pid) internal view {\n require(pid < poolInfos[rewardToken].length, \"vault: pool exists?\");\n }\n\n /**\n * @notice Get user info with reward token address and pid\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _user User address\n * @return amount Deposited amount\n * @return rewardDebt Reward debt (technical value used to track past payouts)\n * @return pendingWithdrawals Requested but not yet executed withdrawals\n */\n function getUserInfo(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals) {\n _ensureValidPool(_rewardToken, _pid);\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n amount = user.amount;\n rewardDebt = user.rewardDebt;\n pendingWithdrawals = user.pendingWithdrawals;\n }\n\n /**\n * @notice Gets the total pending withdrawal amount of a user before upgrade\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The address of the user\n * @return beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade\n */\n function pendingWithdrawalsBeforeUpgrade(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) public view returns (uint256 beforeUpgradeWithdrawalAmount) {\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\n return beforeUpgradeWithdrawalAmount;\n }\n\n /**\n * @notice Get the XVS stake balance of an account (excluding the pending withdrawals)\n * @param account The address of the account to check\n * @return The balance that user staked\n */\n function getStakeAmount(address account) internal view returns (uint96) {\n require(xvsAddress != address(0), \"XVSVault::getStakeAmount: xvs address is not set\");\n\n PoolInfo[] storage poolInfo = poolInfos[xvsAddress];\n\n uint256 length = poolInfo.length;\n for (uint256 pid = 0; pid < length; ++pid) {\n if (address(poolInfo[pid].token) == address(xvsAddress)) {\n UserInfo storage user = userInfos[xvsAddress][pid][account];\n return safe96(user.amount.sub(user.pendingWithdrawals), \"XVSVault::getStakeAmount: votes overflow\");\n }\n }\n return uint96(0);\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) external isActive {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(\n address delegatee,\n uint nonce,\n uint expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external isActive {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(\"XVSVault\")), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ECDSA.recover(digest, v, r, s);\n require(nonce == nonces[signatory]++, \"XVSVault::delegateBySig: invalid nonce\");\n require(block.timestamp <= expiry, \"XVSVault::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = getStakeAmount(delegator);\n delegates[delegator] = delegatee;\n\n emit DelegateChangedV2(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"XVSVault::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"XVSVault::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumberOrSecond = safe32(\n getBlockNumberOrTimestamp(),\n \"XVSVault::_writeCheckpoint: block number or second exceeds 32 bits\"\n );\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlockOrSecond == blockNumberOrSecond) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumberOrSecond, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChangedV2(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n\n /**\n * @notice Determine the xvs stake balance for an account\n * @param account The address of the account to check\n * @param blockNumberOrSecond The block number or second to get the vote balance at\n * @return The balance that user staked\n */\n function getPriorVotes(address account, uint256 blockNumberOrSecond) external view returns (uint96) {\n require(blockNumberOrSecond < getBlockNumberOrTimestamp(), \"XVSVault::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlockOrSecond <= blockNumberOrSecond) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlockOrSecond > blockNumberOrSecond) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlockOrSecond == blockNumberOrSecond) {\n return cp.votes;\n } else if (cp.fromBlockOrSecond < blockNumberOrSecond) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n /*** Admin Functions ***/\n\n function _become(XVSVaultProxy xvsVaultProxy) external {\n require(msg.sender == xvsVaultProxy.admin(), \"only proxy admin can change brains\");\n require(xvsVaultProxy._acceptImplementation() == 0, \"change not authorized\");\n }\n\n function setXvsStore(address _xvs, address _xvsStore) external onlyAdmin {\n _ensureNonzeroAddress(_xvs);\n _ensureNonzeroAddress(_xvsStore);\n\n address oldXvsContract = xvsAddress;\n address oldStore = xvsStore;\n require(oldXvsContract == address(0), \"already initialized\");\n\n xvsAddress = _xvs;\n xvsStore = _xvsStore;\n\n _notEntered = true;\n\n emit StoreUpdated(oldXvsContract, oldStore, _xvs, _xvsStore);\n }\n\n /**\n * @notice Sets the address of the prime token contract\n * @param _primeToken address of the prime token contract\n * @param _primeRewardToken address of reward token\n * @param _primePoolId pool id for reward\n */\n function setPrimeToken(IPrime _primeToken, address _primeRewardToken, uint256 _primePoolId) external onlyAdmin {\n require(address(_primeToken) != address(0), \"prime token cannot be zero address\");\n require(_primeRewardToken != address(0), \"reward cannot be zero address\");\n\n _ensureValidPool(_primeRewardToken, _primePoolId);\n\n emit NewPrimeToken(primeToken, _primeToken, primeRewardToken, _primeRewardToken, primePoolId, _primePoolId);\n\n primeToken = _primeToken;\n primeRewardToken = _primeRewardToken;\n primePoolId = _primePoolId;\n }\n\n /**\n * @dev Initializes the contract to use either blocks or seconds\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\n * @param blocksPerYear_ The number of blocks per year\n */\n function initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) external onlyAdmin {\n _initializeTimeManager(timeBased_, blocksPerYear_);\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n\n /**\n * @dev Reverts if the provided address is a zero address\n * @param address_ Address to check\n */\n function _ensureNonzeroAddress(address address_) internal pure {\n require(address_ != address(0), \"zero address not allowed\");\n }\n\n /**\n * @dev Transfers the reward to the user, taking into account the rewards store\n * balance and the previous debt. If there are not enough rewards in the store,\n * transfers the available funds and records the debt amount in pendingRewardTransfers.\n * @param rewardToken Reward token address\n * @param userAddress User address\n * @param amount Reward amount, in reward tokens\n */\n function _transferReward(address rewardToken, address userAddress, uint256 amount) internal {\n address xvsStore_ = xvsStore;\n uint256 storeBalance = IBEP20(rewardToken).balanceOf(xvsStore_);\n uint256 debtDueToFailedTransfers = pendingRewardTransfers[rewardToken][userAddress];\n uint256 fullAmount = amount.add(debtDueToFailedTransfers);\n\n if (fullAmount <= storeBalance) {\n if (debtDueToFailedTransfers != 0) {\n pendingRewardTransfers[rewardToken][userAddress] = 0;\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, 0);\n }\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, fullAmount);\n return;\n }\n // Overflow isn't possible due to the check above\n uint256 newOwedAmount = fullAmount - storeBalance;\n pendingRewardTransfers[rewardToken][userAddress] = newOwedAmount;\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, newOwedAmount);\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, storeBalance);\n }\n\n /**\n * @dev Computes cumulative reward for all user's shares\n * @param user UserInfo storage struct\n * @param pool PoolInfo storage struct\n */\n function _cumulativeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\n return user.amount.sub(user.pendingWithdrawals).mul(pool.accRewardPerShare).div(1e12);\n }\n\n /**\n * @dev Computes the reward for all user's shares\n * @param user UserInfo storage struct\n * @param pool PoolInfo storage struct\n */\n function _computeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\n return _cumulativeReward(user, pool).sub(user.rewardDebt);\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract XVSVaultErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./XVSVaultStorage.sol\";\nimport \"./XVSVaultErrorReporter.sol\";\n\n/**\n * @title XVS Vault Proxy\n * @author Venus\n * @notice XVS Vault Proxy contract\n */\ncontract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter {\n /**\n * @notice Emitted when pendingXVSVaultImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingXVSVaultImplementation is accepted, which means XVS Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingXVSVaultImplementation;\n\n pendingXVSVaultImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingXVSVaultImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingXVSVaultImplementation;\n\n implementation = pendingXVSVaultImplementation;\n\n pendingXVSVaultImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"../Tokens/Prime/IPrime.sol\";\n\ncontract XVSVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of XVS Vault\n */\n address public implementation;\n\n /**\n * @notice Pending brains of XVS Vault\n */\n address public pendingXVSVaultImplementation;\n}\n\ncontract XVSVaultStorageV1 is XVSVaultAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice The reward token store\n address public xvsStore;\n\n /// @notice The xvs token address\n address public xvsAddress;\n\n // Reward tokens created per block or second indentified by reward token address.\n mapping(address => uint256) public rewardTokenAmountsPerBlockOrSecond;\n\n /// @notice Info of each user.\n struct UserInfo {\n uint256 amount;\n uint256 rewardDebt;\n uint256 pendingWithdrawals;\n }\n\n // Info of each pool.\n struct PoolInfo {\n IBEP20 token; // Address of token contract to stake.\n uint256 allocPoint; // How many allocation points assigned to this pool.\n uint256 lastRewardBlockOrSecond; // Last block number or second that reward tokens distribution occurs.\n uint256 accRewardPerShare; // Accumulated per share, times 1e12. See below.\n uint256 lockPeriod; // Min time between withdrawal request and its execution.\n }\n\n // Infomation about a withdrawal request\n struct WithdrawalRequest {\n uint256 amount;\n uint128 lockedUntil;\n uint128 afterUpgrade;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => mapping(uint256 => mapping(address => UserInfo))) internal userInfos;\n\n // Info of each pool.\n mapping(address => PoolInfo[]) public poolInfos;\n\n // Total allocation points. Must be the sum of all allocation points in all pools.\n mapping(address => uint256) public totalAllocPoints;\n\n // Info of requested but not yet executed withdrawals\n mapping(address => mapping(uint256 => mapping(address => WithdrawalRequest[]))) internal withdrawalRequests;\n\n /// @notice DEPRECATED A record of each accounts delegate (before the voting power fix)\n mapping(address => address) private __oldDelegatesSlot;\n\n /// @notice A checkpoint for marking number of votes from a given block or second\n struct Checkpoint {\n uint32 fromBlockOrSecond;\n uint96 votes;\n }\n\n /// @notice DEPRECATED A record of votes checkpoints for each account, by index (before the voting power fix)\n mapping(address => mapping(uint32 => Checkpoint)) private __oldCheckpointsSlot;\n\n /// @notice DEPRECATED The number of checkpoints for each account (before the voting power fix)\n mapping(address => uint32) private __oldNumCheckpointsSlot;\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n}\n\ncontract XVSVaultStorage is XVSVaultStorageV1 {\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice Tracks pending withdrawals for all users for a particular reward token and pool id\n mapping(address => mapping(uint256 => uint256)) public totalPendingWithdrawals;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /// @notice if the token is added to any of the pools\n mapping(address => bool) public isStakedToken;\n\n /// @notice Amount we owe to users because of failed transfer attempts\n mapping(address => mapping(address => uint256)) public pendingRewardTransfers;\n\n /// @notice Prime token contract address\n IPrime public primeToken;\n\n /// @notice Reward token for which prime token is issued for staking\n address public primeRewardToken;\n\n /// @notice Pool ID for which prime token is issued for staking\n uint256 public primePoolId;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[46] private __gap;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "storageLayout", + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/deployments/opmainnet_addresses.json b/deployments/opmainnet_addresses.json index afe9164bb..0656b86ad 100644 --- a/deployments/opmainnet_addresses.json +++ b/deployments/opmainnet_addresses.json @@ -1,5 +1,17 @@ { "name": "opmainnet", "chainId": "10", - "addresses": {} + "addresses": { + "DefaultProxyAdmin": "0xeaF9490cBEA6fF9bA1D23671C39a799CeD0DCED2", + "Prime": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "PrimeLiquidityProvider": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "PrimeLiquidityProvider_Implementation": "0xF3B8d6b1778548F975D6eBebD8a8e515832Cfb0a", + "PrimeLiquidityProvider_Proxy": "0x6412f6cd58D0182aE150b90B5A99e285b91C1a12", + "Prime_Implementation": "0x7DCF81746fFA44C4469eBA2F6Db86AE3d5f92b10", + "Prime_Proxy": "0xE76d2173546Be97Fa6E18358027BdE9742a649f7", + "VTreasuryV8": "0x104c01EB7b4664551BE6A9bdB26a8C5c6Be7d3da", + "XVSStore": "0xFE548630954129923f63113923eF5373E10589d3", + "XVSVaultProxy": "0x133120607C018c949E91AE333785519F6d947e01", + "XVSVaultProxy_Implementation": "0x8B8651EEB002a7991F2287500B17a395E8cfe7d9" + } } diff --git a/deployments/opsepolia.json b/deployments/opsepolia.json index 1eecf17a5..45cc98c4b 100644 --- a/deployments/opsepolia.json +++ b/deployments/opsepolia.json @@ -2,32 +2,19 @@ "name": "opsepolia", "chainId": "11155420", "contracts": { - "VTreasuryV8": { - "address": "0x5A1a12F47FA7007C9e23cf5e025F3f5d3aC7d755", + "DefaultProxyAdmin": { + "address": "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", "abi": [ { - "inputs": [], - "name": "ZeroAddressNotAllowed", - "type": "error" - }, - { - "anonymous": false, "inputs": [ { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, "internalType": "address", - "name": "newOwner", + "name": "initialOwner", "type": "address" } ], - "name": "OwnershipTransferStarted", - "type": "event" + "stateMutability": "nonpayable", + "type": "constructor" }, { "anonymous": false, @@ -49,63 +36,51 @@ "type": "event" }, { - "anonymous": false, "inputs": [ { - "indexed": false, - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" }, { - "indexed": true, "internalType": "address", - "name": "withdrawAddress", + "name": "newAdmin", "type": "address" } ], - "name": "WithdrawTreasuryNative", - "type": "event" + "name": "changeProxyAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - "anonymous": false, "inputs": [ { - "indexed": true, - "internalType": "address", - "name": "tokenAddress", + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - }, + } + ], + "name": "getProxyAdmin", + "outputs": [ { - "indexed": true, "internalType": "address", - "name": "withdrawAddress", + "name": "", "type": "address" } ], - "name": "WithdrawTreasuryToken", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { - "inputs": [], - "name": "owner", + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyImplementation", "outputs": [ { "internalType": "address", @@ -118,7 +93,7 @@ }, { "inputs": [], - "name": "pendingOwner", + "name": "owner", "outputs": [ { "internalType": "address", @@ -152,47 +127,8175 @@ { "inputs": [ { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" }, { - "internalType": "address payable", - "name": "withdrawAddress", + "internalType": "address", + "name": "implementation", "type": "address" } ], - "name": "withdrawTreasuryNative", + "name": "upgrade", "outputs": [], - "stateMutability": "payable", + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, { "internalType": "address", - "name": "tokenAddress", + "name": "implementation", "type": "address" }, { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ] + }, + "Prime": { + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" }, { + "indexed": false, "internalType": "address", - "name": "withdrawAddress", + "name": "newAdmin", "type": "address" } ], - "name": "withdrawTreasuryToken", + "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": [], + "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" + }, + { + "inputs": [], + "name": "AssetAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "ExpTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "IneligibleToClaim", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAlphaArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidComptroller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFixedPoint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "d", + "type": "uint256" + } + ], + "name": "InvalidFraction", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLimit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimestamp", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVToken", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnNonRealResult", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "MarketAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MarketNotSupported", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NoScoreUpdatesRequired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "UserHasNoPrimeToken", + "type": "error" + }, + { + "inputs": [], + "name": "WaitMoreTime", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "oldNumerator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "newNumerator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "AlphaUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InterestClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "oldIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldRevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "newIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRevocableLimit", + "type": "uint256" + } + ], + "name": "MintLimitsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldBorrowMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowMultiplier", + "type": "uint256" + } + ], + "name": "MultiplierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "StakedAtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "TokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "UserScoreUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAXIMUM_XVS_CAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_STAKED_XVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_MARKET", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WRAPPED_NATIVE_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "accrueInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + } + ], + "name": "accrueInterestAndUpdateScore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "addMarket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alphaDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alphaNumerator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "calculateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimTimeRemaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsStaked", + "type": "uint256" + } + ], + "name": "estimateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getInterestAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct PrimeStorageV1.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "incomeDistributionYearly", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "xvsVault_", + "type": "address" + }, + { + "internalType": "address", + "name": "xvsVaultRewardToken_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "xvsVaultPoolId_", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "alphaNumerator_", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "alphaDenominator_", + "type": "uint128" + }, + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "primeLiquidityProvider_", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolRegistry_", + "type": "address" + } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "interests", + "outputs": [ + { + "internalType": "uint256", + "name": "accrued", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "irrevocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isScoreUpdated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserPrimeHolder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "issue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sumOfMembersScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextScoreUpdateRoundId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "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": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingScoreUpdates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primeLiquidityProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_irrevocableLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_revocableLimit", + "type": "uint256" + } + ], + "name": "setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "timestamps", + "type": "uint256[]" + } + ], + "name": "setStakedAt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "stakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIrrevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalScoreUpdatesRequired", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unreleasedPLPIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_alphaNumerator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_alphaDenominator", + "type": "uint128" + } + ], + "name": "updateAlpha", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "updateMultipliers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "updateScores", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "vTokenForAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "xvsUpdated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "PrimeLiquidityProvider": { + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "abi": [ + { + "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": [], + "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" + }, + { + "inputs": [], + "name": "AddressesMustDiffer", + "type": "error" + }, + { + "inputs": [], + "name": "FundsTransferIsPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "speed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSpeed", + "type": "uint256" + } + ], + "name": "InvalidDistributionSpeed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "TokenNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "MaxTokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPrimeToken", + "type": "address" + } + ], + "name": "PrimeTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + } + ], + "name": "SweepToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenDistributionInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "TokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenTransferredToPrime", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensAccrued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_DISTRIBUTION_SPEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "accrueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "getEffectiveDistributionSpeed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + } + ], + "name": "initializeTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "lastAccruedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastAccruedBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxTokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prime", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "releaseFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resumeFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setMaxTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "prime_", + "type": "address" + } + ], + "name": "setPrimeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token_", + "type": "address" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount_", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "tokenAmountAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] + }, + "PrimeLiquidityProvider_Implementation": { + "address": "0x66aaabFb90852D16e419aB739a64bFa3b5B0a16f", + "abi": [ + { + "inputs": [ + { + "internalType": "bool", + "name": "_timeBased", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AddressesMustDiffer", + "type": "error" + }, + { + "inputs": [], + "name": "FundsTransferIsPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "speed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSpeed", + "type": "uint256" + } + ], + "name": "InvalidDistributionSpeed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "TokenNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "MaxTokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPrimeToken", + "type": "address" + } + ], + "name": "PrimeTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + } + ], + "name": "SweepToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenDistributionInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "TokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenTransferredToPrime", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensAccrued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_DISTRIBUTION_SPEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "accrueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "getEffectiveDistributionSpeed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + } + ], + "name": "initializeTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "lastAccruedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastAccruedBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxTokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prime", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "releaseFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resumeFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setMaxTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "prime_", + "type": "address" + } + ], + "name": "setPrimeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token_", + "type": "address" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount_", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "tokenAmountAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "PrimeLiquidityProvider_Proxy": { + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "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": [], + "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" + } + ] + }, + "Prime_Implementation": { + "address": "0x84cca3c7719d1F9c35b5cfF14BE05801B8fD69d7", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_wrappedNativeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_nativeMarket", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_stakingPeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_minimumStakedXVS", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maximumXVSCap", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_timeBased", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AssetAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "ExpTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "IneligibleToClaim", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAlphaArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidComptroller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFixedPoint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "d", + "type": "uint256" + } + ], + "name": "InvalidFraction", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLimit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimestamp", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVToken", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnNonRealResult", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "MarketAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MarketNotSupported", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NoScoreUpdatesRequired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "UserHasNoPrimeToken", + "type": "error" + }, + { + "inputs": [], + "name": "WaitMoreTime", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "oldNumerator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "newNumerator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "AlphaUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InterestClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "oldIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldRevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "newIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRevocableLimit", + "type": "uint256" + } + ], + "name": "MintLimitsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldBorrowMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowMultiplier", + "type": "uint256" + } + ], + "name": "MultiplierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "StakedAtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "TokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "UserScoreUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAXIMUM_XVS_CAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_STAKED_XVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_MARKET", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WRAPPED_NATIVE_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "accrueInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + } + ], + "name": "accrueInterestAndUpdateScore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "addMarket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alphaDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alphaNumerator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "calculateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimTimeRemaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsStaked", + "type": "uint256" + } + ], + "name": "estimateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getInterestAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct PrimeStorageV1.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "incomeDistributionYearly", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "xvsVault_", + "type": "address" + }, + { + "internalType": "address", + "name": "xvsVaultRewardToken_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "xvsVaultPoolId_", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "alphaNumerator_", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "alphaDenominator_", + "type": "uint128" + }, + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "primeLiquidityProvider_", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolRegistry_", + "type": "address" + } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "interests", + "outputs": [ + { + "internalType": "uint256", + "name": "accrued", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "irrevocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isScoreUpdated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserPrimeHolder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "issue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sumOfMembersScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextScoreUpdateRoundId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "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": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingScoreUpdates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primeLiquidityProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_irrevocableLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_revocableLimit", + "type": "uint256" + } + ], + "name": "setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "timestamps", + "type": "uint256[]" + } + ], + "name": "setStakedAt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "stakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIrrevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalScoreUpdatesRequired", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unreleasedPLPIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_alphaNumerator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_alphaDenominator", + "type": "uint128" + } + ], + "name": "updateAlpha", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "updateMultipliers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "updateScores", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "vTokenForAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "xvsUpdated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "Prime_Proxy": { + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "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": [], + "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" + } + ] + }, + "VTreasuryV8": { + "address": "0x5A1a12F47FA7007C9e23cf5e025F3f5d3aC7d755", + "abi": [ + { + "inputs": [], + "name": "ZeroAddressNotAllowed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "withdrawAddress", + "type": "address" + } + ], + "name": "WithdrawTreasuryNative", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "withdrawAddress", + "type": "address" + } + ], + "name": "WithdrawTreasuryToken", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "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": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "withdrawAddress", + "type": "address" + } + ], + "name": "withdrawTreasuryNative", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "withdrawAddress", + "type": "address" + } + ], + "name": "withdrawTreasuryToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] + }, + "XVSStore": { + "address": "0xE888FA54b32BfaD3cE0e3C7D566EFe809a6A0143", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerTransferred", + "type": "event" + }, + { + "constant": false, + "inputs": [], + "name": "acceptAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "emergencyRewardWithdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardTokens", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "safeRewardTransfer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "setNewOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_admin", + "type": "address" + } + ], + "name": "setPendingAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "setRewardToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "XVSVaultProxy": { + "address": "0x4d344e48F02234E82D7D1dB84d0A4A18Aa43Dacc", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "NewImplementation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "NewPendingImplementation", + "type": "event" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptImplementation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "_setPendingAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "_setPendingImplementation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ] + }, + "XVSVaultProxy_Implementation": { + "address": "0x7A02458c1c1504Abf37160401A5020ED003ba347", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Claim", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ExecutedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IPrime", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IPrime", + "name": "newPrimeToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldPrimeRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPrimeRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldPrimePoolId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPrimePoolId", + "type": "uint256" + } + ], + "name": "NewPrimeToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "allocPoints", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardPerBlockOrSecond", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lockPeriod", + "type": "uint256" + } + ], + "name": "PoolAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldAllocPoints", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newAllocPoints", + "type": "uint256" + } + ], + "name": "PoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RequestedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldReward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReward", + "type": "uint256" + } + ], + "name": "RewardAmountUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldXvs", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldStore", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newXvs", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newStore", + "type": "address" + } + ], + "name": "StoreUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "userAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldOwedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newOwedAmount", + "type": "uint256" + } + ], + "name": "VaultDebtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "VaultPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "VaultResumed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldPeriod", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPeriod", + "type": "uint256" + } + ], + "name": "WithdrawalLockingPeriodUpdated", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_LOCK_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SECONDS_PER_YEAR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract XVSVaultProxy", + "name": "xvsVaultProxy", + "type": "address" + } + ], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV5", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_allocPoint", + "type": "uint256" + }, + { + "internalType": "contract IBEP20", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rewardPerBlockOrSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_lockPeriod", + "type": "uint256" + } + ], + "name": "add", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "fromBlockOrSecond", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "claim", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "delegateBySig", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "executeWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCurrentVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getEligibleWithdrawalAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "withdrawalAmount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumberOrSecond", + "type": "uint256" + } + ], + "name": "getPriorVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getRequestedAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getUserInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pendingWithdrawals", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getWithdrawalRequests", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "lockedUntil", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "afterUpgrade", + "type": "uint128" + } + ], + "internalType": "struct XVSVaultStorageV1.WithdrawalRequest[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "timeBased_", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "blocksPerYear_", + "type": "uint256" + } + ], + "name": "initializeTimeManager", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isStakedToken", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "pause", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "pendingReward", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pendingRewardTransfers", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "pendingWithdrawalsBeforeUpgrade", + "outputs": [ + { + "internalType": "uint256", + "name": "beforeUpgradeWithdrawalAmount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "poolInfos", + "outputs": [ + { + "internalType": "contract IBEP20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allocPoint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastRewardBlockOrSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "accRewardPerShare", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lockPeriod", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + } + ], + "name": "poolLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primePoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primeRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primeToken", + "outputs": [ + { + "internalType": "contract IPrime", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "requestWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "resume", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + } + ], + "name": "rewardTokenAmountsPerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardTokenAmountsPerBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_allocPoint", + "type": "uint256" + } + ], + "name": "set", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newAccessControlAddress", + "type": "address" + } + ], + "name": "setAccessControl", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract IPrime", + "name": "_primeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_primeRewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_primePoolId", + "type": "uint256" + } + ], + "name": "setPrimeToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rewardAmount", + "type": "uint256" + } + ], + "name": "setRewardAmountPerBlockOrSecond", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newPeriod", + "type": "uint256" + } + ], + "name": "setWithdrawalLockingPeriod", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_xvs", + "type": "address" + }, + { + "internalType": "address", + "name": "_xvsStore", + "type": "address" + } + ], + "name": "setXvsStore", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "totalAllocPoints", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "totalPendingWithdrawals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "updatePool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaultPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsStore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" } ] } diff --git a/deployments/opsepolia/DefaultProxyAdmin.json b/deployments/opsepolia/DefaultProxyAdmin.json new file mode 100644 index 000000000..916bafcb1 --- /dev/null +++ b/deployments/opsepolia/DefaultProxyAdmin.json @@ -0,0 +1,257 @@ +{ + "address": "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialOwner", + "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" + }, + { + "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": "0xe2e80958baa3dafd68d4bc67fe2f42d4bb95f54d3eeed579aa5794361d5cc31f", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", + "transactionIndex": 3, + "gasUsed": "644163", + "logsBloom": "0x00000001000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000010000800000000000000000000000000000010400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000000000000000002000000000000000000000000000000000", + "blockHash": "0x02373085940f0267876afa6ffe983c1c59cbb8610e0d1eba557d5e9d461d6ca5", + "transactionHash": "0xe2e80958baa3dafd68d4bc67fe2f42d4bb95f54d3eeed579aa5794361d5cc31f", + "logs": [ + { + "transactionIndex": 3, + "blockNumber": 14172649, + "transactionHash": "0xe2e80958baa3dafd68d4bc67fe2f42d4bb95f54d3eeed579aa5794361d5cc31f", + "address": "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000d57365ee4e850e881229e2f8aa405822f289e78d" + ], + "data": "0x", + "logIndex": 83, + "blockHash": "0x02373085940f0267876afa6ffe983c1c59cbb8610e0d1eba557d5e9d461d6ca5" + } + ], + "blockNumber": 14172649, + "cumulativeGasUsed": "3381686", + "status": 1, + "byzantium": true + }, + "args": ["0xd57365EE4E850e881229e2F8Aa405822f289e78d"], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"initialOwner\",\"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\"},{\"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\":{\"solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol\":\"ProxyAdmin\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/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 (address initialOwner) {\\n _transferOwnership(initialOwner);\\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\":\"0x9b2bbba5bb04f53f277739c1cdff896ba8b3bf591cfc4eab2098c655e8ac251e\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/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\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/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\"},\"solc_0.8/openzeppelin/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 constructor (address initialOwner) Ownable(initialOwner) {}\\n\\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\":\"0x754888b9c9ab5525343460b0a4fa2e2f4fca9b6a7e0e7ddea4154e2b1182a45d\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/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\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/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\"},\"solc_0.8/openzeppelin/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": "0x608060405234801561001057600080fd5b50604051610b17380380610b1783398101604081905261002f91610090565b8061003981610040565b50506100c0565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100a257600080fd5b81516001600160a01b03811681146100b957600080fd5b9392505050565b610a48806100cf6000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220bd6c09ab03bfaf9ec60a4bf8cd98903cecb891974e17e2d76a3b2002c97eeb8964736f6c634300080a0033", + "deployedBytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220bd6c09ab03bfaf9ec60a4bf8cd98903cecb891974e17e2d76a3b2002c97eeb8964736f6c634300080a0033", + "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": 7, + "contract": "solc_0.8/openzeppelin/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/deployments/opsepolia/Prime.json b/deployments/opsepolia/Prime.json new file mode 100644 index 000000000..2bdec94df --- /dev/null +++ b/deployments/opsepolia/Prime.json @@ -0,0 +1,2042 @@ +{ + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "abi": [ + { + "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": [], + "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" + }, + { + "inputs": [], + "name": "AssetAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "ExpTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "IneligibleToClaim", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAlphaArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidComptroller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFixedPoint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "d", + "type": "uint256" + } + ], + "name": "InvalidFraction", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLimit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimestamp", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVToken", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnNonRealResult", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "MarketAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MarketNotSupported", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NoScoreUpdatesRequired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "UserHasNoPrimeToken", + "type": "error" + }, + { + "inputs": [], + "name": "WaitMoreTime", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "oldNumerator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "newNumerator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "AlphaUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InterestClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "oldIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldRevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "newIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRevocableLimit", + "type": "uint256" + } + ], + "name": "MintLimitsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldBorrowMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowMultiplier", + "type": "uint256" + } + ], + "name": "MultiplierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "StakedAtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "TokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "UserScoreUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAXIMUM_XVS_CAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_STAKED_XVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_MARKET", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WRAPPED_NATIVE_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "accrueInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + } + ], + "name": "accrueInterestAndUpdateScore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "addMarket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alphaDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alphaNumerator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "calculateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimTimeRemaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsStaked", + "type": "uint256" + } + ], + "name": "estimateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getInterestAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct PrimeStorageV1.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "incomeDistributionYearly", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "xvsVault_", + "type": "address" + }, + { + "internalType": "address", + "name": "xvsVaultRewardToken_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "xvsVaultPoolId_", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "alphaNumerator_", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "alphaDenominator_", + "type": "uint128" + }, + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "primeLiquidityProvider_", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolRegistry_", + "type": "address" + } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "interests", + "outputs": [ + { + "internalType": "uint256", + "name": "accrued", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "irrevocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isScoreUpdated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserPrimeHolder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "issue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sumOfMembersScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextScoreUpdateRoundId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "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": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingScoreUpdates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primeLiquidityProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_irrevocableLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_revocableLimit", + "type": "uint256" + } + ], + "name": "setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "timestamps", + "type": "uint256[]" + } + ], + "name": "setStakedAt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "stakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIrrevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalScoreUpdatesRequired", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unreleasedPLPIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_alphaNumerator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_alphaDenominator", + "type": "uint128" + } + ], + "name": "updateAlpha", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "updateMultipliers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "updateScores", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "vTokenForAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "xvsUpdated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "transactionIndex": 3, + "gasUsed": "774848", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000800000000000000000000000000000000000000000000000000400000000000008000000000000000000000000000000002000001000000080410000000000000000000000000020000000000000000000800000000810000000000000000000000440000000100000000000008000000000000000000000080000000000000800000000000000000000000002000000400000000000000800000000000000000000000000020000000000000000401040000000000000400000000000000000020000000000200000000000000000000000000000840000000000000800000000000", + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab", + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "logs": [ + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000084cca3c7719d1f9c35b5cff14be05801b8fd69d7" + ], + "data": "0x", + "logIndex": 17, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000476c66ca1fe0e8abb45c8566d635dca9dc930f73" + ], + "data": "0x", + "logIndex": 18, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001652e12c8abe2f0d84466f0fc1fa4286491b3bc1", + "logIndex": 19, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0xc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014", + "logIndex": 20, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0x62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258"], + "data": "0x000000000000000000000000476c66ca1fe0e8abb45c8566d635dca9dc930f73", + "logIndex": 21, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 22, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a9aaf2a1ccf2c3a87997942abaa740887cc89241", + "logIndex": 23, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + } + ], + "blockNumber": 17184828, + "cumulativeGasUsed": "1573606", + "status": 1, + "byzantium": true + }, + "args": [ + "0x84cca3c7719d1F9c35b5cfF14BE05801B8fD69d7", + "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", + "0xb1a250f20000000000000000000000004d344e48f02234e82d7d1db84d0a4a18aa43dacc000000000000000000000000789482e37218f9b26d8d9115e356462fa9a371160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000001652e12c8abe2f0d84466f0fc1fa4286491b3bc1000000000000000000000000e3ec955b94d197a8e4081844f3f25f81047a9af500000000000000000000000000000000000000000000000000000000000000000000000000000000000000006c01eca2b5c97f135406a3a5531445a7d977d28e0000000000000000000000000000000000000000000000000000000000000014" + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"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\":[],\"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.\",\"events\":{\"AdminChanged(address,address)\":{\"details\":\"Emitted when the admin account has changed.\"},\"BeaconUpgraded(address)\":{\"details\":\"Emitted when the beacon is upgraded.\"},\"Upgraded(address)\":{\"details\":\"Emitted when the implementation is upgraded.\"}},\"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`\"},\"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\":{\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\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 _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a0604052604051610d1a380380610d1a833981016040819052610022916103d2565b828161004f60017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6104a2565b600080516020610cd38339815191521461006b5761006b6104c3565b61007782826000610128565b506100a5905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046104a2565b600080516020610cb3833981519152146100c1576100c16104c3565b6001600160a01b0382166080819052600080516020610cb38339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050610528565b61013183610154565b60008251118061013e5750805b1561014f5761014d8383610194565b505b505050565b61015d816101c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606101b98383604051806060016040528060278152602001610cf360279139610263565b90505b92915050565b6001600160a01b0381163b6102345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b600080516020610cd383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6102cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161022b565b600080856001600160a01b0316856040516102e691906104d9565b600060405180830381855af49150503d8060008114610321576040519150601f19603f3d011682016040523d82523d6000602084013e610326565b606091505b509092509050610337828286610343565b925050505b9392505050565b6060831561035257508161033c565b8251156103625782518084602001fd5b8160405162461bcd60e51b815260040161022b91906104f5565b80516001600160a01b038116811461039357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103c95781810151838201526020016103b1565b50506000910152565b6000806000606084860312156103e757600080fd5b6103f08461037c565b92506103fe6020850161037c565b60408501519092506001600160401b038082111561041b57600080fd5b818601915086601f83011261042f57600080fd5b81518181111561044157610441610398565b604051601f8201601f19908116603f0116810190838211818310171561046957610469610398565b8160405282815289602084870101111561048257600080fd5b6104938360208301602088016103ae565b80955050505050509250925092565b818103818111156101bc57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600082516104eb8184602087016103ae565b9190910192915050565b60208152600082518060208401526105148160408501602087016103ae565b601f01601f19169190910160400192915050565b60805161074e6105656000396000818160ef01528181610145015281816101c701528181610211015281816102420152610266015261074e6000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033", + "execute": { + "methodName": "initialize", + "args": [ + "0x4d344e48F02234E82D7D1dB84d0A4A18Aa43Dacc", + "0x789482e37218f9b26d8D9115E356462fA9A37116", + 0, + 1, + 2, + "0x1652E12C8ABE2f0D84466F0fc1fA4286491B3BC1", + "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "0x0000000000000000000000000000000000000000", + "0x6c01ECa2B5C97F135406a3A5531445A7d977D28e", + 20 + ] + }, + "implementation": "0x84cca3c7719d1F9c35b5cfF14BE05801B8fD69d7", + "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.", + "events": { + "AdminChanged(address,address)": { + "details": "Emitted when the admin account has changed." + }, + "BeaconUpgraded(address)": { + "details": "Emitted when the beacon is upgraded." + }, + "Upgraded(address)": { + "details": "Emitted when the implementation is upgraded." + } + }, + "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`" + }, + "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/deployments/opsepolia/PrimeLiquidityProvider.json b/deployments/opsepolia/PrimeLiquidityProvider.json new file mode 100644 index 000000000..e4f9ef1ae --- /dev/null +++ b/deployments/opsepolia/PrimeLiquidityProvider.json @@ -0,0 +1,1113 @@ +{ + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "abi": [ + { + "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": [], + "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" + }, + { + "inputs": [], + "name": "AddressesMustDiffer", + "type": "error" + }, + { + "inputs": [], + "name": "FundsTransferIsPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "speed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSpeed", + "type": "uint256" + } + ], + "name": "InvalidDistributionSpeed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "TokenNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "MaxTokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPrimeToken", + "type": "address" + } + ], + "name": "PrimeTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + } + ], + "name": "SweepToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenDistributionInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "TokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenTransferredToPrime", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensAccrued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_DISTRIBUTION_SPEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "accrueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "getEffectiveDistributionSpeed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + } + ], + "name": "initializeTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "lastAccruedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastAccruedBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxTokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prime", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "releaseFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resumeFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setMaxTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "prime_", + "type": "address" + } + ], + "name": "setPrimeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token_", + "type": "address" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount_", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "tokenAmountAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "transactionIndex": 6, + "gasUsed": "634674", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000800000000000000000000000000000000002000000000000000000000000000008000000000000000000000000000000002000001000000000000000000000000000000000000020000000000000000000800000000800000000400000000000000440000000000000000000040000000000000000000000080000000000000800000000000008000000000002000000400000000000000800000000000000000000000000020000000000000000401040000000000000400000000000000000020000000000200004000000000000000000000000800000000000000000000000000", + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7", + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "logs": [ + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000066aaabfb90852d16e419ab739a64bfa3b5b0a16f" + ], + "data": "0x", + "logIndex": 41, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000476c66ca1fe0e8abb45c8566d635dca9dc930f73" + ], + "data": "0x", + "logIndex": 42, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001652e12c8abe2f0d84466f0fc1fa4286491b3bc1", + "logIndex": 43, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": ["0xc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014", + "logIndex": 44, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 45, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a9aaf2a1ccf2c3a87997942abaa740887cc89241", + "logIndex": 46, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + } + ], + "blockNumber": 17184814, + "cumulativeGasUsed": "2479729", + "status": 1, + "byzantium": true + }, + "args": [ + "0x66aaabFb90852D16e419aB739a64bFa3b5B0a16f", + "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", + "0xe458a65d0000000000000000000000001652e12c8abe2f0d84466f0fc1fa4286491b3bc100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"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\":[],\"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.\",\"events\":{\"AdminChanged(address,address)\":{\"details\":\"Emitted when the admin account has changed.\"},\"BeaconUpgraded(address)\":{\"details\":\"Emitted when the beacon is upgraded.\"},\"Upgraded(address)\":{\"details\":\"Emitted when the implementation is upgraded.\"}},\"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`\"},\"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\":{\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\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 _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a0604052604051610d1a380380610d1a833981016040819052610022916103d2565b828161004f60017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6104a2565b600080516020610cd38339815191521461006b5761006b6104c3565b61007782826000610128565b506100a5905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046104a2565b600080516020610cb3833981519152146100c1576100c16104c3565b6001600160a01b0382166080819052600080516020610cb38339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050610528565b61013183610154565b60008251118061013e5750805b1561014f5761014d8383610194565b505b505050565b61015d816101c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606101b98383604051806060016040528060278152602001610cf360279139610263565b90505b92915050565b6001600160a01b0381163b6102345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b600080516020610cd383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6102cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161022b565b600080856001600160a01b0316856040516102e691906104d9565b600060405180830381855af49150503d8060008114610321576040519150601f19603f3d011682016040523d82523d6000602084013e610326565b606091505b509092509050610337828286610343565b925050505b9392505050565b6060831561035257508161033c565b8251156103625782518084602001fd5b8160405162461bcd60e51b815260040161022b91906104f5565b80516001600160a01b038116811461039357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103c95781810151838201526020016103b1565b50506000910152565b6000806000606084860312156103e757600080fd5b6103f08461037c565b92506103fe6020850161037c565b60408501519092506001600160401b038082111561041b57600080fd5b818601915086601f83011261042f57600080fd5b81518181111561044157610441610398565b604051601f8201601f19908116603f0116810190838211818310171561046957610469610398565b8160405282815289602084870101111561048257600080fd5b6104938360208301602088016103ae565b80955050505050509250925092565b818103818111156101bc57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600082516104eb8184602087016103ae565b9190910192915050565b60208152600082518060208401526105148160408501602087016103ae565b601f01601f19169190910160400192915050565b60805161074e6105656000396000818160ef01528181610145015281816101c701528181610211015281816102420152610266015261074e6000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033", + "execute": { + "methodName": "initialize", + "args": ["0x1652E12C8ABE2f0D84466F0fc1fA4286491B3BC1", [], [], [], 20] + }, + "implementation": "0x66aaabFb90852D16e419aB739a64bFa3b5B0a16f", + "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.", + "events": { + "AdminChanged(address,address)": { + "details": "Emitted when the admin account has changed." + }, + "BeaconUpgraded(address)": { + "details": "Emitted when the beacon is upgraded." + }, + "Upgraded(address)": { + "details": "Emitted when the implementation is upgraded." + } + }, + "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`" + }, + "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/deployments/opsepolia/PrimeLiquidityProvider_Implementation.json b/deployments/opsepolia/PrimeLiquidityProvider_Implementation.json new file mode 100644 index 000000000..7ad891560 --- /dev/null +++ b/deployments/opsepolia/PrimeLiquidityProvider_Implementation.json @@ -0,0 +1,1432 @@ +{ + "address": "0x66aaabFb90852D16e419aB739a64bFa3b5B0a16f", + "abi": [ + { + "inputs": [ + { + "internalType": "bool", + "name": "_timeBased", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AddressesMustDiffer", + "type": "error" + }, + { + "inputs": [], + "name": "FundsTransferIsPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "speed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSpeed", + "type": "uint256" + } + ], + "name": "InvalidDistributionSpeed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "TokenNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "MaxTokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPrimeToken", + "type": "address" + } + ], + "name": "PrimeTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sweepAmount", + "type": "uint256" + } + ], + "name": "SweepToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "TokenDistributionInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldSpeed", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "TokenDistributionSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenTransferredToPrime", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensAccrued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_MAX_DISTRIBUTION_SPEED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "accrueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "getEffectiveDistributionSpeed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + } + ], + "name": "initializeTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "lastAccruedBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastAccruedBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxTokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prime", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "releaseFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resumeFundsTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxDistributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setMaxTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "prime_", + "type": "address" + } + ], + "name": "setPrimeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens_", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "distributionSpeeds_", + "type": "uint256[]" + } + ], + "name": "setTokensDistributionSpeed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token_", + "type": "address" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount_", + "type": "uint256" + } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token_", + "type": "address" + } + ], + "name": "tokenAmountAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenDistributionSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xde86bd4dd4bf9fb21e89f3754b4351e1681e19138a931d496ef7ac0377fbba25", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0x66aaabFb90852D16e419aB739a64bFa3b5B0a16f", + "transactionIndex": 4, + "gasUsed": "1768450", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000", + "blockHash": "0xe96d53e838935947e8c2c5cbfe45ff3b8c8c6cbbc2c7d83d4e8a7858c346fdef", + "transactionHash": "0xde86bd4dd4bf9fb21e89f3754b4351e1681e19138a931d496ef7ac0377fbba25", + "logs": [ + { + "transactionIndex": 4, + "blockNumber": 17184808, + "transactionHash": "0xde86bd4dd4bf9fb21e89f3754b4351e1681e19138a931d496ef7ac0377fbba25", + "address": "0x66aaabFb90852D16e419aB739a64bFa3b5B0a16f", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 19, + "blockHash": "0xe96d53e838935947e8c2c5cbfe45ff3b8c8c6cbbc2c7d83d4e8a7858c346fdef" + } + ], + "blockNumber": 17184808, + "cumulativeGasUsed": "2780886", + "status": 1, + "byzantium": true + }, + "args": [true, 0], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_timeBased\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"_blocksPerYear\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AddressesMustDiffer\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FundsTransferIsPaused\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"sweepAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"name\":\"InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidArguments\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidBlocksPerYear\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidCaller\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"speed\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSpeed\",\"type\":\"uint256\"}],\"name\":\"InvalidDistributionSpeed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTimeBasedConfiguration\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"loopsLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredLoops\",\"type\":\"uint256\"}],\"name\":\"MaxLoopsLimitExceeded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"TokenAlreadyInitialized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"TokenNotInitialized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"calledContract\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"methodSignature\",\"type\":\"string\"}],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldMaxLoopsLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newmaxLoopsLimit\",\"type\":\"uint256\"}],\"name\":\"MaxLoopsLimitUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldSpeed\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSpeed\",\"type\":\"uint256\"}],\"name\":\"MaxTokenDistributionSpeedUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldPrimeToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newPrimeToken\",\"type\":\"address\"}],\"name\":\"PrimeTokenUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"sweepAmount\",\"type\":\"uint256\"}],\"name\":\"SweepToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"TokenDistributionInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldSpeed\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSpeed\",\"type\":\"uint256\"}],\"name\":\"TokenDistributionSpeedUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokenTransferredToPrime\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokensAccrued\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_MAX_DISTRIBUTION_SPEED\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV8\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"accrueTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blocksOrSecondsPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumberOrTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"getEffectiveDistributionSpeed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"tokens_\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"distributionSpeeds_\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"maxDistributionSpeeds_\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"loopsLimit_\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"tokens_\",\"type\":\"address[]\"}],\"name\":\"initializeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isTimeBased\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"lastAccruedBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastAccruedBlockOrSecond\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxLoopsLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"maxTokenDistributionSpeeds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseFundsTransfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"prime\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"releaseFunds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"resumeFundsTransfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"setAccessControlManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"loopsLimit\",\"type\":\"uint256\"}],\"name\":\"setMaxLoopsLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"tokens_\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"maxDistributionSpeeds_\",\"type\":\"uint256[]\"}],\"name\":\"setMaxTokensDistributionSpeed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"prime_\",\"type\":\"address\"}],\"name\":\"setPrimeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"tokens_\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"distributionSpeeds_\",\"type\":\"uint256[]\"}],\"name\":\"setTokensDistributionSpeed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"token_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount_\",\"type\":\"uint256\"}],\"name\":\"sweepToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"tokenAmountAccrued\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"tokenDistributionSpeeds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"Paused(address)\":{\"details\":\"Emitted when the pause is triggered by `account`.\"},\"Unpaused(address)\":{\"details\":\"Emitted when the pause is lifted by `account`.\"}},\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"accrueTokens(address)\":{\"custom:event\":\"Emits TokensAccrued event\",\"params\":{\"token_\":\"Address of the token\"}},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"getBlockNumberOrTimestamp()\":{\"details\":\"Function to simply retrieve block number or block timestamp\",\"returns\":{\"_0\":\"Current block number or block timestamp\"}},\"getEffectiveDistributionSpeed(address)\":{\"params\":{\"token_\":\"Address of the token\"},\"returns\":{\"_0\":\"speed returns the per block or second reward\"}},\"initialize(address,address[],uint256[],uint256[],uint256)\":{\"custom:error\":\"Throw InvalidArguments on different length of tokens and speeds array\",\"details\":\"Initializes the deployer to owner\",\"params\":{\"accessControlManager_\":\"AccessControlManager contract address\",\"distributionSpeeds_\":\"New distribution speeds for tokens\",\"loopsLimit_\":\"Maximum number of loops allowed in a single transaction\",\"tokens_\":\"Array of addresses of the tokens\"}},\"initializeTokens(address[])\":{\"custom:access\":\"Only Governance\",\"params\":{\"tokens_\":\"Array of addresses of the tokens to be intialized\"}},\"lastAccruedBlock(address)\":{\"params\":{\"token_\":\"Address of the token\"},\"returns\":{\"_0\":\"blockNumberOrSecond returns the last accrued block or second\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pauseFundsTransfer()\":{\"custom:access\":\"Controlled by ACM\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"releaseFunds(address)\":{\"custom:error\":\"Throw InvalidArguments on Zero address(token)Throw FundsTransferIsPaused is pausedThrow InvalidCaller if the sender is not the Prime contract\",\"custom:event\":\"Emits TokenTransferredToPrime event\",\"params\":{\"token_\":\"The token to release to the Prime contract\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"resumeFundsTransfer()\":{\"custom:access\":\"Controlled by ACM\"},\"setAccessControlManager(address)\":{\"custom:access\":\"Only Governance\",\"custom:event\":\"Emits NewAccessControlManager event\",\"details\":\"Admin function to set address of AccessControlManager\",\"params\":{\"accessControlManager_\":\"The new address of the AccessControlManager\"}},\"setMaxLoopsLimit(uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:event\":\"Emits MaxLoopsLimitUpdated event on success\",\"params\":{\"loopsLimit\":\"Limit for the max loops can execute at a time\"}},\"setMaxTokensDistributionSpeed(address[],uint256[])\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw InvalidArguments on different length of tokens and speeds array\",\"params\":{\"maxDistributionSpeeds_\":\"New distribution speeds for tokens\",\"tokens_\":\"Array of addresses of the tokens\"}},\"setPrimeToken(address)\":{\"custom:access\":\"Only owner\",\"custom:event\":\"Emits PrimeTokenUpdated event\",\"params\":{\"prime_\":\"The new address of the prime token contract\"}},\"setTokensDistributionSpeed(address[],uint256[])\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw InvalidArguments on different length of tokens and speeds array\",\"params\":{\"distributionSpeeds_\":\"New distribution speeds for tokens\",\"tokens_\":\"Array of addresses of the tokens\"}},\"sweepToken(address,address,uint256)\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract\",\"custom:event\":\"Emits SweepToken event\",\"params\":{\"amount_\":\"The amount of tokens needs to transfer\",\"to_\":\"The address of the recipient\",\"token_\":\"The address of the ERC-20 token to sweep\"}},\"tokenAmountAccrued(address)\":{\"params\":{\"token_\":\"Address of the token\"},\"returns\":{\"_0\":\"returns the amount of accrued tokens for the token provided\"}},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"title\":\"PrimeLiquidityProvider\",\"version\":1},\"userdoc\":{\"errors\":{\"AddressesMustDiffer()\":[{\"notice\":\"Error thrown when argument value in setter is same as previous value\"}],\"FundsTransferIsPaused()\":[{\"notice\":\"Error thrown when funds transfer is paused\"}],\"InsufficientBalance(uint256,uint256)\":[{\"notice\":\"Error thrown when PrimeLiquidityProvider's balance is less than sweep amount\"}],\"InvalidArguments()\":[{\"notice\":\"Thrown when arguments are passed are invalid\"}],\"InvalidBlocksPerYear()\":[{\"notice\":\"Thrown when blocks per year is invalid\"}],\"InvalidCaller()\":[{\"notice\":\"Thrown when caller is not the desired caller\"}],\"InvalidDistributionSpeed(uint256,uint256)\":[{\"notice\":\"Thrown when distribution speed is greater than maxTokenDistributionSpeeds[tokenAddress]\"}],\"InvalidTimeBasedConfiguration()\":[{\"notice\":\"Thrown when time based but blocks per year is provided\"}],\"MaxLoopsLimitExceeded(uint256,uint256)\":[{\"notice\":\"Thrown an error on maxLoopsLimit exceeds for any loop\"}],\"TokenAlreadyInitialized(address)\":[{\"notice\":\"Thrown when token is initialized\"}],\"TokenNotInitialized(address)\":[{\"notice\":\"Error thrown when accrueTokens is called for an uninitialized token\"}],\"Unauthorized(address,address,string)\":[{\"notice\":\"Thrown when the action is prohibited by AccessControlManager\"}]},\"events\":{\"MaxLoopsLimitUpdated(uint256,uint256)\":{\"notice\":\"Emitted when max loops limit is set\"},\"MaxTokenDistributionSpeedUpdated(address,uint256,uint256)\":{\"notice\":\"Emitted when a new max distribution speed for token is set\"},\"NewAccessControlManager(address,address)\":{\"notice\":\"Emitted when access control manager contract address is changed\"},\"PrimeTokenUpdated(address,address)\":{\"notice\":\"Emitted when prime token contract address is changed\"},\"SweepToken(address,address,uint256)\":{\"notice\":\"Emitted on sweep token success\"},\"TokenDistributionInitialized(address)\":{\"notice\":\"Emitted when a token distribution is initialized\"},\"TokenDistributionSpeedUpdated(address,uint256,uint256)\":{\"notice\":\"Emitted when a new token distribution speed is set\"},\"TokenTransferredToPrime(address,uint256)\":{\"notice\":\"Emitted when token is transferred to the prime contract\"},\"TokensAccrued(address,uint256)\":{\"notice\":\"Emitted when distribution state(Index and block or second) is updated\"}},\"kind\":\"user\",\"methods\":{\"DEFAULT_MAX_DISTRIBUTION_SPEED()\":{\"notice\":\"The default max token distribution speed\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"accrueTokens(address)\":{\"notice\":\"Accrue token by updating the distribution state\"},\"blocksOrSecondsPerYear()\":{\"notice\":\"Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\"},\"getEffectiveDistributionSpeed(address)\":{\"notice\":\"Get rewards per block or second for token\"},\"initialize(address,address[],uint256[],uint256[],uint256)\":{\"notice\":\"PrimeLiquidityProvider initializer\"},\"initializeTokens(address[])\":{\"notice\":\"Initialize the distribution of the token\"},\"isTimeBased()\":{\"notice\":\"Acknowledges if a contract is time based or not\"},\"lastAccruedBlock(address)\":{\"notice\":\"Get the last accrued block or second for token\"},\"lastAccruedBlockOrSecond(address)\":{\"notice\":\"The block or second till which rewards are distributed for an asset\"},\"maxTokenDistributionSpeeds(address)\":{\"notice\":\"The max token distribution speed for token\"},\"pauseFundsTransfer()\":{\"notice\":\"Pause fund transfer of tokens to Prime contract\"},\"prime()\":{\"notice\":\"Address of the Prime contract\"},\"releaseFunds(address)\":{\"notice\":\"Claim all the token accrued till last block or second\"},\"resumeFundsTransfer()\":{\"notice\":\"Resume fund transfer of tokens to Prime contract\"},\"setAccessControlManager(address)\":{\"notice\":\"Sets the address of AccessControlManager\"},\"setMaxLoopsLimit(uint256)\":{\"notice\":\"Set the limit for the loops can iterate to avoid the DOS\"},\"setMaxTokensDistributionSpeed(address[],uint256[])\":{\"notice\":\"Set max distribution speed for token (amount of maximum token distribute per block or second)\"},\"setPrimeToken(address)\":{\"notice\":\"Set the prime token contract address\"},\"setTokensDistributionSpeed(address[],uint256[])\":{\"notice\":\"Set distribution speed (amount of token distribute per block or second)\"},\"sweepToken(address,address,uint256)\":{\"notice\":\"A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\"},\"tokenAmountAccrued(address)\":{\"notice\":\"Get the tokens accrued\"},\"tokenDistributionSpeeds(address)\":{\"notice\":\"The rate at which token is distributed (per block or second)\"}},\"notice\":\"PrimeLiquidityProvider is used to fund Prime\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Tokens/Prime/PrimeLiquidityProvider.sol\":\"PrimeLiquidityProvider\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./OwnableUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n function __Ownable2Step_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable2Step_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x9140dabc466abab21b48b72dbda26736b1183a310d0e677d3719d201df026510\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling 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 /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x359a1ab89b46b9aba7bcad3fb651924baf4893d15153049b9976b0fc9be1358e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\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 _requireNotPaused();\\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 _requirePaused();\\n _;\\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 Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\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 /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xad32f6821f860555f9530902a65b54203a4f5db2117f4384ae47a124958078db\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.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 IERC20Upgradeable {\\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(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x0e1f0f5f62f67a881cd1a9597acbc0a5e4071f3c2c10449a183b922ae7272e3f\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x07e881de3b9f6d2c07909f193f24b96c7fe4ea60013260f3f25aecd8bab3c2f8\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) 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(IERC20Upgradeable token, address spender, uint256 value) 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 /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\\n * Revert on invalid signature.\\n */\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\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(IERC20Upgradeable 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 require(returndata.length == 0 || abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\\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 cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return\\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));\\n }\\n}\\n\",\"keccak256\":\"0x23b997be73d3dd46885262704f0f8cfc7273fdadfe303d37969a9561373972b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\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 * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(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 (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport {Initializable} from \\\"../proxy/utils/Initializable.sol\\\";\\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 ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n function _contextSuffixLength() internal view virtual returns (uint256) {\\n return 0;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x75097e35253e7fb282ee4d7f27a80eaacfa759923185bf17302a89cbc059c5ef\",\"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\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title AccessControlledV8\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0dcf283925f4dddc23ca0ee71d2cb96a9dd6e4cf08061b69fde1697ea39dc514\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\n/**\\n * @title IAccessControlManagerV8\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\\n */\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xaa29b098440d0b3a131c5ecdf25ce548790c1b5ac7bf9b5c0264b6af6f7a1e0b\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\n/**\\n * @title MaxLoopsLimitHelper\\n * @author Venus\\n * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.\\n */\\nabstract contract MaxLoopsLimitHelper {\\n // Limit for the loops to avoid the DOS\\n uint256 public maxLoopsLimit;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when max loops limit is set\\n event MaxLoopsLimitUpdated(uint256 oldMaxLoopsLimit, uint256 newmaxLoopsLimit);\\n\\n /// @notice Thrown an error on maxLoopsLimit exceeds for any loop\\n error MaxLoopsLimitExceeded(uint256 loopsLimit, uint256 requiredLoops);\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param limit Limit for the max loops can execute at a time\\n */\\n function _setMaxLoopsLimit(uint256 limit) internal {\\n require(limit > maxLoopsLimit, \\\"Comptroller: Invalid maxLoopsLimit\\\");\\n\\n uint256 oldMaxLoopsLimit = maxLoopsLimit;\\n maxLoopsLimit = limit;\\n\\n emit MaxLoopsLimitUpdated(oldMaxLoopsLimit, limit);\\n }\\n\\n /**\\n * @notice Compare the maxLoopsLimit with number of the times loop iterate\\n * @param len Length of the loops iterate\\n * @custom:error MaxLoopsLimitExceeded error is thrown when loops length exceeds maxLoopsLimit\\n */\\n function _ensureMaxLoops(uint256 len) internal view {\\n if (len > maxLoopsLimit) {\\n revert MaxLoopsLimitExceeded(maxLoopsLimit, len);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4c25e30635485d162177effa384eee51768b0141a567a0da16ff6ad673274166\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { SECONDS_PER_YEAR } from \\\"./constants.sol\\\";\\n\\nabstract contract TimeManagerV8 {\\n /// @notice Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable blocksOrSecondsPerYear;\\n\\n /// @notice Acknowledges if a contract is time based or not\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n bool public immutable isTimeBased;\\n\\n /// @notice Stores the current block timestamp or block number depending on isTimeBased\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n function() view returns (uint256) private immutable _getCurrentSlot;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[48] private __gap;\\n\\n /// @notice Thrown when blocks per year is invalid\\n error InvalidBlocksPerYear();\\n\\n /// @notice Thrown when time based but blocks per year is provided\\n error InvalidTimeBasedConfiguration();\\n\\n /**\\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\\n * @param blocksPerYear_ The number of blocks per year\\n * @custom:error InvalidBlocksPerYear is thrown if blocksPerYear entered is zero and timeBased is false\\n * @custom:error InvalidTimeBasedConfiguration is thrown if blocksPerYear entered is non zero and timeBased is true\\n * @custom:oz-upgrades-unsafe-allow constructor\\n */\\n constructor(bool timeBased_, uint256 blocksPerYear_) {\\n if (!timeBased_ && blocksPerYear_ == 0) {\\n revert InvalidBlocksPerYear();\\n }\\n\\n if (timeBased_ && blocksPerYear_ != 0) {\\n revert InvalidTimeBasedConfiguration();\\n }\\n\\n isTimeBased = timeBased_;\\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\\n _getCurrentSlot = timeBased_ ? _getBlockTimestamp : _getBlockNumber;\\n }\\n\\n /**\\n * @dev Function to simply retrieve block number or block timestamp\\n * @return Current block number or block timestamp\\n */\\n function getBlockNumberOrTimestamp() public view virtual returns (uint256) {\\n return _getCurrentSlot();\\n }\\n\\n /**\\n * @dev Returns the current timestamp in seconds\\n * @return The current timestamp\\n */\\n function _getBlockTimestamp() private view returns (uint256) {\\n return block.timestamp;\\n }\\n\\n /**\\n * @dev Returns the current block number\\n * @return The current block number\\n */\\n function _getBlockNumber() private view returns (uint256) {\\n return block.number;\\n }\\n}\\n\",\"keccak256\":\"0x57a2bbb9b8e02b1c0a5c0e305fef1328a22db56c3d4b148c362010a6e767243c\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/constants.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\\nuint256 constant EXP_SCALE = 1e18;\\n\\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\\nuint256 constant MANTISSA_ONE = EXP_SCALE;\\n\\n/// @dev The approximate number of seconds per year\\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\\n\",\"keccak256\":\"0x14de93ead464da249af31bea0e3bcfb62ec693bea3475fb4d90f055ac81dc5eb\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IPrimeLiquidityProvider.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport { IERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IPrimeLiquidityProvider\\n * @author Venus\\n * @notice Interface for PrimeLiquidityProvider\\n */\\ninterface IPrimeLiquidityProvider {\\n /**\\n * @notice Initialize the distribution of the token\\n * @param tokens_ Array of addresses of the tokens to be intialized\\n */\\n function initializeTokens(address[] calldata tokens_) external;\\n\\n /**\\n * @notice Pause fund transfer of tokens to Prime contract\\n */\\n function pauseFundsTransfer() external;\\n\\n /**\\n * @notice Resume fund transfer of tokens to Prime contract\\n */\\n function resumeFundsTransfer() external;\\n\\n /**\\n * @notice Set distribution speed (amount of token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param distributionSpeeds_ New distribution speeds for tokens\\n */\\n function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external;\\n\\n /**\\n * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param maxDistributionSpeeds_ New distribution speeds for tokens\\n */\\n function setMaxTokensDistributionSpeed(\\n address[] calldata tokens_,\\n uint256[] calldata maxDistributionSpeeds_\\n ) external;\\n\\n /**\\n * @notice Set the prime token contract address\\n * @param prime_ The new address of the prime token contract\\n */\\n function setPrimeToken(address prime_) external;\\n\\n /**\\n * @notice Claim all the token accrued till last block or second\\n * @param token_ The token to release to the Prime contract\\n */\\n function releaseFunds(address token_) external;\\n\\n /**\\n * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\\n * @param token_ The address of the ERC-20 token to sweep\\n * @param to_ The address of the recipient\\n * @param amount_ The amount of tokens needs to transfer\\n */\\n function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external;\\n\\n /**\\n * @notice Accrue token by updating the distribution state\\n * @param token_ Address of the token\\n */\\n function accrueTokens(address token_) external;\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Limit for the max loops can execute at a time\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external;\\n\\n /**\\n * @notice Get rewards per block or second for token\\n * @param token_ Address of the token\\n * @return speed returns the per block or second reward\\n */\\n function getEffectiveDistributionSpeed(address token_) external view returns (uint256);\\n\\n /**\\n * @notice Get the amount of tokens accrued\\n * @param token_ Address of the token\\n * @return Amount of tokens that are accrued\\n */\\n function tokenAmountAccrued(address token_) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x4dca0341931008bcd81de18e627c2d0cd4f9d0be67db4d8f0d678d11ba0d330f\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/PrimeLiquidityProvider.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { PrimeLiquidityProviderStorageV1 } from \\\"./PrimeLiquidityProviderStorage.sol\\\";\\nimport { SafeERC20Upgradeable, IERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport { AccessControlledV8 } from \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\nimport { PausableUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport { IPrimeLiquidityProvider } from \\\"./Interfaces/IPrimeLiquidityProvider.sol\\\";\\nimport { MaxLoopsLimitHelper } from \\\"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\\\";\\nimport { TimeManagerV8 } from \\\"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\\\";\\n\\n/**\\n * @title PrimeLiquidityProvider\\n * @author Venus\\n * @notice PrimeLiquidityProvider is used to fund Prime\\n */\\ncontract PrimeLiquidityProvider is\\n IPrimeLiquidityProvider,\\n AccessControlledV8,\\n PausableUpgradeable,\\n MaxLoopsLimitHelper,\\n PrimeLiquidityProviderStorageV1,\\n TimeManagerV8\\n{\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n /// @notice The default max token distribution speed\\n uint256 public constant DEFAULT_MAX_DISTRIBUTION_SPEED = 1e18;\\n\\n /// @notice Emitted when a token distribution is initialized\\n event TokenDistributionInitialized(address indexed token);\\n\\n /// @notice Emitted when a new token distribution speed is set\\n event TokenDistributionSpeedUpdated(address indexed token, uint256 oldSpeed, uint256 newSpeed);\\n\\n /// @notice Emitted when a new max distribution speed for token is set\\n event MaxTokenDistributionSpeedUpdated(address indexed token, uint256 oldSpeed, uint256 newSpeed);\\n\\n /// @notice Emitted when prime token contract address is changed\\n event PrimeTokenUpdated(address indexed oldPrimeToken, address indexed newPrimeToken);\\n\\n /// @notice Emitted when distribution state(Index and block or second) is updated\\n event TokensAccrued(address indexed token, uint256 amount);\\n\\n /// @notice Emitted when token is transferred to the prime contract\\n event TokenTransferredToPrime(address indexed token, uint256 amount);\\n\\n /// @notice Emitted on sweep token success\\n event SweepToken(address indexed token, address indexed to, uint256 sweepAmount);\\n\\n /// @notice Thrown when arguments are passed are invalid\\n error InvalidArguments();\\n\\n /// @notice Thrown when distribution speed is greater than maxTokenDistributionSpeeds[tokenAddress]\\n error InvalidDistributionSpeed(uint256 speed, uint256 maxSpeed);\\n\\n /// @notice Thrown when caller is not the desired caller\\n error InvalidCaller();\\n\\n /// @notice Thrown when token is initialized\\n error TokenAlreadyInitialized(address token);\\n\\n ///@notice Error thrown when PrimeLiquidityProvider's balance is less than sweep amount\\n error InsufficientBalance(uint256 sweepAmount, uint256 balance);\\n\\n /// @notice Error thrown when funds transfer is paused\\n error FundsTransferIsPaused();\\n\\n /// @notice Error thrown when accrueTokens is called for an uninitialized token\\n error TokenNotInitialized(address token_);\\n\\n /// @notice Error thrown when argument value in setter is same as previous value\\n error AddressesMustDiffer();\\n\\n /**\\n * @notice Compares two addresses to ensure they are different\\n * @param oldAddress The original address to compare\\n * @param newAddress The new address to compare\\n */\\n modifier compareAddress(address oldAddress, address newAddress) {\\n if (newAddress == oldAddress) {\\n revert AddressesMustDiffer();\\n }\\n _;\\n }\\n\\n /**\\n * @notice Prime Liquidity Provider constructor\\n * @param _timeBased A boolean indicating whether the contract is based on time or block.\\n * @param _blocksPerYear total blocks per year\\n */\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(bool _timeBased, uint256 _blocksPerYear) TimeManagerV8(_timeBased, _blocksPerYear) {\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice PrimeLiquidityProvider initializer\\n * @dev Initializes the deployer to owner\\n * @param accessControlManager_ AccessControlManager contract address\\n * @param tokens_ Array of addresses of the tokens\\n * @param distributionSpeeds_ New distribution speeds for tokens\\n * @param loopsLimit_ Maximum number of loops allowed in a single transaction\\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\\n */\\n function initialize(\\n address accessControlManager_,\\n address[] calldata tokens_,\\n uint256[] calldata distributionSpeeds_,\\n uint256[] calldata maxDistributionSpeeds_,\\n uint256 loopsLimit_\\n ) external initializer {\\n _ensureZeroAddress(accessControlManager_);\\n\\n __AccessControlled_init(accessControlManager_);\\n __Pausable_init();\\n _setMaxLoopsLimit(loopsLimit_);\\n\\n uint256 numTokens = tokens_.length;\\n _ensureMaxLoops(numTokens);\\n\\n if ((numTokens != distributionSpeeds_.length) || (numTokens != maxDistributionSpeeds_.length)) {\\n revert InvalidArguments();\\n }\\n\\n for (uint256 i; i < numTokens; ) {\\n _initializeToken(tokens_[i]);\\n _setMaxTokenDistributionSpeed(tokens_[i], maxDistributionSpeeds_[i]);\\n _setTokenDistributionSpeed(tokens_[i], distributionSpeeds_[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Initialize the distribution of the token\\n * @param tokens_ Array of addresses of the tokens to be intialized\\n * @custom:access Only Governance\\n */\\n function initializeTokens(address[] calldata tokens_) external onlyOwner {\\n uint256 tokensLength = tokens_.length;\\n _ensureMaxLoops(tokensLength);\\n\\n for (uint256 i; i < tokensLength; ) {\\n _initializeToken(tokens_[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Pause fund transfer of tokens to Prime contract\\n * @custom:access Controlled by ACM\\n */\\n function pauseFundsTransfer() external {\\n _checkAccessAllowed(\\\"pauseFundsTransfer()\\\");\\n _pause();\\n }\\n\\n /**\\n * @notice Resume fund transfer of tokens to Prime contract\\n * @custom:access Controlled by ACM\\n */\\n function resumeFundsTransfer() external {\\n _checkAccessAllowed(\\\"resumeFundsTransfer()\\\");\\n _unpause();\\n }\\n\\n /**\\n * @notice Set distribution speed (amount of token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param distributionSpeeds_ New distribution speeds for tokens\\n * @custom:access Controlled by ACM\\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\\n */\\n function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external {\\n _checkAccessAllowed(\\\"setTokensDistributionSpeed(address[],uint256[])\\\");\\n uint256 numTokens = tokens_.length;\\n _ensureMaxLoops(numTokens);\\n\\n if (numTokens != distributionSpeeds_.length) {\\n revert InvalidArguments();\\n }\\n\\n for (uint256 i; i < numTokens; ) {\\n _ensureTokenInitialized(tokens_[i]);\\n _setTokenDistributionSpeed(tokens_[i], distributionSpeeds_[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param maxDistributionSpeeds_ New distribution speeds for tokens\\n * @custom:access Controlled by ACM\\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\\n */\\n function setMaxTokensDistributionSpeed(\\n address[] calldata tokens_,\\n uint256[] calldata maxDistributionSpeeds_\\n ) external {\\n _checkAccessAllowed(\\\"setMaxTokensDistributionSpeed(address[],uint256[])\\\");\\n uint256 numTokens = tokens_.length;\\n _ensureMaxLoops(numTokens);\\n\\n if (numTokens != maxDistributionSpeeds_.length) {\\n revert InvalidArguments();\\n }\\n\\n for (uint256 i; i < numTokens; ) {\\n _setMaxTokenDistributionSpeed(tokens_[i], maxDistributionSpeeds_[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Set the prime token contract address\\n * @param prime_ The new address of the prime token contract\\n * @custom:event Emits PrimeTokenUpdated event\\n * @custom:access Only owner\\n */\\n function setPrimeToken(address prime_) external onlyOwner compareAddress(prime, prime_) {\\n _ensureZeroAddress(prime_);\\n\\n emit PrimeTokenUpdated(prime, prime_);\\n prime = prime_;\\n }\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Limit for the max loops can execute at a time\\n * @custom:event Emits MaxLoopsLimitUpdated event on success\\n * @custom:access Controlled by ACM\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external {\\n _checkAccessAllowed(\\\"setMaxLoopsLimit(uint256)\\\");\\n _setMaxLoopsLimit(loopsLimit);\\n }\\n\\n /**\\n * @notice Claim all the token accrued till last block or second\\n * @param token_ The token to release to the Prime contract\\n * @custom:event Emits TokenTransferredToPrime event\\n * @custom:error Throw InvalidArguments on Zero address(token)\\n * @custom:error Throw FundsTransferIsPaused is paused\\n * @custom:error Throw InvalidCaller if the sender is not the Prime contract\\n */\\n function releaseFunds(address token_) external {\\n address _prime = prime;\\n if (msg.sender != _prime) revert InvalidCaller();\\n if (paused()) {\\n revert FundsTransferIsPaused();\\n }\\n\\n accrueTokens(token_);\\n uint256 accruedAmount = _tokenAmountAccrued[token_];\\n delete _tokenAmountAccrued[token_];\\n\\n emit TokenTransferredToPrime(token_, accruedAmount);\\n\\n IERC20Upgradeable(token_).safeTransfer(_prime, accruedAmount);\\n }\\n\\n /**\\n * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\\n * @param token_ The address of the ERC-20 token to sweep\\n * @param to_ The address of the recipient\\n * @param amount_ The amount of tokens needs to transfer\\n * @custom:event Emits SweepToken event\\n * @custom:error Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract\\n * @custom:access Only Governance\\n */\\n function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external onlyOwner {\\n uint256 balance = token_.balanceOf(address(this));\\n if (amount_ > balance) {\\n revert InsufficientBalance(amount_, balance);\\n }\\n\\n emit SweepToken(address(token_), to_, amount_);\\n\\n token_.safeTransfer(to_, amount_);\\n }\\n\\n /**\\n * @notice Get rewards per block or second for token\\n * @param token_ Address of the token\\n * @return speed returns the per block or second reward\\n */\\n function getEffectiveDistributionSpeed(address token_) external view returns (uint256) {\\n uint256 distributionSpeed = tokenDistributionSpeeds[token_];\\n uint256 balance = IERC20Upgradeable(token_).balanceOf(address(this));\\n uint256 accrued = _tokenAmountAccrued[token_];\\n\\n if (balance > accrued) {\\n return distributionSpeed;\\n }\\n\\n return 0;\\n }\\n\\n /**\\n * @notice Accrue token by updating the distribution state\\n * @param token_ Address of the token\\n * @custom:event Emits TokensAccrued event\\n */\\n function accrueTokens(address token_) public {\\n _ensureZeroAddress(token_);\\n\\n _ensureTokenInitialized(token_);\\n\\n uint256 blockNumberOrSecond = getBlockNumberOrTimestamp();\\n uint256 deltaBlocksOrSeconds;\\n unchecked {\\n deltaBlocksOrSeconds = blockNumberOrSecond - lastAccruedBlockOrSecond[token_];\\n }\\n\\n if (deltaBlocksOrSeconds != 0) {\\n uint256 distributionSpeed = tokenDistributionSpeeds[token_];\\n uint256 balance = IERC20Upgradeable(token_).balanceOf(address(this));\\n\\n uint256 balanceDiff = balance - _tokenAmountAccrued[token_];\\n if (distributionSpeed != 0 && balanceDiff != 0) {\\n uint256 accruedSinceUpdate = deltaBlocksOrSeconds * distributionSpeed;\\n uint256 tokenAccrued = (balanceDiff <= accruedSinceUpdate ? balanceDiff : accruedSinceUpdate);\\n\\n _tokenAmountAccrued[token_] += tokenAccrued;\\n emit TokensAccrued(token_, tokenAccrued);\\n }\\n\\n lastAccruedBlockOrSecond[token_] = blockNumberOrSecond;\\n }\\n }\\n\\n /**\\n * @notice Get the last accrued block or second for token\\n * @param token_ Address of the token\\n * @return blockNumberOrSecond returns the last accrued block or second\\n */\\n function lastAccruedBlock(address token_) external view returns (uint256) {\\n return lastAccruedBlockOrSecond[token_];\\n }\\n\\n /**\\n * @notice Get the tokens accrued\\n * @param token_ Address of the token\\n * @return returns the amount of accrued tokens for the token provided\\n */\\n function tokenAmountAccrued(address token_) external view returns (uint256) {\\n return _tokenAmountAccrued[token_];\\n }\\n\\n /**\\n * @notice Initialize the distribution of the token\\n * @param token_ Address of the token to be intialized\\n * @custom:event Emits TokenDistributionInitialized event\\n * @custom:error Throw TokenAlreadyInitialized if token is already initialized\\n */\\n function _initializeToken(address token_) internal {\\n _ensureZeroAddress(token_);\\n uint256 blockNumberOrSecond = getBlockNumberOrTimestamp();\\n uint256 initializedBlockOrSecond = lastAccruedBlockOrSecond[token_];\\n\\n if (initializedBlockOrSecond != 0) {\\n revert TokenAlreadyInitialized(token_);\\n }\\n\\n /*\\n * Update token state block number or second\\n */\\n lastAccruedBlockOrSecond[token_] = blockNumberOrSecond;\\n\\n emit TokenDistributionInitialized(token_);\\n }\\n\\n /**\\n * @notice Set distribution speed (amount of token distribute per block or second)\\n * @param token_ Address of the token\\n * @param distributionSpeed_ New distribution speed for token\\n * @custom:event Emits TokenDistributionSpeedUpdated event\\n * @custom:error Throw InvalidDistributionSpeed if speed is greater than max speed\\n */\\n function _setTokenDistributionSpeed(address token_, uint256 distributionSpeed_) internal {\\n uint256 maxDistributionSpeed = maxTokenDistributionSpeeds[token_];\\n if (maxDistributionSpeed == 0) {\\n maxTokenDistributionSpeeds[token_] = maxDistributionSpeed = DEFAULT_MAX_DISTRIBUTION_SPEED;\\n }\\n\\n if (distributionSpeed_ > maxDistributionSpeed) {\\n revert InvalidDistributionSpeed(distributionSpeed_, maxDistributionSpeed);\\n }\\n\\n uint256 oldDistributionSpeed = tokenDistributionSpeeds[token_];\\n if (oldDistributionSpeed != distributionSpeed_) {\\n // Distribution speed updated so let's update distribution state to ensure that\\n // 1. Token accrued properly for the old speed, and\\n // 2. Token accrued at the new speed starts after this block or second.\\n accrueTokens(token_);\\n\\n // Update speed\\n tokenDistributionSpeeds[token_] = distributionSpeed_;\\n\\n emit TokenDistributionSpeedUpdated(token_, oldDistributionSpeed, distributionSpeed_);\\n }\\n }\\n\\n /**\\n * @notice Set max distribution speed (amount of maximum token distribute per block or second)\\n * @param token_ Address of the token\\n * @param maxDistributionSpeed_ New max distribution speed for token\\n * @custom:event Emits MaxTokenDistributionSpeedUpdated event\\n */\\n function _setMaxTokenDistributionSpeed(address token_, uint256 maxDistributionSpeed_) internal {\\n emit MaxTokenDistributionSpeedUpdated(token_, tokenDistributionSpeeds[token_], maxDistributionSpeed_);\\n maxTokenDistributionSpeeds[token_] = maxDistributionSpeed_;\\n }\\n\\n /**\\n * @notice Revert on non initialized token\\n * @param token_ Token Address to be verified for\\n */\\n function _ensureTokenInitialized(address token_) internal view {\\n uint256 lastBlockOrSecondAccrued = lastAccruedBlockOrSecond[token_];\\n\\n if (lastBlockOrSecondAccrued == 0) {\\n revert TokenNotInitialized(token_);\\n }\\n }\\n\\n /**\\n * @notice Revert on zero address\\n * @param address_ Address to be verified\\n */\\n function _ensureZeroAddress(address address_) internal pure {\\n if (address_ == address(0)) {\\n revert InvalidArguments();\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8fa6826d33694827d2007991f36311a5c1e3a1bc9809e8e704e0de0ce26c83ff\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/PrimeLiquidityProviderStorage.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\n/**\\n * @title PrimeLiquidityProviderStorageV1\\n * @author Venus\\n * @notice Storage for Prime Liquidity Provider\\n */\\ncontract PrimeLiquidityProviderStorageV1 {\\n /// @notice Address of the Prime contract\\n address public prime;\\n\\n /// @notice The rate at which token is distributed (per block or second)\\n mapping(address => uint256) public tokenDistributionSpeeds;\\n\\n /// @notice The max token distribution speed for token\\n mapping(address => uint256) public maxTokenDistributionSpeeds;\\n\\n /// @notice The block or second till which rewards are distributed for an asset\\n mapping(address => uint256) public lastAccruedBlockOrSecond;\\n\\n /// @notice The token accrued but not yet transferred to prime contract\\n mapping(address => uint256) internal _tokenAmountAccrued;\\n\\n /// @dev This empty reserved space is put in place to allow future versions to add new\\n /// variables without shifting down storage in the inheritance chain.\\n uint256[45] private __gap;\\n}\\n\",\"keccak256\":\"0x697e43e039edbec0f14857b1d118fa55f5ca87b2b284dad0a363013d885e7c29\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", + "bytecode": "0x60e060405234801561001057600080fd5b5060405161207a38038061207a83398101604081905261002f916101a3565b81818115801561003d575080155b1561005b576040516302723dfb60e21b815260040160405180910390fd5b81801561006757508015155b156100855760405163ae0fcab360e01b815260040160405180910390fd5b81151560a05281610096578061009c565b6301e133805b608052816100b3576100dc60201b610f61176100be565b6100e060201b610f65175b6001600160401b031660c052506100d590506100e4565b50506101d6565b4390565b4290565b600054610100900460ff16156101505760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146101a1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b600080604083850312156101b657600080fd5b825180151581146101c657600080fd5b6020939093015192949293505050565b60805160a05160c051611e756102056000396000610cb7015260006103e8015260006102db0152611e756000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c806393920bf81161010f578063c7ad0895116100a2578063e30c397811610071578063e30c397814610439578063e458a65d1461044a578063f2fde38b1461045d578063fa7781ff1461047057600080fd5b8063c7ad0895146103e3578063c7ee005e1461040a578063ce82e8411461041e578063e1d146fb1461043157600080fd5b8063b4a0bdf3116100de578063b4a0bdf3146103ae578063bc2f7dc3146103bf578063be26317e146103c7578063c32094c7146103d057600080fd5b806393920bf8146103585780639d3cc5431461036b5780639dd5428e1461038c578063a666642b1461039b57600080fd5b8063637c9b4e1161018757806379ba50971161015657806379ba50971461030557806380d45a2d1461030d5780638aadf799146103205780638da5cb5b1461033357600080fd5b8063637c9b4e146102a257806364aff9ec146102c35780636857249c146102d6578063715018a6146102fd57600080fd5b80633131b065116101c35780633131b0651461024657806343bf7283146102595780635a38f84d146102835780635c975abb1461028b57600080fd5b80630e32cb86146101ea578063192e7a7b146101ff578063231f82bb14610212575b600080fd5b6101fd6101f83660046119e5565b61049a565b005b6101fd61020d3660046119e5565b6104ae565b6102336102203660046119e5565b61012e6020526000908152604090205481565b6040519081526020015b60405180910390f35b6101fd610254366004611a55565b610574565b6102336102673660046119e5565b6001600160a01b03166000908152610130602052604090205490565b6101fd6105ce565b60c95460ff165b604051901515815260200161023d565b6102336102b03660046119e5565b61012f6020526000908152604090205481565b6101fd6102d1366004611a97565b61060d565b6102337f000000000000000000000000000000000000000000000000000000000000000081565b6101fd610713565b6101fd610725565b6101fd61031b366004611ad8565b61079c565b6101fd61032e3660046119e5565b6107e3565b6033546001600160a01b03165b6040516001600160a01b03909116815260200161023d565b6101fd610366366004611af1565b610993565b6102336103793660046119e5565b6101306020526000908152604090205481565b610233670de0b6b3a764000081565b6102336103a93660046119e5565b610a41565b6097546001600160a01b0316610340565b6101fd610af8565b61023360fb5481565b6101fd6103de3660046119e5565b610b36565b6102927f000000000000000000000000000000000000000000000000000000000000000081565b61012d54610340906001600160a01b031681565b6101fd61042c366004611af1565b610bdb565b610233610cb0565b6065546001600160a01b0316610340565b6101fd610458366004611b5d565b610ce3565b6101fd61046b3660046119e5565b610ef0565b61023361047e3660046119e5565b6001600160a01b03166000908152610131602052604090205490565b6104a2610f69565b6104ab81610fc3565b50565b61012d546001600160a01b03163381146104db576040516348f5c3ed60e01b815260040160405180910390fd5b60c95460ff16156104ff5760405163f4eaf50160e01b815260040160405180910390fd5b610508826107e3565b6001600160a01b0382166000818152610131602090815260408083208054939055518281529192917fa80c25cc8959419d41ee66f93961c567b272badc10e0e117261a0ee31b55c312910160405180910390a261056f6001600160a01b0384168383611089565b505050565b61057c610f69565b80610586816110db565b60005b818110156105c8576105c08484838181106105a6576105a6611c11565b90506020020160208101906105bb91906119e5565b61110c565b600101610589565b50505050565b61060360405180604001604052806014815260200173706175736546756e64735472616e73666572282960601b8152506111ad565b61060b61124b565b565b610615610f69565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106809190611c27565b9050808211156106b25760405163cf47918160e01b815260048101839052602481018290526044015b60405180910390fd5b826001600160a01b0316846001600160a01b03167f6d25be279134f4ecaa4770aff0c3d916d9e7c5ef37b65ed95dbdba411f5d54d5846040516106f791815260200190565b60405180910390a36105c86001600160a01b0385168484611089565b61071b610f69565b61060b60006112a5565b60655433906001600160a01b031681146107935760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016106a9565b6104ab816112a5565b6107da6040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e7432353629000000000000008152506111ad565b6104ab816112be565b6107ec81611358565b6107f58161137f565b60006107ff610cb0565b6001600160a01b0383166000908152610130602052604090205490915080820390821461056f576001600160a01b038316600081815261012e60205260408082205490516370a0823160e01b81523060048201529092906370a0823190602401602060405180830381865afa15801561087c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a09190611c27565b6001600160a01b03861660009081526101316020526040812054919250906108c89083611c56565b905082158015906108d857508015155b156109715760006108e98486611c6f565b90506000818311156108fb57816108fd565b825b6001600160a01b0389166000908152610131602052604081208054929350839290919061092b908490611c86565b90915550506040518181526001600160a01b038916907ffe854c4c4e633d5bb31aec1f39f01d9f8f01ad2e0212a0e576825ac986af05899060200160405180910390a250505b505050506001600160a01b039190911660009081526101306020526040902055565b6109b4604051806060016040528060328152602001611ddf603291396111ad565b826109be816110db565b8082146109de576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610a3957610a318686838181106109fe576109fe611c11565b9050602002016020810190610a1391906119e5565b858584818110610a2557610a25611c11565b905060200201356113c5565b6001016109e1565b505050505050565b6001600160a01b038116600081815261012e60205260408082205490516370a0823160e01b8152306004820152919290918391906370a0823190602401602060405180830381865afa158015610a9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abf9190611c27565b6001600160a01b0385166000908152610131602052604090205490915080821115610aed5750909392505050565b506000949350505050565b610b2e60405180604001604052806015815260200174726573756d6546756e64735472616e73666572282960581b8152506111ad565b61060b611436565b610b3e610f69565b61012d546001600160a01b039081169082908116829003610b72576040516380ae98f560e01b815260040160405180910390fd5b610b7b83611358565b61012d546040516001600160a01b038086169216907fcf4d0ac7a2f943727f0189dd1f26ba0cde29a1b14f222163ac866d4f5167db9490600090a3505061012d80546001600160a01b0319166001600160a01b0392909216919091179055565b610bfc6040518060600160405280602f8152602001611e11602f91396111ad565b82610c06816110db565b808214610c26576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610a3957610c60868683818110610c4657610c46611c11565b9050602002016020810190610c5b91906119e5565b61137f565b610ca8868683818110610c7557610c75611c11565b9050602002016020810190610c8a91906119e5565b858584818110610c9c57610c9c611c11565b9050602002013561146f565b600101610c29565b6000610cde7f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b600054610100900460ff1615808015610d035750600054600160ff909116105b80610d1d5750303b158015610d1d575060005460ff166001145b610d805760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106a9565b6000805460ff191660011790558015610da3576000805461ff0019166101001790555b610dac89611358565b610db58961156a565b610dbd6115a2565b610dc6826112be565b86610dd0816110db565b8086141580610ddf5750808414155b15610dfd576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610e9d57610e1d8a8a838181106105a6576105a6611c11565b610e598a8a83818110610e3257610e32611c11565b9050602002016020810190610e4791906119e5565b878784818110610a2557610a25611c11565b610e958a8a83818110610e6e57610e6e611c11565b9050602002016020810190610e8391906119e5565b898984818110610c9c57610c9c611c11565b600101610e00565b50508015610ee5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b610ef8610f69565b606580546001600160a01b0383166001600160a01b03199091168117909155610f296033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b4390565b4290565b6033546001600160a01b0316331461060b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106a9565b6001600160a01b0381166110275760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b60648201526084016106a9565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091015b60405180910390a15050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261056f9084906115d1565b60fb548111156104ab5760fb5460405163792bfb1b60e11b81526004810191909152602481018290526044016106a9565b61111581611358565b600061111f610cb0565b6001600160a01b038316600090815261013060205260409020549091508015611166576040516303b51ceb60e11b81526001600160a01b03841660048201526024016106a9565b6001600160a01b03831660008181526101306020526040808220859055517fcf6e06116a82c1b468912f23d8bb1d126edbb21bc0864d6d5169e3be39b1a8189190a2505050565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906111e09033908690600401611ce9565b602060405180830381865afa1580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112219190611d0d565b90508061124757333083604051634a3fa29360e01b81526004016106a993929190611d2f565b5050565b6112536116a6565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586112883390565b6040516001600160a01b03909116815260200160405180910390a1565b606580546001600160a01b03191690556104ab816116ec565b60fb54811161131a5760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b60648201526084016106a9565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa910161107d565b6001600160a01b0381166104ab576040516317dbc4cb60e21b815260040160405180910390fd5b6001600160a01b0381166000908152610130602052604081205490819003611247576040516341ea4b5960e01b81526001600160a01b03831660048201526024016106a9565b6001600160a01b038216600081815261012e60209081526040918290205482519081529081018490527f2351eb1e51f0d96d3d2dc08e3c9bddbdb2153580843330b57433c3bf5031be01910160405180910390a26001600160a01b03909116600090815261012f6020526040902055565b61143e61173e565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611288565b6001600160a01b038216600090815261012f6020526040812054908190036114b957506001600160a01b038216600090815261012f60205260409020670de0b6b3a7640000908190555b808211156114e457604051631cf8f4dd60e11b815260048101839052602481018290526044016106a9565b6001600160a01b038316600090815261012e60205260409020548281146105c85761150e846107e3565b6001600160a01b038416600081815261012e602090815260409182902086905581518481529081018690527f2a139b40b9bf8c89ae5053746323912620b9d8ea3b076b098b1bc57702abf3a5910160405180910390a250505050565b600054610100900460ff166115915760405162461bcd60e51b81526004016106a990611d64565b611599611787565b6104ab816117b6565b600054610100900460ff166115c95760405162461bcd60e51b81526004016106a990611d64565b61060b6117dd565b6000611626826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118109092919063ffffffff16565b90508051600014806116475750808060200190518101906116479190611d0d565b61056f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106a9565b60c95460ff161561060b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106a9565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60c95460ff1661060b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016106a9565b600054610100900460ff166117ae5760405162461bcd60e51b81526004016106a990611d64565b61060b611827565b600054610100900460ff166104a25760405162461bcd60e51b81526004016106a990611d64565b600054610100900460ff166118045760405162461bcd60e51b81526004016106a990611d64565b60c9805460ff19169055565b606061181f8484600085611857565b949350505050565b600054610100900460ff1661184e5760405162461bcd60e51b81526004016106a990611d64565b61060b336112a5565b6060824710156118b85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106a9565b600080866001600160a01b031685876040516118d49190611daf565b60006040518083038185875af1925050503d8060008114611911576040519150601f19603f3d011682016040523d82523d6000602084013e611916565b606091505b509150915061192787838387611932565b979650505050505050565b606083156119a157825160000361199a576001600160a01b0385163b61199a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106a9565b508161181f565b61181f83838151156119b65781518083602001fd5b8060405162461bcd60e51b81526004016106a99190611dcb565b6001600160a01b03811681146104ab57600080fd5b6000602082840312156119f757600080fd5b8135611a02816119d0565b9392505050565b60008083601f840112611a1b57600080fd5b50813567ffffffffffffffff811115611a3357600080fd5b6020830191508360208260051b8501011115611a4e57600080fd5b9250929050565b60008060208385031215611a6857600080fd5b823567ffffffffffffffff811115611a7f57600080fd5b611a8b85828601611a09565b90969095509350505050565b600080600060608486031215611aac57600080fd5b8335611ab7816119d0565b92506020840135611ac7816119d0565b929592945050506040919091013590565b600060208284031215611aea57600080fd5b5035919050565b60008060008060408587031215611b0757600080fd5b843567ffffffffffffffff80821115611b1f57600080fd5b611b2b88838901611a09565b90965094506020870135915080821115611b4457600080fd5b50611b5187828801611a09565b95989497509550505050565b60008060008060008060008060a0898b031215611b7957600080fd5b8835611b84816119d0565b9750602089013567ffffffffffffffff80821115611ba157600080fd5b611bad8c838d01611a09565b909950975060408b0135915080821115611bc657600080fd5b611bd28c838d01611a09565b909750955060608b0135915080821115611beb57600080fd5b50611bf88b828c01611a09565b999c989b50969995989497949560800135949350505050565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611c3957600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611c6957611c69611c40565b92915050565b8082028115828204841417611c6957611c69611c40565b80820180821115611c6957611c69611c40565b60005b83811015611cb4578181015183820152602001611c9c565b50506000910152565b60008151808452611cd5816020860160208601611c99565b601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009061181f90830184611cbd565b600060208284031215611d1f57600080fd5b81518015158114611a0257600080fd5b6001600160a01b03848116825283166020820152606060408201819052600090611d5b90830184611cbd565b95945050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251611dc1818460208701611c99565b9190910192915050565b602081526000611a026020830184611cbd56fe7365744d6178546f6b656e73446973747269627574696f6e537065656428616464726573735b5d2c75696e743235365b5d29736574546f6b656e73446973747269627574696f6e537065656428616464726573735b5d2c75696e743235365b5d29a26469706673582212200c9d46a058dbf3a96c4cd4ce25d3f05a6a88096bf609a1ae8de1fb215c20c2b864736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101e55760003560e01c806393920bf81161010f578063c7ad0895116100a2578063e30c397811610071578063e30c397814610439578063e458a65d1461044a578063f2fde38b1461045d578063fa7781ff1461047057600080fd5b8063c7ad0895146103e3578063c7ee005e1461040a578063ce82e8411461041e578063e1d146fb1461043157600080fd5b8063b4a0bdf3116100de578063b4a0bdf3146103ae578063bc2f7dc3146103bf578063be26317e146103c7578063c32094c7146103d057600080fd5b806393920bf8146103585780639d3cc5431461036b5780639dd5428e1461038c578063a666642b1461039b57600080fd5b8063637c9b4e1161018757806379ba50971161015657806379ba50971461030557806380d45a2d1461030d5780638aadf799146103205780638da5cb5b1461033357600080fd5b8063637c9b4e146102a257806364aff9ec146102c35780636857249c146102d6578063715018a6146102fd57600080fd5b80633131b065116101c35780633131b0651461024657806343bf7283146102595780635a38f84d146102835780635c975abb1461028b57600080fd5b80630e32cb86146101ea578063192e7a7b146101ff578063231f82bb14610212575b600080fd5b6101fd6101f83660046119e5565b61049a565b005b6101fd61020d3660046119e5565b6104ae565b6102336102203660046119e5565b61012e6020526000908152604090205481565b6040519081526020015b60405180910390f35b6101fd610254366004611a55565b610574565b6102336102673660046119e5565b6001600160a01b03166000908152610130602052604090205490565b6101fd6105ce565b60c95460ff165b604051901515815260200161023d565b6102336102b03660046119e5565b61012f6020526000908152604090205481565b6101fd6102d1366004611a97565b61060d565b6102337f000000000000000000000000000000000000000000000000000000000000000081565b6101fd610713565b6101fd610725565b6101fd61031b366004611ad8565b61079c565b6101fd61032e3660046119e5565b6107e3565b6033546001600160a01b03165b6040516001600160a01b03909116815260200161023d565b6101fd610366366004611af1565b610993565b6102336103793660046119e5565b6101306020526000908152604090205481565b610233670de0b6b3a764000081565b6102336103a93660046119e5565b610a41565b6097546001600160a01b0316610340565b6101fd610af8565b61023360fb5481565b6101fd6103de3660046119e5565b610b36565b6102927f000000000000000000000000000000000000000000000000000000000000000081565b61012d54610340906001600160a01b031681565b6101fd61042c366004611af1565b610bdb565b610233610cb0565b6065546001600160a01b0316610340565b6101fd610458366004611b5d565b610ce3565b6101fd61046b3660046119e5565b610ef0565b61023361047e3660046119e5565b6001600160a01b03166000908152610131602052604090205490565b6104a2610f69565b6104ab81610fc3565b50565b61012d546001600160a01b03163381146104db576040516348f5c3ed60e01b815260040160405180910390fd5b60c95460ff16156104ff5760405163f4eaf50160e01b815260040160405180910390fd5b610508826107e3565b6001600160a01b0382166000818152610131602090815260408083208054939055518281529192917fa80c25cc8959419d41ee66f93961c567b272badc10e0e117261a0ee31b55c312910160405180910390a261056f6001600160a01b0384168383611089565b505050565b61057c610f69565b80610586816110db565b60005b818110156105c8576105c08484838181106105a6576105a6611c11565b90506020020160208101906105bb91906119e5565b61110c565b600101610589565b50505050565b61060360405180604001604052806014815260200173706175736546756e64735472616e73666572282960601b8152506111ad565b61060b61124b565b565b610615610f69565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106809190611c27565b9050808211156106b25760405163cf47918160e01b815260048101839052602481018290526044015b60405180910390fd5b826001600160a01b0316846001600160a01b03167f6d25be279134f4ecaa4770aff0c3d916d9e7c5ef37b65ed95dbdba411f5d54d5846040516106f791815260200190565b60405180910390a36105c86001600160a01b0385168484611089565b61071b610f69565b61060b60006112a5565b60655433906001600160a01b031681146107935760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016106a9565b6104ab816112a5565b6107da6040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e7432353629000000000000008152506111ad565b6104ab816112be565b6107ec81611358565b6107f58161137f565b60006107ff610cb0565b6001600160a01b0383166000908152610130602052604090205490915080820390821461056f576001600160a01b038316600081815261012e60205260408082205490516370a0823160e01b81523060048201529092906370a0823190602401602060405180830381865afa15801561087c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a09190611c27565b6001600160a01b03861660009081526101316020526040812054919250906108c89083611c56565b905082158015906108d857508015155b156109715760006108e98486611c6f565b90506000818311156108fb57816108fd565b825b6001600160a01b0389166000908152610131602052604081208054929350839290919061092b908490611c86565b90915550506040518181526001600160a01b038916907ffe854c4c4e633d5bb31aec1f39f01d9f8f01ad2e0212a0e576825ac986af05899060200160405180910390a250505b505050506001600160a01b039190911660009081526101306020526040902055565b6109b4604051806060016040528060328152602001611ddf603291396111ad565b826109be816110db565b8082146109de576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610a3957610a318686838181106109fe576109fe611c11565b9050602002016020810190610a1391906119e5565b858584818110610a2557610a25611c11565b905060200201356113c5565b6001016109e1565b505050505050565b6001600160a01b038116600081815261012e60205260408082205490516370a0823160e01b8152306004820152919290918391906370a0823190602401602060405180830381865afa158015610a9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abf9190611c27565b6001600160a01b0385166000908152610131602052604090205490915080821115610aed5750909392505050565b506000949350505050565b610b2e60405180604001604052806015815260200174726573756d6546756e64735472616e73666572282960581b8152506111ad565b61060b611436565b610b3e610f69565b61012d546001600160a01b039081169082908116829003610b72576040516380ae98f560e01b815260040160405180910390fd5b610b7b83611358565b61012d546040516001600160a01b038086169216907fcf4d0ac7a2f943727f0189dd1f26ba0cde29a1b14f222163ac866d4f5167db9490600090a3505061012d80546001600160a01b0319166001600160a01b0392909216919091179055565b610bfc6040518060600160405280602f8152602001611e11602f91396111ad565b82610c06816110db565b808214610c26576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610a3957610c60868683818110610c4657610c46611c11565b9050602002016020810190610c5b91906119e5565b61137f565b610ca8868683818110610c7557610c75611c11565b9050602002016020810190610c8a91906119e5565b858584818110610c9c57610c9c611c11565b9050602002013561146f565b600101610c29565b6000610cde7f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b600054610100900460ff1615808015610d035750600054600160ff909116105b80610d1d5750303b158015610d1d575060005460ff166001145b610d805760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106a9565b6000805460ff191660011790558015610da3576000805461ff0019166101001790555b610dac89611358565b610db58961156a565b610dbd6115a2565b610dc6826112be565b86610dd0816110db565b8086141580610ddf5750808414155b15610dfd576040516317dbc4cb60e21b815260040160405180910390fd5b60005b81811015610e9d57610e1d8a8a838181106105a6576105a6611c11565b610e598a8a83818110610e3257610e32611c11565b9050602002016020810190610e4791906119e5565b878784818110610a2557610a25611c11565b610e958a8a83818110610e6e57610e6e611c11565b9050602002016020810190610e8391906119e5565b898984818110610c9c57610c9c611c11565b600101610e00565b50508015610ee5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b610ef8610f69565b606580546001600160a01b0383166001600160a01b03199091168117909155610f296033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b4390565b4290565b6033546001600160a01b0316331461060b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106a9565b6001600160a01b0381166110275760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b60648201526084016106a9565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa091015b60405180910390a15050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261056f9084906115d1565b60fb548111156104ab5760fb5460405163792bfb1b60e11b81526004810191909152602481018290526044016106a9565b61111581611358565b600061111f610cb0565b6001600160a01b038316600090815261013060205260409020549091508015611166576040516303b51ceb60e11b81526001600160a01b03841660048201526024016106a9565b6001600160a01b03831660008181526101306020526040808220859055517fcf6e06116a82c1b468912f23d8bb1d126edbb21bc0864d6d5169e3be39b1a8189190a2505050565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab906111e09033908690600401611ce9565b602060405180830381865afa1580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112219190611d0d565b90508061124757333083604051634a3fa29360e01b81526004016106a993929190611d2f565b5050565b6112536116a6565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586112883390565b6040516001600160a01b03909116815260200160405180910390a1565b606580546001600160a01b03191690556104ab816116ec565b60fb54811161131a5760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b60648201526084016106a9565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa910161107d565b6001600160a01b0381166104ab576040516317dbc4cb60e21b815260040160405180910390fd5b6001600160a01b0381166000908152610130602052604081205490819003611247576040516341ea4b5960e01b81526001600160a01b03831660048201526024016106a9565b6001600160a01b038216600081815261012e60209081526040918290205482519081529081018490527f2351eb1e51f0d96d3d2dc08e3c9bddbdb2153580843330b57433c3bf5031be01910160405180910390a26001600160a01b03909116600090815261012f6020526040902055565b61143e61173e565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611288565b6001600160a01b038216600090815261012f6020526040812054908190036114b957506001600160a01b038216600090815261012f60205260409020670de0b6b3a7640000908190555b808211156114e457604051631cf8f4dd60e11b815260048101839052602481018290526044016106a9565b6001600160a01b038316600090815261012e60205260409020548281146105c85761150e846107e3565b6001600160a01b038416600081815261012e602090815260409182902086905581518481529081018690527f2a139b40b9bf8c89ae5053746323912620b9d8ea3b076b098b1bc57702abf3a5910160405180910390a250505050565b600054610100900460ff166115915760405162461bcd60e51b81526004016106a990611d64565b611599611787565b6104ab816117b6565b600054610100900460ff166115c95760405162461bcd60e51b81526004016106a990611d64565b61060b6117dd565b6000611626826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118109092919063ffffffff16565b90508051600014806116475750808060200190518101906116479190611d0d565b61056f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106a9565b60c95460ff161561060b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106a9565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60c95460ff1661060b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016106a9565b600054610100900460ff166117ae5760405162461bcd60e51b81526004016106a990611d64565b61060b611827565b600054610100900460ff166104a25760405162461bcd60e51b81526004016106a990611d64565b600054610100900460ff166118045760405162461bcd60e51b81526004016106a990611d64565b60c9805460ff19169055565b606061181f8484600085611857565b949350505050565b600054610100900460ff1661184e5760405162461bcd60e51b81526004016106a990611d64565b61060b336112a5565b6060824710156118b85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106a9565b600080866001600160a01b031685876040516118d49190611daf565b60006040518083038185875af1925050503d8060008114611911576040519150601f19603f3d011682016040523d82523d6000602084013e611916565b606091505b509150915061192787838387611932565b979650505050505050565b606083156119a157825160000361199a576001600160a01b0385163b61199a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106a9565b508161181f565b61181f83838151156119b65781518083602001fd5b8060405162461bcd60e51b81526004016106a99190611dcb565b6001600160a01b03811681146104ab57600080fd5b6000602082840312156119f757600080fd5b8135611a02816119d0565b9392505050565b60008083601f840112611a1b57600080fd5b50813567ffffffffffffffff811115611a3357600080fd5b6020830191508360208260051b8501011115611a4e57600080fd5b9250929050565b60008060208385031215611a6857600080fd5b823567ffffffffffffffff811115611a7f57600080fd5b611a8b85828601611a09565b90969095509350505050565b600080600060608486031215611aac57600080fd5b8335611ab7816119d0565b92506020840135611ac7816119d0565b929592945050506040919091013590565b600060208284031215611aea57600080fd5b5035919050565b60008060008060408587031215611b0757600080fd5b843567ffffffffffffffff80821115611b1f57600080fd5b611b2b88838901611a09565b90965094506020870135915080821115611b4457600080fd5b50611b5187828801611a09565b95989497509550505050565b60008060008060008060008060a0898b031215611b7957600080fd5b8835611b84816119d0565b9750602089013567ffffffffffffffff80821115611ba157600080fd5b611bad8c838d01611a09565b909950975060408b0135915080821115611bc657600080fd5b611bd28c838d01611a09565b909750955060608b0135915080821115611beb57600080fd5b50611bf88b828c01611a09565b999c989b50969995989497949560800135949350505050565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611c3957600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611c6957611c69611c40565b92915050565b8082028115828204841417611c6957611c69611c40565b80820180821115611c6957611c69611c40565b60005b83811015611cb4578181015183820152602001611c9c565b50506000910152565b60008151808452611cd5816020860160208601611c99565b601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009061181f90830184611cbd565b600060208284031215611d1f57600080fd5b81518015158114611a0257600080fd5b6001600160a01b03848116825283166020820152606060408201819052600090611d5b90830184611cbd565b95945050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251611dc1818460208701611c99565b9190910192915050565b602081526000611a026020830184611cbd56fe7365744d6178546f6b656e73446973747269627574696f6e537065656428616464726573735b5d2c75696e743235365b5d29736574546f6b656e73446973747269627574696f6e537065656428616464726573735b5d2c75696e743235365b5d29a26469706673582212200c9d46a058dbf3a96c4cd4ce25d3f05a6a88096bf609a1ae8de1fb215c20c2b864736f6c63430008190033", + "devdoc": { + "author": "Venus", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + }, + "Paused(address)": { + "details": "Emitted when the pause is triggered by `account`." + }, + "Unpaused(address)": { + "details": "Emitted when the pause is lifted by `account`." + } + }, + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "accrueTokens(address)": { + "custom:event": "Emits TokensAccrued event", + "params": { + "token_": "Address of the token" + } + }, + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor" + }, + "getBlockNumberOrTimestamp()": { + "details": "Function to simply retrieve block number or block timestamp", + "returns": { + "_0": "Current block number or block timestamp" + } + }, + "getEffectiveDistributionSpeed(address)": { + "params": { + "token_": "Address of the token" + }, + "returns": { + "_0": "speed returns the per block or second reward" + } + }, + "initialize(address,address[],uint256[],uint256[],uint256)": { + "custom:error": "Throw InvalidArguments on different length of tokens and speeds array", + "details": "Initializes the deployer to owner", + "params": { + "accessControlManager_": "AccessControlManager contract address", + "distributionSpeeds_": "New distribution speeds for tokens", + "loopsLimit_": "Maximum number of loops allowed in a single transaction", + "tokens_": "Array of addresses of the tokens" + } + }, + "initializeTokens(address[])": { + "custom:access": "Only Governance", + "params": { + "tokens_": "Array of addresses of the tokens to be intialized" + } + }, + "lastAccruedBlock(address)": { + "params": { + "token_": "Address of the token" + }, + "returns": { + "_0": "blockNumberOrSecond returns the last accrued block or second" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pauseFundsTransfer()": { + "custom:access": "Controlled by ACM" + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "releaseFunds(address)": { + "custom:error": "Throw InvalidArguments on Zero address(token)Throw FundsTransferIsPaused is pausedThrow InvalidCaller if the sender is not the Prime contract", + "custom:event": "Emits TokenTransferredToPrime event", + "params": { + "token_": "The token to release to the Prime contract" + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." + }, + "resumeFundsTransfer()": { + "custom:access": "Controlled by ACM" + }, + "setAccessControlManager(address)": { + "custom:access": "Only Governance", + "custom:event": "Emits NewAccessControlManager event", + "details": "Admin function to set address of AccessControlManager", + "params": { + "accessControlManager_": "The new address of the AccessControlManager" + } + }, + "setMaxLoopsLimit(uint256)": { + "custom:access": "Controlled by ACM", + "custom:event": "Emits MaxLoopsLimitUpdated event on success", + "params": { + "loopsLimit": "Limit for the max loops can execute at a time" + } + }, + "setMaxTokensDistributionSpeed(address[],uint256[])": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw InvalidArguments on different length of tokens and speeds array", + "params": { + "maxDistributionSpeeds_": "New distribution speeds for tokens", + "tokens_": "Array of addresses of the tokens" + } + }, + "setPrimeToken(address)": { + "custom:access": "Only owner", + "custom:event": "Emits PrimeTokenUpdated event", + "params": { + "prime_": "The new address of the prime token contract" + } + }, + "setTokensDistributionSpeed(address[],uint256[])": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw InvalidArguments on different length of tokens and speeds array", + "params": { + "distributionSpeeds_": "New distribution speeds for tokens", + "tokens_": "Array of addresses of the tokens" + } + }, + "sweepToken(address,address,uint256)": { + "custom:access": "Only Governance", + "custom:error": "Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract", + "custom:event": "Emits SweepToken event", + "params": { + "amount_": "The amount of tokens needs to transfer", + "to_": "The address of the recipient", + "token_": "The address of the ERC-20 token to sweep" + } + }, + "tokenAmountAccrued(address)": { + "params": { + "token_": "Address of the token" + }, + "returns": { + "_0": "returns the amount of accrued tokens for the token provided" + } + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "title": "PrimeLiquidityProvider", + "version": 1 + }, + "userdoc": { + "errors": { + "AddressesMustDiffer()": [ + { + "notice": "Error thrown when argument value in setter is same as previous value" + } + ], + "FundsTransferIsPaused()": [ + { + "notice": "Error thrown when funds transfer is paused" + } + ], + "InsufficientBalance(uint256,uint256)": [ + { + "notice": "Error thrown when PrimeLiquidityProvider's balance is less than sweep amount" + } + ], + "InvalidArguments()": [ + { + "notice": "Thrown when arguments are passed are invalid" + } + ], + "InvalidBlocksPerYear()": [ + { + "notice": "Thrown when blocks per year is invalid" + } + ], + "InvalidCaller()": [ + { + "notice": "Thrown when caller is not the desired caller" + } + ], + "InvalidDistributionSpeed(uint256,uint256)": [ + { + "notice": "Thrown when distribution speed is greater than maxTokenDistributionSpeeds[tokenAddress]" + } + ], + "InvalidTimeBasedConfiguration()": [ + { + "notice": "Thrown when time based but blocks per year is provided" + } + ], + "MaxLoopsLimitExceeded(uint256,uint256)": [ + { + "notice": "Thrown an error on maxLoopsLimit exceeds for any loop" + } + ], + "TokenAlreadyInitialized(address)": [ + { + "notice": "Thrown when token is initialized" + } + ], + "TokenNotInitialized(address)": [ + { + "notice": "Error thrown when accrueTokens is called for an uninitialized token" + } + ], + "Unauthorized(address,address,string)": [ + { + "notice": "Thrown when the action is prohibited by AccessControlManager" + } + ] + }, + "events": { + "MaxLoopsLimitUpdated(uint256,uint256)": { + "notice": "Emitted when max loops limit is set" + }, + "MaxTokenDistributionSpeedUpdated(address,uint256,uint256)": { + "notice": "Emitted when a new max distribution speed for token is set" + }, + "NewAccessControlManager(address,address)": { + "notice": "Emitted when access control manager contract address is changed" + }, + "PrimeTokenUpdated(address,address)": { + "notice": "Emitted when prime token contract address is changed" + }, + "SweepToken(address,address,uint256)": { + "notice": "Emitted on sweep token success" + }, + "TokenDistributionInitialized(address)": { + "notice": "Emitted when a token distribution is initialized" + }, + "TokenDistributionSpeedUpdated(address,uint256,uint256)": { + "notice": "Emitted when a new token distribution speed is set" + }, + "TokenTransferredToPrime(address,uint256)": { + "notice": "Emitted when token is transferred to the prime contract" + }, + "TokensAccrued(address,uint256)": { + "notice": "Emitted when distribution state(Index and block or second) is updated" + } + }, + "kind": "user", + "methods": { + "DEFAULT_MAX_DISTRIBUTION_SPEED()": { + "notice": "The default max token distribution speed" + }, + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "accrueTokens(address)": { + "notice": "Accrue token by updating the distribution state" + }, + "blocksOrSecondsPerYear()": { + "notice": "Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored" + }, + "getEffectiveDistributionSpeed(address)": { + "notice": "Get rewards per block or second for token" + }, + "initialize(address,address[],uint256[],uint256[],uint256)": { + "notice": "PrimeLiquidityProvider initializer" + }, + "initializeTokens(address[])": { + "notice": "Initialize the distribution of the token" + }, + "isTimeBased()": { + "notice": "Acknowledges if a contract is time based or not" + }, + "lastAccruedBlock(address)": { + "notice": "Get the last accrued block or second for token" + }, + "lastAccruedBlockOrSecond(address)": { + "notice": "The block or second till which rewards are distributed for an asset" + }, + "maxTokenDistributionSpeeds(address)": { + "notice": "The max token distribution speed for token" + }, + "pauseFundsTransfer()": { + "notice": "Pause fund transfer of tokens to Prime contract" + }, + "prime()": { + "notice": "Address of the Prime contract" + }, + "releaseFunds(address)": { + "notice": "Claim all the token accrued till last block or second" + }, + "resumeFundsTransfer()": { + "notice": "Resume fund transfer of tokens to Prime contract" + }, + "setAccessControlManager(address)": { + "notice": "Sets the address of AccessControlManager" + }, + "setMaxLoopsLimit(uint256)": { + "notice": "Set the limit for the loops can iterate to avoid the DOS" + }, + "setMaxTokensDistributionSpeed(address[],uint256[])": { + "notice": "Set max distribution speed for token (amount of maximum token distribute per block or second)" + }, + "setPrimeToken(address)": { + "notice": "Set the prime token contract address" + }, + "setTokensDistributionSpeed(address[],uint256[])": { + "notice": "Set distribution speed (amount of token distribute per block or second)" + }, + "sweepToken(address,address,uint256)": { + "notice": "A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user" + }, + "tokenAmountAccrued(address)": { + "notice": "Get the tokens accrued" + }, + "tokenDistributionSpeeds(address)": { + "notice": "The rate at which token is distributed (per block or second)" + } + }, + "notice": "PrimeLiquidityProvider is used to fund Prime", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 246, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 249, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1516, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 118, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 238, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 11, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 105, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 5863, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_accessControlManager", + "offset": 0, + "slot": "151", + "type": "t_contract(IAccessControlManagerV8)6048" + }, + { + "astId": 5868, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 430, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_paused", + "offset": 0, + "slot": "201", + "type": "t_bool" + }, + { + "astId": 535, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "202", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 6105, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "maxLoopsLimit", + "offset": 0, + "slot": "251", + "type": "t_uint256" + }, + { + "astId": 6110, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "252", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 22562, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "prime", + "offset": 0, + "slot": "301", + "type": "t_address" + }, + { + "astId": 22567, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "tokenDistributionSpeeds", + "offset": 0, + "slot": "302", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22572, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "maxTokenDistributionSpeeds", + "offset": 0, + "slot": "303", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22577, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "lastAccruedBlockOrSecond", + "offset": 0, + "slot": "304", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22582, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "_tokenAmountAccrued", + "offset": 0, + "slot": "305", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22587, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "306", + "type": "t_array(t_uint256)45_storage" + }, + { + "astId": 6191, + "contract": "contracts/Tokens/Prime/PrimeLiquidityProvider.sol:PrimeLiquidityProvider", + "label": "__gap", + "offset": 0, + "slot": "351", + "type": "t_array(t_uint256)48_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)45_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[45]", + "numberOfBytes": "1440" + }, + "t_array(t_uint256)48_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IAccessControlManagerV8)6048": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV8", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/opsepolia/PrimeLiquidityProvider_Proxy.json b/deployments/opsepolia/PrimeLiquidityProvider_Proxy.json new file mode 100644 index 000000000..30f7d58fc --- /dev/null +++ b/deployments/opsepolia/PrimeLiquidityProvider_Proxy.json @@ -0,0 +1,272 @@ +{ + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "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": [], + "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": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "transactionIndex": 6, + "gasUsed": "634674", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000800000000000000000000000000000000002000000000000000000000000000008000000000000000000000000000000002000001000000000000000000000000000000000000020000000000000000000800000000800000000400000000000000440000000000000000000040000000000000000000000080000000000000800000000000008000000000002000000400000000000000800000000000000000000000000020000000000000000401040000000000000400000000000000000020000000000200004000000000000000000000000800000000000000000000000000", + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7", + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "logs": [ + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000066aaabfb90852d16e419ab739a64bfa3b5b0a16f" + ], + "data": "0x", + "logIndex": 41, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000476c66ca1fe0e8abb45c8566d635dca9dc930f73" + ], + "data": "0x", + "logIndex": 42, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001652e12c8abe2f0d84466f0fc1fa4286491b3bc1", + "logIndex": 43, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": ["0xc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014", + "logIndex": 44, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 45, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + }, + { + "transactionIndex": 6, + "blockNumber": 17184814, + "transactionHash": "0xe742e082404afe9cd4e4e136c2a13a375eb10c81e8fdb3a2cb49f8b005dcfb8e", + "address": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a9aaf2a1ccf2c3a87997942abaa740887cc89241", + "logIndex": 46, + "blockHash": "0x060bd08daf1942e84a6ff12eedd3d5d89778d2d432196ae83630c874a36e12f7" + } + ], + "blockNumber": 17184814, + "cumulativeGasUsed": "2479729", + "status": 1, + "byzantium": true + }, + "args": [ + "0x66aaabFb90852D16e419aB739a64bFa3b5B0a16f", + "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", + "0xe458a65d0000000000000000000000001652e12c8abe2f0d84466f0fc1fa4286491b3bc100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"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\":[],\"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.\",\"events\":{\"AdminChanged(address,address)\":{\"details\":\"Emitted when the admin account has changed.\"},\"BeaconUpgraded(address)\":{\"details\":\"Emitted when the beacon is upgraded.\"},\"Upgraded(address)\":{\"details\":\"Emitted when the implementation is upgraded.\"}},\"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`\"},\"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\":{\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\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 _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a0604052604051610d1a380380610d1a833981016040819052610022916103d2565b828161004f60017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6104a2565b600080516020610cd38339815191521461006b5761006b6104c3565b61007782826000610128565b506100a5905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046104a2565b600080516020610cb3833981519152146100c1576100c16104c3565b6001600160a01b0382166080819052600080516020610cb38339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050610528565b61013183610154565b60008251118061013e5750805b1561014f5761014d8383610194565b505b505050565b61015d816101c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606101b98383604051806060016040528060278152602001610cf360279139610263565b90505b92915050565b6001600160a01b0381163b6102345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b600080516020610cd383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6102cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161022b565b600080856001600160a01b0316856040516102e691906104d9565b600060405180830381855af49150503d8060008114610321576040519150601f19603f3d011682016040523d82523d6000602084013e610326565b606091505b509092509050610337828286610343565b925050505b9392505050565b6060831561035257508161033c565b8251156103625782518084602001fd5b8160405162461bcd60e51b815260040161022b91906104f5565b80516001600160a01b038116811461039357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103c95781810151838201526020016103b1565b50506000910152565b6000806000606084860312156103e757600080fd5b6103f08461037c565b92506103fe6020850161037c565b60408501519092506001600160401b038082111561041b57600080fd5b818601915086601f83011261042f57600080fd5b81518181111561044157610441610398565b604051601f8201601f19908116603f0116810190838211818310171561046957610469610398565b8160405282815289602084870101111561048257600080fd5b6104938360208301602088016103ae565b80955050505050509250925092565b818103818111156101bc57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600082516104eb8184602087016103ae565b9190910192915050565b60208152600082518060208401526105148160408501602087016103ae565b601f01601f19169190910160400192915050565b60805161074e6105656000396000818160ef01528181610145015281816101c701528181610211015281816102420152610266015261074e6000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033", + "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.", + "events": { + "AdminChanged(address,address)": { + "details": "Emitted when the admin account has changed." + }, + "BeaconUpgraded(address)": { + "details": "Emitted when the beacon is upgraded." + }, + "Upgraded(address)": { + "details": "Emitted when the implementation is upgraded." + } + }, + "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`" + }, + "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/deployments/opsepolia/Prime_Implementation.json b/deployments/opsepolia/Prime_Implementation.json new file mode 100644 index 000000000..e19b4849f --- /dev/null +++ b/deployments/opsepolia/Prime_Implementation.json @@ -0,0 +1,2966 @@ +{ + "address": "0x84cca3c7719d1F9c35b5cfF14BE05801B8fD69d7", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_wrappedNativeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_nativeMarket", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_stakingPeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_minimumStakedXVS", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maximumXVSCap", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "_timeBased", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AssetAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "ExpTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "IneligibleToClaim", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAlphaArguments", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBlocksPerYear", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidComptroller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFixedPoint", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "d", + "type": "uint256" + } + ], + "name": "InvalidFraction", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLimit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimeBasedConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTimestamp", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVToken", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnNonRealResult", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "x", + "type": "int256" + } + ], + "name": "LnTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "MarketAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MarketNotSupported", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requiredLoops", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NoScoreUpdatesRequired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "UserHasNoPrimeToken", + "type": "error" + }, + { + "inputs": [], + "name": "WaitMoreTime", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "oldNumerator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "newNumerator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "AlphaUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "InterestClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaxLoopsLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newmaxLoopsLimit", + "type": "uint256" + } + ], + "name": "MaxLoopsLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "oldIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldRevocableLimit", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "newIrrevocableLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newRevocableLimit", + "type": "uint256" + } + ], + "name": "MintLimitsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "oldBorrowMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowMultiplier", + "type": "uint256" + } + ], + "name": "MultiplierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "StakedAtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "TokenUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "UserScoreUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAXIMUM_XVS_CAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINIMUM_STAKED_XVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NATIVE_MARKET", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STAKING_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WRAPPED_NATIVE_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "accrueInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + } + ], + "name": "accrueInterestAndUpdateScore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "addMarket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "alphaDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "alphaNumerator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "calculateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimTimeRemaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsStaked", + "type": "uint256" + } + ], + "name": "estimateAPR", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "supplyAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAPR", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "userScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "xvsBalanceForScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "capital", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cappedBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCapUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCapUSD", + "type": "uint256" + } + ], + "internalType": "struct IPrime.APRInfo", + "name": "aprInfo", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getInterestAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct PrimeStorageV1.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + } + ], + "name": "incomeDistributionYearly", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "xvsVault_", + "type": "address" + }, + { + "internalType": "address", + "name": "xvsVaultRewardToken_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "xvsVaultPoolId_", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "alphaNumerator_", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "alphaDenominator_", + "type": "uint128" + }, + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "primeLiquidityProvider_", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracle_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "loopsLimit_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolRegistry_", + "type": "address" + } + ], + "name": "initializeV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "interests", + "outputs": [ + { + "internalType": "uint256", + "name": "accrued", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "irrevocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isScoreUpdated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserPrimeHolder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "issue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sumOfMembersScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLoopsLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextScoreUpdateRoundId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "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": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingScoreUpdates", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "primeLiquidityProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "revocableLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_irrevocableLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_revocableLimit", + "type": "uint256" + } + ], + "name": "setLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "loopsLimit", + "type": "uint256" + } + ], + "name": "setMaxLoopsLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "timestamps", + "type": "uint256[]" + } + ], + "name": "setStakedAt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "stakedAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isIrrevocable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIrrevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRevocable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalScoreUpdatesRequired", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unreleasedPLPIncome", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_alphaNumerator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_alphaDenominator", + "type": "uint128" + } + ], + "name": "updateAlpha", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMultiplier", + "type": "uint256" + } + ], + "name": "updateMultipliers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + } + ], + "name": "updateScores", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "vTokenForAsset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "xvsUpdated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultPoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "xvsVaultRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x4fb2ddb7d6731f4dc8b74f2acade1a36272476daefb6899e10fd2269bda713b8", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0x84cca3c7719d1F9c35b5cfF14BE05801B8fD69d7", + "transactionIndex": 8, + "gasUsed": "5170093", + "logsBloom": "0x00000000000000000000000200000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x6ad3ca7ba876cbc3f870f866401c0d8b78cfdbee08f82bb97a597b86d7cf12c6", + "transactionHash": "0x4fb2ddb7d6731f4dc8b74f2acade1a36272476daefb6899e10fd2269bda713b8", + "logs": [ + { + "transactionIndex": 8, + "blockNumber": 17184821, + "transactionHash": "0x4fb2ddb7d6731f4dc8b74f2acade1a36272476daefb6899e10fd2269bda713b8", + "address": "0x84cca3c7719d1F9c35b5cfF14BE05801B8fD69d7", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 11, + "blockHash": "0x6ad3ca7ba876cbc3f870f866401c0d8b78cfdbee08f82bb97a597b86d7cf12c6" + } + ], + "blockNumber": 17184821, + "cumulativeGasUsed": "5857150", + "status": 1, + "byzantium": true + }, + "args": [ + "0x0000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000", + 0, + 600, + "1000000000000000000000", + "100000000000000000000000", + true + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wrappedNativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_nativeMarket\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_blocksPerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_stakingPeriod\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_minimumStakedXVS\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maximumXVSCap\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_timeBased\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AssetAlreadyExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"x\",\"type\":\"int256\"}],\"name\":\"ExpTooLarge\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IneligibleToClaim\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAlphaArguments\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidBlocksPerYear\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidComptroller\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidFixedPoint\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"n\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"d\",\"type\":\"uint256\"}],\"name\":\"InvalidFraction\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidLength\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidLimit\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTimeBasedConfiguration\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTimestamp\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidVToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"x\",\"type\":\"int256\"}],\"name\":\"LnNonRealResult\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"x\",\"type\":\"int256\"}],\"name\":\"LnTooLarge\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MarketAlreadyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MarketNotSupported\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"loopsLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredLoops\",\"type\":\"uint256\"}],\"name\":\"MaxLoopsLimitExceeded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NoScoreUpdatesRequired\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"calledContract\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"methodSignature\",\"type\":\"string\"}],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UserHasNoPrimeToken\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WaitMoreTime\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"oldNumerator\",\"type\":\"uint128\"},{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"oldDenominator\",\"type\":\"uint128\"},{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"newNumerator\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"newDenominator\",\"type\":\"uint128\"}],\"name\":\"AlphaUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"Burn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"InterestClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"supplyMultiplier\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowMultiplier\",\"type\":\"uint256\"}],\"name\":\"MarketAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldMaxLoopsLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newmaxLoopsLimit\",\"type\":\"uint256\"}],\"name\":\"MaxLoopsLimitUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isIrrevocable\",\"type\":\"bool\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldIrrevocableLimit\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldRevocableLimit\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newIrrevocableLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newRevocableLimit\",\"type\":\"uint256\"}],\"name\":\"MintLimitsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldSupplyMultiplier\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldBorrowMultiplier\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSupplyMultiplier\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBorrowMultiplier\",\"type\":\"uint256\"}],\"name\":\"MultiplierUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"StakedAtUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"TokenUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"UserScoreUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAXIMUM_XVS_CAP\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINIMUM_STAKED_XVS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NATIVE_MARKET\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"STAKING_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WRAPPED_NATIVE_TOKEN\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV8\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"accrueInterest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"}],\"name\":\"accrueInterestAndUpdateScore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"supplyMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMultiplier\",\"type\":\"uint256\"}],\"name\":\"addMarket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"alphaDenominator\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"alphaNumerator\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blocksOrSecondsPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"calculateAPR\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"supplyAPR\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowAPR\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"userScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"xvsBalanceForScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"capital\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cappedSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cappedBorrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplyCapUSD\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowCapUSD\",\"type\":\"uint256\"}],\"internalType\":\"struct IPrime.APRInfo\",\"name\":\"aprInfo\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"claimInterest\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"claimInterest\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"claimTimeRemaining\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"comptroller\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"xvsStaked\",\"type\":\"uint256\"}],\"name\":\"estimateAPR\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"supplyAPR\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowAPR\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"userScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"xvsBalanceForScore\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"capital\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cappedSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"cappedBorrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplyCapUSD\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowCapUSD\",\"type\":\"uint256\"}],\"internalType\":\"struct IPrime.APRInfo\",\"name\":\"aprInfo\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllMarkets\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumberOrTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getInterestAccrued\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getPendingRewards\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"struct PrimeStorageV1.PendingReward[]\",\"name\":\"pendingRewards\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"incomeDistributionYearly\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"xvsVault_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"xvsVaultRewardToken_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"xvsVaultPoolId_\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"alphaNumerator_\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"alphaDenominator_\",\"type\":\"uint128\"},{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"primeLiquidityProvider_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"oracle_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"loopsLimit_\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolRegistry_\",\"type\":\"address\"}],\"name\":\"initializeV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"interests\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"accrued\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"score\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardIndex\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"irrevocableLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isScoreUpdated\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isTimeBased\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"isUserPrimeHolder\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"isIrrevocable\",\"type\":\"bool\"},{\"internalType\":\"address[]\",\"name\":\"users\",\"type\":\"address[]\"}],\"name\":\"issue\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"markets\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"supplyMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"sumOfMembersScore\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"exists\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxLoopsLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextScoreUpdateRoundId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"outputs\":[{\"internalType\":\"contract ResilientOracleInterface\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"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\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingScoreUpdates\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"poolRegistry\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"primeLiquidityProvider\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"revocableLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"accessControlManager_\",\"type\":\"address\"}],\"name\":\"setAccessControlManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_irrevocableLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_revocableLimit\",\"type\":\"uint256\"}],\"name\":\"setLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"loopsLimit\",\"type\":\"uint256\"}],\"name\":\"setMaxLoopsLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"users\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"timestamps\",\"type\":\"uint256[]\"}],\"name\":\"setStakedAt\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"stakedAt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"togglePause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"tokens\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"exists\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isIrrevocable\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalIrrevocable\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalRevocable\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalScoreUpdatesRequired\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"unreleasedPLPIncome\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"_alphaNumerator\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"_alphaDenominator\",\"type\":\"uint128\"}],\"name\":\"updateAlpha\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"supplyMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMultiplier\",\"type\":\"uint256\"}],\"name\":\"updateMultipliers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"users\",\"type\":\"address[]\"}],\"name\":\"updateScores\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"vTokenForAsset\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"xvsUpdated\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"xvsVault\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"xvsVaultPoolId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"xvsVaultRewardToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"custom:security-contact\":\"https://github.com/VenusProtocol/venus-protocol\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"Paused(address)\":{\"details\":\"Emitted when the pause is triggered by `account`.\"},\"Unpaused(address)\":{\"details\":\"Emitted when the pause is lifted by `account`.\"}},\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"accrueInterest(address)\":{\"custom:error\":\"Throw MarketNotSupported if market is not supported\",\"params\":{\"vToken\":\"the market for which to distribute the income\"}},\"accrueInterestAndUpdateScore(address,address)\":{\"params\":{\"market\":\"the market for which to accrue interest and update score\",\"user\":\"the account address for which to accrue interest and update score\"}},\"addMarket(address,address,uint256,uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw MarketAlreadyExists if market already existsThrow InvalidVToken if market is not valid\",\"custom:event\":\"Emits MarketAdded event\",\"params\":{\"borrowMultiplier\":\"the multiplier for borrow cap. It should be converted to 1e18\",\"comptroller\":\"address of the comptroller\",\"market\":\"address of the market vToken\",\"supplyMultiplier\":\"the multiplier for supply cap. It should be converted to 1e18\"}},\"burn(address)\":{\"custom:access\":\"Controlled by ACM\",\"params\":{\"user\":\"the account address for which the prime token will be burned\"}},\"calculateAPR(address,address)\":{\"params\":{\"market\":\"the market for which to fetch the APR\",\"user\":\"the account for which to get the APR\"},\"returns\":{\"aprInfo\":\"APR information for the user for the given market\"}},\"claimInterest(address)\":{\"params\":{\"vToken\":\"the market for which claim the accrued interest\"},\"returns\":{\"_0\":\"amount the amount of tokens transferred to the msg.sender\"}},\"claimInterest(address,address)\":{\"params\":{\"user\":\"the user for which to claim the accrued interest\",\"vToken\":\"the market for which claim the accrued interest\"},\"returns\":{\"_0\":\"amount the amount of tokens transferred to the user\"}},\"claimTimeRemaining(address)\":{\"params\":{\"user\":\"the account address for which we are checking the remaining time\"},\"returns\":{\"_0\":\"timeRemaining the number of seconds the user needs to wait to claim prime token\"}},\"comptroller()\":{\"returns\":{\"_0\":\"the core pool comptroller address\"}},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"estimateAPR(address,address,uint256,uint256,uint256)\":{\"params\":{\"market\":\"the market for which to fetch the APR\",\"user\":\"the account for which to get the APR\"},\"returns\":{\"aprInfo\":\"APR information for the user for the given market\"}},\"getAllMarkets()\":{\"returns\":{\"_0\":\"an array of addresses representing all available markets\"}},\"getBlockNumberOrTimestamp()\":{\"details\":\"Function to simply retrieve block number or block timestamp\",\"returns\":{\"_0\":\"Current block number or block timestamp\"}},\"getInterestAccrued(address,address)\":{\"params\":{\"user\":\"the account for which to get the accrued interest\",\"vToken\":\"the market for which to fetch the accrued interest\"},\"returns\":{\"_0\":\"interestAccrued the number of underlying tokens accrued by the user since the last accrual\"}},\"getPendingRewards(address)\":{\"params\":{\"user\":\"the account for which to get the accrued interests\"},\"returns\":{\"pendingRewards\":\"the number of underlying tokens accrued by the user for all markets\"}},\"incomeDistributionYearly(address)\":{\"params\":{\"vToken\":\"the market for which to fetch the total income that's going to distributed in a year\"},\"returns\":{\"amount\":\"the total income\"}},\"initialize(address,address,uint256,uint128,uint128,address,address,address,address,uint256)\":{\"custom:error\":\"Throw InvalidAddress if any of the address is invalid\",\"params\":{\"accessControlManager_\":\"Address of AccessControlManager\",\"alphaDenominator_\":\"denominator of alpha. If alpha is 0.5 then denominator is 2. alpha is alphaNumerator_/alphaDenominator_. So, 0 < alpha < 1\",\"alphaNumerator_\":\"numerator of alpha. If alpha is 0.5 then numerator is 1. alphaDenominator_ must be greater than alphaNumerator_, alphaDenominator_ cannot be zero and alphaNumerator_ cannot be zero\",\"comptroller_\":\"Address of core pool comptroller\",\"loopsLimit_\":\"Maximum number of loops allowed in a single transaction\",\"oracle_\":\"Address of Oracle\",\"primeLiquidityProvider_\":\"Address of PrimeLiquidityProvider\",\"xvsVaultPoolId_\":\"Pool id of XVSVault\",\"xvsVaultRewardToken_\":\"Address of XVSVault reward token\",\"xvsVault_\":\"Address of XVSVault\"}},\"initializeV2(address)\":{\"params\":{\"poolRegistry_\":\"Address of IL pool registry\"}},\"isUserPrimeHolder(address)\":{\"returns\":{\"_0\":\"isPrimeHolder true if user is a prime holder\"}},\"issue(bool,address[])\":{\"custom:access\":\"Controlled by ACM\",\"params\":{\"isIrrevocable\":\"are the tokens being issued\",\"users\":\"list of address to issue tokens to\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"setAccessControlManager(address)\":{\"custom:access\":\"Only Governance\",\"custom:event\":\"Emits NewAccessControlManager event\",\"details\":\"Admin function to set address of AccessControlManager\",\"params\":{\"accessControlManager_\":\"The new address of the AccessControlManager\"}},\"setLimit(uint256,uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw InvalidLimit if any of the limit is less than total tokens minted\",\"custom:event\":\"Emits MintLimitsUpdated event\",\"params\":{\"_irrevocableLimit\":\"total number of irrevocable tokens that can be minted\",\"_revocableLimit\":\"total number of revocable tokens that can be minted\"}},\"setMaxLoopsLimit(uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:event\":\"Emits MaxLoopsLimitUpdated event on success\",\"params\":{\"loopsLimit\":\"Number of loops limit\"}},\"setStakedAt(address[],uint256[])\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw InvalidLength if users and timestamps length are not equal\",\"custom:event\":\"Emits StakedAtUpdated event for each user\",\"params\":{\"timestamps\":\"new staked at timestamp for the users\",\"users\":\"accounts for which we need to update staked at timestamp\"}},\"togglePause()\":{\"custom:access\":\"Controlled by ACM\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"},\"updateAlpha(uint128,uint128)\":{\"custom:access\":\"Controlled by ACM\",\"custom:event\":\"Emits AlphaUpdated event\",\"params\":{\"_alphaDenominator\":\"denominator of alpha. If alpha is 0.5 then denominator is 2\",\"_alphaNumerator\":\"numerator of alpha. If alpha is 0.5 then numerator is 1\"}},\"updateMultipliers(address,uint256,uint256)\":{\"custom:access\":\"Controlled by ACM\",\"custom:error\":\"Throw MarketNotSupported if market is not supported\",\"custom:event\":\"Emits MultiplierUpdated event\",\"params\":{\"borrowMultiplier\":\"new borrow multiplier for the market, scaled by 1e18\",\"market\":\"address of the market vToken\",\"supplyMultiplier\":\"new supply multiplier for the market, scaled by 1e18\"}},\"updateScores(address[])\":{\"custom:error\":\"Throw NoScoreUpdatesRequired if no score updates are requiredThrow UserHasNoPrimeToken if user has no prime token\",\"custom:event\":\"Emits UserScoreUpdated event\",\"params\":{\"users\":\"accounts for which we need to update score\"}},\"xvsUpdated(address)\":{\"params\":{\"user\":\"the account address whose balance was updated\"}}},\"stateVariables\":{\"MAXIMUM_XVS_CAP\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"MINIMUM_STAKED_XVS\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"NATIVE_MARKET\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"STAKING_PERIOD\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"WRAPPED_NATIVE_TOKEN\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"Prime\",\"version\":1},\"userdoc\":{\"errors\":{\"AssetAlreadyExists()\":[{\"notice\":\"Error thrown when asset already exists\"}],\"ExpTooLarge(int256)\":[{\"notice\":\"Thrown when exp is given too large of an argument\"}],\"IneligibleToClaim()\":[{\"notice\":\"Error thrown when user is not eligible to claim prime token\"}],\"InvalidAddress()\":[{\"notice\":\"Error thrown when invalid address is passed\"}],\"InvalidAlphaArguments()\":[{\"notice\":\"Error thrown when invalid alpha arguments are passed\"}],\"InvalidBlocksPerYear()\":[{\"notice\":\"Thrown when blocks per year is invalid\"}],\"InvalidComptroller()\":[{\"notice\":\"Error thrown when invalid comptroller is passed\"}],\"InvalidLength()\":[{\"notice\":\"Error thrown when invalid length is passed\"}],\"InvalidLimit()\":[{\"notice\":\"Error thrown when mint limit is reached\"}],\"InvalidTimeBasedConfiguration()\":[{\"notice\":\"Thrown when time based but blocks per year is provided\"}],\"InvalidTimestamp()\":[{\"notice\":\"Error thrown when timestamp is invalid\"}],\"InvalidVToken()\":[{\"notice\":\"Error thrown when invalid vToken is passed\"}],\"LnNonRealResult(int256)\":[{\"notice\":\"Thrown when the natural log would have returned a number outside of \\u211d\"}],\"LnTooLarge(int256)\":[{\"notice\":\"Thrown when the natural log function is given too large of an argument\"}],\"MarketAlreadyExists()\":[{\"notice\":\"Error thrown when market already exists\"}],\"MarketNotSupported()\":[{\"notice\":\"Error thrown when market is not supported\"}],\"MaxLoopsLimitExceeded(uint256,uint256)\":[{\"notice\":\"Thrown an error on maxLoopsLimit exceeds for any loop\"}],\"NoScoreUpdatesRequired()\":[{\"notice\":\"Error thrown when no score updates are required\"}],\"Unauthorized(address,address,string)\":[{\"notice\":\"Thrown when the action is prohibited by AccessControlManager\"}],\"UserHasNoPrimeToken()\":[{\"notice\":\"Error thrown when user has no prime token\"}],\"WaitMoreTime()\":[{\"notice\":\"Error thrown when user needs to wait more time to claim prime token\"}]},\"events\":{\"AlphaUpdated(uint128,uint128,uint128,uint128)\":{\"notice\":\"Emitted when alpha is updated\"},\"Burn(address)\":{\"notice\":\"Emitted when prime token is burned\"},\"InterestClaimed(address,address,uint256)\":{\"notice\":\"Emitted when interest is claimed\"},\"MarketAdded(address,address,uint256,uint256)\":{\"notice\":\"Emitted when a market is added to prime program\"},\"MaxLoopsLimitUpdated(uint256,uint256)\":{\"notice\":\"Emitted when max loops limit is set\"},\"Mint(address,bool)\":{\"notice\":\"Emitted when prime token is minted\"},\"MintLimitsUpdated(uint256,uint256,uint256,uint256)\":{\"notice\":\"Emitted when mint limits are updated\"},\"MultiplierUpdated(address,uint256,uint256,uint256,uint256)\":{\"notice\":\"Emitted when multiplier is updated\"},\"NewAccessControlManager(address,address)\":{\"notice\":\"Emitted when access control manager contract address is changed\"},\"StakedAtUpdated(address,uint256)\":{\"notice\":\"Emitted when stakedAt is updated\"},\"TokenUpgraded(address)\":{\"notice\":\"Emitted when revocable token is upgraded to irrevocable token\"},\"UserScoreUpdated(address)\":{\"notice\":\"Emitted when user score is updated\"}},\"kind\":\"user\",\"methods\":{\"MAXIMUM_XVS_CAP()\":{\"notice\":\"maximum XVS taken in account when calculating user score\"},\"MINIMUM_STAKED_XVS()\":{\"notice\":\"minimum amount of XVS user needs to stake to become a prime member\"},\"NATIVE_MARKET()\":{\"notice\":\"address of native market contract\"},\"STAKING_PERIOD()\":{\"notice\":\"number of days user need to stake to claim prime token\"},\"WRAPPED_NATIVE_TOKEN()\":{\"notice\":\"address of wrapped native token contract\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"accrueInterest(address)\":{\"notice\":\"Distributes income from market since last distribution\"},\"accrueInterestAndUpdateScore(address,address)\":{\"notice\":\"accrues interes and updates score for an user for a specific market\"},\"addMarket(address,address,uint256,uint256)\":{\"notice\":\"Add a market to prime program\"},\"alphaDenominator()\":{\"notice\":\"denominator of alpha. Ex: if alpha is 0.5 then this will be 2\"},\"alphaNumerator()\":{\"notice\":\"numerator of alpha. Ex: if alpha is 0.5 then this will be 1\"},\"blocksOrSecondsPerYear()\":{\"notice\":\"Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\"},\"burn(address)\":{\"notice\":\"For burning any prime token\"},\"calculateAPR(address,address)\":{\"notice\":\"Returns supply and borrow APR for user for a given market\"},\"claim()\":{\"notice\":\"For claiming prime token when staking period is completed\"},\"claimInterest(address)\":{\"notice\":\"For user to claim boosted yield\"},\"claimInterest(address,address)\":{\"notice\":\"For user to claim boosted yield\"},\"claimTimeRemaining(address)\":{\"notice\":\"fetch the numbers of seconds remaining for staking period to complete\"},\"comptroller()\":{\"notice\":\"Retrieves the core pool comptroller address\"},\"estimateAPR(address,address,uint256,uint256,uint256)\":{\"notice\":\"Returns supply and borrow APR for estimated supply, borrow and XVS staked\"},\"getAllMarkets()\":{\"notice\":\"Retrieves an array of all available markets\"},\"getInterestAccrued(address,address)\":{\"notice\":\"Returns boosted interest accrued for a user\"},\"getPendingRewards(address)\":{\"notice\":\"Returns boosted pending interest accrued for a user for all markets\"},\"incomeDistributionYearly(address)\":{\"notice\":\"the total income that's going to be distributed in a year to prime token holders\"},\"initialize(address,address,uint256,uint128,uint128,address,address,address,address,uint256)\":{\"notice\":\"Prime initializer\"},\"initializeV2(address)\":{\"notice\":\"Prime initializer V2 for initializing pool registry\"},\"interests(address,address)\":{\"notice\":\"vToken to user to user index\"},\"irrevocableLimit()\":{\"notice\":\"Indicates maximum irrevocable tokens that can be minted\"},\"isScoreUpdated(uint256,address)\":{\"notice\":\"mapping to check if a account's score was updated in the round\"},\"isTimeBased()\":{\"notice\":\"Acknowledges if a contract is time based or not\"},\"isUserPrimeHolder(address)\":{\"notice\":\"Returns if user is a prime holder\"},\"issue(bool,address[])\":{\"notice\":\"Directly issue prime tokens to users\"},\"markets(address)\":{\"notice\":\"vToken to market configuration\"},\"nextScoreUpdateRoundId()\":{\"notice\":\"unique id for next round\"},\"oracle()\":{\"notice\":\"The address of ResilientOracle contract\"},\"pendingScoreUpdates()\":{\"notice\":\"total number of accounts whose score is yet to be updated\"},\"poolRegistry()\":{\"notice\":\"The address of PoolRegistry contract\"},\"primeLiquidityProvider()\":{\"notice\":\"The address of PLP contract\"},\"revocableLimit()\":{\"notice\":\"Indicates maximum revocable tokens that can be minted\"},\"setAccessControlManager(address)\":{\"notice\":\"Sets the address of AccessControlManager\"},\"setLimit(uint256,uint256)\":{\"notice\":\"Set limits for total tokens that can be minted\"},\"setMaxLoopsLimit(uint256)\":{\"notice\":\"Set the limit for the loops can iterate to avoid the DOS\"},\"setStakedAt(address[],uint256[])\":{\"notice\":\"Update staked at timestamp for multiple users\"},\"stakedAt(address)\":{\"notice\":\"Tracks when prime token eligible users started staking for claiming prime token\"},\"togglePause()\":{\"notice\":\"To pause or unpause claiming of interest\"},\"tokens(address)\":{\"notice\":\"Mapping to get prime token's metadata\"},\"totalIrrevocable()\":{\"notice\":\"Tracks total irrevocable tokens minted\"},\"totalRevocable()\":{\"notice\":\"Tracks total revocable tokens minted\"},\"totalScoreUpdatesRequired()\":{\"notice\":\"total number of accounts whose score needs to be updated\"},\"unreleasedPLPIncome(address)\":{\"notice\":\"unreleased income from PLP that's already distributed to prime holders\"},\"updateAlpha(uint128,uint128)\":{\"notice\":\"Update value of alpha\"},\"updateMultipliers(address,uint256,uint256)\":{\"notice\":\"Update multipliers for a market\"},\"updateScores(address[])\":{\"notice\":\"Update total score of multiple users and market\"},\"vTokenForAsset(address)\":{\"notice\":\"mapping used to find if an asset is part of prime markets\"},\"xvsUpdated(address)\":{\"notice\":\"Executed by XVSVault whenever user's XVSVault balance changes\"},\"xvsVault()\":{\"notice\":\"address of XVS vault\"},\"xvsVaultPoolId()\":{\"notice\":\"address of XVS vault pool id\"},\"xvsVaultRewardToken()\":{\"notice\":\"address of XVS vault reward token\"}},\"notice\":\"Prime Token is used to provide extra rewards to the users who have staked a minimum of `MINIMUM_STAKED_XVS` XVS in the XVSVault for `STAKING_PERIOD` days\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Tokens/Prime/Prime.sol\":\"Prime\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./OwnableUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n function __Ownable2Step_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable2Step_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x9140dabc466abab21b48b72dbda26736b1183a310d0e677d3719d201df026510\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling 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 /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x359a1ab89b46b9aba7bcad3fb651924baf4893d15153049b9976b0fc9be1358e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport {Initializable} from \\\"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\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 _requireNotPaused();\\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 _requirePaused();\\n _;\\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 Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\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 /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xad32f6821f860555f9530902a65b54203a4f5db2117f4384ae47a124958078db\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.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 IERC20Upgradeable {\\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(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x0e1f0f5f62f67a881cd1a9597acbc0a5e4071f3c2c10449a183b922ae7272e3f\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\\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\":\"0x605434219ebbe4653f703640f06969faa5a1d78f0bfef878e5ddbb1ca369ceeb\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x07e881de3b9f6d2c07909f193f24b96c7fe4ea60013260f3f25aecd8bab3c2f8\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) 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(IERC20Upgradeable token, address spender, uint256 value) 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 /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\\n * Revert on invalid signature.\\n */\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\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(IERC20Upgradeable 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 require(returndata.length == 0 || abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\\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 cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return\\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));\\n }\\n}\\n\",\"keccak256\":\"0x23b997be73d3dd46885262704f0f8cfc7273fdadfe303d37969a9561373972b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\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 * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(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 (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport {Initializable} from \\\"../proxy/utils/Initializable.sol\\\";\\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 ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n function _contextSuffixLength() internal view virtual returns (uint256) {\\n return 0;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x75097e35253e7fb282ee4d7f27a80eaacfa759923185bf17302a89cbc059c5ef\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcef50f95b43b038aa40aed25b62fc45906c681a5c1d504a4fdcf3bc6330a8d4b\",\"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\"},\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\\\";\\n\\nimport \\\"./IAccessControlManagerV8.sol\\\";\\n\\n/**\\n * @title AccessControlledV8\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\\n /// @notice Access control manager contract\\n IAccessControlManagerV8 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /// @notice Thrown when the action is prohibited by AccessControlManager\\n error Unauthorized(address sender, address calledContract, string methodSignature);\\n\\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\\n __Ownable2Step_init();\\n __AccessControlled_init_unchained(accessControlManager_);\\n }\\n\\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Sets the address of AccessControlManager\\n * @dev Admin function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n * @custom:event Emits NewAccessControlManager event\\n * @custom:access Only Governance\\n */\\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\\n _setAccessControlManager(accessControlManager_);\\n }\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV8) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert Unauthorized(msg.sender, address(this), signature);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0dcf283925f4dddc23ca0ee71d2cb96a9dd6e4cf08061b69fde1697ea39dc514\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport \\\"@openzeppelin/contracts/access/IAccessControl.sol\\\";\\n\\n/**\\n * @title IAccessControlManagerV8\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\\n */\\ninterface IAccessControlManagerV8 is IAccessControl {\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xaa29b098440d0b3a131c5ecdf25ce548790c1b5ac7bf9b5c0264b6af6f7a1e0b\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\ninterface OracleInterface {\\n function getPrice(address asset) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n\\n function updateAssetPrice(address asset) external;\\n\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address asset) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address asset,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2432799b0d824fc701beb4c30146e912b9aeecf77b5c1635dde6c5fbe6bfc3a7\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\n/**\\n * @title MaxLoopsLimitHelper\\n * @author Venus\\n * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.\\n */\\nabstract contract MaxLoopsLimitHelper {\\n // Limit for the loops to avoid the DOS\\n uint256 public maxLoopsLimit;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when max loops limit is set\\n event MaxLoopsLimitUpdated(uint256 oldMaxLoopsLimit, uint256 newmaxLoopsLimit);\\n\\n /// @notice Thrown an error on maxLoopsLimit exceeds for any loop\\n error MaxLoopsLimitExceeded(uint256 loopsLimit, uint256 requiredLoops);\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param limit Limit for the max loops can execute at a time\\n */\\n function _setMaxLoopsLimit(uint256 limit) internal {\\n require(limit > maxLoopsLimit, \\\"Comptroller: Invalid maxLoopsLimit\\\");\\n\\n uint256 oldMaxLoopsLimit = maxLoopsLimit;\\n maxLoopsLimit = limit;\\n\\n emit MaxLoopsLimitUpdated(oldMaxLoopsLimit, limit);\\n }\\n\\n /**\\n * @notice Compare the maxLoopsLimit with number of the times loop iterate\\n * @param len Length of the loops iterate\\n * @custom:error MaxLoopsLimitExceeded error is thrown when loops length exceeds maxLoopsLimit\\n */\\n function _ensureMaxLoops(uint256 len) internal view {\\n if (len > maxLoopsLimit) {\\n revert MaxLoopsLimitExceeded(maxLoopsLimit, len);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4c25e30635485d162177effa384eee51768b0141a567a0da16ff6ad673274166\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { SECONDS_PER_YEAR } from \\\"./constants.sol\\\";\\n\\nabstract contract TimeManagerV8 {\\n /// @notice Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable blocksOrSecondsPerYear;\\n\\n /// @notice Acknowledges if a contract is time based or not\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n bool public immutable isTimeBased;\\n\\n /// @notice Stores the current block timestamp or block number depending on isTimeBased\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n function() view returns (uint256) private immutable _getCurrentSlot;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[48] private __gap;\\n\\n /// @notice Thrown when blocks per year is invalid\\n error InvalidBlocksPerYear();\\n\\n /// @notice Thrown when time based but blocks per year is provided\\n error InvalidTimeBasedConfiguration();\\n\\n /**\\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\\n * @param blocksPerYear_ The number of blocks per year\\n * @custom:error InvalidBlocksPerYear is thrown if blocksPerYear entered is zero and timeBased is false\\n * @custom:error InvalidTimeBasedConfiguration is thrown if blocksPerYear entered is non zero and timeBased is true\\n * @custom:oz-upgrades-unsafe-allow constructor\\n */\\n constructor(bool timeBased_, uint256 blocksPerYear_) {\\n if (!timeBased_ && blocksPerYear_ == 0) {\\n revert InvalidBlocksPerYear();\\n }\\n\\n if (timeBased_ && blocksPerYear_ != 0) {\\n revert InvalidTimeBasedConfiguration();\\n }\\n\\n isTimeBased = timeBased_;\\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\\n _getCurrentSlot = timeBased_ ? _getBlockTimestamp : _getBlockNumber;\\n }\\n\\n /**\\n * @dev Function to simply retrieve block number or block timestamp\\n * @return Current block number or block timestamp\\n */\\n function getBlockNumberOrTimestamp() public view virtual returns (uint256) {\\n return _getCurrentSlot();\\n }\\n\\n /**\\n * @dev Returns the current timestamp in seconds\\n * @return The current timestamp\\n */\\n function _getBlockTimestamp() private view returns (uint256) {\\n return block.timestamp;\\n }\\n\\n /**\\n * @dev Returns the current block number\\n * @return The current block number\\n */\\n function _getBlockNumber() private view returns (uint256) {\\n return block.number;\\n }\\n}\\n\",\"keccak256\":\"0x57a2bbb9b8e02b1c0a5c0e305fef1328a22db56c3d4b148c362010a6e767243c\",\"license\":\"BSD-3-Clause\"},\"@venusprotocol/solidity-utilities/contracts/constants.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\\nuint256 constant EXP_SCALE = 1e18;\\n\\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\\nuint256 constant MANTISSA_ONE = EXP_SCALE;\\n\\n/// @dev The approximate number of seconds per year\\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\\n\",\"keccak256\":\"0x14de93ead464da249af31bea0e3bcfb62ec693bea3475fb4d90f055ac81dc5eb\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IPoolRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\n/**\\n * @title PoolRegistryInterface\\n * @author Venus\\n * @notice Interface implemented by `PoolRegistry`.\\n */\\ninterface PoolRegistryInterface {\\n /**\\n * @notice Struct for a Venus interest rate pool.\\n */\\n struct VenusPool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /// @notice Get a pool by comptroller address\\n function getPoolByComptroller(address comptroller) external view returns (VenusPool memory);\\n}\\n\",\"keccak256\":\"0x3977ed49a7eaccbdbd674cfbabff12e59e2476301810aad30a4e991c63b8e9ee\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IPrime.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport { PrimeStorageV1 } from \\\"../PrimeStorage.sol\\\";\\n\\n/**\\n * @title IPrime\\n * @author Venus\\n * @notice Interface for Prime Token\\n */\\ninterface IPrime {\\n struct APRInfo {\\n // supply APR of the user in BPS\\n uint256 supplyAPR;\\n // borrow APR of the user in BPS\\n uint256 borrowAPR;\\n // total score of the market\\n uint256 totalScore;\\n // score of the user\\n uint256 userScore;\\n // capped XVS balance of the user\\n uint256 xvsBalanceForScore;\\n // capital of the user\\n uint256 capital;\\n // capped supply of the user\\n uint256 cappedSupply;\\n // capped borrow of the user\\n uint256 cappedBorrow;\\n // capped supply of user in USD\\n uint256 supplyCapUSD;\\n // capped borrow of user in USD\\n uint256 borrowCapUSD;\\n }\\n\\n struct Capital {\\n // capital of the user\\n uint256 capital;\\n // capped supply of the user\\n uint256 cappedSupply;\\n // capped borrow of the user\\n uint256 cappedBorrow;\\n // capped supply of user in USD\\n uint256 supplyCapUSD;\\n // capped borrow of user in USD\\n uint256 borrowCapUSD;\\n }\\n\\n /**\\n * @notice Returns boosted pending interest accrued for a user for all markets\\n * @param user the account for which to get the accrued interests\\n * @return pendingRewards the number of underlying tokens accrued by the user for all markets\\n */\\n function getPendingRewards(address user) external returns (PrimeStorageV1.PendingReward[] memory pendingRewards);\\n\\n /**\\n * @notice Update total score of multiple users and market\\n * @param users accounts for which we need to update score\\n */\\n function updateScores(address[] memory users) external;\\n\\n /**\\n * @notice Update value of alpha\\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\\n */\\n function updateAlpha(uint128 _alphaNumerator, uint128 _alphaDenominator) external;\\n\\n /**\\n * @notice Update multipliers for a market\\n * @param market address of the market vToken\\n * @param supplyMultiplier new supply multiplier for the market, scaled by 1e18\\n * @param borrowMultiplier new borrow multiplier for the market, scaled by 1e18\\n */\\n function updateMultipliers(address market, uint256 supplyMultiplier, uint256 borrowMultiplier) external;\\n\\n /**\\n * @notice Add a market to prime program\\n * @param comptroller address of the comptroller\\n * @param market address of the market vToken\\n * @param supplyMultiplier the multiplier for supply cap. It should be converted to 1e18\\n * @param borrowMultiplier the multiplier for borrow cap. It should be converted to 1e18\\n */\\n function addMarket(\\n address comptroller,\\n address market,\\n uint256 supplyMultiplier,\\n uint256 borrowMultiplier\\n ) external;\\n\\n /**\\n * @notice Set limits for total tokens that can be minted\\n * @param _irrevocableLimit total number of irrevocable tokens that can be minted\\n * @param _revocableLimit total number of revocable tokens that can be minted\\n */\\n function setLimit(uint256 _irrevocableLimit, uint256 _revocableLimit) external;\\n\\n /**\\n * @notice Directly issue prime tokens to users\\n * @param isIrrevocable are the tokens being issued\\n * @param users list of address to issue tokens to\\n */\\n function issue(bool isIrrevocable, address[] calldata users) external;\\n\\n /**\\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\\n * @param user the account address whose balance was updated\\n */\\n function xvsUpdated(address user) external;\\n\\n /**\\n * @notice accrues interest and updates score for an user for a specific market\\n * @param user the account address for which to accrue interest and update score\\n * @param market the market for which to accrue interest and update score\\n */\\n function accrueInterestAndUpdateScore(address user, address market) external;\\n\\n /**\\n * @notice For claiming prime token when staking period is completed\\n */\\n function claim() external;\\n\\n /**\\n * @notice For burning any prime token\\n * @param user the account address for which the prime token will be burned\\n */\\n function burn(address user) external;\\n\\n /**\\n * @notice To pause or unpause claiming of interest\\n */\\n function togglePause() external;\\n\\n /**\\n * @notice For user to claim boosted yield\\n * @param vToken the market for which claim the accrued interest\\n * @return amount the amount of tokens transferred to the user\\n */\\n function claimInterest(address vToken) external returns (uint256);\\n\\n /**\\n * @notice For user to claim boosted yield\\n * @param vToken the market for which claim the accrued interest\\n * @param user the user for which to claim the accrued interest\\n * @return amount the amount of tokens transferred to the user\\n */\\n function claimInterest(address vToken, address user) external returns (uint256);\\n\\n /**\\n * @notice Distributes income from market since last distribution\\n * @param vToken the market for which to distribute the income\\n */\\n function accrueInterest(address vToken) external;\\n\\n /**\\n * @notice Returns boosted interest accrued for a user\\n * @param vToken the market for which to fetch the accrued interest\\n * @param user the account for which to get the accrued interest\\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\\n */\\n function getInterestAccrued(address vToken, address user) external returns (uint256);\\n\\n /**\\n * @notice Retrieves an array of all available markets\\n * @return an array of addresses representing all available markets\\n */\\n function getAllMarkets() external view returns (address[] memory);\\n\\n /**\\n * @notice fetch the numbers of seconds remaining for staking period to complete\\n * @param user the account address for which we are checking the remaining time\\n * @return timeRemaining the number of seconds the user needs to wait to claim prime token\\n */\\n function claimTimeRemaining(address user) external view returns (uint256);\\n\\n /**\\n * @notice Returns supply and borrow APR for user for a given market\\n * @param market the market for which to fetch the APR\\n * @param user the account for which to get the APR\\n * @return aprInfo APR information for the user for the given market\\n */\\n function calculateAPR(address market, address user) external view returns (APRInfo memory aprInfo);\\n\\n /**\\n * @notice Returns supply and borrow APR for estimated supply, borrow and XVS staked\\n * @param market the market for which to fetch the APR\\n * @param user the account for which to get the APR\\n * @param borrow hypothetical borrow amount\\n * @param supply hypothetical supply amount\\n * @param xvsStaked hypothetical staked XVS amount\\n * @return aprInfo APR information for the user for the given market\\n */\\n function estimateAPR(\\n address market,\\n address user,\\n uint256 borrow,\\n uint256 supply,\\n uint256 xvsStaked\\n ) external view returns (APRInfo memory aprInfo);\\n\\n /**\\n * @notice the total income that's going to be distributed in a year to prime token holders\\n * @param vToken the market for which to fetch the total income that's going to distributed in a year\\n * @return amount the total income\\n */\\n function incomeDistributionYearly(address vToken) external view returns (uint256 amount);\\n\\n /**\\n * @notice Returns if user is a prime holder\\n * @return isPrimeHolder true if user is a prime holder\\n */\\n function isUserPrimeHolder(address user) external view returns (bool);\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Number of loops limit\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external;\\n\\n /**\\n * @notice Update staked at timestamp for multiple users\\n * @param users accounts for which we need to update staked at timestamp\\n * @param timestamps new staked at timestamp for the users\\n */\\n function setStakedAt(address[] calldata users, uint256[] calldata timestamps) external;\\n}\\n\",\"keccak256\":\"0xd112f60183416ad796093b4a83a80ddc1b8b655965f02ae55ca82e2a0c68f97d\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IPrimeLiquidityProvider.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\nimport { IERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IPrimeLiquidityProvider\\n * @author Venus\\n * @notice Interface for PrimeLiquidityProvider\\n */\\ninterface IPrimeLiquidityProvider {\\n /**\\n * @notice Initialize the distribution of the token\\n * @param tokens_ Array of addresses of the tokens to be intialized\\n */\\n function initializeTokens(address[] calldata tokens_) external;\\n\\n /**\\n * @notice Pause fund transfer of tokens to Prime contract\\n */\\n function pauseFundsTransfer() external;\\n\\n /**\\n * @notice Resume fund transfer of tokens to Prime contract\\n */\\n function resumeFundsTransfer() external;\\n\\n /**\\n * @notice Set distribution speed (amount of token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param distributionSpeeds_ New distribution speeds for tokens\\n */\\n function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external;\\n\\n /**\\n * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)\\n * @param tokens_ Array of addresses of the tokens\\n * @param maxDistributionSpeeds_ New distribution speeds for tokens\\n */\\n function setMaxTokensDistributionSpeed(\\n address[] calldata tokens_,\\n uint256[] calldata maxDistributionSpeeds_\\n ) external;\\n\\n /**\\n * @notice Set the prime token contract address\\n * @param prime_ The new address of the prime token contract\\n */\\n function setPrimeToken(address prime_) external;\\n\\n /**\\n * @notice Claim all the token accrued till last block or second\\n * @param token_ The token to release to the Prime contract\\n */\\n function releaseFunds(address token_) external;\\n\\n /**\\n * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\\n * @param token_ The address of the ERC-20 token to sweep\\n * @param to_ The address of the recipient\\n * @param amount_ The amount of tokens needs to transfer\\n */\\n function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external;\\n\\n /**\\n * @notice Accrue token by updating the distribution state\\n * @param token_ Address of the token\\n */\\n function accrueTokens(address token_) external;\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Limit for the max loops can execute at a time\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external;\\n\\n /**\\n * @notice Get rewards per block or second for token\\n * @param token_ Address of the token\\n * @return speed returns the per block or second reward\\n */\\n function getEffectiveDistributionSpeed(address token_) external view returns (uint256);\\n\\n /**\\n * @notice Get the amount of tokens accrued\\n * @param token_ Address of the token\\n * @return Amount of tokens that are accrued\\n */\\n function tokenAmountAccrued(address token_) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x4dca0341931008bcd81de18e627c2d0cd4f9d0be67db4d8f0d678d11ba0d330f\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IVToken.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\ninterface IVToken {\\n function borrowBalanceStored(address account) external view returns (uint256);\\n\\n function exchangeRateStored() external view returns (uint256);\\n\\n function balanceOf(address account) external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x63da84a1600e383a030e17b1a696bc168f6887e9f5ef6a986b5d6c1ec98a92ed\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/IXVSVault.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.8.25;\\n\\ninterface IXVSVault {\\n function getUserInfo(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals);\\n\\n function xvsAddress() external view returns (address);\\n}\\n\",\"keccak256\":\"0x576bb0e8c21891de2803251244133f948673bce5c8146aa53157f414889c476d\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/Interfaces/InterfaceComptroller.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity ^0.8.25;\\n\\ninterface InterfaceComptroller {\\n function markets(address) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xb3b6f9b8079d6b8ee93174fd2f96db394012f4f7d307cb389825a60cdb1dc3da\",\"license\":\"GPL-3.0-or-later\"},\"contracts/Tokens/Prime/Prime.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { SafeERC20Upgradeable, IERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport { AccessControlledV8 } from \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\\\";\\nimport { ResilientOracleInterface } from \\\"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\\\";\\nimport { PausableUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport { MaxLoopsLimitHelper } from \\\"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\\\";\\nimport { TimeManagerV8 } from \\\"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\\\";\\n\\nimport { IERC20MetadataUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\\\";\\n\\nimport { PrimeStorageV1 } from \\\"./PrimeStorage.sol\\\";\\nimport { Scores } from \\\"./libs/Scores.sol\\\";\\n\\nimport { IPrimeLiquidityProvider } from \\\"./Interfaces/IPrimeLiquidityProvider.sol\\\";\\nimport { IPrime } from \\\"./Interfaces/IPrime.sol\\\";\\nimport { IXVSVault } from \\\"./Interfaces/IXVSVault.sol\\\";\\nimport { IVToken } from \\\"./Interfaces/IVToken.sol\\\";\\nimport { InterfaceComptroller } from \\\"./Interfaces/InterfaceComptroller.sol\\\";\\nimport { PoolRegistryInterface } from \\\"./Interfaces/IPoolRegistry.sol\\\";\\n\\n/**\\n * @title Prime\\n * @author Venus\\n * @notice Prime Token is used to provide extra rewards to the users who have staked a minimum of `MINIMUM_STAKED_XVS` XVS in the XVSVault for `STAKING_PERIOD` days\\n * @custom:security-contact https://github.com/VenusProtocol/venus-protocol\\n */\\ncontract Prime is IPrime, AccessControlledV8, PausableUpgradeable, MaxLoopsLimitHelper, PrimeStorageV1, TimeManagerV8 {\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n /// @notice address of wrapped native token contract\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WRAPPED_NATIVE_TOKEN;\\n\\n /// @notice address of native market contract\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable NATIVE_MARKET;\\n\\n /// @notice minimum amount of XVS user needs to stake to become a prime member\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable MINIMUM_STAKED_XVS;\\n\\n /// @notice maximum XVS taken in account when calculating user score\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable MAXIMUM_XVS_CAP;\\n\\n /// @notice number of days user need to stake to claim prime token\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable STAKING_PERIOD;\\n\\n /// @notice Emitted when prime token is minted\\n event Mint(address indexed user, bool isIrrevocable);\\n\\n /// @notice Emitted when prime token is burned\\n event Burn(address indexed user);\\n\\n /// @notice Emitted when a market is added to prime program\\n event MarketAdded(\\n address indexed comptroller,\\n address indexed market,\\n uint256 supplyMultiplier,\\n uint256 borrowMultiplier\\n );\\n\\n /// @notice Emitted when mint limits are updated\\n event MintLimitsUpdated(\\n uint256 indexed oldIrrevocableLimit,\\n uint256 indexed oldRevocableLimit,\\n uint256 indexed newIrrevocableLimit,\\n uint256 newRevocableLimit\\n );\\n\\n /// @notice Emitted when user score is updated\\n event UserScoreUpdated(address indexed user);\\n\\n /// @notice Emitted when alpha is updated\\n event AlphaUpdated(\\n uint128 indexed oldNumerator,\\n uint128 indexed oldDenominator,\\n uint128 indexed newNumerator,\\n uint128 newDenominator\\n );\\n\\n /// @notice Emitted when multiplier is updated\\n event MultiplierUpdated(\\n address indexed market,\\n uint256 indexed oldSupplyMultiplier,\\n uint256 indexed oldBorrowMultiplier,\\n uint256 newSupplyMultiplier,\\n uint256 newBorrowMultiplier\\n );\\n\\n /// @notice Emitted when interest is claimed\\n event InterestClaimed(address indexed user, address indexed market, uint256 amount);\\n\\n /// @notice Emitted when revocable token is upgraded to irrevocable token\\n event TokenUpgraded(address indexed user);\\n\\n /// @notice Emitted when stakedAt is updated\\n event StakedAtUpdated(address indexed user, uint256 timestamp);\\n\\n /// @notice Error thrown when market is not supported\\n error MarketNotSupported();\\n\\n /// @notice Error thrown when mint limit is reached\\n error InvalidLimit();\\n\\n /// @notice Error thrown when user is not eligible to claim prime token\\n error IneligibleToClaim();\\n\\n /// @notice Error thrown when user needs to wait more time to claim prime token\\n error WaitMoreTime();\\n\\n /// @notice Error thrown when user has no prime token\\n error UserHasNoPrimeToken();\\n\\n /// @notice Error thrown when no score updates are required\\n error NoScoreUpdatesRequired();\\n\\n /// @notice Error thrown when market already exists\\n error MarketAlreadyExists();\\n\\n /// @notice Error thrown when asset already exists\\n error AssetAlreadyExists();\\n\\n /// @notice Error thrown when invalid address is passed\\n error InvalidAddress();\\n\\n /// @notice Error thrown when invalid alpha arguments are passed\\n error InvalidAlphaArguments();\\n\\n /// @notice Error thrown when invalid vToken is passed\\n error InvalidVToken();\\n\\n /// @notice Error thrown when invalid length is passed\\n error InvalidLength();\\n\\n /// @notice Error thrown when timestamp is invalid\\n error InvalidTimestamp();\\n\\n /// @notice Error thrown when invalid comptroller is passed\\n error InvalidComptroller();\\n\\n /**\\n * @notice Prime constructor\\n * @param _wrappedNativeToken Address of wrapped native token\\n * @param _nativeMarket Address of native market\\n * @param _blocksPerYear total blocks per year\\n * @param _stakingPeriod total number of seconds for which user needs to stake to claim prime token\\n * @param _minimumStakedXVS minimum amount of XVS user needs to stake to become a prime member (scaled by 1e18)\\n * @param _maximumXVSCap maximum XVS taken in account when calculating user score (scaled by 1e18)\\n * @param _timeBased A boolean indicating whether the contract is based on time or block.\\n */\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n address _wrappedNativeToken,\\n address _nativeMarket,\\n uint256 _blocksPerYear,\\n uint256 _stakingPeriod,\\n uint256 _minimumStakedXVS,\\n uint256 _maximumXVSCap,\\n bool _timeBased\\n ) TimeManagerV8(_timeBased, _blocksPerYear) {\\n WRAPPED_NATIVE_TOKEN = _wrappedNativeToken;\\n NATIVE_MARKET = _nativeMarket;\\n STAKING_PERIOD = _stakingPeriod;\\n MINIMUM_STAKED_XVS = _minimumStakedXVS;\\n MAXIMUM_XVS_CAP = _maximumXVSCap;\\n\\n // Note that the contract is upgradeable. Use initialize() or reinitializers\\n // to set the state variables.\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice Prime initializer\\n * @param xvsVault_ Address of XVSVault\\n * @param xvsVaultRewardToken_ Address of XVSVault reward token\\n * @param xvsVaultPoolId_ Pool id of XVSVault\\n * @param alphaNumerator_ numerator of alpha. If alpha is 0.5 then numerator is 1.\\n alphaDenominator_ must be greater than alphaNumerator_, alphaDenominator_ cannot be zero and alphaNumerator_ cannot be zero\\n * @param alphaDenominator_ denominator of alpha. If alpha is 0.5 then denominator is 2.\\n alpha is alphaNumerator_/alphaDenominator_. So, 0 < alpha < 1\\n * @param accessControlManager_ Address of AccessControlManager\\n * @param primeLiquidityProvider_ Address of PrimeLiquidityProvider\\n * @param comptroller_ Address of core pool comptroller\\n * @param oracle_ Address of Oracle\\n * @param loopsLimit_ Maximum number of loops allowed in a single transaction\\n * @custom:error Throw InvalidAddress if any of the address is invalid\\n */\\n function initialize(\\n address xvsVault_,\\n address xvsVaultRewardToken_,\\n uint256 xvsVaultPoolId_,\\n uint128 alphaNumerator_,\\n uint128 alphaDenominator_,\\n address accessControlManager_,\\n address primeLiquidityProvider_,\\n address comptroller_,\\n address oracle_,\\n uint256 loopsLimit_\\n ) external initializer {\\n if (xvsVault_ == address(0)) revert InvalidAddress();\\n if (xvsVaultRewardToken_ == address(0)) revert InvalidAddress();\\n if (oracle_ == address(0)) revert InvalidAddress();\\n if (primeLiquidityProvider_ == address(0)) revert InvalidAddress();\\n\\n _checkAlphaArguments(alphaNumerator_, alphaDenominator_);\\n\\n alphaNumerator = alphaNumerator_;\\n alphaDenominator = alphaDenominator_;\\n xvsVaultRewardToken = xvsVaultRewardToken_;\\n xvsVaultPoolId = xvsVaultPoolId_;\\n xvsVault = xvsVault_;\\n nextScoreUpdateRoundId = 0;\\n primeLiquidityProvider = primeLiquidityProvider_;\\n corePoolComptroller = comptroller_;\\n oracle = ResilientOracleInterface(oracle_);\\n\\n __AccessControlled_init(accessControlManager_);\\n __Pausable_init();\\n _setMaxLoopsLimit(loopsLimit_);\\n\\n _pause();\\n }\\n\\n /**\\n * @notice Prime initializer V2 for initializing pool registry\\n * @param poolRegistry_ Address of IL pool registry\\n */\\n function initializeV2(address poolRegistry_) external reinitializer(2) {\\n poolRegistry = poolRegistry_;\\n }\\n\\n /**\\n * @notice Returns boosted pending interest accrued for a user for all markets\\n * @param user the account for which to get the accrued interests\\n * @return pendingRewards the number of underlying tokens accrued by the user for all markets\\n */\\n function getPendingRewards(address user) external returns (PendingReward[] memory pendingRewards) {\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n pendingRewards = new PendingReward[](marketsLength);\\n for (uint256 i; i < marketsLength; ) {\\n address market = allMarkets[i];\\n uint256 interestAccrued = getInterestAccrued(market, user);\\n uint256 accrued = interests[market][user].accrued;\\n\\n pendingRewards[i] = PendingReward({\\n vToken: market,\\n rewardToken: _getUnderlying(market),\\n amount: interestAccrued + accrued\\n });\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Update total score of multiple users and market\\n * @param users accounts for which we need to update score\\n * @custom:error Throw NoScoreUpdatesRequired if no score updates are required\\n * @custom:error Throw UserHasNoPrimeToken if user has no prime token\\n * @custom:event Emits UserScoreUpdated event\\n */\\n function updateScores(address[] calldata users) external {\\n if (pendingScoreUpdates == 0) revert NoScoreUpdatesRequired();\\n if (nextScoreUpdateRoundId == 0) revert NoScoreUpdatesRequired();\\n\\n for (uint256 i; i < users.length; ) {\\n address user = users[i];\\n\\n if (!tokens[user].exists) revert UserHasNoPrimeToken();\\n if (isScoreUpdated[nextScoreUpdateRoundId][user]) {\\n unchecked {\\n ++i;\\n }\\n continue;\\n }\\n\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n for (uint256 j; j < marketsLength; ) {\\n address market = allMarkets[j];\\n _executeBoost(user, market);\\n _updateScore(user, market);\\n\\n unchecked {\\n ++j;\\n }\\n }\\n\\n --pendingScoreUpdates;\\n isScoreUpdated[nextScoreUpdateRoundId][user] = true;\\n\\n unchecked {\\n ++i;\\n }\\n\\n emit UserScoreUpdated(user);\\n }\\n }\\n\\n /**\\n * @notice Update value of alpha\\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\\n * @custom:event Emits AlphaUpdated event\\n * @custom:access Controlled by ACM\\n */\\n function updateAlpha(uint128 _alphaNumerator, uint128 _alphaDenominator) external {\\n _checkAccessAllowed(\\\"updateAlpha(uint128,uint128)\\\");\\n _checkAlphaArguments(_alphaNumerator, _alphaDenominator);\\n\\n emit AlphaUpdated(alphaNumerator, alphaDenominator, _alphaNumerator, _alphaDenominator);\\n\\n alphaNumerator = _alphaNumerator;\\n alphaDenominator = _alphaDenominator;\\n\\n uint256 marketslength = _allMarkets.length;\\n\\n for (uint256 i; i < marketslength; ) {\\n accrueInterest(_allMarkets[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n\\n _startScoreUpdateRound();\\n }\\n\\n /**\\n * @notice Update multipliers for a market\\n * @param market address of the market vToken\\n * @param supplyMultiplier new supply multiplier for the market, scaled by 1e18\\n * @param borrowMultiplier new borrow multiplier for the market, scaled by 1e18\\n * @custom:error Throw MarketNotSupported if market is not supported\\n * @custom:event Emits MultiplierUpdated event\\n * @custom:access Controlled by ACM\\n */\\n function updateMultipliers(address market, uint256 supplyMultiplier, uint256 borrowMultiplier) external {\\n _checkAccessAllowed(\\\"updateMultipliers(address,uint256,uint256)\\\");\\n\\n Market storage _market = markets[market];\\n if (!_market.exists) revert MarketNotSupported();\\n\\n accrueInterest(market);\\n\\n emit MultiplierUpdated(\\n market,\\n _market.supplyMultiplier,\\n _market.borrowMultiplier,\\n supplyMultiplier,\\n borrowMultiplier\\n );\\n _market.supplyMultiplier = supplyMultiplier;\\n _market.borrowMultiplier = borrowMultiplier;\\n\\n _startScoreUpdateRound();\\n }\\n\\n /**\\n * @notice Update staked at timestamp for multiple users\\n * @param users accounts for which we need to update staked at timestamp\\n * @param timestamps new staked at timestamp for the users\\n * @custom:error Throw InvalidLength if users and timestamps length are not equal\\n * @custom:event Emits StakedAtUpdated event for each user\\n * @custom:access Controlled by ACM\\n */\\n function setStakedAt(address[] calldata users, uint256[] calldata timestamps) external {\\n _checkAccessAllowed(\\\"setStakedAt(address[],uint256[])\\\");\\n if (users.length != timestamps.length) revert InvalidLength();\\n\\n for (uint256 i; i < users.length; ) {\\n if (timestamps[i] > block.timestamp) revert InvalidTimestamp();\\n\\n stakedAt[users[i]] = timestamps[i];\\n emit StakedAtUpdated(users[i], timestamps[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Add a market to prime program\\n * @param comptroller address of the comptroller\\n * @param market address of the market vToken\\n * @param supplyMultiplier the multiplier for supply cap. It should be converted to 1e18\\n * @param borrowMultiplier the multiplier for borrow cap. It should be converted to 1e18\\n * @custom:error Throw MarketAlreadyExists if market already exists\\n * @custom:error Throw InvalidVToken if market is not valid\\n * @custom:event Emits MarketAdded event\\n * @custom:access Controlled by ACM\\n */\\n function addMarket(\\n address comptroller,\\n address market,\\n uint256 supplyMultiplier,\\n uint256 borrowMultiplier\\n ) external {\\n _checkAccessAllowed(\\\"addMarket(address,address,uint256,uint256)\\\");\\n\\n if (comptroller == address(0)) revert InvalidComptroller();\\n\\n if (\\n comptroller != corePoolComptroller &&\\n PoolRegistryInterface(poolRegistry).getPoolByComptroller(comptroller).comptroller != comptroller\\n ) revert InvalidComptroller();\\n\\n Market storage _market = markets[market];\\n if (_market.exists) revert MarketAlreadyExists();\\n\\n bool isMarketExist = InterfaceComptroller(comptroller).markets(market);\\n if (!isMarketExist) revert InvalidVToken();\\n\\n delete _market.rewardIndex;\\n _market.supplyMultiplier = supplyMultiplier;\\n _market.borrowMultiplier = borrowMultiplier;\\n delete _market.sumOfMembersScore;\\n _market.exists = true;\\n\\n address underlying = _getUnderlying(market);\\n\\n if (vTokenForAsset[underlying] != address(0)) revert AssetAlreadyExists();\\n vTokenForAsset[underlying] = market;\\n\\n _allMarkets.push(market);\\n _startScoreUpdateRound();\\n\\n _ensureMaxLoops(_allMarkets.length);\\n\\n emit MarketAdded(comptroller, market, supplyMultiplier, borrowMultiplier);\\n }\\n\\n /**\\n * @notice Set limits for total tokens that can be minted\\n * @param _irrevocableLimit total number of irrevocable tokens that can be minted\\n * @param _revocableLimit total number of revocable tokens that can be minted\\n * @custom:error Throw InvalidLimit if any of the limit is less than total tokens minted\\n * @custom:event Emits MintLimitsUpdated event\\n * @custom:access Controlled by ACM\\n */\\n function setLimit(uint256 _irrevocableLimit, uint256 _revocableLimit) external {\\n _checkAccessAllowed(\\\"setLimit(uint256,uint256)\\\");\\n if (_irrevocableLimit < totalIrrevocable || _revocableLimit < totalRevocable) revert InvalidLimit();\\n\\n emit MintLimitsUpdated(irrevocableLimit, revocableLimit, _irrevocableLimit, _revocableLimit);\\n\\n revocableLimit = _revocableLimit;\\n irrevocableLimit = _irrevocableLimit;\\n }\\n\\n /**\\n * @notice Set the limit for the loops can iterate to avoid the DOS\\n * @param loopsLimit Number of loops limit\\n * @custom:event Emits MaxLoopsLimitUpdated event on success\\n * @custom:access Controlled by ACM\\n */\\n function setMaxLoopsLimit(uint256 loopsLimit) external {\\n _checkAccessAllowed(\\\"setMaxLoopsLimit(uint256)\\\");\\n _setMaxLoopsLimit(loopsLimit);\\n }\\n\\n /**\\n * @notice Directly issue prime tokens to users\\n * @param isIrrevocable are the tokens being issued\\n * @param users list of address to issue tokens to\\n * @custom:access Controlled by ACM\\n */\\n function issue(bool isIrrevocable, address[] calldata users) external {\\n _checkAccessAllowed(\\\"issue(bool,address[])\\\");\\n\\n if (isIrrevocable) {\\n for (uint256 i; i < users.length; ) {\\n Token storage userToken = tokens[users[i]];\\n if (userToken.exists && !userToken.isIrrevocable) {\\n _upgrade(users[i]);\\n } else {\\n _mint(true, users[i]);\\n _initializeMarkets(users[i]);\\n }\\n\\n unchecked {\\n ++i;\\n }\\n }\\n } else {\\n for (uint256 i; i < users.length; ) {\\n _mint(false, users[i]);\\n _initializeMarkets(users[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n }\\n\\n /**\\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\\n * @param user the account address whose balance was updated\\n */\\n function xvsUpdated(address user) external {\\n uint256 totalStaked = _xvsBalanceOfUser(user);\\n bool isAccountEligible = _isEligible(totalStaked);\\n\\n uint256 userStakedAt = stakedAt[user];\\n Token memory token = tokens[user];\\n\\n if (token.exists && !isAccountEligible) {\\n delete stakedAt[user];\\n emit StakedAtUpdated(user, 0);\\n\\n if (token.isIrrevocable) {\\n _accrueInterestAndUpdateScore(user);\\n } else {\\n _burn(user);\\n }\\n } else if (!isAccountEligible && !token.exists && userStakedAt != 0) {\\n delete stakedAt[user];\\n emit StakedAtUpdated(user, 0);\\n } else if (userStakedAt == 0 && isAccountEligible && !token.exists) {\\n stakedAt[user] = block.timestamp;\\n emit StakedAtUpdated(user, block.timestamp);\\n } else if (token.exists && isAccountEligible) {\\n _accrueInterestAndUpdateScore(user);\\n\\n if (stakedAt[user] == 0) {\\n stakedAt[user] = block.timestamp;\\n emit StakedAtUpdated(user, block.timestamp);\\n }\\n }\\n }\\n\\n /**\\n * @notice accrues interes and updates score for an user for a specific market\\n * @param user the account address for which to accrue interest and update score\\n * @param market the market for which to accrue interest and update score\\n */\\n function accrueInterestAndUpdateScore(address user, address market) external {\\n _executeBoost(user, market);\\n _updateScore(user, market);\\n }\\n\\n /**\\n * @notice For claiming prime token when staking period is completed\\n */\\n function claim() external {\\n uint256 userStakedAt = stakedAt[msg.sender];\\n if (userStakedAt == 0) revert IneligibleToClaim();\\n if (block.timestamp - userStakedAt < STAKING_PERIOD) revert WaitMoreTime();\\n\\n _mint(false, msg.sender);\\n _initializeMarkets(msg.sender);\\n }\\n\\n /**\\n * @notice For burning any prime token\\n * @param user the account address for which the prime token will be burned\\n * @custom:access Controlled by ACM\\n */\\n function burn(address user) external {\\n _checkAccessAllowed(\\\"burn(address)\\\");\\n _burn(user);\\n }\\n\\n /**\\n * @notice To pause or unpause claiming of interest\\n * @custom:access Controlled by ACM\\n */\\n function togglePause() external {\\n _checkAccessAllowed(\\\"togglePause()\\\");\\n if (paused()) {\\n _unpause();\\n } else {\\n _pause();\\n }\\n }\\n\\n /**\\n * @notice For user to claim boosted yield\\n * @param vToken the market for which claim the accrued interest\\n * @return amount the amount of tokens transferred to the msg.sender\\n */\\n function claimInterest(address vToken) external whenNotPaused returns (uint256) {\\n return _claimInterest(vToken, msg.sender);\\n }\\n\\n /**\\n * @notice For user to claim boosted yield\\n * @param vToken the market for which claim the accrued interest\\n * @param user the user for which to claim the accrued interest\\n * @return amount the amount of tokens transferred to the user\\n */\\n function claimInterest(address vToken, address user) external whenNotPaused returns (uint256) {\\n return _claimInterest(vToken, user);\\n }\\n\\n /**\\n * @notice Retrieves an array of all available markets\\n * @return an array of addresses representing all available markets\\n */\\n function getAllMarkets() external view returns (address[] memory) {\\n return _allMarkets;\\n }\\n\\n /**\\n * @notice Retrieves the core pool comptroller address\\n * @return the core pool comptroller address\\n */\\n function comptroller() external view returns (address) {\\n return corePoolComptroller;\\n }\\n\\n /**\\n * @notice fetch the numbers of seconds remaining for staking period to complete\\n * @param user the account address for which we are checking the remaining time\\n * @return timeRemaining the number of seconds the user needs to wait to claim prime token\\n */\\n function claimTimeRemaining(address user) external view returns (uint256) {\\n uint256 userStakedAt = stakedAt[user];\\n if (userStakedAt == 0) return STAKING_PERIOD;\\n\\n uint256 totalTimeStaked;\\n unchecked {\\n totalTimeStaked = block.timestamp - userStakedAt;\\n }\\n\\n if (totalTimeStaked < STAKING_PERIOD) {\\n unchecked {\\n return STAKING_PERIOD - totalTimeStaked;\\n }\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Returns if user is a prime holder\\n * @return isPrimeHolder true if user is a prime holder\\n */\\n function isUserPrimeHolder(address user) external view returns (bool) {\\n return tokens[user].exists;\\n }\\n\\n /**\\n * @notice Returns supply and borrow APR for user for a given market\\n * @param market the market for which to fetch the APR\\n * @param user the account for which to get the APR\\n * @return aprInfo APR information for the user for the given market\\n */\\n function calculateAPR(address market, address user) external view returns (APRInfo memory aprInfo) {\\n IVToken vToken = IVToken(market);\\n uint256 borrow = vToken.borrowBalanceStored(user);\\n uint256 exchangeRate = vToken.exchangeRateStored();\\n uint256 balanceOfAccount = vToken.balanceOf(user);\\n uint256 supply = (exchangeRate * balanceOfAccount) / EXP_SCALE;\\n\\n aprInfo.userScore = interests[market][user].score;\\n aprInfo.totalScore = markets[market].sumOfMembersScore;\\n\\n aprInfo.xvsBalanceForScore = _xvsBalanceForScore(_xvsBalanceOfUser(user));\\n Capital memory capital = _capitalForScore(aprInfo.xvsBalanceForScore, borrow, supply, address(vToken));\\n\\n aprInfo.capital = capital.capital;\\n aprInfo.cappedSupply = capital.cappedSupply;\\n aprInfo.cappedBorrow = capital.cappedBorrow;\\n aprInfo.supplyCapUSD = capital.supplyCapUSD;\\n aprInfo.borrowCapUSD = capital.borrowCapUSD;\\n\\n (aprInfo.supplyAPR, aprInfo.borrowAPR) = _calculateUserAPR(\\n market,\\n supply,\\n borrow,\\n aprInfo.cappedSupply,\\n aprInfo.cappedBorrow,\\n aprInfo.userScore,\\n aprInfo.totalScore\\n );\\n }\\n\\n /**\\n * @notice Returns supply and borrow APR for estimated supply, borrow and XVS staked\\n * @param market the market for which to fetch the APR\\n * @param user the account for which to get the APR\\n * @return aprInfo APR information for the user for the given market\\n */\\n function estimateAPR(\\n address market,\\n address user,\\n uint256 borrow,\\n uint256 supply,\\n uint256 xvsStaked\\n ) external view returns (APRInfo memory aprInfo) {\\n aprInfo.totalScore = markets[market].sumOfMembersScore - interests[market][user].score;\\n\\n aprInfo.xvsBalanceForScore = _xvsBalanceForScore(xvsStaked);\\n Capital memory capital = _capitalForScore(aprInfo.xvsBalanceForScore, borrow, supply, market);\\n\\n aprInfo.capital = capital.capital;\\n aprInfo.cappedSupply = capital.cappedSupply;\\n aprInfo.cappedBorrow = capital.cappedBorrow;\\n aprInfo.supplyCapUSD = capital.supplyCapUSD;\\n aprInfo.borrowCapUSD = capital.borrowCapUSD;\\n\\n uint256 decimals = IERC20MetadataUpgradeable(_getUnderlying(market)).decimals();\\n aprInfo.capital = aprInfo.capital * (10 ** (18 - decimals));\\n\\n aprInfo.userScore = Scores._calculateScore(\\n aprInfo.xvsBalanceForScore,\\n aprInfo.capital,\\n alphaNumerator,\\n alphaDenominator\\n );\\n\\n aprInfo.totalScore = aprInfo.totalScore + aprInfo.userScore;\\n\\n (aprInfo.supplyAPR, aprInfo.borrowAPR) = _calculateUserAPR(\\n market,\\n supply,\\n borrow,\\n aprInfo.cappedSupply,\\n aprInfo.cappedBorrow,\\n aprInfo.userScore,\\n aprInfo.totalScore\\n );\\n }\\n\\n /**\\n * @notice Distributes income from market since last distribution\\n * @param vToken the market for which to distribute the income\\n * @custom:error Throw MarketNotSupported if market is not supported\\n */\\n function accrueInterest(address vToken) public {\\n Market storage market = markets[vToken];\\n\\n if (!market.exists) revert MarketNotSupported();\\n\\n address underlying = _getUnderlying(vToken);\\n\\n IPrimeLiquidityProvider _primeLiquidityProvider = IPrimeLiquidityProvider(primeLiquidityProvider);\\n _primeLiquidityProvider.accrueTokens(underlying);\\n uint256 totalAccruedInPLP = _primeLiquidityProvider.tokenAmountAccrued(underlying);\\n uint256 unreleasedPLPAccruedInterest = totalAccruedInPLP - unreleasedPLPIncome[underlying];\\n uint256 distributionIncome = unreleasedPLPAccruedInterest;\\n\\n if (distributionIncome == 0) {\\n return;\\n }\\n\\n unreleasedPLPIncome[underlying] = totalAccruedInPLP;\\n\\n uint256 delta;\\n if (market.sumOfMembersScore != 0) {\\n delta = ((distributionIncome * EXP_SCALE) / market.sumOfMembersScore);\\n }\\n\\n market.rewardIndex += delta;\\n }\\n\\n /**\\n * @notice Returns boosted interest accrued for a user\\n * @param vToken the market for which to fetch the accrued interest\\n * @param user the account for which to get the accrued interest\\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\\n */\\n function getInterestAccrued(address vToken, address user) public returns (uint256) {\\n accrueInterest(vToken);\\n\\n return _interestAccrued(vToken, user);\\n }\\n\\n /**\\n * @notice accrues interest and updates score of all markets for an user\\n * @param user the account address for which to accrue interest and update score\\n */\\n function _accrueInterestAndUpdateScore(address user) internal {\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n for (uint256 i; i < marketsLength; ) {\\n address market = allMarkets[i];\\n _executeBoost(user, market);\\n _updateScore(user, market);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice Initializes all the markets for the user when a prime token is minted\\n * @param account the account address for which markets needs to be initialized\\n */\\n function _initializeMarkets(address account) internal {\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n for (uint256 i; i < marketsLength; ) {\\n address market = allMarkets[i];\\n accrueInterest(market);\\n\\n interests[market][account].rewardIndex = markets[market].rewardIndex;\\n\\n uint256 score = _calculateScore(market, account);\\n interests[market][account].score = score;\\n markets[market].sumOfMembersScore = markets[market].sumOfMembersScore + score;\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /**\\n * @notice calculate the current score of user\\n * @param market the market for which to calculate the score\\n * @param user the account for which to calculate the score\\n * @return score the score of the user\\n */\\n function _calculateScore(address market, address user) internal returns (uint256) {\\n uint256 xvsBalanceForScore = _xvsBalanceForScore(_xvsBalanceOfUser(user));\\n\\n IVToken vToken = IVToken(market);\\n uint256 borrow = vToken.borrowBalanceStored(user);\\n uint256 exchangeRate = vToken.exchangeRateStored();\\n uint256 balanceOfAccount = vToken.balanceOf(user);\\n uint256 supply = (exchangeRate * balanceOfAccount) / EXP_SCALE;\\n\\n address xvsToken = IXVSVault(xvsVault).xvsAddress();\\n oracle.updateAssetPrice(xvsToken);\\n oracle.updatePrice(market);\\n\\n Capital memory capital = _capitalForScore(xvsBalanceForScore, borrow, supply, market);\\n\\n uint256 decimals = IERC20MetadataUpgradeable(_getUnderlying(market)).decimals();\\n\\n capital.capital = capital.capital * (10 ** (18 - decimals));\\n\\n return Scores._calculateScore(xvsBalanceForScore, capital.capital, alphaNumerator, alphaDenominator);\\n }\\n\\n /**\\n * @notice To transfer the accrued interest to user\\n * @param vToken the market for which to claim\\n * @param user the account for which to get the accrued interest\\n * @return amount the amount of tokens transferred to the user\\n * @custom:event Emits InterestClaimed event\\n */\\n function _claimInterest(address vToken, address user) internal returns (uint256) {\\n uint256 amount = getInterestAccrued(vToken, user);\\n amount += interests[vToken][user].accrued;\\n\\n interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;\\n delete interests[vToken][user].accrued;\\n\\n address underlying = _getUnderlying(vToken);\\n IERC20Upgradeable asset = IERC20Upgradeable(underlying);\\n\\n if (amount > asset.balanceOf(address(this))) {\\n delete unreleasedPLPIncome[underlying];\\n IPrimeLiquidityProvider(primeLiquidityProvider).releaseFunds(address(asset));\\n }\\n\\n asset.safeTransfer(user, amount);\\n\\n emit InterestClaimed(user, vToken, amount);\\n\\n return amount;\\n }\\n\\n /**\\n * @notice Used to mint a new prime token\\n * @param isIrrevocable is the tokens being issued is irrevocable\\n * @param user token owner\\n * @custom:error Throw IneligibleToClaim if user is not eligible to claim prime token\\n * @custom:event Emits Mint event\\n */\\n function _mint(bool isIrrevocable, address user) internal {\\n Token storage token = tokens[user];\\n if (token.exists) revert IneligibleToClaim();\\n\\n token.exists = true;\\n token.isIrrevocable = isIrrevocable;\\n\\n if (isIrrevocable) {\\n ++totalIrrevocable;\\n } else {\\n ++totalRevocable;\\n }\\n\\n if (totalIrrevocable > irrevocableLimit || totalRevocable > revocableLimit) revert InvalidLimit();\\n _updateRoundAfterTokenMinted(user);\\n\\n emit Mint(user, isIrrevocable);\\n }\\n\\n /**\\n * @notice Used to burn a new prime token\\n * @param user owner whose prime token to burn\\n * @custom:error Throw UserHasNoPrimeToken if user has no prime token\\n * @custom:event Emits Burn event\\n */\\n function _burn(address user) internal {\\n Token memory token = tokens[user];\\n if (!token.exists) revert UserHasNoPrimeToken();\\n\\n address[] storage allMarkets = _allMarkets;\\n uint256 marketsLength = allMarkets.length;\\n\\n for (uint256 i; i < marketsLength; ) {\\n address market = allMarkets[i];\\n _executeBoost(user, market);\\n markets[market].sumOfMembersScore = markets[market].sumOfMembersScore - interests[market][user].score;\\n\\n delete interests[market][user].score;\\n delete interests[market][user].rewardIndex;\\n\\n unchecked {\\n ++i;\\n }\\n }\\n\\n if (token.isIrrevocable) {\\n --totalIrrevocable;\\n } else {\\n --totalRevocable;\\n }\\n\\n delete tokens[user].exists;\\n delete tokens[user].isIrrevocable;\\n\\n _updateRoundAfterTokenBurned(user);\\n\\n emit Burn(user);\\n }\\n\\n /**\\n * @notice Used to upgrade an token\\n * @param user owner whose prime token to upgrade\\n * @custom:error Throw InvalidLimit if total irrevocable tokens exceeds the limit\\n * @custom:event Emits TokenUpgraded event\\n */\\n function _upgrade(address user) internal {\\n Token storage userToken = tokens[user];\\n\\n userToken.isIrrevocable = true;\\n ++totalIrrevocable;\\n --totalRevocable;\\n\\n if (totalIrrevocable > irrevocableLimit) revert InvalidLimit();\\n\\n emit TokenUpgraded(user);\\n }\\n\\n /**\\n * @notice Accrue rewards for the user. Must be called before updating score\\n * @param user account for which we need to accrue rewards\\n * @param vToken the market for which we need to accrue rewards\\n */\\n function _executeBoost(address user, address vToken) internal {\\n if (!markets[vToken].exists || !tokens[user].exists) {\\n return;\\n }\\n\\n accrueInterest(vToken);\\n interests[vToken][user].accrued += _interestAccrued(vToken, user);\\n interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;\\n }\\n\\n /**\\n * @notice Update total score of user and market. Must be called after changing account's borrow or supply balance.\\n * @param user account for which we need to update score\\n * @param market the market for which we need to score\\n */\\n function _updateScore(address user, address market) internal {\\n Market storage _market = markets[market];\\n if (!_market.exists || !tokens[user].exists) {\\n return;\\n }\\n\\n uint256 score = _calculateScore(market, user);\\n _market.sumOfMembersScore = _market.sumOfMembersScore - interests[market][user].score + score;\\n\\n interests[market][user].score = score;\\n }\\n\\n /**\\n * @notice Verify new alpha arguments\\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\\n * @custom:error Throw InvalidAlphaArguments if alpha is invalid\\n */\\n function _checkAlphaArguments(uint128 _alphaNumerator, uint128 _alphaDenominator) internal pure {\\n if (_alphaNumerator >= _alphaDenominator || _alphaNumerator == 0) {\\n revert InvalidAlphaArguments();\\n }\\n }\\n\\n /**\\n * @notice starts round to update scores of a particular or all markets\\n */\\n function _startScoreUpdateRound() internal {\\n nextScoreUpdateRoundId++;\\n totalScoreUpdatesRequired = totalIrrevocable + totalRevocable;\\n pendingScoreUpdates = totalScoreUpdatesRequired;\\n }\\n\\n /**\\n * @notice update the required score updates when token is burned before round is completed\\n */\\n function _updateRoundAfterTokenBurned(address user) internal {\\n if (totalScoreUpdatesRequired != 0) --totalScoreUpdatesRequired;\\n\\n if (pendingScoreUpdates != 0 && !isScoreUpdated[nextScoreUpdateRoundId][user]) {\\n --pendingScoreUpdates;\\n }\\n }\\n\\n /**\\n * @notice update the required score updates when token is minted before round is completed\\n */\\n function _updateRoundAfterTokenMinted(address user) internal {\\n if (totalScoreUpdatesRequired != 0) isScoreUpdated[nextScoreUpdateRoundId][user] = true;\\n }\\n\\n /**\\n * @notice fetch the current XVS balance of user in the XVSVault\\n * @param user the account address\\n * @return xvsBalance the XVS balance of user\\n */\\n function _xvsBalanceOfUser(address user) internal view returns (uint256) {\\n (uint256 xvs, , uint256 pendingWithdrawals) = IXVSVault(xvsVault).getUserInfo(\\n xvsVaultRewardToken,\\n xvsVaultPoolId,\\n user\\n );\\n return (xvs - pendingWithdrawals);\\n }\\n\\n /**\\n * @notice calculate the current XVS balance that will be used in calculation of score\\n * @param xvs the actual XVS balance of user\\n * @return xvsBalanceForScore the XVS balance to use in score\\n */\\n function _xvsBalanceForScore(uint256 xvs) internal view returns (uint256) {\\n if (xvs > MAXIMUM_XVS_CAP) {\\n return MAXIMUM_XVS_CAP;\\n }\\n return xvs;\\n }\\n\\n /**\\n * @notice calculate the capital for calculation of score\\n * @param xvs the actual XVS balance of user\\n * @param borrow the borrow balance of user\\n * @param supply the supply balance of user\\n * @param market the market vToken address\\n * @return capital the capital to use in calculation of score\\n */\\n function _capitalForScore(\\n uint256 xvs,\\n uint256 borrow,\\n uint256 supply,\\n address market\\n ) internal view returns (Capital memory capital) {\\n address xvsToken = IXVSVault(xvsVault).xvsAddress();\\n\\n uint256 xvsPrice = oracle.getPrice(xvsToken);\\n capital.borrowCapUSD = (xvsPrice * ((xvs * markets[market].borrowMultiplier) / EXP_SCALE)) / EXP_SCALE;\\n capital.supplyCapUSD = (xvsPrice * ((xvs * markets[market].supplyMultiplier) / EXP_SCALE)) / EXP_SCALE;\\n\\n uint256 tokenPrice = oracle.getUnderlyingPrice(market);\\n uint256 supplyUSD = (tokenPrice * supply) / EXP_SCALE;\\n uint256 borrowUSD = (tokenPrice * borrow) / EXP_SCALE;\\n\\n if (supplyUSD >= capital.supplyCapUSD) {\\n supply = supplyUSD != 0 ? (supply * capital.supplyCapUSD) / supplyUSD : 0;\\n }\\n\\n if (borrowUSD >= capital.borrowCapUSD) {\\n borrow = borrowUSD != 0 ? (borrow * capital.borrowCapUSD) / borrowUSD : 0;\\n }\\n\\n capital.capital = supply + borrow;\\n capital.cappedSupply = supply;\\n capital.cappedBorrow = borrow;\\n }\\n\\n /**\\n * @notice Used to get if the XVS balance is eligible for prime token\\n * @param amount amount of XVS\\n * @return isEligible true if the staked XVS amount is enough to consider the associated user eligible for a Prime token, false otherwise\\n */\\n function _isEligible(uint256 amount) internal view returns (bool) {\\n if (amount >= MINIMUM_STAKED_XVS) {\\n return true;\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Calculate the interests accrued by the user in the market, since the last accrual\\n * @param vToken the market for which to calculate the accrued interest\\n * @param user the user for which to calculate the accrued interest\\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\\n */\\n function _interestAccrued(address vToken, address user) internal view returns (uint256) {\\n Interest memory interest = interests[vToken][user];\\n uint256 index = markets[vToken].rewardIndex - interest.rewardIndex;\\n\\n uint256 score = interest.score;\\n\\n return (index * score) / EXP_SCALE;\\n }\\n\\n /**\\n * @notice Returns the underlying token associated with the VToken, or wrapped native token if the market is native market\\n * @param vToken the market whose underlying token will be returned\\n * @return underlying The address of the underlying token associated with the VToken, or the address of the WRAPPED_NATIVE_TOKEN token if the market is NATIVE_MARKET\\n */\\n function _getUnderlying(address vToken) internal view returns (address) {\\n if (vToken == NATIVE_MARKET) {\\n return WRAPPED_NATIVE_TOKEN;\\n }\\n return IVToken(vToken).underlying();\\n }\\n\\n //////////////////////////////////////////////////\\n //////////////// APR Calculation ////////////////\\n ////////////////////////////////////////////////\\n\\n /**\\n * @notice the total income that's going to be distributed in a year to prime token holders\\n * @param vToken the market for which to fetch the total income that's going to distributed in a year\\n * @return amount the total income\\n */\\n function incomeDistributionYearly(address vToken) public view returns (uint256 amount) {\\n uint256 totalIncomePerBlockOrSecondFromPLP = IPrimeLiquidityProvider(primeLiquidityProvider)\\n .getEffectiveDistributionSpeed(_getUnderlying(vToken));\\n amount = blocksOrSecondsPerYear * totalIncomePerBlockOrSecondFromPLP;\\n }\\n\\n /**\\n * @notice used to calculate the supply and borrow APR of the user\\n * @param vToken the market for which to fetch the APR\\n * @param totalSupply the total token supply of the user\\n * @param totalBorrow the total tokens borrowed by the user\\n * @param totalCappedSupply the total token capped supply of the user\\n * @param totalCappedBorrow the total capped tokens borrowed by the user\\n * @param userScore the score of the user\\n * @param totalScore the total market score\\n * @return supplyAPR the supply APR of the user\\n * @return borrowAPR the borrow APR of the user\\n */\\n function _calculateUserAPR(\\n address vToken,\\n uint256 totalSupply,\\n uint256 totalBorrow,\\n uint256 totalCappedSupply,\\n uint256 totalCappedBorrow,\\n uint256 userScore,\\n uint256 totalScore\\n ) internal view returns (uint256 supplyAPR, uint256 borrowAPR) {\\n if (totalScore == 0) return (0, 0);\\n\\n uint256 userYearlyIncome = (userScore * incomeDistributionYearly(vToken)) / totalScore;\\n\\n uint256 totalCappedValue = totalCappedSupply + totalCappedBorrow;\\n\\n if (totalCappedValue == 0) return (0, 0);\\n\\n uint256 maximumBps = MAXIMUM_BPS;\\n uint256 userSupplyIncomeYearly;\\n uint256 userBorrowIncomeYearly;\\n userSupplyIncomeYearly = (userYearlyIncome * totalCappedSupply) / totalCappedValue;\\n userBorrowIncomeYearly = (userYearlyIncome * totalCappedBorrow) / totalCappedValue;\\n supplyAPR = totalSupply == 0 ? 0 : ((userSupplyIncomeYearly * maximumBps) / totalSupply);\\n borrowAPR = totalBorrow == 0 ? 0 : ((userBorrowIncomeYearly * maximumBps) / totalBorrow);\\n }\\n}\\n\",\"keccak256\":\"0xa0f8eb4edd3cba1ea9b35c3bd368c8694ff9c6ac0ce71501fdc5d8fb4902f1de\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/PrimeStorage.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.25;\\n\\nimport { ResilientOracleInterface } from \\\"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\\\";\\n\\n/**\\n * @title PrimeStorageV1\\n * @author Venus\\n * @notice Storage for Prime Token\\n */\\ncontract PrimeStorageV1 {\\n struct Token {\\n bool exists;\\n bool isIrrevocable;\\n }\\n\\n struct Market {\\n uint256 supplyMultiplier;\\n uint256 borrowMultiplier;\\n uint256 rewardIndex;\\n uint256 sumOfMembersScore;\\n bool exists;\\n }\\n\\n struct Interest {\\n uint256 accrued;\\n uint256 score;\\n uint256 rewardIndex;\\n }\\n\\n struct PendingReward {\\n address vToken;\\n address rewardToken;\\n uint256 amount;\\n }\\n\\n /// @notice Base unit for computations, usually used in scaling (multiplications, divisions)\\n uint256 internal constant EXP_SCALE = 1e18;\\n\\n /// @notice maximum BPS = 100%\\n uint256 internal constant MAXIMUM_BPS = 1e4;\\n\\n /// @notice Mapping to get prime token's metadata\\n mapping(address => Token) public tokens;\\n\\n /// @notice Tracks total irrevocable tokens minted\\n uint256 public totalIrrevocable;\\n\\n /// @notice Tracks total revocable tokens minted\\n uint256 public totalRevocable;\\n\\n /// @notice Indicates maximum revocable tokens that can be minted\\n uint256 public revocableLimit;\\n\\n /// @notice Indicates maximum irrevocable tokens that can be minted\\n uint256 public irrevocableLimit;\\n\\n /// @notice Tracks when prime token eligible users started staking for claiming prime token\\n mapping(address => uint256) public stakedAt;\\n\\n /// @notice vToken to market configuration\\n mapping(address => Market) public markets;\\n\\n /// @notice vToken to user to user index\\n mapping(address => mapping(address => Interest)) public interests;\\n\\n /// @notice A list of boosted markets\\n address[] internal _allMarkets;\\n\\n /// @notice numerator of alpha. Ex: if alpha is 0.5 then this will be 1\\n uint128 public alphaNumerator;\\n\\n /// @notice denominator of alpha. Ex: if alpha is 0.5 then this will be 2\\n uint128 public alphaDenominator;\\n\\n /// @notice address of XVS vault\\n address public xvsVault;\\n\\n /// @notice address of XVS vault reward token\\n address public xvsVaultRewardToken;\\n\\n /// @notice address of XVS vault pool id\\n uint256 public xvsVaultPoolId;\\n\\n /// @notice mapping to check if a account's score was updated in the round\\n mapping(uint256 => mapping(address => bool)) public isScoreUpdated;\\n\\n /// @notice unique id for next round\\n uint256 public nextScoreUpdateRoundId;\\n\\n /// @notice total number of accounts whose score needs to be updated\\n uint256 public totalScoreUpdatesRequired;\\n\\n /// @notice total number of accounts whose score is yet to be updated\\n uint256 public pendingScoreUpdates;\\n\\n /// @notice mapping used to find if an asset is part of prime markets\\n mapping(address => address) public vTokenForAsset;\\n\\n /// @notice Address of core pool comptroller contract\\n address internal corePoolComptroller;\\n\\n /// @notice unreleased income from PLP that's already distributed to prime holders\\n /// @dev mapping of asset address => amount\\n mapping(address => uint256) public unreleasedPLPIncome;\\n\\n /// @notice The address of PLP contract\\n address public primeLiquidityProvider;\\n\\n /// @notice The address of ResilientOracle contract\\n ResilientOracleInterface public oracle;\\n\\n /// @notice The address of PoolRegistry contract\\n address public poolRegistry;\\n\\n /// @dev This empty reserved space is put in place to allow future versions to add new\\n /// variables without shifting down storage in the inheritance chain.\\n uint256[26] private __gap;\\n}\\n\",\"keccak256\":\"0x5285c875114db2ea2be0b81b65722d5761806217022db733323c4e03365a95e7\",\"license\":\"BSD-3-Clause\"},\"contracts/Tokens/Prime/libs/FixedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// solhint-disable var-name-mixedcase\\n\\npragma solidity 0.8.25;\\n\\nimport { SafeCastUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\nimport { FixedMath0x } from \\\"./FixedMath0x.sol\\\";\\n\\nusing SafeCastUpgradeable for uint256;\\n\\nerror InvalidFixedPoint();\\n\\n/**\\n * @title FixedMath\\n * @author Venus\\n * @notice FixedMath library is used for complex mathematical operations\\n */\\nlibrary FixedMath {\\n error InvalidFraction(uint256 n, uint256 d);\\n\\n /**\\n * @notice Convert some uint256 fraction `n` numerator / `d` denominator to a fixed-point number `f`.\\n * @param n numerator\\n * @param d denominator\\n * @return fixed-point number\\n */\\n function _toFixed(uint256 n, uint256 d) internal pure returns (int256) {\\n if (d.toInt256() < n.toInt256()) revert InvalidFraction(n, d);\\n\\n return (n.toInt256() * FixedMath0x.FIXED_1) / int256(d.toInt256());\\n }\\n\\n /**\\n * @notice Divide some unsigned int `u` by a fixed point number `f`\\n * @param u unsigned dividend\\n * @param f fixed point divisor, in FIXED_1 units\\n * @return unsigned int quotient\\n */\\n function _uintDiv(uint256 u, int256 f) internal pure returns (uint256) {\\n if (f < 0) revert InvalidFixedPoint();\\n // multiply `u` by FIXED_1 to cancel out the built-in FIXED_1 in f\\n return uint256((u.toInt256() * FixedMath0x.FIXED_1) / f);\\n }\\n\\n /**\\n * @notice Multiply some unsigned int `u` by a fixed point number `f`\\n * @param u unsigned multiplicand\\n * @param f fixed point multiplier, in FIXED_1 units\\n * @return unsigned int product\\n */\\n function _uintMul(uint256 u, int256 f) internal pure returns (uint256) {\\n if (f < 0) revert InvalidFixedPoint();\\n // divide the product by FIXED_1 to cancel out the built-in FIXED_1 in f\\n return uint256((u.toInt256() * f) / FixedMath0x.FIXED_1);\\n }\\n\\n /// @notice see FixedMath0x\\n function _ln(int256 x) internal pure returns (int256) {\\n return FixedMath0x._ln(x);\\n }\\n\\n /// @notice see FixedMath0x\\n function _exp(int256 x) internal pure returns (int256) {\\n return FixedMath0x._exp(x);\\n }\\n}\\n\",\"keccak256\":\"0x9079477d98acfc1a1dab1279230eb33d5cc6898e17c3b61aec912de0ba4fee8a\",\"license\":\"MIT\"},\"contracts/Tokens/Prime/libs/FixedMath0x.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// solhint-disable max-line-length\\n\\npragma solidity 0.8.25;\\n\\n// Below is code from 0x's LibFixedMath.sol. Changes:\\n// - addition of 0.8-style errors\\n// - removal of unused functions\\n// - added comments for clarity\\n// https://github.com/0xProject/exchange-v3/blob/aae46bef841bfd1cc31028f41793db4fe7197084/contracts/staking/contracts/src/libs/LibFixedMath.sol\\n\\n/*\\n\\n Copyright 2017 Bprotocol Foundation, 2019 ZeroEx Intl.\\n\\n Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n you may not use this file except in compliance with the License.\\n You may obtain a copy of the License at\\n\\n http://www.apache.org/licenses/LICENSE-2.0\\n\\n Unless required by applicable law or agreed to in writing, software\\n distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n See the License for the specific language governing permissions and\\n limitations under the License.\\n\\n*/\\n/// Thrown when the natural log function is given too large of an argument\\nerror LnTooLarge(int256 x);\\n/// Thrown when the natural log would have returned a number outside of \\u211d\\nerror LnNonRealResult(int256 x);\\n/// Thrown when exp is given too large of an argument\\nerror ExpTooLarge(int256 x);\\n/// Thrown when an unsigned value is too large to be converted to a signed value\\nerror UnsignedValueTooLarge(uint256 x);\\n\\n/**\\n * @title FixedMath0x\\n * @notice Signed, fixed-point, 127-bit precision math library\\n */\\nlibrary FixedMath0x {\\n // Base for the fixed point numbers (this is our 1)\\n int256 internal constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000);\\n // Maximum ln argument (1)\\n int256 private constant LN_MAX_VAL = FIXED_1;\\n // Minimum ln argument. Notice this is related to EXP_MIN_VAL (e ^ -63.875)\\n int256 private constant LN_MIN_VAL = int256(0x0000000000000000000000000000000000000000000000000000000733048c5a);\\n // Maximum exp argument (0)\\n int256 private constant EXP_MAX_VAL = 0;\\n // Minimum exp argument. Notice this is related to LN_MIN_VAL (-63.875)\\n int256 private constant EXP_MIN_VAL = -int256(0x0000000000000000000000000000001ff0000000000000000000000000000000);\\n\\n /// @dev Get the natural logarithm of a fixed-point number 0 < `x` <= LN_MAX_VAL\\n function _ln(int256 x) internal pure returns (int256 r) {\\n if (x > LN_MAX_VAL) {\\n revert LnTooLarge(x);\\n }\\n if (x <= 0) {\\n revert LnNonRealResult(x);\\n }\\n if (x == FIXED_1) {\\n return 0;\\n }\\n if (x <= LN_MIN_VAL) {\\n return EXP_MIN_VAL;\\n }\\n\\n int256 y;\\n int256 z;\\n int256 w;\\n\\n // Rewrite the input as a quotient of negative natural exponents and a single residual q, such that 1 < q < 2\\n // For example: log(0.3) = log(e^-1 * e^-0.25 * 1.0471028872385522)\\n // = 1 - 0.25 - log(1 + 0.0471028872385522)\\n // e ^ -32\\n if (x <= int256(0x00000000000000000000000000000000000000000001c8464f76164760000000)) {\\n r -= int256(0x0000000000000000000000000000001000000000000000000000000000000000); // - 32\\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32\\n }\\n // e ^ -16\\n if (x <= int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000)) {\\n r -= int256(0x0000000000000000000000000000000800000000000000000000000000000000); // - 16\\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000); // / e ^ -16\\n }\\n // e ^ -8\\n if (x <= int256(0x00000000000000000000000000000000000afe10820813d78000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000400000000000000000000000000000000); // - 8\\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000afe10820813d78000000000000000); // / e ^ -8\\n }\\n // e ^ -4\\n if (x <= int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000200000000000000000000000000000000); // - 4\\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000); // / e ^ -4\\n }\\n // e ^ -2\\n if (x <= int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000100000000000000000000000000000000); // - 2\\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000); // / e ^ -2\\n }\\n // e ^ -1\\n if (x <= int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000080000000000000000000000000000000); // - 1\\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000); // / e ^ -1\\n }\\n // e ^ -0.5\\n if (x <= int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000040000000000000000000000000000000); // - 0.5\\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000); // / e ^ -0.5\\n }\\n // e ^ -0.25\\n if (x <= int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000)) {\\n r -= int256(0x0000000000000000000000000000000020000000000000000000000000000000); // - 0.25\\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000); // / e ^ -0.25\\n }\\n // e ^ -0.125\\n if (x <= int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) {\\n r -= int256(0x0000000000000000000000000000000010000000000000000000000000000000); // - 0.125\\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d); // / e ^ -0.125\\n }\\n // `x` is now our residual in the range of 1 <= x <= 2 (or close enough).\\n\\n // Add the taylor series for log(1 + z), where z = x - 1\\n z = y = x - FIXED_1;\\n w = (y * y) / FIXED_1;\\n r += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02\\n r += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04\\n r += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06\\n r += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08\\n r += (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / 0x500000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^09 / 09 - y^10 / 10\\n r += (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / 0x600000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^11 / 11 - y^12 / 12\\n r += (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / 0x700000000000000000000000000000000;\\n z = (z * w) / FIXED_1; // add y^13 / 13 - y^14 / 14\\n r += (z * (0x088888888888888888888888888888888 - y)) / 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16\\n }\\n\\n /// @dev Compute the natural exponent for a fixed-point number EXP_MIN_VAL <= `x` <= 1\\n function _exp(int256 x) internal pure returns (int256 r) {\\n if (x < EXP_MIN_VAL) {\\n // Saturate to zero below EXP_MIN_VAL.\\n return 0;\\n }\\n if (x == 0) {\\n return FIXED_1;\\n }\\n if (x > EXP_MAX_VAL) {\\n revert ExpTooLarge(x);\\n }\\n\\n // Rewrite the input as a product of natural exponents and a\\n // single residual q, where q is a number of small magnitude.\\n // For example: e^-34.419 = e^(-32 - 2 - 0.25 - 0.125 - 0.044)\\n // = e^-32 * e^-2 * e^-0.25 * e^-0.125 * e^-0.044\\n // -> q = -0.044\\n\\n // Multiply with the taylor series for e^q\\n int256 y;\\n int256 z;\\n // q = x % 0.125 (the residual)\\n z = y = x % 0x0000000000000000000000000000000010000000000000000000000000000000;\\n z = (z * y) / FIXED_1;\\n r += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x004807432bc18000; // add y^05 * (20! / 05!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000017499f00; // add y^13 * (20! / 13!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x00000000001c6380; // add y^15 * (20! / 15!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000000000001c638; // add y^16 * (20! / 16!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x000000000000017c; // add y^18 * (20! / 18!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000000000014; // add y^19 * (20! / 19!)\\n z = (z * y) / FIXED_1;\\n r += z * 0x0000000000000001; // add y^20 * (20! / 20!)\\n r = r / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!\\n\\n // Multiply with the non-residual terms.\\n x = -x;\\n // e ^ -32\\n if ((x & int256(0x0000000000000000000000000000001000000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x00000000000000000000000000000000000000f1aaddd7742e56d32fb9f99744)) /\\n int256(0x0000000000000000000000000043cbaf42a000812488fc5c220ad7b97bf6e99e); // * e ^ -32\\n }\\n // e ^ -16\\n if ((x & int256(0x0000000000000000000000000000000800000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x00000000000000000000000000000000000afe10820813d65dfe6a33c07f738f)) /\\n int256(0x000000000000000000000000000005d27a9f51c31b7c2f8038212a0574779991); // * e ^ -16\\n }\\n // e ^ -8\\n if ((x & int256(0x0000000000000000000000000000000400000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x0000000000000000000000000000000002582ab704279e8efd15e0265855c47a)) /\\n int256(0x0000000000000000000000000000001b4c902e273a58678d6d3bfdb93db96d02); // * e ^ -8\\n }\\n // e ^ -4\\n if ((x & int256(0x0000000000000000000000000000000200000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x000000000000000000000000000000001152aaa3bf81cb9fdb76eae12d029571)) /\\n int256(0x00000000000000000000000000000003b1cc971a9bb5b9867477440d6d157750); // * e ^ -4\\n }\\n // e ^ -2\\n if ((x & int256(0x0000000000000000000000000000000100000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x000000000000000000000000000000002f16ac6c59de6f8d5d6f63c1482a7c86)) /\\n int256(0x000000000000000000000000000000015bf0a8b1457695355fb8ac404e7a79e3); // * e ^ -2\\n }\\n // e ^ -1\\n if ((x & int256(0x0000000000000000000000000000000080000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x000000000000000000000000000000004da2cbf1be5827f9eb3ad1aa9866ebb3)) /\\n int256(0x00000000000000000000000000000000d3094c70f034de4b96ff7d5b6f99fcd8); // * e ^ -1\\n }\\n // e ^ -0.5\\n if ((x & int256(0x0000000000000000000000000000000040000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x0000000000000000000000000000000063afbe7ab2082ba1a0ae5e4eb1b479dc)) /\\n int256(0x00000000000000000000000000000000a45af1e1f40c333b3de1db4dd55f29a7); // * e ^ -0.5\\n }\\n // e ^ -0.25\\n if ((x & int256(0x0000000000000000000000000000000020000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) /\\n int256(0x00000000000000000000000000000000910b022db7ae67ce76b441c27035c6a1); // * e ^ -0.25\\n }\\n // e ^ -0.125\\n if ((x & int256(0x0000000000000000000000000000000010000000000000000000000000000000)) != 0) {\\n r =\\n (r * int256(0x00000000000000000000000000000000783eafef1c0a8f3978c7f81824d62ebf)) /\\n int256(0x0000000000000000000000000000000088415abbe9a76bead8d00cf112e4d4a8); // * e ^ -0.125\\n }\\n }\\n}\\n\",\"keccak256\":\"0xda0304ab7a6b5953a0fed087ba324eeaacbf826a412c5492cb0e445dc03a88a3\",\"license\":\"MIT\"},\"contracts/Tokens/Prime/libs/Scores.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.25;\\n\\nimport { SafeCastUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\nimport { FixedMath } from \\\"./FixedMath.sol\\\";\\n\\nusing SafeCastUpgradeable for uint256;\\n\\n/**\\n * @title Scores\\n * @author Venus\\n * @notice Scores library is used to calculate score of users\\n */\\nlibrary Scores {\\n /**\\n * @notice Calculate a membership score given some amount of `xvs` and `capital`, along\\n * with some \\ud835\\udf70 = `alphaNumerator` / `alphaDenominator`.\\n * @param xvs amount of xvs (xvs, 1e18 decimal places)\\n * @param capital amount of capital (1e18 decimal places)\\n * @param alphaNumerator alpha param numerator\\n * @param alphaDenominator alpha param denominator\\n * @return membership score with 1e18 decimal places\\n *\\n * @dev \\ud835\\udf70 must be in the range [0, 1]\\n */\\n function _calculateScore(\\n uint256 xvs,\\n uint256 capital,\\n uint256 alphaNumerator,\\n uint256 alphaDenominator\\n ) internal pure returns (uint256) {\\n // Score function is:\\n // xvs^\\ud835\\udf70 * capital^(1-\\ud835\\udf70)\\n // = capital * capital^(-\\ud835\\udf70) * xvs^\\ud835\\udf70\\n // = capital * (xvs / capital)^\\ud835\\udf70\\n // = capital * (e ^ (ln(xvs / capital))) ^ \\ud835\\udf70\\n // = capital * e ^ (\\ud835\\udf70 * ln(xvs / capital)) (1)\\n // or\\n // = capital / ( 1 / e ^ (\\ud835\\udf70 * ln(xvs / capital)))\\n // = capital / (e ^ (\\ud835\\udf70 * ln(xvs / capital)) ^ -1)\\n // = capital / e ^ (\\ud835\\udf70 * -1 * ln(xvs / capital))\\n // = capital / e ^ (\\ud835\\udf70 * ln(capital / xvs)) (2)\\n //\\n // To avoid overflows, use (1) when xvs < capital and\\n // use (2) when capital < xvs\\n\\n // If any side is 0, exit early\\n if (xvs == 0 || capital == 0) return 0;\\n\\n // If both sides are equal, we have:\\n // xvs^\\ud835\\udf70 * capital^(1-\\ud835\\udf70)\\n // = xvs^\\ud835\\udf70 * xvs^(1-\\ud835\\udf70)\\n // = xvs^(\\ud835\\udf70 + 1 - \\ud835\\udf70) = xvs\\n if (xvs == capital) return xvs;\\n\\n bool lessxvsThanCapital = xvs < capital;\\n\\n // (xvs / capital) or (capital / xvs), always in range (0, 1)\\n int256 ratio = lessxvsThanCapital ? FixedMath._toFixed(xvs, capital) : FixedMath._toFixed(capital, xvs);\\n\\n // e ^ ( ln(ratio) * \\ud835\\udf70 )\\n int256 exponentiation = FixedMath._exp(\\n (FixedMath._ln(ratio) * alphaNumerator.toInt256()) / alphaDenominator.toInt256()\\n );\\n\\n if (lessxvsThanCapital) {\\n // capital * e ^ (\\ud835\\udf70 * ln(xvs / capital))\\n return FixedMath._uintMul(capital, exponentiation);\\n }\\n\\n // capital / e ^ (\\ud835\\udf70 * ln(capital / xvs))\\n return FixedMath._uintDiv(capital, exponentiation);\\n }\\n}\\n\",\"keccak256\":\"0xa02a36d836711c975f20b8e67fc134d986881f5fd9f835be285ed8021ffc10ca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x61018060405234801561001157600080fd5b50604051615f00380380615f00833981016040819052610030916101ea565b80858115801561003e575080155b1561005c576040516302723dfb60e21b815260040160405180910390fd5b81801561006857508015155b156100865760405163ae0fcab360e01b815260040160405180910390fd5b81151560a05281610097578061009d565b6301e133805b608052816100b45761010760201b6125fb176100bf565b61010b60201b6125ff175b6001600160401b031660c05250506001600160a01b0380881660e0528616610100526101608490526101208390526101408290526100fb61010f565b5050505050505061025d565b4390565b4290565b600054610100900460ff161561017b5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146101cc576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146101e557600080fd5b919050565b600080600080600080600060e0888a03121561020557600080fd5b61020e886101ce565b965061021c602089016101ce565b955060408801519450606088015193506080880151925060a0880151915060c0880151801515811461024d57600080fd5b8091505092959891949750929550565b60805160a05160c05160e05161010051610120516101405161016051615bf8610308600039600081816103f00152818161107701528181612182015281816121ad01526121d5015260008181610ac301528181613416015261343f0152600081816105a40152612a180152600081816109330152612ebf01526000818161043f0152612ef901526000612132015260006108f80152600081816105cb01526113a60152615bf86000f3fe608060405234801561001057600080fd5b50600436106103e65760003560e01c80639f6506ce1161020a578063cdaa21b711610125578063e30c3978116100b8578063ef36bbde11610087578063ef36bbde14610a57578063f2fde38b14610a78578063f6ed201714610a8b578063fa6d5f1814610aab578063fe1006ad14610abe57600080fd5b8063e30c3978146109c5578063e4676f37146109d6578063e4860339146109e9578063ee6b13fc14610a2d57600080fd5b8063d88b9d2e116100f4578063d88b9d2e14610996578063da6ab4f8146109a0578063e18f8822146109aa578063e1d146fb146109bd57600080fd5b8063cdaa21b71461092e578063ce85361314610955578063cf329d1614610970578063d65bd2411461098357600080fd5b8063ba437c681161019d578063c3db3c361161016c578063c3db3c36146108e1578063c4ae3168146108eb578063c7ad0895146108f3578063c86d1a781461091a57600080fd5b8063ba437c68146108a8578063bc5dc4c3146108bb578063bd212c0e146108ce578063be26317e146108d857600080fd5b8063b1a250f2116101d9578063b1a250f2146107a2578063b4a0bdf3146107b5578063b7f2d258146107c6578063b9eb69f61461085257600080fd5b80639f6506ce14610765578063a15753dc1461076f578063afcff50f14610779578063b0772d0b1461078d57600080fd5b80635fe3b5671161030557806380d45a2d1161029857806389afcb441161026757806389afcb44146106945780638da5cb5b146106a75780638e8f294b146106b85780639198e515146107235780639565d3d21461073657600080fd5b806380d45a2d14610650578063856c3aa41461066357806388bead731461066d57806388d742c21461068157600080fd5b806379ba5097116102d457806379ba5097146105f55780637dafcd89146105fd5780637dc0d1d0146106105780637ef820701461062457600080fd5b80635fe3b5671461058d5780636426b4a71461059f5780636857249c146105c6578063715018a6146105ed57600080fd5b806337f23cd31161037d57806355d36c981161034c57806355d36c9814610549578063594a67ee1461055c5780635c975abb1461056f5780635d536d301461057a57600080fd5b806337f23cd3146104e757806338f6a434146104fa578063487b0dfb146105375780634e71d92d1461054157600080fd5b80631bffac89116103b95780631bffac891461048d578063207add91146104ae57806324e6baf2146104c157806329b6eca9146104d457600080fd5b80630104db1b146103eb5780630e32cb86146104255780631b3f8c5e1461043a5780631b9ce57514610479575b600080fd5b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6104386104333660046150ac565b610ae5565b005b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161041c565b61013754610461906001600160a01b031681565b61041261049b3660046150ac565b6101406020526000908152604090205481565b6104386104bc3660046150c9565b610af9565b6104386104cf366004615137565b610bb4565b6104386104e23660046150ac565b610d80565b6104386104f53660046150ac565b610e38565b6105276105083660046150ac565b6001600160a01b0316600090815261012d602052604090205460ff1690565b604051901515815260200161041c565b6104126101395481565b610438611044565b610438610557366004615179565b6110d3565b61043861056a3660046151ae565b61119e565b60c95460ff16610527565b6104126105883660046150ac565b611316565b61013f546001600160a01b0316610461565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104386113d1565b6104386113e5565b61043861060b366004615228565b61145c565b61014254610461906001600160a01b031681565b61013654610638906001600160801b031681565b6040516001600160801b03909116815260200161041c565b61043861065e36600461527d565b6115e6565b6104126101315481565b61013854610461906001600160a01b031681565b61041261068f3660046150ac565b61162d565b6104386106a23660046150ac565b611649565b6033546001600160a01b0316610461565b6106f96106c63660046150ac565b61013360205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161041c565b6104386107313660046150ac565b611680565b610527610744366004615296565b61013a60209081526000928352604080842090915290825290205460ff1681565b61041261012f5481565b61041261013b5481565b61014354610461906001600160a01b031681565b610795611844565b60405161041c91906152c6565b6104386107b036600461532a565b6118a7565b6097546001600160a01b0316610461565b6107d96107d43660046153e4565b611abc565b60405161041c9190600061014082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525092915050565b61088d610860366004615435565b61013460209081526000928352604080842090915290825290208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161041c565b6104126108b6366004615435565b611c76565b6104386108c9366004615463565b611c93565b61041261013c5481565b61041260fb5481565b61041261013d5481565b610438611fb1565b6105277f000000000000000000000000000000000000000000000000000000000000000081565b61014154610461906001600160a01b031681565b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6101365461063890600160801b90046001600160801b031681565b61043861097e366004615435565b611ffa565b610412610991366004615435565b612012565b61041261012e5481565b6104126101305481565b6104386109b83660046154a9565b612027565b61041261212b565b6065546001600160a01b0316610461565b6104126109e43660046150ac565b61215e565b610a166109f73660046150ac565b61012d6020526000908152604090205460ff8082169161010090041682565b60408051921515835290151560208301520161041c565b610461610a3b3660046150ac565b61013e602052600090815260409020546001600160a01b031681565b610412610a653660046150ac565b6101326020526000908152604090205481565b610438610a863660046150ac565b612206565b610a9e610a993660046150ac565b612277565b60405161041c91906154dc565b6107d9610ab9366004615435565b6123b9565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b610aed612603565b610af68161265d565b50565b610b376040518060400160405280601981526020017f7365744c696d69742875696e743235362c75696e74323536290000000000000081525061271b565b61012e54821080610b4a575061012f5481105b15610b685760405163e55fb50960e01b815260040160405180910390fd5b8161013054610131547f6c52f3e195bdc534883e903e0612c49261a466aacd492501870b0a0ac0b1835584604051610ba291815260200190565b60405180910390a46101305561013155565b61013d54600003610bd85760405163071a45dd60e31b815260040160405180910390fd5b61013b54600003610bfc5760405163071a45dd60e31b815260040160405180910390fd5b60005b81811015610d7b576000838383818110610c1b57610c1b615541565b9050602002016020810190610c3091906150ac565b6001600160a01b038116600090815261012d602052604090205490915060ff16610c6d57604051633aeb927b60e11b815260040160405180910390fd5b61013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff1615610ca65750600101610bff565b610135805460005b81811015610cfe576000838281548110610cca57610cca615541565b6000918252602090912001546001600160a01b03169050610ceb85826127b5565b610cf58582612891565b50600101610cae565b5061013d60008154610d0f9061556d565b9091555061013b54600090815261013a602090815260408083206001600160a01b0387168085529252808320805460ff19166001908117909155905196019590917fa699df4aa8f89fc1f5408fe78ae114651f18b25ed1601680e4c70c15177d8b1b91a2505050610bff565b505050565b600054600290610100900460ff16158015610da2575060005460ff8083169116105b610dc75760405162461bcd60e51b8152600401610dbe90615584565b60405180910390fd5b6000805461014380546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6000610e438261296e565b90506000610e5082612a14565b6001600160a01b0384166000908152610132602090815260408083205461012d83529281902081518083019092525460ff808216158015808552610100909304909116151593830193909352939450919290610eaa575082155b15610f0c576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615b79833981519152910160405180910390a2806020015115610f0357610efe85612a4d565b61103d565b610efe85612aa5565b82158015610f1957508051155b8015610f2457508115155b15610f6b576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615b7983398151915291015b60405180910390a261103d565b81158015610f765750825b8015610f8157508051155b15610fc3576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615b798339815191529101610f5e565b80518015610fce5750825b1561103d57610fdc85612a4d565b6001600160a01b03851660009081526101326020526040812054900361103d576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615b79833981519152910160405180910390a25b5050505050565b3360009081526101326020526040812054908190036110755760405162c4e3d160e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006110a082426155d2565b10156110bf5760405163beb98cab60e01b815260040160405180910390fd5b6110ca600033612c79565b610af633612d8a565b6110f46040518060600160405280602a8152602001615b4f602a913961271b565b6001600160a01b038316600090815261013360205260409020600481015460ff1661113257604051630ff2e4a960e31b815260040160405180910390fd5b61113b84611680565b6001810154815460408051868152602081018690526001600160a01b038816917f91e78a55b6df3a0eac1c12a64572a8c0faced385bafba688817f5ce6daa33537910160405180910390a482815560018101829055611198612e87565b50505050565b6111dc6040518060400160405280602081526020017f7365745374616b6564417428616464726573735b5d2c75696e743235365b5d2981525061271b565b8281146111fc5760405163251f56a160e21b815260040160405180910390fd5b60005b8381101561103d574283838381811061121a5761121a615541565b9050602002013511156112405760405163b7d0949760e01b815260040160405180910390fd5b82828281811061125257611252615541565b90506020020135610132600087878581811061127057611270615541565b905060200201602081019061128591906150ac565b6001600160a01b031681526020810191909152604001600020558484828181106112b1576112b1615541565b90506020020160208101906112c691906150ac565b6001600160a01b0316600080516020615b798339815191528484848181106112f0576112f0615541565b9050602002013560405161130691815260200190565b60405180910390a26001016111ff565b6101415460009081906001600160a01b031663a666642b61133685612ebb565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561137a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139e91906155e5565b90506113ca817f00000000000000000000000000000000000000000000000000000000000000006155fe565b9392505050565b6113d9612603565b6113e36000612f7f565b565b60655433906001600160a01b031681146114535760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610dbe565b610af681612f7f565b61149260405180604001604052806015815260200174697373756528626f6f6c2c616464726573735b5d2960581b81525061271b565b82156115a75760005b8181101561119857600061012d60008585858181106114bc576114bc615541565b90506020020160208101906114d191906150ac565b6001600160a01b031681526020810191909152604001600020805490915060ff16801561150557508054610100900460ff16155b1561153e5761153984848481811061151f5761151f615541565b905060200201602081019061153491906150ac565b612f98565b61159e565b61156f600185858581811061155557611555615541565b905060200201602081019061156a91906150ac565b612c79565b61159e84848481811061158457611584615541565b905060200201602081019061159991906150ac565b612d8a565b5060010161149b565b60005b81811015611198576115c9600084848481811061155557611555615541565b6115de83838381811061158457611584615541565b6001016115aa565b6116246040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e74323536290000000000000081525061271b565b610af681613048565b60006116376130e2565b6116418233613128565b90505b919050565b6116776040518060400160405280600d81526020016c6275726e28616464726573732960981b81525061271b565b610af681612aa5565b6001600160a01b038116600090815261013360205260409020600481015460ff166116be57604051630ff2e4a960e31b815260040160405180910390fd5b60006116c983612ebb565b61014154604051638aadf79960e01b81526001600160a01b0380841660048301529293509116908190638aadf79990602401600060405180830381600087803b15801561171557600080fd5b505af1158015611729573d6000803e3d6000fd5b505060405163fa7781ff60e01b81526001600160a01b038581166004830152600093508416915063fa7781ff90602401602060405180830381865afa158015611776573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179a91906155e5565b6001600160a01b03841660009081526101406020526040812054919250906117c290836155d2565b90508060008190036117d75750505050505050565b6001600160a01b038516600090815261014060205260408120849055600387015415611821576003870154611814670de0b6b3a7640000846155fe565b61181e919061562b565b90505b80876002016000828254611835919061563f565b90915550505050505050505050565b606061013580548060200260200160405190810160405280929190818152602001828054801561189d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161187f575b5050505050905090565b600054610100900460ff16158080156118c75750600054600160ff909116105b806118e15750303b1580156118e1575060005460ff166001145b6118fd5760405162461bcd60e51b8152600401610dbe90615584565b6000805460ff191660011790558015611920576000805461ff0019166101001790555b6001600160a01b038b166119475760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038a1661196e5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0383166119955760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0385166119bc5760405163e6c4247b60e01b815260040160405180910390fd5b6119c6888861330b565b6001600160801b03878116600160801b02908916176101365561013880546001600160a01b03808d166001600160a01b0319928316179092556101398b905561013780548e8416908316179055600061013b55610141805488841690831617905561013f8054878416908316179055610142805492861692909116919091179055611a5086613351565b611a58613389565b611a6182613048565b611a696133b8565b8015611aaf576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b611ac4615044565b6001600160a01b03808716600081815261013460209081526040808320948a1683529381528382206001015492825261013390529190912060030154611b0a91906155d2565b6040820152611b1882613412565b60808201819052600090611b2e9086868a613467565b805160a0840152602081015160c0840152604081015160e08401526060810151610100840152608081015161012084015290506000611b6c88612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcd9190615652565b60ff169050611bdd8160126155d2565b611be890600a615759565b8360a00151611bf791906155fe565b60a08401819052608084015161013654611c2592906001600160801b0380821691600160801b900416613775565b606084018190526040840151611c3b919061563f565b836040018181525050611c638886888660c001518760e001518860600151896040015161382d565b6020850152835250909695505050505050565b6000611c806130e2565b611c8a8383613128565b90505b92915050565b611cb46040518060600160405280602a8152602001615b99602a913961271b565b6001600160a01b038416611cdb576040516383aebebd60e01b815260040160405180910390fd5b61013f546001600160a01b03858116911614801590611d79575061014354604051637aee632d60e01b81526001600160a01b0386811660048301819052921690637aee632d90602401600060405180830381865afa158015611d41573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d699190810190615804565b604001516001600160a01b031614155b15611d97576040516383aebebd60e01b815260040160405180910390fd5b6001600160a01b038316600090815261013360205260409020600481015460ff1615611dd657604051630313b28560e01b815260040160405180910390fd5b604051638e8f294b60e01b81526001600160a01b03858116600483015260009190871690638e8f294b90602401602060405180830381865afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4491906158fa565b905080611e6457604051633d21810360e21b815260040160405180910390fd5b60006002830181905584835560018084018590556003840182905560048401805460ff19169091179055611e9786612ebb565b6001600160a01b03808216600090815261013e60205260409020549192501615611ed45760405163dc0d0aab60e01b815260040160405180910390fd5b6001600160a01b03808216600090815261013e6020526040812080549289166001600160a01b03199384168117909155610135805460018101825592527fdf37d27e88e3bd0b85262482997e409a463f5be0ebb19232abf994dd8474090d9091018054909216179055611f45612e87565b61013554611f5290613919565b856001600160a01b0316876001600160a01b03167f1322eaea77217179bf4ef6084dc2f48c897e0d5a6b8365213804360e4d8ba9a28787604051611fa0929190918252602082015260400190565b60405180910390a350505050505050565b611fdf6040518060400160405280600d81526020016c746f67676c655061757365282960981b81525061271b565b60c95460ff1615611ff2576113e361394a565b6113e36133b8565b61200482826127b5565b61200e8282612891565b5050565b600061201d83611680565b611c8a8383613983565b6120656040518060400160405280601c81526020017f757064617465416c7068612875696e743132382c75696e74313238290000000081525061271b565b61206f828261330b565b610136546040516001600160801b03838116825284811692600160801b81048216929116907f9122c3fdea272423a0586803b53902139919baf05be731f04724ef8f363d378d9060200160405180910390a46001600160801b03818116600160801b0290831617610136556101355460005b818110156121225761211a610135828154811061210057612100615541565b6000918252602090912001546001600160a01b0316611680565b6001016120e1565b50610d7b612e87565b60006121597f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b6001600160a01b038116600090815261013260205260408120548082036121a757507f000000000000000000000000000000000000000000000000000000000000000092915050565b428190037f00000000000000000000000000000000000000000000000000000000000000008110156121fc577f0000000000000000000000000000000000000000000000000000000000000000039392505050565b5060009392505050565b61220e612603565b606580546001600160a01b0383166001600160a01b0319909116811790915561223f6033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6101358054606091908067ffffffffffffffff81111561229957612299615765565b6040519080825280602002602001820160405280156122e457816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816122b75790505b50925060005b818110156123b157600083828154811061230657612306615541565b60009182526020822001546001600160a01b031691506123268288612012565b6001600160a01b03808416600081815261013460209081526040808320948d168352938152908390205483516060810190945291835292935091810161236b85612ebb565b6001600160a01b03168152602001612383838561563f565b81525087858151811061239857612398615541565b60200260200101819052508360010193505050506122ea565b505050919050565b6123c1615044565b6040516395dd919360e01b81526001600160a01b03838116600483015284916000918316906395dd919390602401602060405180830381865afa15801561240c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243091906155e5565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015612472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249691906155e5565b6040516370a0823160e01b81526001600160a01b0387811660048301529192506000918516906370a0823190602401602060405180830381865afa1580156124e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250691906155e5565b90506000670de0b6b3a764000061251d83856155fe565b612527919061562b565b6001600160a01b03808a16600081815261013460209081526040808320948d1683529381528382206001015460608c01529181526101339091528190206003015490880152905061257f61257a8861296e565b613412565b6080870181905260009061259590868489613467565b805160a0890152602081015160c0890181905260408083015160e08b018190526060808501516101008d015260808501516101208d01528b0151918b01519394506125e7938d9387938b93919261382d565b602089015287525094979650505050505050565b4390565b4290565b6033546001600160a01b031633146113e35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610dbe565b6001600160a01b0381166126c15760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610dbe565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa09101610e2c565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab9061274e9033908690600401615943565b602060405180830381865afa15801561276b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278f91906158fa565b90508061200e57333083604051634a3fa29360e01b8152600401610dbe93929190615967565b6001600160a01b0381166000908152610133602052604090206004015460ff1615806127fb57506001600160a01b038216600090815261012d602052604090205460ff16155b15612804575050565b61280d81611680565b6128178183613983565b6001600160a01b038083166000908152610134602090815260408083209387168352929052908120805490919061284f90849061563f565b90915550506001600160a01b03908116600090815261013360209081526040808320600290810154610134845282852096909516845294909152902090910155565b6001600160a01b038116600090815261013360205260409020600481015460ff1615806128d857506001600160a01b038316600090815261012d602052604090205460ff16155b156128e257505050565b60006128ee8385613a1a565b6001600160a01b03808516600090815261013460209081526040808320938916835292905220600101546003840154919250829161292c91906155d2565b612936919061563f565b6003909201919091556001600160a01b0391821660009081526101346020908152604080832095909416825293909352912060010155565b6101375461013854610139546040516398e1b31b60e01b81526001600160a01b03928316600482015260248101919091528382166044820152600092839283929116906398e1b31b90606401606060405180830381865afa1580156129d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fb9190615993565b92505091508082612a0c91906155d2565b949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000008210612a4557506001919050565b506000919050565b610135805460005b81811015611198576000838281548110612a7157612a71615541565b6000918252602090912001546001600160a01b03169050612a9285826127b5565b612a9c8582612891565b50600101612a55565b6001600160a01b038116600090815261012d602090815260409182902082518084019093525460ff808216151580855261010090920416151591830191909152612b0257604051633aeb927b60e11b815260040160405180910390fd5b610135805460005b81811015612bdb576000838281548110612b2657612b26615541565b6000918252602090912001546001600160a01b03169050612b4786826127b5565b6001600160a01b03808216600081815261013460209081526040808320948b1683529381528382206001015492825261013390529190912060030154612b8d91906155d2565b6001600160a01b039182166000908152610133602090815260408083206003019390935561013481528282209389168252929092528120600180820183905560029091019190915501612b0a565b50826020015115612bff5761012e60008154612bf69061556d565b90915550612c14565b61012f60008154612c0f9061556d565b909155505b6001600160a01b038416600090815261012d60205260409020805461ffff19169055612c3f84613daa565b6040516001600160a01b038516907fe22de1457cb61fb61b60176bc4235a9abd19466126b46692bc14fc573f09924990600090a250505050565b6001600160a01b038116600090815261012d60205260409020805460ff1615612cb45760405162c4e3d160e01b815260040160405180910390fd5b8054831580156101000261ffff19909216919091176001178255612ceb5761012e60008154612ce2906159c1565b90915550612d00565b61012f60008154612cfb906159c1565b909155505b6101315461012e541180612d1957506101305461012f54115b15612d375760405163e55fb50960e01b815260040160405180910390fd5b612d4082613e1e565b816001600160a01b03167fdd032f28700d4e4b1719b8fa26918a7d68608b4e36def571ce5fe7a3ecd69f4584604051612d7d911515815260200190565b60405180910390a2505050565b610135805460005b81811015611198576000838281548110612dae57612dae615541565b6000918252602090912001546001600160a01b03169050612dce81611680565b6001600160a01b038082166000908152610133602090815260408083206002908101546101348452828520958b1685529490925282200191909155612e138287613a1a565b6001600160a01b03808416600081815261013460209081526040808320948c1683529381528382206001018590559181526101339091522060030154909150612e5d90829061563f565b6001600160a01b039092166000908152610133602052604090206003019190915550600101612d92565b61013b8054906000612e98836159c1565b919050555061012f5461012e54612eaf919061563f565b61013c81905561013d55565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603612f1d57507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164191906159da565b606580546001600160a01b0319169055610af681613e5c565b6001600160a01b038116600090815261012d60205260408120805461ff00191661010017815561012e805491929091612fd0906159c1565b9091555061012f8054600090612fe59061556d565b909155506101315461012e5411156130105760405163e55fb50960e01b815260040160405180910390fd5b6040516001600160a01b038316907f5272e69bcef8da96614ac4a5d1e95ca02c35ea627bf7ecf389ec88d8d78b86bb90600090a25050565b60fb5481116130a45760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b6064820152608401610dbe565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa9101610e2c565b60c95460ff16156113e35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610dbe565b6000806131358484612012565b6001600160a01b0380861660009081526101346020908152604080832093881683529290522054909150613169908261563f565b6001600160a01b038581166000908152610133602090815260408083206002908101546101348452828520958a16855294909252822090810192909255908190559091506131b685612ebb565b6040516370a0823160e01b815230600482015290915081906001600160a01b038216906370a0823190602401602060405180830381865afa1580156131ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322391906155e5565b8311156132a0576001600160a01b03828116600090815261014060205260408082209190915561014154905163192e7a7b60e01b8152838316600482015291169063192e7a7b90602401600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b505050505b6132b46001600160a01b0382168685613eae565b856001600160a01b0316856001600160a01b03167fc7edf5cfe443c04a10a60ff6084c847114348c55b257a01d62700326219adbba856040516132f991815260200190565b60405180910390a35090949350505050565b806001600160801b0316826001600160801b031610158061333357506001600160801b038216155b1561200e57604051630381eb6d60e61b815260040160405180910390fd5b600054610100900460ff166133785760405162461bcd60e51b8152600401610dbe906159f7565b613380613f00565b610af681613f2f565b600054610100900460ff166133b05760405162461bcd60e51b8152600401610dbe906159f7565b6113e3613f56565b6133c06130e2565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586133f53390565b6040516001600160a01b03909116815260200160405180910390a1565b60007f000000000000000000000000000000000000000000000000000000000000000082111561346357507f0000000000000000000000000000000000000000000000000000000000000000919050565b5090565b6134996040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6101375460408051631ac5701b60e11b815290516000926001600160a01b03169163358ae0369160048083019260209291908290030181865afa1580156134e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061350891906159da565b610142546040516341976e0960e01b81526001600160a01b038084166004830152929350600092909116906341976e0990602401602060405180830381865afa158015613559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061357d91906155e5565b6001600160a01b03851660009081526101336020526040902060010154909150670de0b6b3a76400009081906135b3908a6155fe565b6135bd919061562b565b6135c790836155fe565b6135d1919061562b565b60808401526001600160a01b03841660009081526101336020526040902054670de0b6b3a7640000908190613606908a6155fe565b613610919061562b565b61361a90836155fe565b613624919061562b565b60608401526101425460405163fc57d4df60e01b81526001600160a01b038681166004830152600092169063fc57d4df90602401602060405180830381865afa158015613675573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369991906155e5565b90506000670de0b6b3a76400006136b088846155fe565b6136ba919061562b565b90506000670de0b6b3a76400006136d18a856155fe565b6136db919061562b565b90508560600151821061371557816000036136f7576000613712565b8186606001518961370891906155fe565b613712919061562b565b97505b8560800151811061374d578060000361372f57600061374a565b8086608001518a61374091906155fe565b61374a919061562b565b98505b613757898961563f565b86525050505060208201939093526040810193909352509092915050565b6000841580613782575083155b1561378f57506000612a0c565b83850361379d575083612a0c565b8385106000816137b6576137b18688613f89565b6137c0565b6137c08787613f89565b905060006137fb6137d086613ff1565b6137d988613ff1565b6137e28561405b565b6137ec9190615a42565b6137f69190615a72565b614066565b905082156138175761380d8782614071565b9350505050612a0c565b61382187826140a3565b98975050505050505050565b600080826000036138435750600090508061390d565b60008361384f8b611316565b61385990876155fe565b613863919061562b565b90506000613871878961563f565b9050806000036138895760008093509350505061390d565b6127106000808361389a8c876155fe565b6138a4919061562b565b9150836138b18b876155fe565b6138bb919061562b565b90508c156138dd578c6138ce84846155fe565b6138d8919061562b565b6138e0565b60005b96508b15613902578b6138f384836155fe565b6138fd919061562b565b613905565b60005b955050505050505b97509795505050505050565b60fb54811115610af65760fb5460405163792bfb1b60e11b8152600481019190915260248101829052604401610dbe565b6139526140d5565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336133f5565b6001600160a01b0380831660008181526101346020908152604080832094861683529381528382208451606081018652815481526001820154818401526002918201548187018190529484526101339092529382209093015490929183916139eb91906155d2565b6020830151909150670de0b6b3a7640000613a0682846155fe565b613a10919061562b565b9695505050505050565b600080613a2961257a8461296e565b6040516395dd919360e01b81526001600160a01b0385811660048301529192508591600091908316906395dd919390602401602060405180830381865afa158015613a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9c91906155e5565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0291906155e5565b6040516370a0823160e01b81526001600160a01b0388811660048301529192506000918516906370a0823190602401602060405180830381865afa158015613b4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7291906155e5565b90506000670de0b6b3a7640000613b8983856155fe565b613b93919061562b565b9050600061013760009054906101000a90046001600160a01b03166001600160a01b031663358ae0366040518163ffffffff1660e01b8152600401602060405180830381865afa158015613beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0f91906159da565b6101425460405163b62cad6960e01b81526001600160a01b03808416600483015292935091169063b62cad6990602401600060405180830381600087803b158015613c5957600080fd5b505af1158015613c6d573d6000803e3d6000fd5b5050610142546040516396e85ced60e01b81526001600160a01b038e8116600483015290911692506396e85ced9150602401600060405180830381600087803b158015613cb957600080fd5b505af1158015613ccd573d6000803e3d6000fd5b505050506000613cdf8887858e613467565b90506000613cec8c612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4d9190615652565b60ff169050613d5d8160126155d2565b613d6890600a615759565b8251613d7491906155fe565b80835261013654613d9a918b916001600160801b0380821691600160801b900416613775565b9c9b505050505050505050505050565b61013c5415613dc85761013c60008154613dc39061556d565b909155505b61013d5415801590613e02575061013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff16155b15610af65761013d60008154613e179061556d565b9091555050565b61013c5415610af65761013b54600090815261013a602090815260408083206001600160a01b03851684529091529020805460ff1916600117905550565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d7b90849061411e565b600054610100900460ff16613f275760405162461bcd60e51b8152600401610dbe906159f7565b6113e36141f3565b600054610100900460ff16610aed5760405162461bcd60e51b8152600401610dbe906159f7565b600054610100900460ff16613f7d5760405162461bcd60e51b8152600401610dbe906159f7565b60c9805460ff19169055565b6000613f9483613ff1565b613f9d83613ff1565b1215613fc6576040516360c1ae3960e01b81526004810184905260248101839052604401610dbe565b613fcf82613ff1565b6001607f1b613fdd85613ff1565b613fe79190615a42565b611c8a9190615a72565b60006001600160ff1b038211156134635760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610dbe565b600061164182614223565b600061164182614810565b60008082121561409457604051639603648160e01b815260040160405180910390fd5b6001607f1b82613fdd85613ff1565b6000808212156140c657604051639603648160e01b815260040160405180910390fd5b816001607f1b613fdd85613ff1565b60c95460ff166113e35760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610dbe565b6000614173826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614f219092919063ffffffff16565b905080516000148061419457508080602001905181019061419491906158fa565b610d7b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dbe565b600054610100900460ff1661421a5760405162461bcd60e51b8152600401610dbe906159f7565b6113e333612f7f565b60006001607f1b82131561424d57604051633ce23a3d60e11b815260048101839052602401610dbe565b60008213614271576040516330ecaa3d60e21b815260048101839052602401610dbe565b6001607f1b820361428457506000919050565b640733048c5a821361429e576116416101ff607c1b615aa0565b60008060006a01c8464f7616476000000085136142ec576142c3600160841b85615abc565b93506a01c8464f761647600000006142df6001607f1b87615a42565b6142e99190615a72565b94505b6cf1aaddd7742e9000000000000085136143395761430e600160831b85615abc565b93506cf1aaddd7742e9000000000000061432c6001607f1b87615a42565b6143369190615a72565b94505b6615fc21041027af603f1b851361438057614358600160821b85615abc565b93506615fc21041027af603f1b6143736001607f1b87615a42565b61437d9190615a72565b94505b660960aadc109e7b60461b85136143c75761439f600160811b85615abc565b9350660960aadc109e7b60461b6143ba6001607f1b87615a42565b6143c49190615a72565b94505b660454aaa8efe073604a1b851361440e576143e6600160801b85615abc565b9350660454aaa8efe073604a1b6144016001607f1b87615a42565b61440b9190615a72565b94505b6602f16ac6c59de7604c1b85136144555761442d6001607f1b85615abc565b93506602f16ac6c59de7604c1b6144486001607f1b87615a42565b6144529190615a72565b94505b6609b4597e37cb05604b1b851361449c576144746001607e1b85615abc565b93506609b4597e37cb05604b1b61448f6001607f1b87615a42565b6144999190615a72565b94505b6618ebef9eac820b604a1b85136144e3576144bb6001607d1b85615abc565b93506618ebef9eac820b604a1b6144d66001607f1b87615a42565b6144e09190615a72565b94505b6f70f5a893b608861e1f58934f97aea57d8513614536576145086001607c1b85615abc565b93506f70f5a893b608861e1f58934f97aea57d6145296001607f1b87615a42565b6145339190615a72565b94505b6145446001607f1b86615abc565b92508291506001607f1b6145588380615a42565b6145629190615a72565b9050600160801b6145738482615abc565b61457d9084615a42565b6145879190615a72565b6145919085615ae3565b93506001607f1b6145a28284615a42565b6145ac9190615a72565b9150600160811b6145cd846faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa615abc565b6145d79084615a42565b6145e19190615a72565b6145eb9085615ae3565b93506001607f1b6145fc8284615a42565b6146069190615a72565b9150600360801b614627846f99999999999999999999999999999999615abc565b6146319084615a42565b61463b9190615a72565b6146459085615ae3565b93506001607f1b6146568284615a42565b6146609190615a72565b9150600160821b614681846f92492492492492492492492492492492615abc565b61468b9084615a42565b6146959190615a72565b61469f9085615ae3565b93506001607f1b6146b08284615a42565b6146ba9190615a72565b9150600560801b6146db846f8e38e38e38e38e38e38e38e38e38e38e615abc565b6146e59084615a42565b6146ef9190615a72565b6146f99085615ae3565b93506001607f1b61470a8284615a42565b6147149190615a72565b9150600360811b614735846f8ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b615abc565b61473f9084615a42565b6147499190615a72565b6147539085615ae3565b93506001607f1b6147648284615a42565b61476e9190615a72565b9150600760801b61478f846f89d89d89d89d89d89d89d89d89d89d89615abc565b6147999084615a42565b6147a39190615a72565b6147ad9085615ae3565b93506001607f1b6147be8284615a42565b6147c89190615a72565b9150600160831b6147e9846f88888888888888888888888888888888615abc565b6147f39084615a42565b6147fd9190615a72565b6148079085615ae3565b95945050505050565b60006148206101ff607c1b615aa0565b82121561482f57506000919050565b8160000361484257506001607f1b919050565b600082131561486757604051631086170d60e01b815260048101839052602401610dbe565b6000806148786001607c1b85615b0b565b91508190506001607f1b61488c8280615a42565b6148969190615a72565b90506148aa816710e1b3be415a0000615a42565b6148b49084615ae3565b92506001607f1b6148c58383615a42565b6148cf9190615a72565b90506148e3816705a0913f6b1e0000615a42565b6148ed9084615ae3565b92506001607f1b6148fe8383615a42565b6149089190615a72565b905061491c81670168244fdac78000615a42565b6149269084615ae3565b92506001607f1b6149378383615a42565b6149419190615a72565b905061495481664807432bc18000615a42565b61495e9084615ae3565b92506001607f1b61496f8383615a42565b6149799190615a72565b905061498c81660c0135dca04000615a42565b6149969084615ae3565b92506001607f1b6149a78383615a42565b6149b19190615a72565b90506149c4816601b707b1cdc000615a42565b6149ce9084615ae3565b92506001607f1b6149df8383615a42565b6149e99190615a72565b90506149fb816536e0f639b800615a42565b614a059084615ae3565b92506001607f1b614a168383615a42565b614a209190615a72565b9050614a3281650618fee9f800615a42565b614a3c9084615ae3565b92506001607f1b614a4d8383615a42565b614a579190615a72565b9050614a6881649c197dcc00615a42565b614a729084615ae3565b92506001607f1b614a838383615a42565b614a8d9190615a72565b9050614a9e81640e30dce400615a42565b614aa89084615ae3565b92506001607f1b614ab98383615a42565b614ac39190615a72565b9050614ad48164012ebd1300615a42565b614ade9084615ae3565b92506001607f1b614aef8383615a42565b614af99190615a72565b9050614b09816317499f00615a42565b614b139084615ae3565b92506001607f1b614b248383615a42565b614b2e9190615a72565b9050614b3e816301a9d480615a42565b614b489084615ae3565b92506001607f1b614b598383615a42565b614b639190615a72565b9050614b7281621c6380615a42565b614b7c9084615ae3565b92506001607f1b614b8d8383615a42565b614b979190615a72565b9050614ba6816201c638615a42565b614bb09084615ae3565b92506001607f1b614bc18383615a42565b614bcb9190615a72565b9050614bd981611ab8615a42565b614be39084615ae3565b92506001607f1b614bf48383615a42565b614bfe9190615a72565b9050614c0c8161017c615a42565b614c169084615ae3565b92506001607f1b614c278383615a42565b614c319190615a72565b9050614c3e816014615a42565b614c489084615ae3565b92506001607f1b614c598383615a42565b614c639190615a72565b9050614c70816001615a42565b614c7a9084615ae3565b92506001607f1b82614c946721c3677c82b4000086615a72565b614c9e9190615ae3565b614ca89190615ae3565b9250614cb384615aa0565b9350600160841b841615614cf9577243cbaf42a000812488fc5c220ad7b97bf6e99e614cec6cf1aaddd7742e56d32fb9f9974485615a42565b614cf69190615a72565b92505b600160831b841615614d3e577105d27a9f51c31b7c2f8038212a0574779991614d316e0afe10820813d65dfe6a33c07f738f85615a42565b614d3b9190615a72565b92505b600160821b841615614d8357701b4c902e273a58678d6d3bfdb93db96d02614d766f02582ab704279e8efd15e0265855c47a85615a42565b614d809190615a72565b92505b600160811b841615614dc8577003b1cc971a9bb5b9867477440d6d157750614dbb6f1152aaa3bf81cb9fdb76eae12d02957185615a42565b614dc59190615a72565b92505b600160801b841615614e0d5770015bf0a8b1457695355fb8ac404e7a79e3614e006f2f16ac6c59de6f8d5d6f63c1482a7c8685615a42565b614e0a9190615a72565b92505b6001607f1b841615614e51576fd3094c70f034de4b96ff7d5b6f99fcd8614e446f4da2cbf1be5827f9eb3ad1aa9866ebb385615a42565b614e4e9190615a72565b92505b6001607e1b841615614e95576fa45af1e1f40c333b3de1db4dd55f29a7614e886f63afbe7ab2082ba1a0ae5e4eb1b479dc85615a42565b614e929190615a72565b92505b6001607d1b841615614ed9576f910b022db7ae67ce76b441c27035c6a1614ecc6f70f5a893b608861e1f58934f97aea57d85615a42565b614ed69190615a72565b92505b6001607c1b841615614f1a576f88415abbe9a76bead8d00cf112e4d4a8614f106f783eafef1c0a8f3978c7f81824d62ebf85615a42565b612a0c9190615a72565b5050919050565b6060612a0c848460008585600080866001600160a01b03168587604051614f489190615b1f565b60006040518083038185875af1925050503d8060008114614f85576040519150601f19603f3d011682016040523d82523d6000602084013e614f8a565b606091505b5091509150614f9b87838387614fa6565b979650505050505050565b6060831561501557825160000361500e576001600160a01b0385163b61500e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dbe565b5081612a0c565b612a0c838381511561502a5781518083602001fd5b8060405162461bcd60e51b8152600401610dbe9190615b3b565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0381168114610af657600080fd5b6000602082840312156150be57600080fd5b81356113ca81615097565b600080604083850312156150dc57600080fd5b50508035926020909101359150565b60008083601f8401126150fd57600080fd5b50813567ffffffffffffffff81111561511557600080fd5b6020830191508360208260051b850101111561513057600080fd5b9250929050565b6000806020838503121561514a57600080fd5b823567ffffffffffffffff81111561516157600080fd5b61516d858286016150eb565b90969095509350505050565b60008060006060848603121561518e57600080fd5b833561519981615097565b95602085013595506040909401359392505050565b600080600080604085870312156151c457600080fd5b843567ffffffffffffffff808211156151dc57600080fd5b6151e8888389016150eb565b9096509450602087013591508082111561520157600080fd5b5061520e878288016150eb565b95989497509550505050565b8015158114610af657600080fd5b60008060006040848603121561523d57600080fd5b83356152488161521a565b9250602084013567ffffffffffffffff81111561526457600080fd5b615270868287016150eb565b9497909650939450505050565b60006020828403121561528f57600080fd5b5035919050565b600080604083850312156152a957600080fd5b8235915060208301356152bb81615097565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156153075783516001600160a01b0316835292840192918401916001016152e2565b50909695505050505050565b80356001600160801b038116811461164457600080fd5b6000806000806000806000806000806101408b8d03121561534a57600080fd5b8a3561535581615097565b995060208b013561536581615097565b985060408b0135975061537a60608c01615313565b965061538860808c01615313565b955060a08b013561539881615097565b945060c08b01356153a881615097565b935060e08b01356153b881615097565b92506101008b01356153c981615097565b809250506101208b013590509295989b9194979a5092959850565b600080600080600060a086880312156153fc57600080fd5b853561540781615097565b9450602086013561541781615097565b94979496505050506040830135926060810135926080909101359150565b6000806040838503121561544857600080fd5b823561545381615097565b915060208301356152bb81615097565b6000806000806080858703121561547957600080fd5b843561548481615097565b9350602085013561549481615097565b93969395505050506040820135916060013590565b600080604083850312156154bc57600080fd5b6154c583615313565b91506154d360208401615313565b90509250929050565b602080825282518282018190526000919060409081850190868401855b8281101561553457815180516001600160a01b03908116865287820151168786015285015185850152606090930192908501906001016154f9565b5091979650505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008161557c5761557c615557565b506000190190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b81810381811115611c8d57611c8d615557565b6000602082840312156155f757600080fd5b5051919050565b8082028115828204841417611c8d57611c8d615557565b634e487b7160e01b600052601260045260246000fd5b60008261563a5761563a615615565b500490565b80820180821115611c8d57611c8d615557565b60006020828403121561566457600080fd5b815160ff811681146113ca57600080fd5b600181815b808511156156b057816000190482111561569657615696615557565b808516156156a357918102915b93841c939080029061567a565b509250929050565b6000826156c757506001611c8d565b816156d457506000611c8d565b81600181146156ea57600281146156f457615710565b6001915050611c8d565b60ff84111561570557615705615557565b50506001821b611c8d565b5060208310610133831016604e8410600b8410161715615733575081810a611c8d565b61573d8383615675565b806000190482111561575157615751615557565b029392505050565b6000611c8a83836156b8565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561579e5761579e615765565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156157cd576157cd615765565b604052919050565b60005b838110156157f05781810151838201526020016157d8565b50506000910152565b805161164481615097565b6000602080838503121561581757600080fd5b825167ffffffffffffffff8082111561582f57600080fd5b9084019060a0828703121561584357600080fd5b61584b61577b565b82518281111561585a57600080fd5b8301601f8101881361586b57600080fd5b80518381111561587d5761587d615765565b61588f601f8201601f191687016157a4565b935080845288868284010111156158a557600080fd5b6158b4818786018885016157d5565b50508181526158c48484016157f9565b848201526158d4604084016157f9565b604082015260608301516060820152608083015160808201528094505050505092915050565b60006020828403121561590c57600080fd5b81516113ca8161521a565b6000815180845261592f8160208601602086016157d5565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090612a0c90830184615917565b6001600160a01b0384811682528316602082015260606040820181905260009061480790830184615917565b6000806000606084860312156159a857600080fd5b8351925060208401519150604084015190509250925092565b6000600182016159d3576159d3615557565b5060010190565b6000602082840312156159ec57600080fd5b81516113ca81615097565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b80820260008212600160ff1b84141615615a5e57615a5e615557565b8181058314821517611c8d57611c8d615557565b600082615a8157615a81615615565b600160ff1b821460001984141615615a9b57615a9b615557565b500590565b6000600160ff1b8201615ab557615ab5615557565b5060000390565b8181036000831280158383131683831282161715615adc57615adc615557565b5092915050565b8082018281126000831280158216821582161715615b0357615b03615557565b505092915050565b600082615b1a57615b1a615615565b500790565b60008251615b318184602087016157d5565b9190910192915050565b602081526000611c8a602083018461591756fe7570646174654d756c7469706c6965727328616464726573732c75696e743235362c75696e743235362909d2594e8892daceca055f74be758146a8b8b1167444d0b4ccb96e74168198cc6164644d61726b657428616464726573732c616464726573732c75696e743235362c75696e7432353629a2646970667358221220d7842351882c76ed9cd16c268489fd8f3a58a0b4e004c3ca395a20eaf26d410a64736f6c63430008190033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103e65760003560e01c80639f6506ce1161020a578063cdaa21b711610125578063e30c3978116100b8578063ef36bbde11610087578063ef36bbde14610a57578063f2fde38b14610a78578063f6ed201714610a8b578063fa6d5f1814610aab578063fe1006ad14610abe57600080fd5b8063e30c3978146109c5578063e4676f37146109d6578063e4860339146109e9578063ee6b13fc14610a2d57600080fd5b8063d88b9d2e116100f4578063d88b9d2e14610996578063da6ab4f8146109a0578063e18f8822146109aa578063e1d146fb146109bd57600080fd5b8063cdaa21b71461092e578063ce85361314610955578063cf329d1614610970578063d65bd2411461098357600080fd5b8063ba437c681161019d578063c3db3c361161016c578063c3db3c36146108e1578063c4ae3168146108eb578063c7ad0895146108f3578063c86d1a781461091a57600080fd5b8063ba437c68146108a8578063bc5dc4c3146108bb578063bd212c0e146108ce578063be26317e146108d857600080fd5b8063b1a250f2116101d9578063b1a250f2146107a2578063b4a0bdf3146107b5578063b7f2d258146107c6578063b9eb69f61461085257600080fd5b80639f6506ce14610765578063a15753dc1461076f578063afcff50f14610779578063b0772d0b1461078d57600080fd5b80635fe3b5671161030557806380d45a2d1161029857806389afcb441161026757806389afcb44146106945780638da5cb5b146106a75780638e8f294b146106b85780639198e515146107235780639565d3d21461073657600080fd5b806380d45a2d14610650578063856c3aa41461066357806388bead731461066d57806388d742c21461068157600080fd5b806379ba5097116102d457806379ba5097146105f55780637dafcd89146105fd5780637dc0d1d0146106105780637ef820701461062457600080fd5b80635fe3b5671461058d5780636426b4a71461059f5780636857249c146105c6578063715018a6146105ed57600080fd5b806337f23cd31161037d57806355d36c981161034c57806355d36c9814610549578063594a67ee1461055c5780635c975abb1461056f5780635d536d301461057a57600080fd5b806337f23cd3146104e757806338f6a434146104fa578063487b0dfb146105375780634e71d92d1461054157600080fd5b80631bffac89116103b95780631bffac891461048d578063207add91146104ae57806324e6baf2146104c157806329b6eca9146104d457600080fd5b80630104db1b146103eb5780630e32cb86146104255780631b3f8c5e1461043a5780631b9ce57514610479575b600080fd5b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6104386104333660046150ac565b610ae5565b005b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161041c565b61013754610461906001600160a01b031681565b61041261049b3660046150ac565b6101406020526000908152604090205481565b6104386104bc3660046150c9565b610af9565b6104386104cf366004615137565b610bb4565b6104386104e23660046150ac565b610d80565b6104386104f53660046150ac565b610e38565b6105276105083660046150ac565b6001600160a01b0316600090815261012d602052604090205460ff1690565b604051901515815260200161041c565b6104126101395481565b610438611044565b610438610557366004615179565b6110d3565b61043861056a3660046151ae565b61119e565b60c95460ff16610527565b6104126105883660046150ac565b611316565b61013f546001600160a01b0316610461565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104386113d1565b6104386113e5565b61043861060b366004615228565b61145c565b61014254610461906001600160a01b031681565b61013654610638906001600160801b031681565b6040516001600160801b03909116815260200161041c565b61043861065e36600461527d565b6115e6565b6104126101315481565b61013854610461906001600160a01b031681565b61041261068f3660046150ac565b61162d565b6104386106a23660046150ac565b611649565b6033546001600160a01b0316610461565b6106f96106c63660046150ac565b61013360205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161041c565b6104386107313660046150ac565b611680565b610527610744366004615296565b61013a60209081526000928352604080842090915290825290205460ff1681565b61041261012f5481565b61041261013b5481565b61014354610461906001600160a01b031681565b610795611844565b60405161041c91906152c6565b6104386107b036600461532a565b6118a7565b6097546001600160a01b0316610461565b6107d96107d43660046153e4565b611abc565b60405161041c9190600061014082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525092915050565b61088d610860366004615435565b61013460209081526000928352604080842090915290825290208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161041c565b6104126108b6366004615435565b611c76565b6104386108c9366004615463565b611c93565b61041261013c5481565b61041260fb5481565b61041261013d5481565b610438611fb1565b6105277f000000000000000000000000000000000000000000000000000000000000000081565b61014154610461906001600160a01b031681565b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6101365461063890600160801b90046001600160801b031681565b61043861097e366004615435565b611ffa565b610412610991366004615435565b612012565b61041261012e5481565b6104126101305481565b6104386109b83660046154a9565b612027565b61041261212b565b6065546001600160a01b0316610461565b6104126109e43660046150ac565b61215e565b610a166109f73660046150ac565b61012d6020526000908152604090205460ff8082169161010090041682565b60408051921515835290151560208301520161041c565b610461610a3b3660046150ac565b61013e602052600090815260409020546001600160a01b031681565b610412610a653660046150ac565b6101326020526000908152604090205481565b610438610a863660046150ac565b612206565b610a9e610a993660046150ac565b612277565b60405161041c91906154dc565b6107d9610ab9366004615435565b6123b9565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b610aed612603565b610af68161265d565b50565b610b376040518060400160405280601981526020017f7365744c696d69742875696e743235362c75696e74323536290000000000000081525061271b565b61012e54821080610b4a575061012f5481105b15610b685760405163e55fb50960e01b815260040160405180910390fd5b8161013054610131547f6c52f3e195bdc534883e903e0612c49261a466aacd492501870b0a0ac0b1835584604051610ba291815260200190565b60405180910390a46101305561013155565b61013d54600003610bd85760405163071a45dd60e31b815260040160405180910390fd5b61013b54600003610bfc5760405163071a45dd60e31b815260040160405180910390fd5b60005b81811015610d7b576000838383818110610c1b57610c1b615541565b9050602002016020810190610c3091906150ac565b6001600160a01b038116600090815261012d602052604090205490915060ff16610c6d57604051633aeb927b60e11b815260040160405180910390fd5b61013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff1615610ca65750600101610bff565b610135805460005b81811015610cfe576000838281548110610cca57610cca615541565b6000918252602090912001546001600160a01b03169050610ceb85826127b5565b610cf58582612891565b50600101610cae565b5061013d60008154610d0f9061556d565b9091555061013b54600090815261013a602090815260408083206001600160a01b0387168085529252808320805460ff19166001908117909155905196019590917fa699df4aa8f89fc1f5408fe78ae114651f18b25ed1601680e4c70c15177d8b1b91a2505050610bff565b505050565b600054600290610100900460ff16158015610da2575060005460ff8083169116105b610dc75760405162461bcd60e51b8152600401610dbe90615584565b60405180910390fd5b6000805461014380546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6000610e438261296e565b90506000610e5082612a14565b6001600160a01b0384166000908152610132602090815260408083205461012d83529281902081518083019092525460ff808216158015808552610100909304909116151593830193909352939450919290610eaa575082155b15610f0c576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615b79833981519152910160405180910390a2806020015115610f0357610efe85612a4d565b61103d565b610efe85612aa5565b82158015610f1957508051155b8015610f2457508115155b15610f6b576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615b7983398151915291015b60405180910390a261103d565b81158015610f765750825b8015610f8157508051155b15610fc3576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615b798339815191529101610f5e565b80518015610fce5750825b1561103d57610fdc85612a4d565b6001600160a01b03851660009081526101326020526040812054900361103d576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615b79833981519152910160405180910390a25b5050505050565b3360009081526101326020526040812054908190036110755760405162c4e3d160e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006110a082426155d2565b10156110bf5760405163beb98cab60e01b815260040160405180910390fd5b6110ca600033612c79565b610af633612d8a565b6110f46040518060600160405280602a8152602001615b4f602a913961271b565b6001600160a01b038316600090815261013360205260409020600481015460ff1661113257604051630ff2e4a960e31b815260040160405180910390fd5b61113b84611680565b6001810154815460408051868152602081018690526001600160a01b038816917f91e78a55b6df3a0eac1c12a64572a8c0faced385bafba688817f5ce6daa33537910160405180910390a482815560018101829055611198612e87565b50505050565b6111dc6040518060400160405280602081526020017f7365745374616b6564417428616464726573735b5d2c75696e743235365b5d2981525061271b565b8281146111fc5760405163251f56a160e21b815260040160405180910390fd5b60005b8381101561103d574283838381811061121a5761121a615541565b9050602002013511156112405760405163b7d0949760e01b815260040160405180910390fd5b82828281811061125257611252615541565b90506020020135610132600087878581811061127057611270615541565b905060200201602081019061128591906150ac565b6001600160a01b031681526020810191909152604001600020558484828181106112b1576112b1615541565b90506020020160208101906112c691906150ac565b6001600160a01b0316600080516020615b798339815191528484848181106112f0576112f0615541565b9050602002013560405161130691815260200190565b60405180910390a26001016111ff565b6101415460009081906001600160a01b031663a666642b61133685612ebb565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561137a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139e91906155e5565b90506113ca817f00000000000000000000000000000000000000000000000000000000000000006155fe565b9392505050565b6113d9612603565b6113e36000612f7f565b565b60655433906001600160a01b031681146114535760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610dbe565b610af681612f7f565b61149260405180604001604052806015815260200174697373756528626f6f6c2c616464726573735b5d2960581b81525061271b565b82156115a75760005b8181101561119857600061012d60008585858181106114bc576114bc615541565b90506020020160208101906114d191906150ac565b6001600160a01b031681526020810191909152604001600020805490915060ff16801561150557508054610100900460ff16155b1561153e5761153984848481811061151f5761151f615541565b905060200201602081019061153491906150ac565b612f98565b61159e565b61156f600185858581811061155557611555615541565b905060200201602081019061156a91906150ac565b612c79565b61159e84848481811061158457611584615541565b905060200201602081019061159991906150ac565b612d8a565b5060010161149b565b60005b81811015611198576115c9600084848481811061155557611555615541565b6115de83838381811061158457611584615541565b6001016115aa565b6116246040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e74323536290000000000000081525061271b565b610af681613048565b60006116376130e2565b6116418233613128565b90505b919050565b6116776040518060400160405280600d81526020016c6275726e28616464726573732960981b81525061271b565b610af681612aa5565b6001600160a01b038116600090815261013360205260409020600481015460ff166116be57604051630ff2e4a960e31b815260040160405180910390fd5b60006116c983612ebb565b61014154604051638aadf79960e01b81526001600160a01b0380841660048301529293509116908190638aadf79990602401600060405180830381600087803b15801561171557600080fd5b505af1158015611729573d6000803e3d6000fd5b505060405163fa7781ff60e01b81526001600160a01b038581166004830152600093508416915063fa7781ff90602401602060405180830381865afa158015611776573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179a91906155e5565b6001600160a01b03841660009081526101406020526040812054919250906117c290836155d2565b90508060008190036117d75750505050505050565b6001600160a01b038516600090815261014060205260408120849055600387015415611821576003870154611814670de0b6b3a7640000846155fe565b61181e919061562b565b90505b80876002016000828254611835919061563f565b90915550505050505050505050565b606061013580548060200260200160405190810160405280929190818152602001828054801561189d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161187f575b5050505050905090565b600054610100900460ff16158080156118c75750600054600160ff909116105b806118e15750303b1580156118e1575060005460ff166001145b6118fd5760405162461bcd60e51b8152600401610dbe90615584565b6000805460ff191660011790558015611920576000805461ff0019166101001790555b6001600160a01b038b166119475760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038a1661196e5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0383166119955760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0385166119bc5760405163e6c4247b60e01b815260040160405180910390fd5b6119c6888861330b565b6001600160801b03878116600160801b02908916176101365561013880546001600160a01b03808d166001600160a01b0319928316179092556101398b905561013780548e8416908316179055600061013b55610141805488841690831617905561013f8054878416908316179055610142805492861692909116919091179055611a5086613351565b611a58613389565b611a6182613048565b611a696133b8565b8015611aaf576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b611ac4615044565b6001600160a01b03808716600081815261013460209081526040808320948a1683529381528382206001015492825261013390529190912060030154611b0a91906155d2565b6040820152611b1882613412565b60808201819052600090611b2e9086868a613467565b805160a0840152602081015160c0840152604081015160e08401526060810151610100840152608081015161012084015290506000611b6c88612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcd9190615652565b60ff169050611bdd8160126155d2565b611be890600a615759565b8360a00151611bf791906155fe565b60a08401819052608084015161013654611c2592906001600160801b0380821691600160801b900416613775565b606084018190526040840151611c3b919061563f565b836040018181525050611c638886888660c001518760e001518860600151896040015161382d565b6020850152835250909695505050505050565b6000611c806130e2565b611c8a8383613128565b90505b92915050565b611cb46040518060600160405280602a8152602001615b99602a913961271b565b6001600160a01b038416611cdb576040516383aebebd60e01b815260040160405180910390fd5b61013f546001600160a01b03858116911614801590611d79575061014354604051637aee632d60e01b81526001600160a01b0386811660048301819052921690637aee632d90602401600060405180830381865afa158015611d41573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d699190810190615804565b604001516001600160a01b031614155b15611d97576040516383aebebd60e01b815260040160405180910390fd5b6001600160a01b038316600090815261013360205260409020600481015460ff1615611dd657604051630313b28560e01b815260040160405180910390fd5b604051638e8f294b60e01b81526001600160a01b03858116600483015260009190871690638e8f294b90602401602060405180830381865afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4491906158fa565b905080611e6457604051633d21810360e21b815260040160405180910390fd5b60006002830181905584835560018084018590556003840182905560048401805460ff19169091179055611e9786612ebb565b6001600160a01b03808216600090815261013e60205260409020549192501615611ed45760405163dc0d0aab60e01b815260040160405180910390fd5b6001600160a01b03808216600090815261013e6020526040812080549289166001600160a01b03199384168117909155610135805460018101825592527fdf37d27e88e3bd0b85262482997e409a463f5be0ebb19232abf994dd8474090d9091018054909216179055611f45612e87565b61013554611f5290613919565b856001600160a01b0316876001600160a01b03167f1322eaea77217179bf4ef6084dc2f48c897e0d5a6b8365213804360e4d8ba9a28787604051611fa0929190918252602082015260400190565b60405180910390a350505050505050565b611fdf6040518060400160405280600d81526020016c746f67676c655061757365282960981b81525061271b565b60c95460ff1615611ff2576113e361394a565b6113e36133b8565b61200482826127b5565b61200e8282612891565b5050565b600061201d83611680565b611c8a8383613983565b6120656040518060400160405280601c81526020017f757064617465416c7068612875696e743132382c75696e74313238290000000081525061271b565b61206f828261330b565b610136546040516001600160801b03838116825284811692600160801b81048216929116907f9122c3fdea272423a0586803b53902139919baf05be731f04724ef8f363d378d9060200160405180910390a46001600160801b03818116600160801b0290831617610136556101355460005b818110156121225761211a610135828154811061210057612100615541565b6000918252602090912001546001600160a01b0316611680565b6001016120e1565b50610d7b612e87565b60006121597f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b6001600160a01b038116600090815261013260205260408120548082036121a757507f000000000000000000000000000000000000000000000000000000000000000092915050565b428190037f00000000000000000000000000000000000000000000000000000000000000008110156121fc577f0000000000000000000000000000000000000000000000000000000000000000039392505050565b5060009392505050565b61220e612603565b606580546001600160a01b0383166001600160a01b0319909116811790915561223f6033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6101358054606091908067ffffffffffffffff81111561229957612299615765565b6040519080825280602002602001820160405280156122e457816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816122b75790505b50925060005b818110156123b157600083828154811061230657612306615541565b60009182526020822001546001600160a01b031691506123268288612012565b6001600160a01b03808416600081815261013460209081526040808320948d168352938152908390205483516060810190945291835292935091810161236b85612ebb565b6001600160a01b03168152602001612383838561563f565b81525087858151811061239857612398615541565b60200260200101819052508360010193505050506122ea565b505050919050565b6123c1615044565b6040516395dd919360e01b81526001600160a01b03838116600483015284916000918316906395dd919390602401602060405180830381865afa15801561240c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243091906155e5565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015612472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249691906155e5565b6040516370a0823160e01b81526001600160a01b0387811660048301529192506000918516906370a0823190602401602060405180830381865afa1580156124e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250691906155e5565b90506000670de0b6b3a764000061251d83856155fe565b612527919061562b565b6001600160a01b03808a16600081815261013460209081526040808320948d1683529381528382206001015460608c01529181526101339091528190206003015490880152905061257f61257a8861296e565b613412565b6080870181905260009061259590868489613467565b805160a0890152602081015160c0890181905260408083015160e08b018190526060808501516101008d015260808501516101208d01528b0151918b01519394506125e7938d9387938b93919261382d565b602089015287525094979650505050505050565b4390565b4290565b6033546001600160a01b031633146113e35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610dbe565b6001600160a01b0381166126c15760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610dbe565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa09101610e2c565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab9061274e9033908690600401615943565b602060405180830381865afa15801561276b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278f91906158fa565b90508061200e57333083604051634a3fa29360e01b8152600401610dbe93929190615967565b6001600160a01b0381166000908152610133602052604090206004015460ff1615806127fb57506001600160a01b038216600090815261012d602052604090205460ff16155b15612804575050565b61280d81611680565b6128178183613983565b6001600160a01b038083166000908152610134602090815260408083209387168352929052908120805490919061284f90849061563f565b90915550506001600160a01b03908116600090815261013360209081526040808320600290810154610134845282852096909516845294909152902090910155565b6001600160a01b038116600090815261013360205260409020600481015460ff1615806128d857506001600160a01b038316600090815261012d602052604090205460ff16155b156128e257505050565b60006128ee8385613a1a565b6001600160a01b03808516600090815261013460209081526040808320938916835292905220600101546003840154919250829161292c91906155d2565b612936919061563f565b6003909201919091556001600160a01b0391821660009081526101346020908152604080832095909416825293909352912060010155565b6101375461013854610139546040516398e1b31b60e01b81526001600160a01b03928316600482015260248101919091528382166044820152600092839283929116906398e1b31b90606401606060405180830381865afa1580156129d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fb9190615993565b92505091508082612a0c91906155d2565b949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000008210612a4557506001919050565b506000919050565b610135805460005b81811015611198576000838281548110612a7157612a71615541565b6000918252602090912001546001600160a01b03169050612a9285826127b5565b612a9c8582612891565b50600101612a55565b6001600160a01b038116600090815261012d602090815260409182902082518084019093525460ff808216151580855261010090920416151591830191909152612b0257604051633aeb927b60e11b815260040160405180910390fd5b610135805460005b81811015612bdb576000838281548110612b2657612b26615541565b6000918252602090912001546001600160a01b03169050612b4786826127b5565b6001600160a01b03808216600081815261013460209081526040808320948b1683529381528382206001015492825261013390529190912060030154612b8d91906155d2565b6001600160a01b039182166000908152610133602090815260408083206003019390935561013481528282209389168252929092528120600180820183905560029091019190915501612b0a565b50826020015115612bff5761012e60008154612bf69061556d565b90915550612c14565b61012f60008154612c0f9061556d565b909155505b6001600160a01b038416600090815261012d60205260409020805461ffff19169055612c3f84613daa565b6040516001600160a01b038516907fe22de1457cb61fb61b60176bc4235a9abd19466126b46692bc14fc573f09924990600090a250505050565b6001600160a01b038116600090815261012d60205260409020805460ff1615612cb45760405162c4e3d160e01b815260040160405180910390fd5b8054831580156101000261ffff19909216919091176001178255612ceb5761012e60008154612ce2906159c1565b90915550612d00565b61012f60008154612cfb906159c1565b909155505b6101315461012e541180612d1957506101305461012f54115b15612d375760405163e55fb50960e01b815260040160405180910390fd5b612d4082613e1e565b816001600160a01b03167fdd032f28700d4e4b1719b8fa26918a7d68608b4e36def571ce5fe7a3ecd69f4584604051612d7d911515815260200190565b60405180910390a2505050565b610135805460005b81811015611198576000838281548110612dae57612dae615541565b6000918252602090912001546001600160a01b03169050612dce81611680565b6001600160a01b038082166000908152610133602090815260408083206002908101546101348452828520958b1685529490925282200191909155612e138287613a1a565b6001600160a01b03808416600081815261013460209081526040808320948c1683529381528382206001018590559181526101339091522060030154909150612e5d90829061563f565b6001600160a01b039092166000908152610133602052604090206003019190915550600101612d92565b61013b8054906000612e98836159c1565b919050555061012f5461012e54612eaf919061563f565b61013c81905561013d55565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603612f1d57507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164191906159da565b606580546001600160a01b0319169055610af681613e5c565b6001600160a01b038116600090815261012d60205260408120805461ff00191661010017815561012e805491929091612fd0906159c1565b9091555061012f8054600090612fe59061556d565b909155506101315461012e5411156130105760405163e55fb50960e01b815260040160405180910390fd5b6040516001600160a01b038316907f5272e69bcef8da96614ac4a5d1e95ca02c35ea627bf7ecf389ec88d8d78b86bb90600090a25050565b60fb5481116130a45760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b6064820152608401610dbe565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa9101610e2c565b60c95460ff16156113e35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610dbe565b6000806131358484612012565b6001600160a01b0380861660009081526101346020908152604080832093881683529290522054909150613169908261563f565b6001600160a01b038581166000908152610133602090815260408083206002908101546101348452828520958a16855294909252822090810192909255908190559091506131b685612ebb565b6040516370a0823160e01b815230600482015290915081906001600160a01b038216906370a0823190602401602060405180830381865afa1580156131ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322391906155e5565b8311156132a0576001600160a01b03828116600090815261014060205260408082209190915561014154905163192e7a7b60e01b8152838316600482015291169063192e7a7b90602401600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b505050505b6132b46001600160a01b0382168685613eae565b856001600160a01b0316856001600160a01b03167fc7edf5cfe443c04a10a60ff6084c847114348c55b257a01d62700326219adbba856040516132f991815260200190565b60405180910390a35090949350505050565b806001600160801b0316826001600160801b031610158061333357506001600160801b038216155b1561200e57604051630381eb6d60e61b815260040160405180910390fd5b600054610100900460ff166133785760405162461bcd60e51b8152600401610dbe906159f7565b613380613f00565b610af681613f2f565b600054610100900460ff166133b05760405162461bcd60e51b8152600401610dbe906159f7565b6113e3613f56565b6133c06130e2565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586133f53390565b6040516001600160a01b03909116815260200160405180910390a1565b60007f000000000000000000000000000000000000000000000000000000000000000082111561346357507f0000000000000000000000000000000000000000000000000000000000000000919050565b5090565b6134996040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6101375460408051631ac5701b60e11b815290516000926001600160a01b03169163358ae0369160048083019260209291908290030181865afa1580156134e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061350891906159da565b610142546040516341976e0960e01b81526001600160a01b038084166004830152929350600092909116906341976e0990602401602060405180830381865afa158015613559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061357d91906155e5565b6001600160a01b03851660009081526101336020526040902060010154909150670de0b6b3a76400009081906135b3908a6155fe565b6135bd919061562b565b6135c790836155fe565b6135d1919061562b565b60808401526001600160a01b03841660009081526101336020526040902054670de0b6b3a7640000908190613606908a6155fe565b613610919061562b565b61361a90836155fe565b613624919061562b565b60608401526101425460405163fc57d4df60e01b81526001600160a01b038681166004830152600092169063fc57d4df90602401602060405180830381865afa158015613675573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369991906155e5565b90506000670de0b6b3a76400006136b088846155fe565b6136ba919061562b565b90506000670de0b6b3a76400006136d18a856155fe565b6136db919061562b565b90508560600151821061371557816000036136f7576000613712565b8186606001518961370891906155fe565b613712919061562b565b97505b8560800151811061374d578060000361372f57600061374a565b8086608001518a61374091906155fe565b61374a919061562b565b98505b613757898961563f565b86525050505060208201939093526040810193909352509092915050565b6000841580613782575083155b1561378f57506000612a0c565b83850361379d575083612a0c565b8385106000816137b6576137b18688613f89565b6137c0565b6137c08787613f89565b905060006137fb6137d086613ff1565b6137d988613ff1565b6137e28561405b565b6137ec9190615a42565b6137f69190615a72565b614066565b905082156138175761380d8782614071565b9350505050612a0c565b61382187826140a3565b98975050505050505050565b600080826000036138435750600090508061390d565b60008361384f8b611316565b61385990876155fe565b613863919061562b565b90506000613871878961563f565b9050806000036138895760008093509350505061390d565b6127106000808361389a8c876155fe565b6138a4919061562b565b9150836138b18b876155fe565b6138bb919061562b565b90508c156138dd578c6138ce84846155fe565b6138d8919061562b565b6138e0565b60005b96508b15613902578b6138f384836155fe565b6138fd919061562b565b613905565b60005b955050505050505b97509795505050505050565b60fb54811115610af65760fb5460405163792bfb1b60e11b8152600481019190915260248101829052604401610dbe565b6139526140d5565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336133f5565b6001600160a01b0380831660008181526101346020908152604080832094861683529381528382208451606081018652815481526001820154818401526002918201548187018190529484526101339092529382209093015490929183916139eb91906155d2565b6020830151909150670de0b6b3a7640000613a0682846155fe565b613a10919061562b565b9695505050505050565b600080613a2961257a8461296e565b6040516395dd919360e01b81526001600160a01b0385811660048301529192508591600091908316906395dd919390602401602060405180830381865afa158015613a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9c91906155e5565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0291906155e5565b6040516370a0823160e01b81526001600160a01b0388811660048301529192506000918516906370a0823190602401602060405180830381865afa158015613b4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7291906155e5565b90506000670de0b6b3a7640000613b8983856155fe565b613b93919061562b565b9050600061013760009054906101000a90046001600160a01b03166001600160a01b031663358ae0366040518163ffffffff1660e01b8152600401602060405180830381865afa158015613beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0f91906159da565b6101425460405163b62cad6960e01b81526001600160a01b03808416600483015292935091169063b62cad6990602401600060405180830381600087803b158015613c5957600080fd5b505af1158015613c6d573d6000803e3d6000fd5b5050610142546040516396e85ced60e01b81526001600160a01b038e8116600483015290911692506396e85ced9150602401600060405180830381600087803b158015613cb957600080fd5b505af1158015613ccd573d6000803e3d6000fd5b505050506000613cdf8887858e613467565b90506000613cec8c612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4d9190615652565b60ff169050613d5d8160126155d2565b613d6890600a615759565b8251613d7491906155fe565b80835261013654613d9a918b916001600160801b0380821691600160801b900416613775565b9c9b505050505050505050505050565b61013c5415613dc85761013c60008154613dc39061556d565b909155505b61013d5415801590613e02575061013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff16155b15610af65761013d60008154613e179061556d565b9091555050565b61013c5415610af65761013b54600090815261013a602090815260408083206001600160a01b03851684529091529020805460ff1916600117905550565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d7b90849061411e565b600054610100900460ff16613f275760405162461bcd60e51b8152600401610dbe906159f7565b6113e36141f3565b600054610100900460ff16610aed5760405162461bcd60e51b8152600401610dbe906159f7565b600054610100900460ff16613f7d5760405162461bcd60e51b8152600401610dbe906159f7565b60c9805460ff19169055565b6000613f9483613ff1565b613f9d83613ff1565b1215613fc6576040516360c1ae3960e01b81526004810184905260248101839052604401610dbe565b613fcf82613ff1565b6001607f1b613fdd85613ff1565b613fe79190615a42565b611c8a9190615a72565b60006001600160ff1b038211156134635760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610dbe565b600061164182614223565b600061164182614810565b60008082121561409457604051639603648160e01b815260040160405180910390fd5b6001607f1b82613fdd85613ff1565b6000808212156140c657604051639603648160e01b815260040160405180910390fd5b816001607f1b613fdd85613ff1565b60c95460ff166113e35760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610dbe565b6000614173826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614f219092919063ffffffff16565b905080516000148061419457508080602001905181019061419491906158fa565b610d7b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dbe565b600054610100900460ff1661421a5760405162461bcd60e51b8152600401610dbe906159f7565b6113e333612f7f565b60006001607f1b82131561424d57604051633ce23a3d60e11b815260048101839052602401610dbe565b60008213614271576040516330ecaa3d60e21b815260048101839052602401610dbe565b6001607f1b820361428457506000919050565b640733048c5a821361429e576116416101ff607c1b615aa0565b60008060006a01c8464f7616476000000085136142ec576142c3600160841b85615abc565b93506a01c8464f761647600000006142df6001607f1b87615a42565b6142e99190615a72565b94505b6cf1aaddd7742e9000000000000085136143395761430e600160831b85615abc565b93506cf1aaddd7742e9000000000000061432c6001607f1b87615a42565b6143369190615a72565b94505b6615fc21041027af603f1b851361438057614358600160821b85615abc565b93506615fc21041027af603f1b6143736001607f1b87615a42565b61437d9190615a72565b94505b660960aadc109e7b60461b85136143c75761439f600160811b85615abc565b9350660960aadc109e7b60461b6143ba6001607f1b87615a42565b6143c49190615a72565b94505b660454aaa8efe073604a1b851361440e576143e6600160801b85615abc565b9350660454aaa8efe073604a1b6144016001607f1b87615a42565b61440b9190615a72565b94505b6602f16ac6c59de7604c1b85136144555761442d6001607f1b85615abc565b93506602f16ac6c59de7604c1b6144486001607f1b87615a42565b6144529190615a72565b94505b6609b4597e37cb05604b1b851361449c576144746001607e1b85615abc565b93506609b4597e37cb05604b1b61448f6001607f1b87615a42565b6144999190615a72565b94505b6618ebef9eac820b604a1b85136144e3576144bb6001607d1b85615abc565b93506618ebef9eac820b604a1b6144d66001607f1b87615a42565b6144e09190615a72565b94505b6f70f5a893b608861e1f58934f97aea57d8513614536576145086001607c1b85615abc565b93506f70f5a893b608861e1f58934f97aea57d6145296001607f1b87615a42565b6145339190615a72565b94505b6145446001607f1b86615abc565b92508291506001607f1b6145588380615a42565b6145629190615a72565b9050600160801b6145738482615abc565b61457d9084615a42565b6145879190615a72565b6145919085615ae3565b93506001607f1b6145a28284615a42565b6145ac9190615a72565b9150600160811b6145cd846faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa615abc565b6145d79084615a42565b6145e19190615a72565b6145eb9085615ae3565b93506001607f1b6145fc8284615a42565b6146069190615a72565b9150600360801b614627846f99999999999999999999999999999999615abc565b6146319084615a42565b61463b9190615a72565b6146459085615ae3565b93506001607f1b6146568284615a42565b6146609190615a72565b9150600160821b614681846f92492492492492492492492492492492615abc565b61468b9084615a42565b6146959190615a72565b61469f9085615ae3565b93506001607f1b6146b08284615a42565b6146ba9190615a72565b9150600560801b6146db846f8e38e38e38e38e38e38e38e38e38e38e615abc565b6146e59084615a42565b6146ef9190615a72565b6146f99085615ae3565b93506001607f1b61470a8284615a42565b6147149190615a72565b9150600360811b614735846f8ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b615abc565b61473f9084615a42565b6147499190615a72565b6147539085615ae3565b93506001607f1b6147648284615a42565b61476e9190615a72565b9150600760801b61478f846f89d89d89d89d89d89d89d89d89d89d89615abc565b6147999084615a42565b6147a39190615a72565b6147ad9085615ae3565b93506001607f1b6147be8284615a42565b6147c89190615a72565b9150600160831b6147e9846f88888888888888888888888888888888615abc565b6147f39084615a42565b6147fd9190615a72565b6148079085615ae3565b95945050505050565b60006148206101ff607c1b615aa0565b82121561482f57506000919050565b8160000361484257506001607f1b919050565b600082131561486757604051631086170d60e01b815260048101839052602401610dbe565b6000806148786001607c1b85615b0b565b91508190506001607f1b61488c8280615a42565b6148969190615a72565b90506148aa816710e1b3be415a0000615a42565b6148b49084615ae3565b92506001607f1b6148c58383615a42565b6148cf9190615a72565b90506148e3816705a0913f6b1e0000615a42565b6148ed9084615ae3565b92506001607f1b6148fe8383615a42565b6149089190615a72565b905061491c81670168244fdac78000615a42565b6149269084615ae3565b92506001607f1b6149378383615a42565b6149419190615a72565b905061495481664807432bc18000615a42565b61495e9084615ae3565b92506001607f1b61496f8383615a42565b6149799190615a72565b905061498c81660c0135dca04000615a42565b6149969084615ae3565b92506001607f1b6149a78383615a42565b6149b19190615a72565b90506149c4816601b707b1cdc000615a42565b6149ce9084615ae3565b92506001607f1b6149df8383615a42565b6149e99190615a72565b90506149fb816536e0f639b800615a42565b614a059084615ae3565b92506001607f1b614a168383615a42565b614a209190615a72565b9050614a3281650618fee9f800615a42565b614a3c9084615ae3565b92506001607f1b614a4d8383615a42565b614a579190615a72565b9050614a6881649c197dcc00615a42565b614a729084615ae3565b92506001607f1b614a838383615a42565b614a8d9190615a72565b9050614a9e81640e30dce400615a42565b614aa89084615ae3565b92506001607f1b614ab98383615a42565b614ac39190615a72565b9050614ad48164012ebd1300615a42565b614ade9084615ae3565b92506001607f1b614aef8383615a42565b614af99190615a72565b9050614b09816317499f00615a42565b614b139084615ae3565b92506001607f1b614b248383615a42565b614b2e9190615a72565b9050614b3e816301a9d480615a42565b614b489084615ae3565b92506001607f1b614b598383615a42565b614b639190615a72565b9050614b7281621c6380615a42565b614b7c9084615ae3565b92506001607f1b614b8d8383615a42565b614b979190615a72565b9050614ba6816201c638615a42565b614bb09084615ae3565b92506001607f1b614bc18383615a42565b614bcb9190615a72565b9050614bd981611ab8615a42565b614be39084615ae3565b92506001607f1b614bf48383615a42565b614bfe9190615a72565b9050614c0c8161017c615a42565b614c169084615ae3565b92506001607f1b614c278383615a42565b614c319190615a72565b9050614c3e816014615a42565b614c489084615ae3565b92506001607f1b614c598383615a42565b614c639190615a72565b9050614c70816001615a42565b614c7a9084615ae3565b92506001607f1b82614c946721c3677c82b4000086615a72565b614c9e9190615ae3565b614ca89190615ae3565b9250614cb384615aa0565b9350600160841b841615614cf9577243cbaf42a000812488fc5c220ad7b97bf6e99e614cec6cf1aaddd7742e56d32fb9f9974485615a42565b614cf69190615a72565b92505b600160831b841615614d3e577105d27a9f51c31b7c2f8038212a0574779991614d316e0afe10820813d65dfe6a33c07f738f85615a42565b614d3b9190615a72565b92505b600160821b841615614d8357701b4c902e273a58678d6d3bfdb93db96d02614d766f02582ab704279e8efd15e0265855c47a85615a42565b614d809190615a72565b92505b600160811b841615614dc8577003b1cc971a9bb5b9867477440d6d157750614dbb6f1152aaa3bf81cb9fdb76eae12d02957185615a42565b614dc59190615a72565b92505b600160801b841615614e0d5770015bf0a8b1457695355fb8ac404e7a79e3614e006f2f16ac6c59de6f8d5d6f63c1482a7c8685615a42565b614e0a9190615a72565b92505b6001607f1b841615614e51576fd3094c70f034de4b96ff7d5b6f99fcd8614e446f4da2cbf1be5827f9eb3ad1aa9866ebb385615a42565b614e4e9190615a72565b92505b6001607e1b841615614e95576fa45af1e1f40c333b3de1db4dd55f29a7614e886f63afbe7ab2082ba1a0ae5e4eb1b479dc85615a42565b614e929190615a72565b92505b6001607d1b841615614ed9576f910b022db7ae67ce76b441c27035c6a1614ecc6f70f5a893b608861e1f58934f97aea57d85615a42565b614ed69190615a72565b92505b6001607c1b841615614f1a576f88415abbe9a76bead8d00cf112e4d4a8614f106f783eafef1c0a8f3978c7f81824d62ebf85615a42565b612a0c9190615a72565b5050919050565b6060612a0c848460008585600080866001600160a01b03168587604051614f489190615b1f565b60006040518083038185875af1925050503d8060008114614f85576040519150601f19603f3d011682016040523d82523d6000602084013e614f8a565b606091505b5091509150614f9b87838387614fa6565b979650505050505050565b6060831561501557825160000361500e576001600160a01b0385163b61500e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dbe565b5081612a0c565b612a0c838381511561502a5781518083602001fd5b8060405162461bcd60e51b8152600401610dbe9190615b3b565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0381168114610af657600080fd5b6000602082840312156150be57600080fd5b81356113ca81615097565b600080604083850312156150dc57600080fd5b50508035926020909101359150565b60008083601f8401126150fd57600080fd5b50813567ffffffffffffffff81111561511557600080fd5b6020830191508360208260051b850101111561513057600080fd5b9250929050565b6000806020838503121561514a57600080fd5b823567ffffffffffffffff81111561516157600080fd5b61516d858286016150eb565b90969095509350505050565b60008060006060848603121561518e57600080fd5b833561519981615097565b95602085013595506040909401359392505050565b600080600080604085870312156151c457600080fd5b843567ffffffffffffffff808211156151dc57600080fd5b6151e8888389016150eb565b9096509450602087013591508082111561520157600080fd5b5061520e878288016150eb565b95989497509550505050565b8015158114610af657600080fd5b60008060006040848603121561523d57600080fd5b83356152488161521a565b9250602084013567ffffffffffffffff81111561526457600080fd5b615270868287016150eb565b9497909650939450505050565b60006020828403121561528f57600080fd5b5035919050565b600080604083850312156152a957600080fd5b8235915060208301356152bb81615097565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156153075783516001600160a01b0316835292840192918401916001016152e2565b50909695505050505050565b80356001600160801b038116811461164457600080fd5b6000806000806000806000806000806101408b8d03121561534a57600080fd5b8a3561535581615097565b995060208b013561536581615097565b985060408b0135975061537a60608c01615313565b965061538860808c01615313565b955060a08b013561539881615097565b945060c08b01356153a881615097565b935060e08b01356153b881615097565b92506101008b01356153c981615097565b809250506101208b013590509295989b9194979a5092959850565b600080600080600060a086880312156153fc57600080fd5b853561540781615097565b9450602086013561541781615097565b94979496505050506040830135926060810135926080909101359150565b6000806040838503121561544857600080fd5b823561545381615097565b915060208301356152bb81615097565b6000806000806080858703121561547957600080fd5b843561548481615097565b9350602085013561549481615097565b93969395505050506040820135916060013590565b600080604083850312156154bc57600080fd5b6154c583615313565b91506154d360208401615313565b90509250929050565b602080825282518282018190526000919060409081850190868401855b8281101561553457815180516001600160a01b03908116865287820151168786015285015185850152606090930192908501906001016154f9565b5091979650505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008161557c5761557c615557565b506000190190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b81810381811115611c8d57611c8d615557565b6000602082840312156155f757600080fd5b5051919050565b8082028115828204841417611c8d57611c8d615557565b634e487b7160e01b600052601260045260246000fd5b60008261563a5761563a615615565b500490565b80820180821115611c8d57611c8d615557565b60006020828403121561566457600080fd5b815160ff811681146113ca57600080fd5b600181815b808511156156b057816000190482111561569657615696615557565b808516156156a357918102915b93841c939080029061567a565b509250929050565b6000826156c757506001611c8d565b816156d457506000611c8d565b81600181146156ea57600281146156f457615710565b6001915050611c8d565b60ff84111561570557615705615557565b50506001821b611c8d565b5060208310610133831016604e8410600b8410161715615733575081810a611c8d565b61573d8383615675565b806000190482111561575157615751615557565b029392505050565b6000611c8a83836156b8565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561579e5761579e615765565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156157cd576157cd615765565b604052919050565b60005b838110156157f05781810151838201526020016157d8565b50506000910152565b805161164481615097565b6000602080838503121561581757600080fd5b825167ffffffffffffffff8082111561582f57600080fd5b9084019060a0828703121561584357600080fd5b61584b61577b565b82518281111561585a57600080fd5b8301601f8101881361586b57600080fd5b80518381111561587d5761587d615765565b61588f601f8201601f191687016157a4565b935080845288868284010111156158a557600080fd5b6158b4818786018885016157d5565b50508181526158c48484016157f9565b848201526158d4604084016157f9565b604082015260608301516060820152608083015160808201528094505050505092915050565b60006020828403121561590c57600080fd5b81516113ca8161521a565b6000815180845261592f8160208601602086016157d5565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090612a0c90830184615917565b6001600160a01b0384811682528316602082015260606040820181905260009061480790830184615917565b6000806000606084860312156159a857600080fd5b8351925060208401519150604084015190509250925092565b6000600182016159d3576159d3615557565b5060010190565b6000602082840312156159ec57600080fd5b81516113ca81615097565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b80820260008212600160ff1b84141615615a5e57615a5e615557565b8181058314821517611c8d57611c8d615557565b600082615a8157615a81615615565b600160ff1b821460001984141615615a9b57615a9b615557565b500590565b6000600160ff1b8201615ab557615ab5615557565b5060000390565b8181036000831280158383131683831282161715615adc57615adc615557565b5092915050565b8082018281126000831280158216821582161715615b0357615b03615557565b505092915050565b600082615b1a57615b1a615615565b500790565b60008251615b318184602087016157d5565b9190910192915050565b602081526000611c8a602083018461591756fe7570646174654d756c7469706c6965727328616464726573732c75696e743235362c75696e743235362909d2594e8892daceca055f74be758146a8b8b1167444d0b4ccb96e74168198cc6164644d61726b657428616464726573732c616464726573732c75696e743235362c75696e7432353629a2646970667358221220d7842351882c76ed9cd16c268489fd8f3a58a0b4e004c3ca395a20eaf26d410a64736f6c63430008190033", + "devdoc": { + "author": "Venus", + "custom:security-contact": "https://github.com/VenusProtocol/venus-protocol", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + }, + "Paused(address)": { + "details": "Emitted when the pause is triggered by `account`." + }, + "Unpaused(address)": { + "details": "Emitted when the pause is lifted by `account`." + } + }, + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "accrueInterest(address)": { + "custom:error": "Throw MarketNotSupported if market is not supported", + "params": { + "vToken": "the market for which to distribute the income" + } + }, + "accrueInterestAndUpdateScore(address,address)": { + "params": { + "market": "the market for which to accrue interest and update score", + "user": "the account address for which to accrue interest and update score" + } + }, + "addMarket(address,address,uint256,uint256)": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw MarketAlreadyExists if market already existsThrow InvalidVToken if market is not valid", + "custom:event": "Emits MarketAdded event", + "params": { + "borrowMultiplier": "the multiplier for borrow cap. It should be converted to 1e18", + "comptroller": "address of the comptroller", + "market": "address of the market vToken", + "supplyMultiplier": "the multiplier for supply cap. It should be converted to 1e18" + } + }, + "burn(address)": { + "custom:access": "Controlled by ACM", + "params": { + "user": "the account address for which the prime token will be burned" + } + }, + "calculateAPR(address,address)": { + "params": { + "market": "the market for which to fetch the APR", + "user": "the account for which to get the APR" + }, + "returns": { + "aprInfo": "APR information for the user for the given market" + } + }, + "claimInterest(address)": { + "params": { + "vToken": "the market for which claim the accrued interest" + }, + "returns": { + "_0": "amount the amount of tokens transferred to the msg.sender" + } + }, + "claimInterest(address,address)": { + "params": { + "user": "the user for which to claim the accrued interest", + "vToken": "the market for which claim the accrued interest" + }, + "returns": { + "_0": "amount the amount of tokens transferred to the user" + } + }, + "claimTimeRemaining(address)": { + "params": { + "user": "the account address for which we are checking the remaining time" + }, + "returns": { + "_0": "timeRemaining the number of seconds the user needs to wait to claim prime token" + } + }, + "comptroller()": { + "returns": { + "_0": "the core pool comptroller address" + } + }, + "constructor": { + "custom:oz-upgrades-unsafe-allow": "constructor" + }, + "estimateAPR(address,address,uint256,uint256,uint256)": { + "params": { + "market": "the market for which to fetch the APR", + "user": "the account for which to get the APR" + }, + "returns": { + "aprInfo": "APR information for the user for the given market" + } + }, + "getAllMarkets()": { + "returns": { + "_0": "an array of addresses representing all available markets" + } + }, + "getBlockNumberOrTimestamp()": { + "details": "Function to simply retrieve block number or block timestamp", + "returns": { + "_0": "Current block number or block timestamp" + } + }, + "getInterestAccrued(address,address)": { + "params": { + "user": "the account for which to get the accrued interest", + "vToken": "the market for which to fetch the accrued interest" + }, + "returns": { + "_0": "interestAccrued the number of underlying tokens accrued by the user since the last accrual" + } + }, + "getPendingRewards(address)": { + "params": { + "user": "the account for which to get the accrued interests" + }, + "returns": { + "pendingRewards": "the number of underlying tokens accrued by the user for all markets" + } + }, + "incomeDistributionYearly(address)": { + "params": { + "vToken": "the market for which to fetch the total income that's going to distributed in a year" + }, + "returns": { + "amount": "the total income" + } + }, + "initialize(address,address,uint256,uint128,uint128,address,address,address,address,uint256)": { + "custom:error": "Throw InvalidAddress if any of the address is invalid", + "params": { + "accessControlManager_": "Address of AccessControlManager", + "alphaDenominator_": "denominator of alpha. If alpha is 0.5 then denominator is 2. alpha is alphaNumerator_/alphaDenominator_. So, 0 < alpha < 1", + "alphaNumerator_": "numerator of alpha. If alpha is 0.5 then numerator is 1. alphaDenominator_ must be greater than alphaNumerator_, alphaDenominator_ cannot be zero and alphaNumerator_ cannot be zero", + "comptroller_": "Address of core pool comptroller", + "loopsLimit_": "Maximum number of loops allowed in a single transaction", + "oracle_": "Address of Oracle", + "primeLiquidityProvider_": "Address of PrimeLiquidityProvider", + "xvsVaultPoolId_": "Pool id of XVSVault", + "xvsVaultRewardToken_": "Address of XVSVault reward token", + "xvsVault_": "Address of XVSVault" + } + }, + "initializeV2(address)": { + "params": { + "poolRegistry_": "Address of IL pool registry" + } + }, + "isUserPrimeHolder(address)": { + "returns": { + "_0": "isPrimeHolder true if user is a prime holder" + } + }, + "issue(bool,address[])": { + "custom:access": "Controlled by ACM", + "params": { + "isIrrevocable": "are the tokens being issued", + "users": "list of address to issue tokens to" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." + }, + "setAccessControlManager(address)": { + "custom:access": "Only Governance", + "custom:event": "Emits NewAccessControlManager event", + "details": "Admin function to set address of AccessControlManager", + "params": { + "accessControlManager_": "The new address of the AccessControlManager" + } + }, + "setLimit(uint256,uint256)": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw InvalidLimit if any of the limit is less than total tokens minted", + "custom:event": "Emits MintLimitsUpdated event", + "params": { + "_irrevocableLimit": "total number of irrevocable tokens that can be minted", + "_revocableLimit": "total number of revocable tokens that can be minted" + } + }, + "setMaxLoopsLimit(uint256)": { + "custom:access": "Controlled by ACM", + "custom:event": "Emits MaxLoopsLimitUpdated event on success", + "params": { + "loopsLimit": "Number of loops limit" + } + }, + "setStakedAt(address[],uint256[])": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw InvalidLength if users and timestamps length are not equal", + "custom:event": "Emits StakedAtUpdated event for each user", + "params": { + "timestamps": "new staked at timestamp for the users", + "users": "accounts for which we need to update staked at timestamp" + } + }, + "togglePause()": { + "custom:access": "Controlled by ACM" + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + }, + "updateAlpha(uint128,uint128)": { + "custom:access": "Controlled by ACM", + "custom:event": "Emits AlphaUpdated event", + "params": { + "_alphaDenominator": "denominator of alpha. If alpha is 0.5 then denominator is 2", + "_alphaNumerator": "numerator of alpha. If alpha is 0.5 then numerator is 1" + } + }, + "updateMultipliers(address,uint256,uint256)": { + "custom:access": "Controlled by ACM", + "custom:error": "Throw MarketNotSupported if market is not supported", + "custom:event": "Emits MultiplierUpdated event", + "params": { + "borrowMultiplier": "new borrow multiplier for the market, scaled by 1e18", + "market": "address of the market vToken", + "supplyMultiplier": "new supply multiplier for the market, scaled by 1e18" + } + }, + "updateScores(address[])": { + "custom:error": "Throw NoScoreUpdatesRequired if no score updates are requiredThrow UserHasNoPrimeToken if user has no prime token", + "custom:event": "Emits UserScoreUpdated event", + "params": { + "users": "accounts for which we need to update score" + } + }, + "xvsUpdated(address)": { + "params": { + "user": "the account address whose balance was updated" + } + } + }, + "stateVariables": { + "MAXIMUM_XVS_CAP": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "MINIMUM_STAKED_XVS": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "NATIVE_MARKET": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "STAKING_PERIOD": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + }, + "WRAPPED_NATIVE_TOKEN": { + "custom:oz-upgrades-unsafe-allow": "state-variable-immutable" + } + }, + "title": "Prime", + "version": 1 + }, + "userdoc": { + "errors": { + "AssetAlreadyExists()": [ + { + "notice": "Error thrown when asset already exists" + } + ], + "ExpTooLarge(int256)": [ + { + "notice": "Thrown when exp is given too large of an argument" + } + ], + "IneligibleToClaim()": [ + { + "notice": "Error thrown when user is not eligible to claim prime token" + } + ], + "InvalidAddress()": [ + { + "notice": "Error thrown when invalid address is passed" + } + ], + "InvalidAlphaArguments()": [ + { + "notice": "Error thrown when invalid alpha arguments are passed" + } + ], + "InvalidBlocksPerYear()": [ + { + "notice": "Thrown when blocks per year is invalid" + } + ], + "InvalidComptroller()": [ + { + "notice": "Error thrown when invalid comptroller is passed" + } + ], + "InvalidLength()": [ + { + "notice": "Error thrown when invalid length is passed" + } + ], + "InvalidLimit()": [ + { + "notice": "Error thrown when mint limit is reached" + } + ], + "InvalidTimeBasedConfiguration()": [ + { + "notice": "Thrown when time based but blocks per year is provided" + } + ], + "InvalidTimestamp()": [ + { + "notice": "Error thrown when timestamp is invalid" + } + ], + "InvalidVToken()": [ + { + "notice": "Error thrown when invalid vToken is passed" + } + ], + "LnNonRealResult(int256)": [ + { + "notice": "Thrown when the natural log would have returned a number outside of ℝ" + } + ], + "LnTooLarge(int256)": [ + { + "notice": "Thrown when the natural log function is given too large of an argument" + } + ], + "MarketAlreadyExists()": [ + { + "notice": "Error thrown when market already exists" + } + ], + "MarketNotSupported()": [ + { + "notice": "Error thrown when market is not supported" + } + ], + "MaxLoopsLimitExceeded(uint256,uint256)": [ + { + "notice": "Thrown an error on maxLoopsLimit exceeds for any loop" + } + ], + "NoScoreUpdatesRequired()": [ + { + "notice": "Error thrown when no score updates are required" + } + ], + "Unauthorized(address,address,string)": [ + { + "notice": "Thrown when the action is prohibited by AccessControlManager" + } + ], + "UserHasNoPrimeToken()": [ + { + "notice": "Error thrown when user has no prime token" + } + ], + "WaitMoreTime()": [ + { + "notice": "Error thrown when user needs to wait more time to claim prime token" + } + ] + }, + "events": { + "AlphaUpdated(uint128,uint128,uint128,uint128)": { + "notice": "Emitted when alpha is updated" + }, + "Burn(address)": { + "notice": "Emitted when prime token is burned" + }, + "InterestClaimed(address,address,uint256)": { + "notice": "Emitted when interest is claimed" + }, + "MarketAdded(address,address,uint256,uint256)": { + "notice": "Emitted when a market is added to prime program" + }, + "MaxLoopsLimitUpdated(uint256,uint256)": { + "notice": "Emitted when max loops limit is set" + }, + "Mint(address,bool)": { + "notice": "Emitted when prime token is minted" + }, + "MintLimitsUpdated(uint256,uint256,uint256,uint256)": { + "notice": "Emitted when mint limits are updated" + }, + "MultiplierUpdated(address,uint256,uint256,uint256,uint256)": { + "notice": "Emitted when multiplier is updated" + }, + "NewAccessControlManager(address,address)": { + "notice": "Emitted when access control manager contract address is changed" + }, + "StakedAtUpdated(address,uint256)": { + "notice": "Emitted when stakedAt is updated" + }, + "TokenUpgraded(address)": { + "notice": "Emitted when revocable token is upgraded to irrevocable token" + }, + "UserScoreUpdated(address)": { + "notice": "Emitted when user score is updated" + } + }, + "kind": "user", + "methods": { + "MAXIMUM_XVS_CAP()": { + "notice": "maximum XVS taken in account when calculating user score" + }, + "MINIMUM_STAKED_XVS()": { + "notice": "minimum amount of XVS user needs to stake to become a prime member" + }, + "NATIVE_MARKET()": { + "notice": "address of native market contract" + }, + "STAKING_PERIOD()": { + "notice": "number of days user need to stake to claim prime token" + }, + "WRAPPED_NATIVE_TOKEN()": { + "notice": "address of wrapped native token contract" + }, + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "accrueInterest(address)": { + "notice": "Distributes income from market since last distribution" + }, + "accrueInterestAndUpdateScore(address,address)": { + "notice": "accrues interes and updates score for an user for a specific market" + }, + "addMarket(address,address,uint256,uint256)": { + "notice": "Add a market to prime program" + }, + "alphaDenominator()": { + "notice": "denominator of alpha. Ex: if alpha is 0.5 then this will be 2" + }, + "alphaNumerator()": { + "notice": "numerator of alpha. Ex: if alpha is 0.5 then this will be 1" + }, + "blocksOrSecondsPerYear()": { + "notice": "Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored" + }, + "burn(address)": { + "notice": "For burning any prime token" + }, + "calculateAPR(address,address)": { + "notice": "Returns supply and borrow APR for user for a given market" + }, + "claim()": { + "notice": "For claiming prime token when staking period is completed" + }, + "claimInterest(address)": { + "notice": "For user to claim boosted yield" + }, + "claimInterest(address,address)": { + "notice": "For user to claim boosted yield" + }, + "claimTimeRemaining(address)": { + "notice": "fetch the numbers of seconds remaining for staking period to complete" + }, + "comptroller()": { + "notice": "Retrieves the core pool comptroller address" + }, + "estimateAPR(address,address,uint256,uint256,uint256)": { + "notice": "Returns supply and borrow APR for estimated supply, borrow and XVS staked" + }, + "getAllMarkets()": { + "notice": "Retrieves an array of all available markets" + }, + "getInterestAccrued(address,address)": { + "notice": "Returns boosted interest accrued for a user" + }, + "getPendingRewards(address)": { + "notice": "Returns boosted pending interest accrued for a user for all markets" + }, + "incomeDistributionYearly(address)": { + "notice": "the total income that's going to be distributed in a year to prime token holders" + }, + "initialize(address,address,uint256,uint128,uint128,address,address,address,address,uint256)": { + "notice": "Prime initializer" + }, + "initializeV2(address)": { + "notice": "Prime initializer V2 for initializing pool registry" + }, + "interests(address,address)": { + "notice": "vToken to user to user index" + }, + "irrevocableLimit()": { + "notice": "Indicates maximum irrevocable tokens that can be minted" + }, + "isScoreUpdated(uint256,address)": { + "notice": "mapping to check if a account's score was updated in the round" + }, + "isTimeBased()": { + "notice": "Acknowledges if a contract is time based or not" + }, + "isUserPrimeHolder(address)": { + "notice": "Returns if user is a prime holder" + }, + "issue(bool,address[])": { + "notice": "Directly issue prime tokens to users" + }, + "markets(address)": { + "notice": "vToken to market configuration" + }, + "nextScoreUpdateRoundId()": { + "notice": "unique id for next round" + }, + "oracle()": { + "notice": "The address of ResilientOracle contract" + }, + "pendingScoreUpdates()": { + "notice": "total number of accounts whose score is yet to be updated" + }, + "poolRegistry()": { + "notice": "The address of PoolRegistry contract" + }, + "primeLiquidityProvider()": { + "notice": "The address of PLP contract" + }, + "revocableLimit()": { + "notice": "Indicates maximum revocable tokens that can be minted" + }, + "setAccessControlManager(address)": { + "notice": "Sets the address of AccessControlManager" + }, + "setLimit(uint256,uint256)": { + "notice": "Set limits for total tokens that can be minted" + }, + "setMaxLoopsLimit(uint256)": { + "notice": "Set the limit for the loops can iterate to avoid the DOS" + }, + "setStakedAt(address[],uint256[])": { + "notice": "Update staked at timestamp for multiple users" + }, + "stakedAt(address)": { + "notice": "Tracks when prime token eligible users started staking for claiming prime token" + }, + "togglePause()": { + "notice": "To pause or unpause claiming of interest" + }, + "tokens(address)": { + "notice": "Mapping to get prime token's metadata" + }, + "totalIrrevocable()": { + "notice": "Tracks total irrevocable tokens minted" + }, + "totalRevocable()": { + "notice": "Tracks total revocable tokens minted" + }, + "totalScoreUpdatesRequired()": { + "notice": "total number of accounts whose score needs to be updated" + }, + "unreleasedPLPIncome(address)": { + "notice": "unreleased income from PLP that's already distributed to prime holders" + }, + "updateAlpha(uint128,uint128)": { + "notice": "Update value of alpha" + }, + "updateMultipliers(address,uint256,uint256)": { + "notice": "Update multipliers for a market" + }, + "updateScores(address[])": { + "notice": "Update total score of multiple users and market" + }, + "vTokenForAsset(address)": { + "notice": "mapping used to find if an asset is part of prime markets" + }, + "xvsUpdated(address)": { + "notice": "Executed by XVSVault whenever user's XVSVault balance changes" + }, + "xvsVault()": { + "notice": "address of XVS vault" + }, + "xvsVaultPoolId()": { + "notice": "address of XVS vault pool id" + }, + "xvsVaultRewardToken()": { + "notice": "address of XVS vault reward token" + } + }, + "notice": "Prime Token is used to provide extra rewards to the users who have staked a minimum of `MINIMUM_STAKED_XVS` XVS in the XVSVault for `STAKING_PERIOD` days", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 246, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 249, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1516, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 118, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 238, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 11, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 105, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 5863, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_accessControlManager", + "offset": 0, + "slot": "151", + "type": "t_contract(IAccessControlManagerV8)6048" + }, + { + "astId": 5868, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 430, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_paused", + "offset": 0, + "slot": "201", + "type": "t_bool" + }, + { + "astId": 535, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "202", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 6105, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "maxLoopsLimit", + "offset": 0, + "slot": "251", + "type": "t_uint256" + }, + { + "astId": 6110, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "252", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 22637, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "tokens", + "offset": 0, + "slot": "301", + "type": "t_mapping(t_address,t_struct(Token)22598_storage)" + }, + { + "astId": 22640, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "totalIrrevocable", + "offset": 0, + "slot": "302", + "type": "t_uint256" + }, + { + "astId": 22643, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "totalRevocable", + "offset": 0, + "slot": "303", + "type": "t_uint256" + }, + { + "astId": 22646, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "revocableLimit", + "offset": 0, + "slot": "304", + "type": "t_uint256" + }, + { + "astId": 22649, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "irrevocableLimit", + "offset": 0, + "slot": "305", + "type": "t_uint256" + }, + { + "astId": 22654, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "stakedAt", + "offset": 0, + "slot": "306", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22660, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "markets", + "offset": 0, + "slot": "307", + "type": "t_mapping(t_address,t_struct(Market)22609_storage)" + }, + { + "astId": 22668, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "interests", + "offset": 0, + "slot": "308", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(Interest)22616_storage))" + }, + { + "astId": 22672, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "_allMarkets", + "offset": 0, + "slot": "309", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 22675, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "alphaNumerator", + "offset": 0, + "slot": "310", + "type": "t_uint128" + }, + { + "astId": 22678, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "alphaDenominator", + "offset": 16, + "slot": "310", + "type": "t_uint128" + }, + { + "astId": 22681, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "xvsVault", + "offset": 0, + "slot": "311", + "type": "t_address" + }, + { + "astId": 22684, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "xvsVaultRewardToken", + "offset": 0, + "slot": "312", + "type": "t_address" + }, + { + "astId": 22687, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "xvsVaultPoolId", + "offset": 0, + "slot": "313", + "type": "t_uint256" + }, + { + "astId": 22694, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "isScoreUpdated", + "offset": 0, + "slot": "314", + "type": "t_mapping(t_uint256,t_mapping(t_address,t_bool))" + }, + { + "astId": 22697, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "nextScoreUpdateRoundId", + "offset": 0, + "slot": "315", + "type": "t_uint256" + }, + { + "astId": 22700, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "totalScoreUpdatesRequired", + "offset": 0, + "slot": "316", + "type": "t_uint256" + }, + { + "astId": 22703, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "pendingScoreUpdates", + "offset": 0, + "slot": "317", + "type": "t_uint256" + }, + { + "astId": 22708, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "vTokenForAsset", + "offset": 0, + "slot": "318", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 22711, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "corePoolComptroller", + "offset": 0, + "slot": "319", + "type": "t_address" + }, + { + "astId": 22716, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "unreleasedPLPIncome", + "offset": 0, + "slot": "320", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 22719, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "primeLiquidityProvider", + "offset": 0, + "slot": "321", + "type": "t_address" + }, + { + "astId": 22723, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "oracle", + "offset": 0, + "slot": "322", + "type": "t_contract(ResilientOracleInterface)6078" + }, + { + "astId": 22726, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "poolRegistry", + "offset": 0, + "slot": "323", + "type": "t_address" + }, + { + "astId": 22731, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "324", + "type": "t_array(t_uint256)26_storage" + }, + { + "astId": 6191, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "__gap", + "offset": 0, + "slot": "350", + "type": "t_array(t_uint256)48_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)26_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[26]", + "numberOfBytes": "832" + }, + "t_array(t_uint256)48_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IAccessControlManagerV8)6048": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV8", + "numberOfBytes": "20" + }, + "t_contract(ResilientOracleInterface)6078": { + "encoding": "inplace", + "label": "contract ResilientOracleInterface", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_mapping(t_address,t_struct(Interest)22616_storage))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => struct PrimeStorageV1.Interest))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_struct(Interest)22616_storage)" + }, + "t_mapping(t_address,t_struct(Interest)22616_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct PrimeStorageV1.Interest)", + "numberOfBytes": "32", + "value": "t_struct(Interest)22616_storage" + }, + "t_mapping(t_address,t_struct(Market)22609_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct PrimeStorageV1.Market)", + "numberOfBytes": "32", + "value": "t_struct(Market)22609_storage" + }, + "t_mapping(t_address,t_struct(Token)22598_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct PrimeStorageV1.Token)", + "numberOfBytes": "32", + "value": "t_struct(Token)22598_storage" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_struct(Interest)22616_storage": { + "encoding": "inplace", + "label": "struct PrimeStorageV1.Interest", + "members": [ + { + "astId": 22611, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "accrued", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 22613, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "score", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 22615, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "rewardIndex", + "offset": 0, + "slot": "2", + "type": "t_uint256" + } + ], + "numberOfBytes": "96" + }, + "t_struct(Market)22609_storage": { + "encoding": "inplace", + "label": "struct PrimeStorageV1.Market", + "members": [ + { + "astId": 22600, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "supplyMultiplier", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 22602, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "borrowMultiplier", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 22604, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "rewardIndex", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 22606, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "sumOfMembersScore", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 22608, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "exists", + "offset": 0, + "slot": "4", + "type": "t_bool" + } + ], + "numberOfBytes": "160" + }, + "t_struct(Token)22598_storage": { + "encoding": "inplace", + "label": "struct PrimeStorageV1.Token", + "members": [ + { + "astId": 22595, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "exists", + "offset": 0, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 22597, + "contract": "contracts/Tokens/Prime/Prime.sol:Prime", + "label": "isIrrevocable", + "offset": 1, + "slot": "0", + "type": "t_bool" + } + ], + "numberOfBytes": "32" + }, + "t_uint128": { + "encoding": "inplace", + "label": "uint128", + "numberOfBytes": "16" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/opsepolia/Prime_Proxy.json b/deployments/opsepolia/Prime_Proxy.json new file mode 100644 index 000000000..57ce7659b --- /dev/null +++ b/deployments/opsepolia/Prime_Proxy.json @@ -0,0 +1,282 @@ +{ + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "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": [], + "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": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "transactionIndex": 3, + "gasUsed": "774848", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000800000000000000000000000000000000000000000000000000400000000000008000000000000000000000000000000002000001000000080410000000000000000000000000020000000000000000000800000000810000000000000000000000440000000100000000000008000000000000000000000080000000000000800000000000000000000000002000000400000000000000800000000000000000000000000020000000000000000401040000000000000400000000000000000020000000000200000000000000000000000000000840000000000000800000000000", + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab", + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "logs": [ + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000084cca3c7719d1f9c35b5cff14be05801b8fd69d7" + ], + "data": "0x", + "logIndex": 17, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000476c66ca1fe0e8abb45c8566d635dca9dc930f73" + ], + "data": "0x", + "logIndex": 18, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0x66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001652e12c8abe2f0d84466f0fc1fa4286491b3bc1", + "logIndex": 19, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0xc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa"], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014", + "logIndex": 20, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0x62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258"], + "data": "0x000000000000000000000000476c66ca1fe0e8abb45c8566d635dca9dc930f73", + "logIndex": 21, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 22, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + }, + { + "transactionIndex": 3, + "blockNumber": 17184828, + "transactionHash": "0x4cb9f8697366b221da850480c3bdcbcdd216ff745e1dad227c14fc78fd86d2bb", + "address": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a9aaf2a1ccf2c3a87997942abaa740887cc89241", + "logIndex": 23, + "blockHash": "0xcc44b789915e6e5e6df5a878462479e1747f7f91be31b80139672776c75efeab" + } + ], + "blockNumber": 17184828, + "cumulativeGasUsed": "1573606", + "status": 1, + "byzantium": true + }, + "args": [ + "0x84cca3c7719d1F9c35b5cfF14BE05801B8fD69d7", + "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", + "0xb1a250f20000000000000000000000004d344e48f02234e82d7d1db84d0a4a18aa43dacc000000000000000000000000789482e37218f9b26d8d9115e356462fa9a371160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000001652e12c8abe2f0d84466f0fc1fa4286491b3bc1000000000000000000000000e3ec955b94d197a8e4081844f3f25f81047a9af500000000000000000000000000000000000000000000000000000000000000000000000000000000000000006c01eca2b5c97f135406a3a5531445a7d977d28e0000000000000000000000000000000000000000000000000000000000000014" + ], + "numDeployments": 1, + "solcInputHash": "7584667b44eb77970ba8d274006d81ae", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"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\":[],\"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.\",\"events\":{\"AdminChanged(address,address)\":{\"details\":\"Emitted when the admin account has changed.\"},\"BeaconUpgraded(address)\":{\"details\":\"Emitted when the beacon is upgraded.\"},\"Upgraded(address)\":{\"details\":\"Emitted when the implementation is upgraded.\"}},\"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`\"},\"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\":{\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\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\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"hardhat-deploy/solc_0.8/openzeppelin/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\"},\"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\\n address internal immutable _ADMIN;\\n\\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 _ADMIN = admin_;\\n\\n // still store it to work with EIP-1967\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, admin_)\\n }\\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\\n return _ADMIN;\\n }\\n}\\n\",\"keccak256\":\"0xa30117644e27fa5b49e162aae2f62b36c1aca02f801b8c594d46e2024963a534\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a0604052604051610d1a380380610d1a833981016040819052610022916103d2565b828161004f60017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd6104a2565b600080516020610cd38339815191521461006b5761006b6104c3565b61007782826000610128565b506100a5905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61046104a2565b600080516020610cb3833981519152146100c1576100c16104c3565b6001600160a01b0382166080819052600080516020610cb38339815191528381556040805160008152602081019390935290917f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a150505050610528565b61013183610154565b60008251118061013e5750805b1561014f5761014d8383610194565b505b505050565b61015d816101c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606101b98383604051806060016040528060278152602001610cf360279139610263565b90505b92915050565b6001600160a01b0381163b6102345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b600080516020610cd383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6102cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161022b565b600080856001600160a01b0316856040516102e691906104d9565b600060405180830381855af49150503d8060008114610321576040519150601f19603f3d011682016040523d82523d6000602084013e610326565b606091505b509092509050610337828286610343565b925050505b9392505050565b6060831561035257508161033c565b8251156103625782518084602001fd5b8160405162461bcd60e51b815260040161022b91906104f5565b80516001600160a01b038116811461039357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103c95781810151838201526020016103b1565b50506000910152565b6000806000606084860312156103e757600080fd5b6103f08461037c565b92506103fe6020850161037c565b60408501519092506001600160401b038082111561041b57600080fd5b818601915086601f83011261042f57600080fd5b81518181111561044157610441610398565b604051601f8201601f19908116603f0116810190838211818310171561046957610469610398565b8160405282815289602084870101111561048257600080fd5b6104938360208301602088016103ae565b80955050505050509250925092565b818103818111156101bc57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600082516104eb8184602087016103ae565b9190910192915050565b60208152600082518060208401526105148160408501602087016103ae565b601f01601f19169190910160400192915050565b60805161074e6105656000396000818160ef01528181610145015281816101c701528181610211015281816102420152610266015261074e6000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461007a5780635c60da1b1461008d578063f851a440146100be57610052565b36610052576100506100d3565b005b6100506100d3565b34801561006657600080fd5b506100506100753660046105e0565b6100ed565b6100506100883660046105fb565b610143565b34801561009957600080fd5b506100a26101c3565b6040516001600160a01b03909116815260200160405180910390f35b3480156100ca57600080fd5b506100a261020d565b6100db610264565b6100eb6100e6610312565b610345565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361013b5761013881604051806020016040528060008152506000610369565b50565b6101386100d3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036101bb576101b68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610369915050565b505050565b6101b66100d3565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610202576101fd610312565b905090565b61020a6100d3565b90565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361020257507f000000000000000000000000000000000000000000000000000000000000000090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100eb5760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b3660008037600080366000845af43d6000803e808015610364573d6000f35b3d6000fd5b61037283610394565b60008251118061037f5750805b156101b65761038e83836103d4565b50505050565b61039d81610400565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606103f983836040518060600160405280602781526020016106f2602791396104ae565b9392505050565b6001600160a01b0381163b61046d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610309565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60606001600160a01b0384163b6105165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610309565b600080856001600160a01b03168560405161053191906106a2565b600060405180830381855af49150503d806000811461056c576040519150601f19603f3d011682016040523d82523d6000602084013e610571565b606091505b509150915061058182828661058b565b9695505050505050565b6060831561059a5750816103f9565b8251156105aa5782518084602001fd5b8160405162461bcd60e51b815260040161030991906106be565b80356001600160a01b03811681146105db57600080fd5b919050565b6000602082840312156105f257600080fd5b6103f9826105c4565b60008060006040848603121561061057600080fd5b610619846105c4565b9250602084013567ffffffffffffffff8082111561063657600080fd5b818601915086601f83011261064a57600080fd5b81358181111561065957600080fd5b87602082850101111561066b57600080fd5b6020830194508093505050509250925092565b60005b83811015610699578181015183820152602001610681565b50506000910152565b600082516106b481846020870161067e565b9190910192915050565b60208152600082518060208401526106dd81604085016020870161067e565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207502388c3ffe7f7efd00a218c70c5d02b728d9a5b26b11a37a02a8761f7f520764736f6c63430008190033", + "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.", + "events": { + "AdminChanged(address,address)": { + "details": "Emitted when the admin account has changed." + }, + "BeaconUpgraded(address)": { + "details": "Emitted when the beacon is upgraded." + }, + "Upgraded(address)": { + "details": "Emitted when the implementation is upgraded." + } + }, + "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`" + }, + "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/deployments/opsepolia/XVSStore.json b/deployments/opsepolia/XVSStore.json new file mode 100644 index 000000000..c347ff2a8 --- /dev/null +++ b/deployments/opsepolia/XVSStore.json @@ -0,0 +1,374 @@ +{ + "address": "0xE888FA54b32BfaD3cE0e3C7D566EFe809a6A0143", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerTransferred", + "type": "event" + }, + { + "constant": false, + "inputs": [], + "name": "acceptAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "emergencyRewardWithdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardTokens", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "safeRewardTransfer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "setNewOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_admin", + "type": "address" + } + ], + "name": "setPendingAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "setRewardToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x0aeffe8d906a71d501b252033955ed3576944da19a3ddcd26840830c3d6ae3ef", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0xE888FA54b32BfaD3cE0e3C7D566EFe809a6A0143", + "transactionIndex": 5, + "gasUsed": "634554", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x2c32306cf87251e994bb34f7dc3c644badac5a22f328be005164c623bc2b3681", + "transactionHash": "0x0aeffe8d906a71d501b252033955ed3576944da19a3ddcd26840830c3d6ae3ef", + "logs": [], + "blockNumber": 14184215, + "cumulativeGasUsed": "3721882", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "1ccea21f99f9d0cf6dcde9df90c8a652", + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldAdmin\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"NewPendingAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnerTransferred\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[],\"name\":\"acceptAdmin\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"emergencyRewardWithdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"rewardTokens\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"safeRewardTransfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"setNewOwner\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_admin\",\"type\":\"address\"}],\"name\":\"setPendingAdmin\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"setRewardToken\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"methods\":{\"emergencyRewardWithdraw(address,uint256)\":{\"params\":{\"_amount\":\"Amount of token to withdraw\",\"_tokenAddress\":\"Reward token address to withdraw\"}},\"safeRewardTransfer(address,address,uint256)\":{\"details\":\"Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\",\"params\":{\"_amount\":\"Amount to transfer\",\"_to\":\"Destination address of the reward\",\"token\":\"Reward token to transfer\"}},\"setNewOwner(address)\":{\"params\":{\"_owner\":\"The address of the owner to set Only callable admin\"}},\"setPendingAdmin(address)\":{\"params\":{\"_admin\":\"Propose an account as admin of the XVS store\"}},\"setRewardToken(address,bool)\":{\"params\":{\"_tokenAddress\":\"The address of a token to set as active or inactive\",\"status\":\"Set whether a reward token is active or not\"}}},\"title\":\"XVS Store\"},\"userdoc\":{\"methods\":{\"acceptAdmin()\":{\"notice\":\"Allows an account that is pending as admin to accept the role nly calllable by the pending admin\"},\"emergencyRewardWithdraw(address,uint256)\":{\"notice\":\"Security function to allow the owner of the contract to withdraw from the contract\"},\"safeRewardTransfer(address,address,uint256)\":{\"notice\":\"Safely transfer rewards. Only active reward tokens can be sent using this function. Only callable by owner\"},\"setNewOwner(address)\":{\"notice\":\"Set the contract owner\"},\"setPendingAdmin(address)\":{\"notice\":\"Allows the admin to propose a new admin Only callable admin\"},\"setRewardToken(address,bool)\":{\"notice\":\"Set or disable a reward token\"}},\"notice\":\"XVS Store responsible for distributing XVS rewards\"}},\"settings\":{\"compilationTarget\":{\"contracts/XVSVault/XVSStore.sol\":\"XVSStore\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/Utils/Address.sol\":{\"content\":\"pragma solidity ^0.5.5;\\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 function isContract(address account) internal view returns (bool) {\\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\\n // for accounts without code, i.e. `keccak256('')`\\n bytes32 codehash;\\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n codehash := extcodehash(account)\\n }\\n return (codehash != accountHash && codehash != 0x0);\\n }\\n\\n /**\\n * @dev Converts an `address` into `address payable`. Note that this is\\n * simply a type cast: the actual underlying value is not changed.\\n *\\n * _Available since v2.4.0._\\n */\\n function toPayable(address account) internal pure returns (address payable) {\\n return address(uint160(account));\\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 * _Available since v2.4.0._\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-call-value\\n // solium-disable-next-line security/no-call-value\\n (bool success, ) = recipient.call.value(amount)(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n}\\n\",\"keccak256\":\"0x3c2ef780599a2ae6913282b982633f07e405a4a9c8511590df571e2b773aef9d\"},\"contracts/Utils/IBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\n/**\\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\\n * the optional functions; to access them see {BEP20Detailed}.\\n */\\ninterface IBEP20 {\\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 `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\\n\\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\",\"keccak256\":\"0x839b08895eb1ad83502d3631e8e9e3a856d2a8c63c46f070d604af7b26c62c07\"},\"contracts/Utils/SafeBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\nimport \\\"./SafeMath.sol\\\";\\nimport \\\"./IBEP20.sol\\\";\\nimport \\\"./Address.sol\\\";\\n\\n/**\\n * @title SafeBEP20\\n * @dev Wrappers around BEP20 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 SafeBEP20 for BEP20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeBEP20 {\\n using SafeMath for uint256;\\n using Address for address;\\n\\n function safeTransfer(IBEP20 token, address to, uint256 value) internal {\\n callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(IBEP20 token, address from, address to, uint256 value) internal {\\n callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n function safeApprove(IBEP20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeBEP20: approve from non-zero to non-zero allowance\\\"\\n );\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).sub(\\n value,\\n \\\"SafeBEP20: decreased allowance below zero\\\"\\n );\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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(IBEP20 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.\\n\\n // A Solidity high level call has three parts:\\n // 1. The target address is checked to verify it contains contract code\\n // 2. The call itself is made, and success asserted\\n // 3. The return value is decoded, which in turn checks the size of the returned data.\\n // solhint-disable-next-line max-line-length\\n require(address(token).isContract(), \\\"SafeBEP20: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = address(token).call(data);\\n require(success, \\\"SafeBEP20: low-level call failed\\\");\\n\\n if (returndata.length > 0) {\\n // Return data is optional\\n // solhint-disable-next-line max-line-length\\n require(abi.decode(returndata, (bool)), \\\"SafeBEP20: BEP20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x540ef6ddc47232a59d3ab0e95537f7a7d1c8a36f8dba315b010e60c6487bd768\"},\"contracts/Utils/SafeMath.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add(a, b, \\\"SafeMath: addition overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub(a, b, \\\"SafeMath: subtraction overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n uint256 c = a - b;\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) {\\n return 0;\\n }\\n\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div(a, b, \\\"SafeMath: division by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n // Solidity only automatically asserts when dividing by 0\\n require(b > 0, errorMessage);\\n uint256 c = a / b;\\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mod(a, b, \\\"SafeMath: modulo by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts with custom message when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b != 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x9431fd772ed4abc038cdfe9ce6c0066897bd1685ad45848748d1952935d5b8ef\"},\"contracts/XVSVault/XVSStore.sol\":{\"content\":\"pragma solidity 0.5.16;\\nimport \\\"../Utils/SafeBEP20.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\n\\n/**\\n * @title XVS Store\\n * @author Venus\\n * @notice XVS Store responsible for distributing XVS rewards\\n */\\ncontract XVSStore {\\n using SafeMath for uint256;\\n using SafeBEP20 for IBEP20;\\n\\n /// @notice The Admin Address\\n address public admin;\\n\\n /// @notice The pending admin address\\n address public pendingAdmin;\\n\\n /// @notice The Owner Address\\n address public owner;\\n\\n /// @notice The reward tokens\\n mapping(address => bool) public rewardTokens;\\n\\n /// @notice Emitted when pendingAdmin is changed\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /// @notice Event emitted when admin changed\\n event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);\\n\\n /// @notice Event emitted when owner changed\\n event OwnerTransferred(address indexed oldOwner, address indexed newOwner);\\n\\n constructor() public {\\n admin = msg.sender;\\n }\\n\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"only admin can\\\");\\n _;\\n }\\n\\n modifier onlyOwner() {\\n require(msg.sender == owner, \\\"only owner can\\\");\\n _;\\n }\\n\\n /**\\n * @notice Safely transfer rewards. Only active reward tokens can be sent using this function.\\n * Only callable by owner\\n * @dev Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\\n * @param token Reward token to transfer\\n * @param _to Destination address of the reward\\n * @param _amount Amount to transfer\\n */\\n function safeRewardTransfer(address token, address _to, uint256 _amount) external onlyOwner {\\n require(rewardTokens[token] == true, \\\"only reward token can\\\");\\n\\n if (address(token) != address(0)) {\\n uint256 tokenBalance = IBEP20(token).balanceOf(address(this));\\n if (_amount > tokenBalance) {\\n IBEP20(token).safeTransfer(_to, tokenBalance);\\n } else {\\n IBEP20(token).safeTransfer(_to, _amount);\\n }\\n }\\n }\\n\\n /**\\n * @notice Allows the admin to propose a new admin\\n * Only callable admin\\n * @param _admin Propose an account as admin of the XVS store\\n */\\n function setPendingAdmin(address _admin) external onlyAdmin {\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = _admin;\\n emit NewPendingAdmin(oldPendingAdmin, _admin);\\n }\\n\\n /**\\n * @notice Allows an account that is pending as admin to accept the role\\n * nly calllable by the pending admin\\n */\\n function acceptAdmin() external {\\n require(msg.sender == pendingAdmin, \\\"only pending admin\\\");\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n emit AdminTransferred(oldAdmin, admin);\\n }\\n\\n /**\\n * @notice Set the contract owner\\n * @param _owner The address of the owner to set\\n * Only callable admin\\n */\\n function setNewOwner(address _owner) external onlyAdmin {\\n require(_owner != address(0), \\\"new owner is the zero address\\\");\\n address oldOwner = owner;\\n owner = _owner;\\n emit OwnerTransferred(oldOwner, _owner);\\n }\\n\\n /**\\n * @notice Set or disable a reward token\\n * @param _tokenAddress The address of a token to set as active or inactive\\n * @param status Set whether a reward token is active or not\\n */\\n function setRewardToken(address _tokenAddress, bool status) external {\\n require(msg.sender == admin || msg.sender == owner, \\\"only admin or owner can\\\");\\n rewardTokens[_tokenAddress] = status;\\n }\\n\\n /**\\n * @notice Security function to allow the owner of the contract to withdraw from the contract\\n * @param _tokenAddress Reward token address to withdraw\\n * @param _amount Amount of token to withdraw\\n */\\n function emergencyRewardWithdraw(address _tokenAddress, uint256 _amount) external onlyOwner {\\n IBEP20(_tokenAddress).safeTransfer(address(msg.sender), _amount);\\n }\\n}\\n\",\"keccak256\":\"0x8082f92b13448bd4fa982c93c763439f10fe016a5f3be6d613dfe3cca68501ef\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b03191633179055610a1b806100326000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80639ad99e68116100665780639ad99e681461012b578063f5a1f5b414610161578063f5ab16cc14610187578063f851a440146101c1578063fb66fb4d146101c95761009e565b80630e18b681146100a357806326782247146100ad5780634dd18bf5146100d1578063804e523e146100f75780638da5cb5b14610123575b600080fd5b6100ab6101f7565b005b6100b56102f3565b604080516001600160a01b039092168252519081900360200190f35b6100ab600480360360208110156100e757600080fd5b50356001600160a01b0316610302565b6100ab6004803603604081101561010d57600080fd5b506001600160a01b0381351690602001356103b5565b6100b5610423565b6100ab6004803603606081101561014157600080fd5b506001600160a01b03813581169160208101359091169060400135610432565b6100ab6004803603602081101561017757600080fd5b50356001600160a01b03166105bb565b6101ad6004803603602081101561019d57600080fd5b50356001600160a01b03166106b8565b604080519115158252519081900360200190f35b6100b56106cd565b6100ab600480360360408110156101df57600080fd5b506001600160a01b03813516906020013515156106dc565b6001546001600160a01b0316331461024b576040805162461bcd60e51b815260206004820152601260248201527137b7363c903832b73234b7339030b236b4b760711b604482015290519081900360640190fd5b60008054600180546001600160a01b038082166001600160a01b0319808616821787559092169092556040805182815260208101959095528051929093169390927fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a992918290030190a1600080546040516001600160a01b0391821692918516917ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec691a35050565b6001546001600160a01b031681565b6000546001600160a01b03163314610352576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9030b236b4b71031b0b760911b604482015290519081900360640190fd5b600180546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a15050565b6002546001600160a01b03163314610405576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9037bbb732b91031b0b760911b604482015290519081900360640190fd5b61041f6001600160a01b038316338363ffffffff61077b16565b5050565b6002546001600160a01b031681565b6002546001600160a01b03163314610482576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9037bbb732b91031b0b760911b604482015290519081900360640190fd5b6001600160a01b03831660009081526003602052604090205460ff1615156001146104ec576040805162461bcd60e51b815260206004820152601560248201527437b7363c903932bbb0b932103a37b5b2b71031b0b760591b604482015290519081900360640190fd5b6001600160a01b038316156105b657604080516370a0823160e01b815230600482015290516000916001600160a01b038616916370a0823191602480820192602092909190829003018186803b15801561054557600080fd5b505afa158015610559573d6000803e3d6000fd5b505050506040513d602081101561056f57600080fd5b505190508082111561059a576105956001600160a01b038516848363ffffffff61077b16565b6105b4565b6105b46001600160a01b038516848463ffffffff61077b16565b505b505050565b6000546001600160a01b0316331461060b576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9030b236b4b71031b0b760911b604482015290519081900360640190fd5b6001600160a01b038116610666576040805162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f2061646472657373000000604482015290519081900360640190fd5b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8934ce4adea8d9ce0d714d2c22b86790e41b7731c84b926fbbdc1d40ff6533c990600090a35050565b60036020526000908152604090205460ff1681565b6000546001600160a01b031681565b6000546001600160a01b03163314806106ff57506002546001600160a01b031633145b610750576040805162461bcd60e51b815260206004820152601760248201527f6f6e6c792061646d696e206f72206f776e65722063616e000000000000000000604482015290519081900360640190fd5b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105b69084906107da826001600160a01b0316610980565b61082b576040805162461bcd60e51b815260206004820152601f60248201527f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106108695780518252601f19909201916020918201910161084a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146108cb576040519150601f19603f3d011682016040523d82523d6000602084013e6108d0565b606091505b509150915081610927576040805162461bcd60e51b815260206004820181905260248201527f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156105b45780806020019051602081101561094357600080fd5b50516105b45760405162461bcd60e51b815260040180806020018281038252602a8152602001806109bd602a913960400191505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906109b457508115155b94935050505056fe5361666542455032303a204245503230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a723158209e938a047cf0499058d9e6866f246e93c241e398b266c69ad7069ce461bc206364736f6c63430005100032", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80639ad99e68116100665780639ad99e681461012b578063f5a1f5b414610161578063f5ab16cc14610187578063f851a440146101c1578063fb66fb4d146101c95761009e565b80630e18b681146100a357806326782247146100ad5780634dd18bf5146100d1578063804e523e146100f75780638da5cb5b14610123575b600080fd5b6100ab6101f7565b005b6100b56102f3565b604080516001600160a01b039092168252519081900360200190f35b6100ab600480360360208110156100e757600080fd5b50356001600160a01b0316610302565b6100ab6004803603604081101561010d57600080fd5b506001600160a01b0381351690602001356103b5565b6100b5610423565b6100ab6004803603606081101561014157600080fd5b506001600160a01b03813581169160208101359091169060400135610432565b6100ab6004803603602081101561017757600080fd5b50356001600160a01b03166105bb565b6101ad6004803603602081101561019d57600080fd5b50356001600160a01b03166106b8565b604080519115158252519081900360200190f35b6100b56106cd565b6100ab600480360360408110156101df57600080fd5b506001600160a01b03813516906020013515156106dc565b6001546001600160a01b0316331461024b576040805162461bcd60e51b815260206004820152601260248201527137b7363c903832b73234b7339030b236b4b760711b604482015290519081900360640190fd5b60008054600180546001600160a01b038082166001600160a01b0319808616821787559092169092556040805182815260208101959095528051929093169390927fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a992918290030190a1600080546040516001600160a01b0391821692918516917ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec691a35050565b6001546001600160a01b031681565b6000546001600160a01b03163314610352576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9030b236b4b71031b0b760911b604482015290519081900360640190fd5b600180546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a15050565b6002546001600160a01b03163314610405576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9037bbb732b91031b0b760911b604482015290519081900360640190fd5b61041f6001600160a01b038316338363ffffffff61077b16565b5050565b6002546001600160a01b031681565b6002546001600160a01b03163314610482576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9037bbb732b91031b0b760911b604482015290519081900360640190fd5b6001600160a01b03831660009081526003602052604090205460ff1615156001146104ec576040805162461bcd60e51b815260206004820152601560248201527437b7363c903932bbb0b932103a37b5b2b71031b0b760591b604482015290519081900360640190fd5b6001600160a01b038316156105b657604080516370a0823160e01b815230600482015290516000916001600160a01b038616916370a0823191602480820192602092909190829003018186803b15801561054557600080fd5b505afa158015610559573d6000803e3d6000fd5b505050506040513d602081101561056f57600080fd5b505190508082111561059a576105956001600160a01b038516848363ffffffff61077b16565b6105b4565b6105b46001600160a01b038516848463ffffffff61077b16565b505b505050565b6000546001600160a01b0316331461060b576040805162461bcd60e51b815260206004820152600e60248201526d37b7363c9030b236b4b71031b0b760911b604482015290519081900360640190fd5b6001600160a01b038116610666576040805162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f2061646472657373000000604482015290519081900360640190fd5b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8934ce4adea8d9ce0d714d2c22b86790e41b7731c84b926fbbdc1d40ff6533c990600090a35050565b60036020526000908152604090205460ff1681565b6000546001600160a01b031681565b6000546001600160a01b03163314806106ff57506002546001600160a01b031633145b610750576040805162461bcd60e51b815260206004820152601760248201527f6f6e6c792061646d696e206f72206f776e65722063616e000000000000000000604482015290519081900360640190fd5b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105b69084906107da826001600160a01b0316610980565b61082b576040805162461bcd60e51b815260206004820152601f60248201527f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106108695780518252601f19909201916020918201910161084a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146108cb576040519150601f19603f3d011682016040523d82523d6000602084013e6108d0565b606091505b509150915081610927576040805162461bcd60e51b815260206004820181905260248201527f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156105b45780806020019051602081101561094357600080fd5b50516105b45760405162461bcd60e51b815260040180806020018281038252602a8152602001806109bd602a913960400191505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906109b457508115155b94935050505056fe5361666542455032303a204245503230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a723158209e938a047cf0499058d9e6866f246e93c241e398b266c69ad7069ce461bc206364736f6c63430005100032", + "devdoc": { + "author": "Venus", + "methods": { + "emergencyRewardWithdraw(address,uint256)": { + "params": { + "_amount": "Amount of token to withdraw", + "_tokenAddress": "Reward token address to withdraw" + } + }, + "safeRewardTransfer(address,address,uint256)": { + "details": "Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.", + "params": { + "_amount": "Amount to transfer", + "_to": "Destination address of the reward", + "token": "Reward token to transfer" + } + }, + "setNewOwner(address)": { + "params": { + "_owner": "The address of the owner to set Only callable admin" + } + }, + "setPendingAdmin(address)": { + "params": { + "_admin": "Propose an account as admin of the XVS store" + } + }, + "setRewardToken(address,bool)": { + "params": { + "_tokenAddress": "The address of a token to set as active or inactive", + "status": "Set whether a reward token is active or not" + } + } + }, + "title": "XVS Store" + }, + "userdoc": { + "methods": { + "acceptAdmin()": { + "notice": "Allows an account that is pending as admin to accept the role nly calllable by the pending admin" + }, + "emergencyRewardWithdraw(address,uint256)": { + "notice": "Security function to allow the owner of the contract to withdraw from the contract" + }, + "safeRewardTransfer(address,address,uint256)": { + "notice": "Safely transfer rewards. Only active reward tokens can be sent using this function. Only callable by owner" + }, + "setNewOwner(address)": { + "notice": "Set the contract owner" + }, + "setPendingAdmin(address)": { + "notice": "Allows the admin to propose a new admin Only callable admin" + }, + "setRewardToken(address,bool)": { + "notice": "Set or disable a reward token" + } + }, + "notice": "XVS Store responsible for distributing XVS rewards" + }, + "storageLayout": { + "storage": [ + { + "astId": 30838, + "contract": "contracts/XVSVault/XVSStore.sol:XVSStore", + "label": "admin", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 30840, + "contract": "contracts/XVSVault/XVSStore.sol:XVSStore", + "label": "pendingAdmin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 30842, + "contract": "contracts/XVSVault/XVSStore.sol:XVSStore", + "label": "owner", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 30846, + "contract": "contracts/XVSVault/XVSStore.sol:XVSStore", + "label": "rewardTokens", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_bool)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + } + } + } +} diff --git a/deployments/opsepolia/XVSVaultProxy.json b/deployments/opsepolia/XVSVaultProxy.json new file mode 100644 index 000000000..e6bd93896 --- /dev/null +++ b/deployments/opsepolia/XVSVaultProxy.json @@ -0,0 +1,352 @@ +{ + "address": "0x4d344e48F02234E82D7D1dB84d0A4A18Aa43Dacc", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "NewImplementation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingImplementation", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "NewPendingImplementation", + "type": "event" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptImplementation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "_setPendingAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPendingImplementation", + "type": "address" + } + ], + "name": "_setPendingImplementation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x12a662e7448db17e24e43ae473bb35a1fee7f6c74b0c35249a1ae46c18651c09", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0x4d344e48F02234E82D7D1dB84d0A4A18Aa43Dacc", + "transactionIndex": 7, + "gasUsed": "394440", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xc806c50b9c22084c3de06ddbf767fcfd357045a82fc6093ed20c0754458c0da9", + "transactionHash": "0x12a662e7448db17e24e43ae473bb35a1fee7f6c74b0c35249a1ae46c18651c09", + "logs": [], + "blockNumber": 14184211, + "cumulativeGasUsed": "5014617", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "1ccea21f99f9d0cf6dcde9df90c8a652", + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"error\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"info\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"detail\",\"type\":\"uint256\"}],\"name\":\"Failure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"NewAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"NewImplementation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"NewPendingAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingImplementation\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingImplementation\",\"type\":\"address\"}],\"name\":\"NewPendingImplementation\",\"type\":\"event\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"constant\":false,\"inputs\":[],\"name\":\"_acceptAdmin\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"_acceptImplementation\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"_setPendingAdmin\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingImplementation\",\"type\":\"address\"}],\"name\":\"_setPendingImplementation\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingXVSVaultImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"methods\":{\"_acceptAdmin()\":{\"details\":\"Admin function for pending admin to accept role and update admin\",\"return\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"},\"_acceptImplementation()\":{\"details\":\"Admin function for new implementation to accept it's role as implementation\",\"return\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"},\"_setPendingAdmin(address)\":{\"details\":\"Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\",\"params\":{\"newPendingAdmin\":\"New pending admin.\"},\"return\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"title\":\"XVS Vault Proxy\"},\"userdoc\":{\"methods\":{\"_acceptAdmin()\":{\"notice\":\"Accepts transfer of admin rights. msg.sender must be pendingAdmin\"},\"_acceptImplementation()\":{\"notice\":\"Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\"},\"_setPendingAdmin(address)\":{\"notice\":\"Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\"},\"_setPendingImplementation(address)\":{\"notice\":\"* Admin Functions **\"}},\"notice\":\"XVS Vault Proxy contract\"}},\"settings\":{\"compilationTarget\":{\"contracts/XVSVault/XVSVaultProxy.sol\":\"XVSVaultProxy\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/Tokens/Prime/IPrime.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.5.16;\\npragma experimental ABIEncoderV2;\\n\\n/**\\n * @title IPrime\\n * @author Venus\\n * @notice Interface for Prime Token\\n */\\ninterface IPrime {\\n /**\\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\\n * @param user the account address whose balance was updated\\n */\\n function xvsUpdated(address user) external;\\n\\n /**\\n * @notice accrues interest and updates score for an user for a specific market\\n * @param user the account address for which to accrue interest and update score\\n * @param market the market for which to accrue interest and update score\\n */\\n function accrueInterestAndUpdateScore(address user, address market) external;\\n\\n /**\\n * @notice Distributes income from market since last distribution\\n * @param vToken the market for which to distribute the income\\n */\\n function accrueInterest(address vToken) external;\\n\\n /**\\n * @notice Returns if user is a prime holder\\n * @param isPrimeHolder returns if the user is a prime holder\\n */\\n function isUserPrimeHolder(address user) external view returns (bool isPrimeHolder);\\n}\\n\",\"keccak256\":\"0x58861c0c05b8757f1a5d50b107eff479c8680878e6aa51bc93af420caf73f500\"},\"contracts/Utils/IBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\n/**\\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\\n * the optional functions; to access them see {BEP20Detailed}.\\n */\\ninterface IBEP20 {\\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 `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\\n\\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\",\"keccak256\":\"0x839b08895eb1ad83502d3631e8e9e3a856d2a8c63c46f070d604af7b26c62c07\"},\"contracts/Utils/SafeMath.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add(a, b, \\\"SafeMath: addition overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub(a, b, \\\"SafeMath: subtraction overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n uint256 c = a - b;\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) {\\n return 0;\\n }\\n\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div(a, b, \\\"SafeMath: division by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n // Solidity only automatically asserts when dividing by 0\\n require(b > 0, errorMessage);\\n uint256 c = a / b;\\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mod(a, b, \\\"SafeMath: modulo by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts with custom message when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b != 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x9431fd772ed4abc038cdfe9ce6c0066897bd1685ad45848748d1952935d5b8ef\"},\"contracts/XVSVault/XVSVaultErrorReporter.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\ncontract XVSVaultErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint error, uint info, uint detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint) {\\n emit Failure(uint(err), uint(info), 0);\\n\\n return uint(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\\n emit Failure(uint(err), uint(info), opaqueError);\\n\\n return uint(err);\\n }\\n}\\n\",\"keccak256\":\"0xa79877a281d024f0d03dbf1842a36a972ee6c1aa36ba93e3d646726d40684a26\"},\"contracts/XVSVault/XVSVaultProxy.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"./XVSVaultStorage.sol\\\";\\nimport \\\"./XVSVaultErrorReporter.sol\\\";\\n\\n/**\\n * @title XVS Vault Proxy\\n * @author Venus\\n * @notice XVS Vault Proxy contract\\n */\\ncontract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter {\\n /**\\n * @notice Emitted when pendingXVSVaultImplementation is changed\\n */\\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\\n\\n /**\\n * @notice Emitted when pendingXVSVaultImplementation is accepted, which means XVS Vault implementation is updated\\n */\\n event NewImplementation(address oldImplementation, address newImplementation);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor() public {\\n // Set admin to caller\\n admin = msg.sender;\\n }\\n\\n /*** Admin Functions ***/\\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\\n if (msg.sender != admin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\\n }\\n\\n address oldPendingImplementation = pendingXVSVaultImplementation;\\n\\n pendingXVSVaultImplementation = newPendingImplementation;\\n\\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\\n * @dev Admin function for new implementation to accept it's role as implementation\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptImplementation() public returns (uint) {\\n // Check caller is pendingImplementation\\n if (msg.sender != pendingXVSVaultImplementation) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldImplementation = implementation;\\n address oldPendingImplementation = pendingXVSVaultImplementation;\\n\\n implementation = pendingXVSVaultImplementation;\\n\\n pendingXVSVaultImplementation = address(0);\\n\\n emit NewImplementation(oldImplementation, implementation);\\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\\n // Check caller = admin\\n if (msg.sender != admin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n // Save current value, if any, for inclusion in log\\n address oldPendingAdmin = pendingAdmin;\\n\\n // Store pendingAdmin with value newPendingAdmin\\n pendingAdmin = newPendingAdmin;\\n\\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint) {\\n // Check caller is pendingAdmin\\n if (msg.sender != pendingAdmin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n // Store admin with value pendingAdmin\\n admin = pendingAdmin;\\n\\n // Clear the pending value\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @dev Delegates execution to an implementation contract.\\n * It returns to the external caller whatever the implementation returns\\n * or forwards reverts.\\n */\\n function() external payable {\\n // delegate all other functions to current implementation\\n (bool success, ) = implementation.delegatecall(msg.data);\\n\\n assembly {\\n let free_mem_ptr := mload(0x40)\\n returndatacopy(free_mem_ptr, 0, returndatasize)\\n\\n switch success\\n case 0 {\\n revert(free_mem_ptr, returndatasize)\\n }\\n default {\\n return(free_mem_ptr, returndatasize)\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb39af917833659fe38f2f76924deda420babed8259b27741dc6cb402ade4d124\"},\"contracts/XVSVault/XVSVaultStorage.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"../Utils/SafeMath.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\nimport \\\"../Tokens/Prime/IPrime.sol\\\";\\n\\ncontract XVSVaultAdminStorage {\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Active brains of XVS Vault\\n */\\n address public implementation;\\n\\n /**\\n * @notice Pending brains of XVS Vault\\n */\\n address public pendingXVSVaultImplementation;\\n}\\n\\ncontract XVSVaultStorageV1 is XVSVaultAdminStorage {\\n /// @notice Guard variable for re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @notice The reward token store\\n address public xvsStore;\\n\\n /// @notice The xvs token address\\n address public xvsAddress;\\n\\n // Reward tokens created per block or second indentified by reward token address.\\n mapping(address => uint256) public rewardTokenAmountsPerBlockOrSecond;\\n\\n /// @notice Info of each user.\\n struct UserInfo {\\n uint256 amount;\\n uint256 rewardDebt;\\n uint256 pendingWithdrawals;\\n }\\n\\n // Info of each pool.\\n struct PoolInfo {\\n IBEP20 token; // Address of token contract to stake.\\n uint256 allocPoint; // How many allocation points assigned to this pool.\\n uint256 lastRewardBlockOrSecond; // Last block number or second that reward tokens distribution occurs.\\n uint256 accRewardPerShare; // Accumulated per share, times 1e12. See below.\\n uint256 lockPeriod; // Min time between withdrawal request and its execution.\\n }\\n\\n // Infomation about a withdrawal request\\n struct WithdrawalRequest {\\n uint256 amount;\\n uint128 lockedUntil;\\n uint128 afterUpgrade;\\n }\\n\\n // Info of each user that stakes tokens.\\n mapping(address => mapping(uint256 => mapping(address => UserInfo))) internal userInfos;\\n\\n // Info of each pool.\\n mapping(address => PoolInfo[]) public poolInfos;\\n\\n // Total allocation points. Must be the sum of all allocation points in all pools.\\n mapping(address => uint256) public totalAllocPoints;\\n\\n // Info of requested but not yet executed withdrawals\\n mapping(address => mapping(uint256 => mapping(address => WithdrawalRequest[]))) internal withdrawalRequests;\\n\\n /// @notice DEPRECATED A record of each accounts delegate (before the voting power fix)\\n mapping(address => address) private __oldDelegatesSlot;\\n\\n /// @notice A checkpoint for marking number of votes from a given block or second\\n struct Checkpoint {\\n uint32 fromBlockOrSecond;\\n uint96 votes;\\n }\\n\\n /// @notice DEPRECATED A record of votes checkpoints for each account, by index (before the voting power fix)\\n mapping(address => mapping(uint32 => Checkpoint)) private __oldCheckpointsSlot;\\n\\n /// @notice DEPRECATED The number of checkpoints for each account (before the voting power fix)\\n mapping(address => uint32) private __oldNumCheckpointsSlot;\\n\\n /// @notice A record of states for signing / validating signatures\\n mapping(address => uint) public nonces;\\n\\n /// @notice The EIP-712 typehash for the contract's domain\\n bytes32 public constant DOMAIN_TYPEHASH =\\n keccak256(\\\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\\\");\\n\\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\\\");\\n}\\n\\ncontract XVSVaultStorage is XVSVaultStorageV1 {\\n /// @notice A record of each accounts delegate\\n mapping(address => address) public delegates;\\n\\n /// @notice A record of votes checkpoints for each account, by index\\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\\n\\n /// @notice The number of checkpoints for each account\\n mapping(address => uint32) public numCheckpoints;\\n\\n /// @notice Tracks pending withdrawals for all users for a particular reward token and pool id\\n mapping(address => mapping(uint256 => uint256)) public totalPendingWithdrawals;\\n\\n /// @notice pause indicator for Vault\\n bool public vaultPaused;\\n\\n /// @notice if the token is added to any of the pools\\n mapping(address => bool) public isStakedToken;\\n\\n /// @notice Amount we owe to users because of failed transfer attempts\\n mapping(address => mapping(address => uint256)) public pendingRewardTransfers;\\n\\n /// @notice Prime token contract address\\n IPrime public primeToken;\\n\\n /// @notice Reward token for which prime token is issued for staking\\n address public primeRewardToken;\\n\\n /// @notice Pool ID for which prime token is issued for staking\\n uint256 public primePoolId;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[46] private __gap;\\n}\\n\",\"keccak256\":\"0xb09f9295c41bdac1350a3607f2b4ea326cb295a6d08f4145bc33ff87844cd02b\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b031916331790556105c3806100326000396000f3fe60806040526004361061007b5760003560e01c8063de0368b21161004e578063de0368b21461019e578063e992a041146101b3578063e9c714f2146101e6578063f851a440146101fb5761007b565b806326782247146100fe5780635c60da1b1461012f578063b71d1a0c14610144578063c1e8033414610189575b6002546040516000916001600160a01b031690829036908083838082843760405192019450600093509091505080830381855af49150503d80600081146100de576040519150601f19603f3d011682016040523d82523d6000602084013e6100e3565b606091505b505090506040513d6000823e8180156100fa573d82f35b3d82fd5b34801561010a57600080fd5b50610113610210565b604080516001600160a01b039092168252519081900360200190f35b34801561013b57600080fd5b5061011361021f565b34801561015057600080fd5b506101776004803603602081101561016757600080fd5b50356001600160a01b031661022e565b60408051918252519081900360200190f35b34801561019557600080fd5b506101776102bf565b3480156101aa57600080fd5b506101136103a4565b3480156101bf57600080fd5b50610177600480360360208110156101d657600080fd5b50356001600160a01b03166103b3565b3480156101f257600080fd5b50610177610437565b34801561020757600080fd5b50610113610512565b6001546001600160a01b031681565b6002546001600160a01b031681565b600080546001600160a01b031633146102545761024d60016002610521565b90506102ba565b600180546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a160005b9150505b919050565b6003546000906001600160a01b031633146102e6576102df600180610521565b90506103a1565b60028054600380546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a92908290030190a1600354604080516001600160a01b038085168252909216602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160005b925050505b90565b6003546001600160a01b031681565b600080546001600160a01b031633146103d25761024d60016003610521565b600380546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160006102b6565b6001546000906001600160a01b03163314610458576102df60016000610521565b60008054600180546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600154604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a1600061039c565b6000546001600160a01b031681565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083600181111561055057fe5b83600381111561055c57fe5b604080519283526020830191909152600082820152519081900360600190a182600181111561058757fe5b939250505056fea265627a7a7231582084fdc8ea05652a3963f2e50c5c1aa2b7bce63ac2749395e3dffd6f658334c6ae64736f6c63430005100032", + "deployedBytecode": "0x60806040526004361061007b5760003560e01c8063de0368b21161004e578063de0368b21461019e578063e992a041146101b3578063e9c714f2146101e6578063f851a440146101fb5761007b565b806326782247146100fe5780635c60da1b1461012f578063b71d1a0c14610144578063c1e8033414610189575b6002546040516000916001600160a01b031690829036908083838082843760405192019450600093509091505080830381855af49150503d80600081146100de576040519150601f19603f3d011682016040523d82523d6000602084013e6100e3565b606091505b505090506040513d6000823e8180156100fa573d82f35b3d82fd5b34801561010a57600080fd5b50610113610210565b604080516001600160a01b039092168252519081900360200190f35b34801561013b57600080fd5b5061011361021f565b34801561015057600080fd5b506101776004803603602081101561016757600080fd5b50356001600160a01b031661022e565b60408051918252519081900360200190f35b34801561019557600080fd5b506101776102bf565b3480156101aa57600080fd5b506101136103a4565b3480156101bf57600080fd5b50610177600480360360208110156101d657600080fd5b50356001600160a01b03166103b3565b3480156101f257600080fd5b50610177610437565b34801561020757600080fd5b50610113610512565b6001546001600160a01b031681565b6002546001600160a01b031681565b600080546001600160a01b031633146102545761024d60016002610521565b90506102ba565b600180546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a160005b9150505b919050565b6003546000906001600160a01b031633146102e6576102df600180610521565b90506103a1565b60028054600380546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a92908290030190a1600354604080516001600160a01b038085168252909216602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160005b925050505b90565b6003546001600160a01b031681565b600080546001600160a01b031633146103d25761024d60016003610521565b600380546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160006102b6565b6001546000906001600160a01b03163314610458576102df60016000610521565b60008054600180546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600154604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a1600061039c565b6000546001600160a01b031681565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083600181111561055057fe5b83600381111561055c57fe5b604080519283526020830191909152600082820152519081900360600190a182600181111561058757fe5b939250505056fea265627a7a7231582084fdc8ea05652a3963f2e50c5c1aa2b7bce63ac2749395e3dffd6f658334c6ae64736f6c63430005100032", + "devdoc": { + "author": "Venus", + "methods": { + "_acceptAdmin()": { + "details": "Admin function for pending admin to accept role and update admin", + "return": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + }, + "_acceptImplementation()": { + "details": "Admin function for new implementation to accept it's role as implementation", + "return": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + }, + "_setPendingAdmin(address)": { + "details": "Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.", + "params": { + "newPendingAdmin": "New pending admin." + }, + "return": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "title": "XVS Vault Proxy" + }, + "userdoc": { + "methods": { + "_acceptAdmin()": { + "notice": "Accepts transfer of admin rights. msg.sender must be pendingAdmin" + }, + "_acceptImplementation()": { + "notice": "Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation" + }, + "_setPendingAdmin(address)": { + "notice": "Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer." + }, + "_setPendingImplementation(address)": { + "notice": "* Admin Functions **" + } + }, + "notice": "XVS Vault Proxy contract" + }, + "storageLayout": { + "storage": [ + { + "astId": 34484, + "contract": "contracts/XVSVault/XVSVaultProxy.sol:XVSVaultProxy", + "label": "admin", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 34486, + "contract": "contracts/XVSVault/XVSVaultProxy.sol:XVSVaultProxy", + "label": "pendingAdmin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 34488, + "contract": "contracts/XVSVault/XVSVaultProxy.sol:XVSVaultProxy", + "label": "implementation", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 34490, + "contract": "contracts/XVSVault/XVSVaultProxy.sol:XVSVaultProxy", + "label": "pendingXVSVaultImplementation", + "offset": 0, + "slot": "3", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + } + } + } +} diff --git a/deployments/opsepolia/XVSVaultProxy_Implementation.json b/deployments/opsepolia/XVSVaultProxy_Implementation.json new file mode 100644 index 000000000..78d8e02ae --- /dev/null +++ b/deployments/opsepolia/XVSVaultProxy_Implementation.json @@ -0,0 +1,2572 @@ +{ + "address": "0x7A02458c1c1504Abf37160401A5020ED003ba347", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Claim", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ExecutedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IPrime", + "name": "oldPrimeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IPrime", + "name": "newPrimeToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldPrimeRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPrimeRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldPrimePoolId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPrimePoolId", + "type": "uint256" + } + ], + "name": "NewPrimeToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "allocPoints", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardPerBlockOrSecond", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lockPeriod", + "type": "uint256" + } + ], + "name": "PoolAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldAllocPoints", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newAllocPoints", + "type": "uint256" + } + ], + "name": "PoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RequestedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldReward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReward", + "type": "uint256" + } + ], + "name": "RewardAmountUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldXvs", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldStore", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newXvs", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newStore", + "type": "address" + } + ], + "name": "StoreUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "userAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldOwedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newOwedAmount", + "type": "uint256" + } + ], + "name": "VaultDebtUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "VaultPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "VaultResumed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "pid", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldPeriod", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPeriod", + "type": "uint256" + } + ], + "name": "WithdrawalLockingPeriodUpdated", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_LOCK_PERIOD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SECONDS_PER_YEAR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract XVSVaultProxy", + "name": "xvsVaultProxy", + "type": "address" + } + ], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV5", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_allocPoint", + "type": "uint256" + }, + { + "internalType": "contract IBEP20", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rewardPerBlockOrSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_lockPeriod", + "type": "uint256" + } + ], + "name": "add", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "blocksOrSecondsPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "fromBlockOrSecond", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "claim", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "delegateBySig", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "executeWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlockNumberOrTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getCurrentVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getEligibleWithdrawalAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "withdrawalAmount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumberOrSecond", + "type": "uint256" + } + ], + "name": "getPriorVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getRequestedAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getUserInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardDebt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pendingWithdrawals", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "getWithdrawalRequests", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "lockedUntil", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "afterUpgrade", + "type": "uint128" + } + ], + "internalType": "struct XVSVaultStorageV1.WithdrawalRequest[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "timeBased_", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "blocksPerYear_", + "type": "uint256" + } + ], + "name": "initializeTimeManager", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isStakedToken", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isTimeBased", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "pause", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "pendingReward", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pendingRewardTransfers", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "pendingWithdrawalsBeforeUpgrade", + "outputs": [ + { + "internalType": "uint256", + "name": "beforeUpgradeWithdrawalAmount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "poolInfos", + "outputs": [ + { + "internalType": "contract IBEP20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allocPoint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastRewardBlockOrSecond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "accRewardPerShare", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lockPeriod", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + } + ], + "name": "poolLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primePoolId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primeRewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "primeToken", + "outputs": [ + { + "internalType": "contract IPrime", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "requestWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "resume", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + } + ], + "name": "rewardTokenAmountsPerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardTokenAmountsPerBlockOrSecond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_allocPoint", + "type": "uint256" + } + ], + "name": "set", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newAccessControlAddress", + "type": "address" + } + ], + "name": "setAccessControl", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract IPrime", + "name": "_primeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_primeRewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_primePoolId", + "type": "uint256" + } + ], + "name": "setPrimeToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_rewardAmount", + "type": "uint256" + } + ], + "name": "setRewardAmountPerBlockOrSecond", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newPeriod", + "type": "uint256" + } + ], + "name": "setWithdrawalLockingPeriod", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_xvs", + "type": "address" + }, + { + "internalType": "address", + "name": "_xvsStore", + "type": "address" + } + ], + "name": "setXvsStore", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "totalAllocPoints", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "totalPendingWithdrawals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_pid", + "type": "uint256" + } + ], + "name": "updatePool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaultPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsStore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x38ff691e1f5f4a1e7a47c1678c597e068162ea63912168d8f99551ec4e35c959", + "receipt": { + "to": null, + "from": "0x476c66CA1fE0E8AbB45c8566D635DcA9dC930F73", + "contractAddress": "0x7A02458c1c1504Abf37160401A5020ED003ba347", + "transactionIndex": 5, + "gasUsed": "4916687", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xf4dfef0b7ebe26cedb24e787e8b731da081945404e3715c727e454f824d21f25", + "transactionHash": "0x38ff691e1f5f4a1e7a47c1678c597e068162ea63912168d8f99551ec4e35c959", + "logs": [], + "blockNumber": 14184207, + "cumulativeGasUsed": "8197104", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "1ccea21f99f9d0cf6dcde9df90c8a652", + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Claim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"fromDelegate\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"toDelegate\",\"type\":\"address\"}],\"name\":\"DelegateChangedV2\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"DelegateVotesChangedV2\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ExecutedWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAccessControlManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAccessControlManager\",\"type\":\"address\"}],\"name\":\"NewAccessControlManager\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IPrime\",\"name\":\"oldPrimeToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IPrime\",\"name\":\"newPrimeToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPrimeRewardToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPrimeRewardToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldPrimePoolId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newPrimePoolId\",\"type\":\"uint256\"}],\"name\":\"NewPrimeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"allocPoints\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rewardPerBlockOrSecond\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lockPeriod\",\"type\":\"uint256\"}],\"name\":\"PoolAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAllocPoints\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAllocPoints\",\"type\":\"uint256\"}],\"name\":\"PoolUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RequestedWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldReward\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newReward\",\"type\":\"uint256\"}],\"name\":\"RewardAmountUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldXvs\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldStore\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newXvs\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newStore\",\"type\":\"address\"}],\"name\":\"StoreUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldOwedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newOwedAmount\",\"type\":\"uint256\"}],\"name\":\"VaultDebtUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"VaultPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"VaultResumed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newPeriod\",\"type\":\"uint256\"}],\"name\":\"WithdrawalLockingPeriodUpdated\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[],\"name\":\"DELEGATION_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"DOMAIN_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MAX_LOCK_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"SECONDS_PER_YEAR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"contract XVSVaultProxy\",\"name\":\"xvsVaultProxy\",\"type\":\"address\"}],\"name\":\"_become\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"accessControlManager\",\"outputs\":[{\"internalType\":\"contract IAccessControlManagerV5\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_allocPoint\",\"type\":\"uint256\"},{\"internalType\":\"contract IBEP20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_rewardPerBlockOrSecond\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_lockPeriod\",\"type\":\"uint256\"}],\"name\":\"add\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"blocksOrSecondsPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"checkpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"fromBlockOrSecond\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"}],\"name\":\"claim\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"delegate\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"delegateBySig\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"delegates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"}],\"name\":\"executeWithdrawal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getBlockNumberOrTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getCurrentVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getEligibleWithdrawalAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawalAmount\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumberOrSecond\",\"type\":\"uint256\"}],\"name\":\"getPriorVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getRequestedAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getUserInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardDebt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"pendingWithdrawals\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"getWithdrawalRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"lockedUntil\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"afterUpgrade\",\"type\":\"uint128\"}],\"internalType\":\"struct XVSVaultStorageV1.WithdrawalRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bool\",\"name\":\"timeBased_\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"blocksPerYear_\",\"type\":\"uint256\"}],\"name\":\"initializeTimeManager\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isStakedToken\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isTimeBased\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"numCheckpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"pendingReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pendingRewardTransfers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"pendingWithdrawalsBeforeUpgrade\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"beforeUpgradeWithdrawalAmount\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pendingXVSVaultImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"poolInfos\",\"outputs\":[{\"internalType\":\"contract IBEP20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"allocPoint\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"lastRewardBlockOrSecond\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"accRewardPerShare\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"lockPeriod\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"}],\"name\":\"poolLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"primePoolId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"primeRewardToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"primeToken\",\"outputs\":[{\"internalType\":\"contract IPrime\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"requestWithdrawal\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"resume\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"}],\"name\":\"rewardTokenAmountsPerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"rewardTokenAmountsPerBlockOrSecond\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_allocPoint\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAccessControlAddress\",\"type\":\"address\"}],\"name\":\"setAccessControl\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"contract IPrime\",\"name\":\"_primeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_primeRewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_primePoolId\",\"type\":\"uint256\"}],\"name\":\"setPrimeToken\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_rewardAmount\",\"type\":\"uint256\"}],\"name\":\"setRewardAmountPerBlockOrSecond\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_newPeriod\",\"type\":\"uint256\"}],\"name\":\"setWithdrawalLockingPeriod\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_xvs\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_xvsStore\",\"type\":\"address\"}],\"name\":\"setXvsStore\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"totalAllocPoints\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"totalPendingWithdrawals\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_rewardToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_pid\",\"type\":\"uint256\"}],\"name\":\"updatePool\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"vaultPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"xvsAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"xvsStore\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Venus\",\"methods\":{\"add(address,uint256,address,uint256,uint256)\":{\"details\":\"This vault DOES NOT support deflationary tokens \\u2014 it expects that the amount of transferred tokens would equal the actually deposited amount. In practice this means that this vault DOES NOT support USDT and similar tokens (that do not provide these guarantees).\",\"params\":{\"_allocPoint\":\"Number of allocation points assigned to this pool\",\"_lockPeriod\":\"A period between withdrawal request and a moment when it's executable\",\"_rewardPerBlockOrSecond\":\"Initial reward per block or second, in terms of _rewardToken\",\"_rewardToken\":\"Reward token address\",\"_token\":\"Staked token\"}},\"claim(address,address,uint256)\":{\"params\":{\"_account\":\"The account for which to claim rewards\",\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\"}},\"delegate(address)\":{\"params\":{\"delegatee\":\"The address to delegate votes to\"}},\"delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)\":{\"params\":{\"delegatee\":\"The address to delegate votes to\",\"expiry\":\"The time at which to expire the signature\",\"nonce\":\"The contract state required to match the signature\",\"r\":\"Half of the ECDSA signature pair\",\"s\":\"Half of the ECDSA signature pair\",\"v\":\"The recovery byte of the signature\"}},\"deposit(address,uint256,uint256)\":{\"params\":{\"_amount\":\"The amount to deposit to vault\",\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\"}},\"executeWithdrawal(address,uint256)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\"}},\"getBlockNumberOrTimestamp()\":{\"details\":\"Function to simply retrieve block number or block timestamp\",\"return\":\"Current block number or block timestamp\"},\"getCurrentVotes(address)\":{\"params\":{\"account\":\"The address to get votes balance\"},\"return\":\"The number of current votes for `account`\"},\"getEligibleWithdrawalAmount(address,uint256,address)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\",\"_user\":\"The User Address\"},\"return\":\"withdrawalAmount Amount that the user can withdraw\"},\"getPriorVotes(address,uint256)\":{\"params\":{\"account\":\"The address of the account to check\",\"blockNumberOrSecond\":\"The block number or second to get the vote balance at\"},\"return\":\"The balance that user staked\"},\"getRequestedAmount(address,uint256,address)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\",\"_user\":\"The User Address\"},\"return\":\"Total amount of requested but not yet executed withdrawals (including both executable and locked ones)\"},\"getUserInfo(address,uint256,address)\":{\"params\":{\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\",\"_user\":\"User address\"},\"return\":\"amount Deposited amountrewardDebt Reward debt (technical value used to track past payouts)pendingWithdrawals Requested but not yet executed withdrawals\"},\"getWithdrawalRequests(address,uint256,address)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\",\"_user\":\"The User Address\"},\"return\":\"An array of withdrawal requests\"},\"initializeTimeManager(bool,uint256)\":{\"details\":\"Initializes the contract to use either blocks or seconds\",\"params\":{\"blocksPerYear_\":\"The number of blocks per year\",\"timeBased_\":\"A boolean indicating whether the contract is based on time or block If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\"}},\"pendingReward(address,uint256,address)\":{\"params\":{\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\",\"_user\":\"User address\"},\"return\":\"Reward the user is eligible for in this pool, in terms of _rewardToken\"},\"pendingWithdrawalsBeforeUpgrade(address,uint256,address)\":{\"params\":{\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\",\"_user\":\"The address of the user\"},\"return\":\"beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade\"},\"poolLength(address)\":{\"params\":{\"rewardToken\":\"Reward token address\"},\"return\":\"Number of pools that distribute the specified token as a reward\"},\"requestWithdrawal(address,uint256,uint256)\":{\"params\":{\"_amount\":\"The amount to withdraw from the vault\",\"_pid\":\"The Pool Index\",\"_rewardToken\":\"The Reward Token Address\"}},\"rewardTokenAmountsPerBlock(address)\":{\"params\":{\"_rewardToken\":\"Reward token address\"},\"return\":\"Number of reward tokens created per block or second\"},\"set(address,uint256,uint256)\":{\"params\":{\"_allocPoint\":\"Number of allocation points assigned to this pool\",\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\"}},\"setAccessControl(address)\":{\"details\":\"Admin function to set the access control address\",\"params\":{\"newAccessControlAddress\":\"New address for the access control\"}},\"setPrimeToken(address,address,uint256)\":{\"params\":{\"_primePoolId\":\"pool id for reward\",\"_primeRewardToken\":\"address of reward token\",\"_primeToken\":\"address of the prime token contract\"}},\"setRewardAmountPerBlockOrSecond(address,uint256)\":{\"params\":{\"_rewardAmount\":\"Number of allocation points assigned to this pool\",\"_rewardToken\":\"Reward token address\"}},\"setWithdrawalLockingPeriod(address,uint256,uint256)\":{\"params\":{\"_newPeriod\":\"New lock period\",\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\"}},\"updatePool(address,uint256)\":{\"params\":{\"_pid\":\"Pool index\",\"_rewardToken\":\"Reward token address\"}}},\"title\":\"XVS Vault\"},\"userdoc\":{\"methods\":{\"_become(address)\":{\"notice\":\"* Admin Functions **\"},\"accessControlManager()\":{\"notice\":\"Returns the address of the access control manager contract\"},\"add(address,uint256,address,uint256,uint256)\":{\"notice\":\"Add a new token pool\"},\"claim(address,address,uint256)\":{\"notice\":\"Claim rewards for pool\"},\"constructor\":\"XVSVault constructor\",\"delegate(address)\":{\"notice\":\"Delegate votes from `msg.sender` to `delegatee`\"},\"delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"Delegates votes from signatory to `delegatee`\"},\"deposit(address,uint256,uint256)\":{\"notice\":\"Deposit XVSVault for XVS allocation\"},\"executeWithdrawal(address,uint256)\":{\"notice\":\"Execute withdrawal to XVSVault for XVS allocation\"},\"getCurrentVotes(address)\":{\"notice\":\"Gets the current votes balance for `account`\"},\"getEligibleWithdrawalAmount(address,uint256,address)\":{\"notice\":\"Get unlocked withdrawal amount\"},\"getPriorVotes(address,uint256)\":{\"notice\":\"Determine the xvs stake balance for an account\"},\"getRequestedAmount(address,uint256,address)\":{\"notice\":\"Get requested amount\"},\"getUserInfo(address,uint256,address)\":{\"notice\":\"Get user info with reward token address and pid\"},\"getWithdrawalRequests(address,uint256,address)\":{\"notice\":\"Returns the array of withdrawal requests that have not been executed yet\"},\"pause()\":{\"notice\":\"Pauses vault\"},\"pendingReward(address,uint256,address)\":{\"notice\":\"View function to see pending XVSs on frontend\"},\"pendingWithdrawalsBeforeUpgrade(address,uint256,address)\":{\"notice\":\"Gets the total pending withdrawal amount of a user before upgrade\"},\"poolLength(address)\":{\"notice\":\"Returns the number of pools with the specified reward token\"},\"requestWithdrawal(address,uint256,uint256)\":{\"notice\":\"Request withdrawal to XVSVault for XVS allocation\"},\"resume()\":{\"notice\":\"Resume vault\"},\"rewardTokenAmountsPerBlock(address)\":{\"notice\":\"Returns the number of reward tokens created per block or second\"},\"set(address,uint256,uint256)\":{\"notice\":\"Update the given pool's reward allocation point\"},\"setAccessControl(address)\":{\"notice\":\"Sets the address of the access control of this contract\"},\"setPrimeToken(address,address,uint256)\":{\"notice\":\"Sets the address of the prime token contract\"},\"setRewardAmountPerBlockOrSecond(address,uint256)\":{\"notice\":\"Update the given reward token's amount per block or second\"},\"setWithdrawalLockingPeriod(address,uint256,uint256)\":{\"notice\":\"Update the lock period after which a requested withdrawal can be executed\"},\"updatePool(address,uint256)\":{\"notice\":\"Update reward variables of the given pool to be up-to-date\"}},\"notice\":\"The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS.\"}},\"settings\":{\"compilationTarget\":{\"contracts/XVSVault/XVSVault.sol\":\"XVSVault\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.5.16;\\n\\nimport \\\"./IAccessControlManagerV5.sol\\\";\\n\\n/**\\n * @title AccessControlledV5\\n * @author Venus\\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.5.16)\\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\\n */\\ncontract AccessControlledV5 {\\n /// @notice Access control manager contract\\n IAccessControlManagerV5 private _accessControlManager;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n\\n /// @notice Emitted when access control manager contract address is changed\\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\\n\\n /**\\n * @notice Returns the address of the access control manager contract\\n */\\n function accessControlManager() external view returns (IAccessControlManagerV5) {\\n return _accessControlManager;\\n }\\n\\n /**\\n * @dev Internal function to set address of AccessControlManager\\n * @param accessControlManager_ The new address of the AccessControlManager\\n */\\n function _setAccessControlManager(address accessControlManager_) internal {\\n require(address(accessControlManager_) != address(0), \\\"invalid acess control manager address\\\");\\n address oldAccessControlManager = address(_accessControlManager);\\n _accessControlManager = IAccessControlManagerV5(accessControlManager_);\\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\\n }\\n\\n /**\\n * @notice Reverts if the call is not allowed by AccessControlManager\\n * @param signature Method signature\\n */\\n function _checkAccessAllowed(string memory signature) internal view {\\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\\n\\n if (!isAllowedToCall) {\\n revert(\\\"Unauthorized\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4b724928650b944935bc91713782a8cf5bbd9cdb98b3e3fedf31e611c7e6df19\"},\"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.5.16;\\n\\n/**\\n * @title IAccessControlManagerV5\\n * @author Venus\\n * @notice Interface implemented by the `AccessControlManagerV5` contract.\\n */\\ninterface IAccessControlManagerV5 {\\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 */\\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 /**\\n * @notice Gives a function call permission to one single account\\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\\n * \\t\\tMay emit a {RoleGranted} event.\\n * @param contractAddress address of contract for which call permissions will be granted\\n * @param functionSig signature e.g. \\\"functionName(uint,bool)\\\"\\n */\\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\\n\\n /**\\n * @notice Revokes an account's permission to a particular function call\\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\\n * \\t\\tMay emit a {RoleRevoked} event.\\n * @param contractAddress address of contract for which call permissions will be revoked\\n * @param functionSig signature e.g. \\\"functionName(uint,bool)\\\"\\n */\\n function revokeCallPermission(\\n address contractAddress,\\n string calldata functionSig,\\n address accountToRevoke\\n ) external;\\n\\n /**\\n * @notice Verifies if the given account can call a praticular contract's function\\n * @dev Since the contract is calling itself this function, we can get contracts address with msg.sender\\n * @param account address (eoa or contract) for which call permissions will be checked\\n * @param functionSig signature e.g. \\\"functionName(uint,bool)\\\"\\n * @return false if the user account cannot call the particular contract function\\n *\\n */\\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\\n\\n function hasPermission(\\n address account,\\n address contractAddress,\\n string calldata functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x3563db4c75f7aa0b8a982bab591907dda192438a2368511b62a9c587a3e54226\"},\"@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.5.16;\\n\\ncontract TimeManagerV5 {\\n /// @dev The approximate number of seconds per year\\n uint256 public constant SECONDS_PER_YEAR = 31_536_000;\\n\\n /// @notice Number of blocks per year or seconds per year\\n uint256 public blocksOrSecondsPerYear;\\n\\n /// @dev Sets true when block timestamp is used\\n bool public isTimeBased;\\n\\n /// @dev Sets true when contract is initialized\\n bool private isInitialized;\\n\\n /// @notice Deprecated slot for _getCurrentSlot function pointer\\n bytes8 private __deprecatedSlot1;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[48] private __gap;\\n\\n /**\\n * @dev Function to simply retrieve block number or block timestamp\\n * @return Current block number or block timestamp\\n */\\n function getBlockNumberOrTimestamp() public view returns (uint256) {\\n return isTimeBased ? _getBlockTimestamp() : _getBlockNumber();\\n }\\n\\n /**\\n * @dev Initializes the contract to use either blocks or seconds\\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\\n * @param blocksPerYear_ The number of blocks per year\\n */\\n function _initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) internal {\\n if (isInitialized) revert(\\\"Already initialized TimeManager\\\");\\n\\n if (!timeBased_ && blocksPerYear_ == 0) {\\n revert(\\\"Invalid blocks per year\\\");\\n }\\n if (timeBased_ && blocksPerYear_ != 0) {\\n revert(\\\"Invalid time based configuration\\\");\\n }\\n\\n isTimeBased = timeBased_;\\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\\n isInitialized = true;\\n }\\n\\n /**\\n * @dev Returns the current timestamp in seconds\\n * @return The current timestamp\\n */\\n function _getBlockTimestamp() private view returns (uint256) {\\n return block.timestamp;\\n }\\n\\n /**\\n * @dev Returns the current block number\\n * @return The current block number\\n */\\n function _getBlockNumber() private view returns (uint256) {\\n return block.number;\\n }\\n}\\n\",\"keccak256\":\"0x0d35813e9a6d4fe7cf466466573ca12b6b378cad8f6da0b36b13e0d428a757f0\"},\"contracts/Tokens/Prime/IPrime.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity ^0.5.16;\\npragma experimental ABIEncoderV2;\\n\\n/**\\n * @title IPrime\\n * @author Venus\\n * @notice Interface for Prime Token\\n */\\ninterface IPrime {\\n /**\\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\\n * @param user the account address whose balance was updated\\n */\\n function xvsUpdated(address user) external;\\n\\n /**\\n * @notice accrues interest and updates score for an user for a specific market\\n * @param user the account address for which to accrue interest and update score\\n * @param market the market for which to accrue interest and update score\\n */\\n function accrueInterestAndUpdateScore(address user, address market) external;\\n\\n /**\\n * @notice Distributes income from market since last distribution\\n * @param vToken the market for which to distribute the income\\n */\\n function accrueInterest(address vToken) external;\\n\\n /**\\n * @notice Returns if user is a prime holder\\n * @param isPrimeHolder returns if the user is a prime holder\\n */\\n function isUserPrimeHolder(address user) external view returns (bool isPrimeHolder);\\n}\\n\",\"keccak256\":\"0x58861c0c05b8757f1a5d50b107eff479c8680878e6aa51bc93af420caf73f500\"},\"contracts/Utils/Address.sol\":{\"content\":\"pragma solidity ^0.5.5;\\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 function isContract(address account) internal view returns (bool) {\\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\\n // for accounts without code, i.e. `keccak256('')`\\n bytes32 codehash;\\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n codehash := extcodehash(account)\\n }\\n return (codehash != accountHash && codehash != 0x0);\\n }\\n\\n /**\\n * @dev Converts an `address` into `address payable`. Note that this is\\n * simply a type cast: the actual underlying value is not changed.\\n *\\n * _Available since v2.4.0._\\n */\\n function toPayable(address account) internal pure returns (address payable) {\\n return address(uint160(account));\\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 * _Available since v2.4.0._\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-call-value\\n // solium-disable-next-line security/no-call-value\\n (bool success, ) = recipient.call.value(amount)(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n}\\n\",\"keccak256\":\"0x3c2ef780599a2ae6913282b982633f07e405a4a9c8511590df571e2b773aef9d\"},\"contracts/Utils/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// Adapted from OpenZeppelin Contracts v4.3.2 (utils/cryptography/ECDSA.sol)\\n\\n// SPDX-Copyright-Text: OpenZeppelin, 2021\\n// SPDX-Copyright-Text: Venus, 2021\\n\\npragma solidity ^0.5.16;\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\ncontract ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n}\\n\",\"keccak256\":\"0xf27d7ad488b72c627370afa6e9acc520d4834a082363d1dc46b5573ac40a2d0a\"},\"contracts/Utils/IBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\n/**\\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\\n * the optional functions; to access them see {BEP20Detailed}.\\n */\\ninterface IBEP20 {\\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 `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\\n\\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\",\"keccak256\":\"0x839b08895eb1ad83502d3631e8e9e3a856d2a8c63c46f070d604af7b26c62c07\"},\"contracts/Utils/SafeBEP20.sol\":{\"content\":\"pragma solidity ^0.5.0;\\n\\nimport \\\"./SafeMath.sol\\\";\\nimport \\\"./IBEP20.sol\\\";\\nimport \\\"./Address.sol\\\";\\n\\n/**\\n * @title SafeBEP20\\n * @dev Wrappers around BEP20 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 SafeBEP20 for BEP20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeBEP20 {\\n using SafeMath for uint256;\\n using Address for address;\\n\\n function safeTransfer(IBEP20 token, address to, uint256 value) internal {\\n callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(IBEP20 token, address from, address to, uint256 value) internal {\\n callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n function safeApprove(IBEP20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeBEP20: approve from non-zero to non-zero allowance\\\"\\n );\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).sub(\\n value,\\n \\\"SafeBEP20: decreased allowance below zero\\\"\\n );\\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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(IBEP20 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.\\n\\n // A Solidity high level call has three parts:\\n // 1. The target address is checked to verify it contains contract code\\n // 2. The call itself is made, and success asserted\\n // 3. The return value is decoded, which in turn checks the size of the returned data.\\n // solhint-disable-next-line max-line-length\\n require(address(token).isContract(), \\\"SafeBEP20: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = address(token).call(data);\\n require(success, \\\"SafeBEP20: low-level call failed\\\");\\n\\n if (returndata.length > 0) {\\n // Return data is optional\\n // solhint-disable-next-line max-line-length\\n require(abi.decode(returndata, (bool)), \\\"SafeBEP20: BEP20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x540ef6ddc47232a59d3ab0e95537f7a7d1c8a36f8dba315b010e60c6487bd768\"},\"contracts/Utils/SafeCast.sol\":{\"content\":\"pragma solidity ^0.5.16;\\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 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 < 2 ** 128, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(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 < 2 ** 64, \\\"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 < 2 ** 32, \\\"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 < 2 ** 16, \\\"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 < 2 ** 8, \\\"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 >= -2 ** 127 && value < 2 ** 127, \\\"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 >= -2 ** 63 && value < 2 ** 63, \\\"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 >= -2 ** 31 && value < 2 ** 31, \\\"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 >= -2 ** 15 && value < 2 ** 15, \\\"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 >= -2 ** 7 && value < 2 ** 7, \\\"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 require(value < 2 ** 255, \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xe6222292bd226980fd73c00eaf3a102c8638777aa3f9c7cd9b0d0fb621da0661\"},\"contracts/Utils/SafeMath.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add(a, b, \\\"SafeMath: addition overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub(a, b, \\\"SafeMath: subtraction overflow\\\");\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n uint256 c = a - b;\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) {\\n return 0;\\n }\\n\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div(a, b, \\\"SafeMath: division by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n // Solidity only automatically asserts when dividing by 0\\n require(b > 0, errorMessage);\\n uint256 c = a / b;\\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\\n\\n return c;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mod(a, b, \\\"SafeMath: modulo by zero\\\");\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * Reverts with custom message when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b != 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x9431fd772ed4abc038cdfe9ce6c0066897bd1685ad45848748d1952935d5b8ef\"},\"contracts/XVSVault/XVSStore.sol\":{\"content\":\"pragma solidity 0.5.16;\\nimport \\\"../Utils/SafeBEP20.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\n\\n/**\\n * @title XVS Store\\n * @author Venus\\n * @notice XVS Store responsible for distributing XVS rewards\\n */\\ncontract XVSStore {\\n using SafeMath for uint256;\\n using SafeBEP20 for IBEP20;\\n\\n /// @notice The Admin Address\\n address public admin;\\n\\n /// @notice The pending admin address\\n address public pendingAdmin;\\n\\n /// @notice The Owner Address\\n address public owner;\\n\\n /// @notice The reward tokens\\n mapping(address => bool) public rewardTokens;\\n\\n /// @notice Emitted when pendingAdmin is changed\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /// @notice Event emitted when admin changed\\n event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);\\n\\n /// @notice Event emitted when owner changed\\n event OwnerTransferred(address indexed oldOwner, address indexed newOwner);\\n\\n constructor() public {\\n admin = msg.sender;\\n }\\n\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"only admin can\\\");\\n _;\\n }\\n\\n modifier onlyOwner() {\\n require(msg.sender == owner, \\\"only owner can\\\");\\n _;\\n }\\n\\n /**\\n * @notice Safely transfer rewards. Only active reward tokens can be sent using this function.\\n * Only callable by owner\\n * @dev Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\\n * @param token Reward token to transfer\\n * @param _to Destination address of the reward\\n * @param _amount Amount to transfer\\n */\\n function safeRewardTransfer(address token, address _to, uint256 _amount) external onlyOwner {\\n require(rewardTokens[token] == true, \\\"only reward token can\\\");\\n\\n if (address(token) != address(0)) {\\n uint256 tokenBalance = IBEP20(token).balanceOf(address(this));\\n if (_amount > tokenBalance) {\\n IBEP20(token).safeTransfer(_to, tokenBalance);\\n } else {\\n IBEP20(token).safeTransfer(_to, _amount);\\n }\\n }\\n }\\n\\n /**\\n * @notice Allows the admin to propose a new admin\\n * Only callable admin\\n * @param _admin Propose an account as admin of the XVS store\\n */\\n function setPendingAdmin(address _admin) external onlyAdmin {\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = _admin;\\n emit NewPendingAdmin(oldPendingAdmin, _admin);\\n }\\n\\n /**\\n * @notice Allows an account that is pending as admin to accept the role\\n * nly calllable by the pending admin\\n */\\n function acceptAdmin() external {\\n require(msg.sender == pendingAdmin, \\\"only pending admin\\\");\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n emit AdminTransferred(oldAdmin, admin);\\n }\\n\\n /**\\n * @notice Set the contract owner\\n * @param _owner The address of the owner to set\\n * Only callable admin\\n */\\n function setNewOwner(address _owner) external onlyAdmin {\\n require(_owner != address(0), \\\"new owner is the zero address\\\");\\n address oldOwner = owner;\\n owner = _owner;\\n emit OwnerTransferred(oldOwner, _owner);\\n }\\n\\n /**\\n * @notice Set or disable a reward token\\n * @param _tokenAddress The address of a token to set as active or inactive\\n * @param status Set whether a reward token is active or not\\n */\\n function setRewardToken(address _tokenAddress, bool status) external {\\n require(msg.sender == admin || msg.sender == owner, \\\"only admin or owner can\\\");\\n rewardTokens[_tokenAddress] = status;\\n }\\n\\n /**\\n * @notice Security function to allow the owner of the contract to withdraw from the contract\\n * @param _tokenAddress Reward token address to withdraw\\n * @param _amount Amount of token to withdraw\\n */\\n function emergencyRewardWithdraw(address _tokenAddress, uint256 _amount) external onlyOwner {\\n IBEP20(_tokenAddress).safeTransfer(address(msg.sender), _amount);\\n }\\n}\\n\",\"keccak256\":\"0x8082f92b13448bd4fa982c93c763439f10fe016a5f3be6d613dfe3cca68501ef\"},\"contracts/XVSVault/XVSVault.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\n\\npragma solidity 0.5.16;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"../Utils/ECDSA.sol\\\";\\nimport \\\"../Utils/SafeBEP20.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\nimport \\\"./XVSVaultStorage.sol\\\";\\nimport \\\"../Tokens/Prime/IPrime.sol\\\";\\nimport \\\"../Utils/SafeCast.sol\\\";\\nimport \\\"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\\\";\\nimport \\\"@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol\\\";\\n\\nimport { XVSStore } from \\\"./XVSStore.sol\\\";\\nimport { XVSVaultProxy } from \\\"./XVSVaultProxy.sol\\\";\\n\\n/**\\n * @title XVS Vault\\n * @author Venus\\n * @notice The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS.\\n */\\ncontract XVSVault is XVSVaultStorage, ECDSA, AccessControlledV5, TimeManagerV5 {\\n using SafeMath for uint256;\\n using SafeCast for uint256;\\n using SafeBEP20 for IBEP20;\\n\\n /// @notice The upper bound for the lock period in a pool, 10 years\\n uint256 public constant MAX_LOCK_PERIOD = 60 * 60 * 24 * 365 * 10;\\n\\n /// @notice Event emitted when deposit\\n event Deposit(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\\n\\n /// @notice Event emitted when execute withrawal\\n event ExecutedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\\n\\n /// @notice Event emitted when request withrawal\\n event RequestedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\\n\\n /// @notice An event thats emitted when an account changes its delegate\\n event DelegateChangedV2(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\\n\\n /// @notice An event thats emitted when a delegate account's vote balance changes\\n event DelegateVotesChangedV2(address indexed delegate, uint previousBalance, uint newBalance);\\n\\n /// @notice An event emitted when the reward store address is updated\\n event StoreUpdated(address oldXvs, address oldStore, address newXvs, address newStore);\\n\\n /// @notice An event emitted when the withdrawal locking period is updated for a pool\\n event WithdrawalLockingPeriodUpdated(address indexed rewardToken, uint indexed pid, uint oldPeriod, uint newPeriod);\\n\\n /// @notice An event emitted when the reward amount per block or second is modified for a pool\\n event RewardAmountUpdated(address indexed rewardToken, uint oldReward, uint newReward);\\n\\n /// @notice An event emitted when a new pool is added\\n event PoolAdded(\\n address indexed rewardToken,\\n uint indexed pid,\\n address indexed token,\\n uint allocPoints,\\n uint rewardPerBlockOrSecond,\\n uint lockPeriod\\n );\\n\\n /// @notice An event emitted when a pool allocation points are updated\\n event PoolUpdated(address indexed rewardToken, uint indexed pid, uint oldAllocPoints, uint newAllocPoints);\\n\\n /// @notice Event emitted when reward claimed\\n event Claim(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\\n\\n /// @notice Event emitted when vault is paused\\n event VaultPaused(address indexed admin);\\n\\n /// @notice Event emitted when vault is resumed after pause\\n event VaultResumed(address indexed admin);\\n\\n /// @notice Event emitted when protocol logs a debt to a user due to insufficient funds for pending reward distribution\\n event VaultDebtUpdated(\\n address indexed rewardToken,\\n address indexed userAddress,\\n uint256 oldOwedAmount,\\n uint256 newOwedAmount\\n );\\n\\n /// @notice Emitted when prime token contract address is changed\\n event NewPrimeToken(\\n IPrime indexed oldPrimeToken,\\n IPrime indexed newPrimeToken,\\n address oldPrimeRewardToken,\\n address newPrimeRewardToken,\\n uint256 oldPrimePoolId,\\n uint256 newPrimePoolId\\n );\\n\\n /**\\n * @notice XVSVault constructor\\n */\\n constructor() public {\\n admin = msg.sender;\\n }\\n\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"only admin can\\\");\\n _;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n */\\n modifier nonReentrant() {\\n require(_notEntered, \\\"re-entered\\\");\\n _notEntered = false;\\n _;\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n\\n /**\\n * @dev Prevents functions to execute when vault is paused.\\n */\\n modifier isActive() {\\n require(!vaultPaused, \\\"Vault is paused\\\");\\n _;\\n }\\n\\n /**\\n * @notice Pauses vault\\n */\\n function pause() external {\\n _checkAccessAllowed(\\\"pause()\\\");\\n require(!vaultPaused, \\\"Vault is already paused\\\");\\n vaultPaused = true;\\n emit VaultPaused(msg.sender);\\n }\\n\\n /**\\n * @notice Resume vault\\n */\\n function resume() external {\\n _checkAccessAllowed(\\\"resume()\\\");\\n require(vaultPaused, \\\"Vault is not paused\\\");\\n vaultPaused = false;\\n emit VaultResumed(msg.sender);\\n }\\n\\n /**\\n * @notice Returns the number of pools with the specified reward token\\n * @param rewardToken Reward token address\\n * @return Number of pools that distribute the specified token as a reward\\n */\\n function poolLength(address rewardToken) external view returns (uint256) {\\n return poolInfos[rewardToken].length;\\n }\\n\\n /**\\n * @notice Returns the number of reward tokens created per block or second\\n * @param _rewardToken Reward token address\\n * @return Number of reward tokens created per block or second\\n */\\n function rewardTokenAmountsPerBlock(address _rewardToken) external view returns (uint256) {\\n return rewardTokenAmountsPerBlockOrSecond[_rewardToken];\\n }\\n\\n /**\\n * @notice Add a new token pool\\n * @dev This vault DOES NOT support deflationary tokens \\u2014 it expects that\\n * the amount of transferred tokens would equal the actually deposited\\n * amount. In practice this means that this vault DOES NOT support USDT\\n * and similar tokens (that do not provide these guarantees).\\n * @param _rewardToken Reward token address\\n * @param _allocPoint Number of allocation points assigned to this pool\\n * @param _token Staked token\\n * @param _rewardPerBlockOrSecond Initial reward per block or second, in terms of _rewardToken\\n * @param _lockPeriod A period between withdrawal request and a moment when it's executable\\n */\\n function add(\\n address _rewardToken,\\n uint256 _allocPoint,\\n IBEP20 _token,\\n uint256 _rewardPerBlockOrSecond,\\n uint256 _lockPeriod\\n ) external {\\n _checkAccessAllowed(\\\"add(address,uint256,address,uint256,uint256)\\\");\\n _ensureNonzeroAddress(_rewardToken);\\n _ensureNonzeroAddress(address(_token));\\n require(address(xvsStore) != address(0), \\\"Store contract address is empty\\\");\\n require(_allocPoint > 0, \\\"Alloc points must not be zero\\\");\\n\\n massUpdatePools(_rewardToken);\\n\\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\\n\\n uint256 length = poolInfo.length;\\n for (uint256 pid = 0; pid < length; ++pid) {\\n require(poolInfo[pid].token != _token, \\\"Pool already added\\\");\\n }\\n\\n // We use balanceOf to get the supply amount, so shouldn't be possible to\\n // configure pools with different reward token but the same staked token\\n require(!isStakedToken[address(_token)], \\\"Token exists in other pool\\\");\\n\\n totalAllocPoints[_rewardToken] = totalAllocPoints[_rewardToken].add(_allocPoint);\\n\\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardPerBlockOrSecond;\\n\\n poolInfo.push(\\n PoolInfo({\\n token: _token,\\n allocPoint: _allocPoint,\\n lastRewardBlockOrSecond: getBlockNumberOrTimestamp(),\\n accRewardPerShare: 0,\\n lockPeriod: _lockPeriod\\n })\\n );\\n isStakedToken[address(_token)] = true;\\n\\n XVSStore(xvsStore).setRewardToken(_rewardToken, true);\\n\\n emit PoolAdded(\\n _rewardToken,\\n poolInfo.length - 1,\\n address(_token),\\n _allocPoint,\\n _rewardPerBlockOrSecond,\\n _lockPeriod\\n );\\n }\\n\\n /**\\n * @notice Update the given pool's reward allocation point\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n * @param _allocPoint Number of allocation points assigned to this pool\\n */\\n function set(address _rewardToken, uint256 _pid, uint256 _allocPoint) external {\\n _checkAccessAllowed(\\\"set(address,uint256,uint256)\\\");\\n _ensureValidPool(_rewardToken, _pid);\\n\\n massUpdatePools(_rewardToken);\\n\\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\\n uint256 newTotalAllocPoints = totalAllocPoints[_rewardToken].sub(poolInfo[_pid].allocPoint).add(_allocPoint);\\n require(newTotalAllocPoints > 0, \\\"Alloc points per reward token must not be zero\\\");\\n\\n uint256 oldAllocPoints = poolInfo[_pid].allocPoint;\\n poolInfo[_pid].allocPoint = _allocPoint;\\n totalAllocPoints[_rewardToken] = newTotalAllocPoints;\\n\\n emit PoolUpdated(_rewardToken, _pid, oldAllocPoints, _allocPoint);\\n }\\n\\n /**\\n * @notice Update the given reward token's amount per block or second\\n * @param _rewardToken Reward token address\\n * @param _rewardAmount Number of allocation points assigned to this pool\\n */\\n function setRewardAmountPerBlockOrSecond(address _rewardToken, uint256 _rewardAmount) external {\\n _checkAccessAllowed(\\\"setRewardAmountPerBlockOrSecond(address,uint256)\\\");\\n require(XVSStore(xvsStore).rewardTokens(_rewardToken), \\\"Invalid reward token\\\");\\n massUpdatePools(_rewardToken);\\n uint256 oldReward = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardAmount;\\n\\n emit RewardAmountUpdated(_rewardToken, oldReward, _rewardAmount);\\n }\\n\\n /**\\n * @notice Update the lock period after which a requested withdrawal can be executed\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n * @param _newPeriod New lock period\\n */\\n function setWithdrawalLockingPeriod(address _rewardToken, uint256 _pid, uint256 _newPeriod) external {\\n _checkAccessAllowed(\\\"setWithdrawalLockingPeriod(address,uint256,uint256)\\\");\\n _ensureValidPool(_rewardToken, _pid);\\n require(_newPeriod > 0 && _newPeriod < MAX_LOCK_PERIOD, \\\"Invalid new locking period\\\");\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n uint256 oldPeriod = pool.lockPeriod;\\n pool.lockPeriod = _newPeriod;\\n\\n emit WithdrawalLockingPeriodUpdated(_rewardToken, _pid, oldPeriod, _newPeriod);\\n }\\n\\n /**\\n * @notice Deposit XVSVault for XVS allocation\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _amount The amount to deposit to vault\\n */\\n function deposit(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\\n _updatePool(_rewardToken, _pid);\\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, msg.sender) == 0, \\\"execute pending withdrawal\\\");\\n\\n if (user.amount > 0) {\\n uint256 pending = _computeReward(user, pool);\\n if (pending > 0) {\\n _transferReward(_rewardToken, msg.sender, pending);\\n emit Claim(msg.sender, _rewardToken, _pid, pending);\\n }\\n }\\n pool.token.safeTransferFrom(msg.sender, address(this), _amount);\\n user.amount = user.amount.add(_amount);\\n user.rewardDebt = _cumulativeReward(user, pool);\\n\\n // Update Delegate Amount\\n if (address(pool.token) == xvsAddress) {\\n _moveDelegates(address(0), delegates[msg.sender], safe96(_amount, \\\"XVSVault::deposit: votes overflow\\\"));\\n }\\n\\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\\n primeToken.xvsUpdated(msg.sender);\\n }\\n\\n emit Deposit(msg.sender, _rewardToken, _pid, _amount);\\n }\\n\\n /**\\n * @notice Claim rewards for pool\\n * @param _account The account for which to claim rewards\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n */\\n function claim(address _account, address _rewardToken, uint256 _pid) external nonReentrant isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n UserInfo storage user = userInfos[_rewardToken][_pid][_account];\\n _updatePool(_rewardToken, _pid);\\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, _account) == 0, \\\"execute pending withdrawal\\\");\\n\\n if (user.amount > 0) {\\n uint256 pending = _computeReward(user, pool);\\n\\n if (pending > 0) {\\n user.rewardDebt = _cumulativeReward(user, pool);\\n\\n _transferReward(_rewardToken, _account, pending);\\n emit Claim(_account, _rewardToken, _pid, pending);\\n }\\n }\\n }\\n\\n /**\\n * @notice Pushes withdrawal request to the requests array and updates\\n * the pending withdrawals amount. The requests are always sorted\\n * by unlock time (descending) so that the earliest to execute requests\\n * are always at the end of the array.\\n * @param _user The user struct storage pointer\\n * @param _requests The user's requests array storage pointer\\n * @param _amount The amount being requested\\n */\\n function pushWithdrawalRequest(\\n UserInfo storage _user,\\n WithdrawalRequest[] storage _requests,\\n uint _amount,\\n uint _lockedUntil\\n ) internal {\\n uint i = _requests.length;\\n _requests.push(WithdrawalRequest(0, 0, 1));\\n // Keep it sorted so that the first to get unlocked request is always at the end\\n for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) {\\n _requests[i] = _requests[i - 1];\\n }\\n _requests[i] = WithdrawalRequest(_amount, _lockedUntil.toUint128(), 1);\\n _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount);\\n }\\n\\n /**\\n * @notice Pops the requests with unlock time < now from the requests\\n * array and deducts the computed amount from the user's pending\\n * withdrawals counter. Assumes that the requests array is sorted\\n * by unclock time (descending).\\n * @dev This function **removes** the eligible requests from the requests\\n * array. If this function is called, the withdrawal should actually\\n * happen (or the transaction should be reverted).\\n * @param _user The user struct storage pointer\\n * @param _requests The user's requests array storage pointer\\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade (this amount should be\\n * sent to the user, otherwise the state would be inconsistent).\\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade (this amount should be\\n * sent to the user, otherwise the state would be inconsistent).\\n */\\n function popEligibleWithdrawalRequests(\\n UserInfo storage _user,\\n WithdrawalRequest[] storage _requests\\n ) internal returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\\n // Since the requests are sorted by their unlock time, we can just\\n // pop them from the array and stop at the first not-yet-eligible one\\n for (uint i = _requests.length; i > 0 && isUnlocked(_requests[i - 1]); --i) {\\n if (_requests[i - 1].afterUpgrade == 1) {\\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\\n } else {\\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\\n }\\n\\n _requests.pop();\\n }\\n _user.pendingWithdrawals = _user.pendingWithdrawals.sub(\\n afterUpgradeWithdrawalAmount.add(beforeUpgradeWithdrawalAmount)\\n );\\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\\n }\\n\\n /**\\n * @notice Checks if the request is eligible for withdrawal.\\n * @param _request The request struct storage pointer\\n * @return True if the request is eligible for withdrawal, false otherwise\\n */\\n function isUnlocked(WithdrawalRequest storage _request) private view returns (bool) {\\n return _request.lockedUntil <= block.timestamp;\\n }\\n\\n /**\\n * @notice Execute withdrawal to XVSVault for XVS allocation\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n */\\n function executeWithdrawal(address _rewardToken, uint256 _pid) external nonReentrant isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\\n\\n uint256 beforeUpgradeWithdrawalAmount;\\n uint256 afterUpgradeWithdrawalAmount;\\n\\n (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount) = popEligibleWithdrawalRequests(user, requests);\\n require(beforeUpgradeWithdrawalAmount > 0 || afterUpgradeWithdrawalAmount > 0, \\\"nothing to withdraw\\\");\\n\\n // Having both old-style and new-style requests is not allowed and shouldn't be possible\\n require(beforeUpgradeWithdrawalAmount == 0 || afterUpgradeWithdrawalAmount == 0, \\\"inconsistent state\\\");\\n\\n if (beforeUpgradeWithdrawalAmount > 0) {\\n _updatePool(_rewardToken, _pid);\\n uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub(user.rewardDebt);\\n XVSStore(xvsStore).safeRewardTransfer(_rewardToken, msg.sender, pending);\\n user.amount = user.amount.sub(beforeUpgradeWithdrawalAmount);\\n user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);\\n pool.token.safeTransfer(address(msg.sender), beforeUpgradeWithdrawalAmount);\\n } else {\\n user.amount = user.amount.sub(afterUpgradeWithdrawalAmount);\\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].sub(\\n afterUpgradeWithdrawalAmount\\n );\\n pool.token.safeTransfer(address(msg.sender), afterUpgradeWithdrawalAmount);\\n }\\n\\n emit ExecutedWithdrawal(\\n msg.sender,\\n _rewardToken,\\n _pid,\\n beforeUpgradeWithdrawalAmount.add(afterUpgradeWithdrawalAmount)\\n );\\n }\\n\\n /**\\n * @notice Returns before and after upgrade pending withdrawal amount\\n * @param _requests The user's requests array storage pointer\\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade\\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade\\n */\\n function getRequestedWithdrawalAmount(\\n WithdrawalRequest[] storage _requests\\n ) internal view returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\\n for (uint i = _requests.length; i > 0; --i) {\\n if (_requests[i - 1].afterUpgrade == 1) {\\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\\n } else {\\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\\n }\\n }\\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\\n }\\n\\n /**\\n * @notice Request withdrawal to XVSVault for XVS allocation\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _amount The amount to withdraw from the vault\\n */\\n function requestWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n require(_amount > 0, \\\"requested amount cannot be zero\\\");\\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\\n require(user.amount >= user.pendingWithdrawals.add(_amount), \\\"requested amount is invalid\\\");\\n\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\\n\\n uint beforeUpgradeWithdrawalAmount;\\n\\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\\n require(beforeUpgradeWithdrawalAmount == 0, \\\"execute pending withdrawal\\\");\\n\\n _updatePool(_rewardToken, _pid);\\n uint256 pending = _computeReward(user, pool);\\n _transferReward(_rewardToken, msg.sender, pending);\\n\\n uint lockedUntil = pool.lockPeriod.add(block.timestamp);\\n\\n pushWithdrawalRequest(user, requests, _amount, lockedUntil);\\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].add(_amount);\\n user.rewardDebt = _cumulativeReward(user, pool);\\n\\n // Update Delegate Amount\\n if (address(pool.token) == xvsAddress) {\\n _moveDelegates(\\n delegates[msg.sender],\\n address(0),\\n safe96(_amount, \\\"XVSVault::requestWithdrawal: votes overflow\\\")\\n );\\n }\\n\\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\\n primeToken.xvsUpdated(msg.sender);\\n }\\n\\n emit Claim(msg.sender, _rewardToken, _pid, pending);\\n emit RequestedWithdrawal(msg.sender, _rewardToken, _pid, _amount);\\n }\\n\\n /**\\n * @notice Get unlocked withdrawal amount\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _user The User Address\\n * @return withdrawalAmount Amount that the user can withdraw\\n */\\n function getEligibleWithdrawalAmount(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) external view returns (uint withdrawalAmount) {\\n _ensureValidPool(_rewardToken, _pid);\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\\n // Since the requests are sorted by their unlock time, we can take\\n // the entries from the end of the array and stop at the first\\n // not-yet-eligible one\\n for (uint i = requests.length; i > 0 && isUnlocked(requests[i - 1]); --i) {\\n withdrawalAmount = withdrawalAmount.add(requests[i - 1].amount);\\n }\\n return withdrawalAmount;\\n }\\n\\n /**\\n * @notice Get requested amount\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _user The User Address\\n * @return Total amount of requested but not yet executed withdrawals (including both executable and locked ones)\\n */\\n function getRequestedAmount(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\\n _ensureValidPool(_rewardToken, _pid);\\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\\n return user.pendingWithdrawals;\\n }\\n\\n /**\\n * @notice Returns the array of withdrawal requests that have not been executed yet\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _user The User Address\\n * @return An array of withdrawal requests\\n */\\n function getWithdrawalRequests(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) external view returns (WithdrawalRequest[] memory) {\\n _ensureValidPool(_rewardToken, _pid);\\n return withdrawalRequests[_rewardToken][_pid][_user];\\n }\\n\\n /**\\n * @notice View function to see pending XVSs on frontend\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n * @param _user User address\\n * @return Reward the user is eligible for in this pool, in terms of _rewardToken\\n */\\n function pendingReward(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\\n _ensureValidPool(_rewardToken, _pid);\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\\n uint256 accRewardPerShare = pool.accRewardPerShare;\\n uint256 supply = pool.token.balanceOf(address(this)).sub(totalPendingWithdrawals[_rewardToken][_pid]);\\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\\n uint256 rewardTokenPerBlockOrSecond = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\\n if (curBlockNumberOrSecond > pool.lastRewardBlockOrSecond && supply != 0) {\\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\\n uint256 reward = multiplier.mul(rewardTokenPerBlockOrSecond).mul(pool.allocPoint).div(\\n totalAllocPoints[_rewardToken]\\n );\\n accRewardPerShare = accRewardPerShare.add(reward.mul(1e12).div(supply));\\n }\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\\n (, uint256 afterUpgradeWithdrawalAmount) = getRequestedWithdrawalAmount(requests);\\n return user.amount.sub(afterUpgradeWithdrawalAmount).mul(accRewardPerShare).div(1e12).sub(user.rewardDebt);\\n }\\n\\n // Update reward variables for all pools. Be careful of gas spending!\\n function massUpdatePools(address _rewardToken) internal {\\n uint256 length = poolInfos[_rewardToken].length;\\n for (uint256 pid = 0; pid < length; ++pid) {\\n _updatePool(_rewardToken, pid);\\n }\\n }\\n\\n /**\\n * @notice Update reward variables of the given pool to be up-to-date\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n */\\n function updatePool(address _rewardToken, uint256 _pid) external isActive {\\n _ensureValidPool(_rewardToken, _pid);\\n _updatePool(_rewardToken, _pid);\\n }\\n\\n // Update reward variables of the given pool to be up-to-date.\\n function _updatePool(address _rewardToken, uint256 _pid) internal {\\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\\n if (getBlockNumberOrTimestamp() <= pool.lastRewardBlockOrSecond) {\\n return;\\n }\\n uint256 supply = pool.token.balanceOf(address(this));\\n supply = supply.sub(totalPendingWithdrawals[_rewardToken][_pid]);\\n if (supply == 0) {\\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\\n return;\\n }\\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\\n uint256 reward = multiplier.mul(rewardTokenAmountsPerBlockOrSecond[_rewardToken]).mul(pool.allocPoint).div(\\n totalAllocPoints[_rewardToken]\\n );\\n pool.accRewardPerShare = pool.accRewardPerShare.add(reward.mul(1e12).div(supply));\\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\\n }\\n\\n function _ensureValidPool(address rewardToken, uint256 pid) internal view {\\n require(pid < poolInfos[rewardToken].length, \\\"vault: pool exists?\\\");\\n }\\n\\n /**\\n * @notice Get user info with reward token address and pid\\n * @param _rewardToken Reward token address\\n * @param _pid Pool index\\n * @param _user User address\\n * @return amount Deposited amount\\n * @return rewardDebt Reward debt (technical value used to track past payouts)\\n * @return pendingWithdrawals Requested but not yet executed withdrawals\\n */\\n function getUserInfo(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals) {\\n _ensureValidPool(_rewardToken, _pid);\\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\\n amount = user.amount;\\n rewardDebt = user.rewardDebt;\\n pendingWithdrawals = user.pendingWithdrawals;\\n }\\n\\n /**\\n * @notice Gets the total pending withdrawal amount of a user before upgrade\\n * @param _rewardToken The Reward Token Address\\n * @param _pid The Pool Index\\n * @param _user The address of the user\\n * @return beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade\\n */\\n function pendingWithdrawalsBeforeUpgrade(\\n address _rewardToken,\\n uint256 _pid,\\n address _user\\n ) public view returns (uint256 beforeUpgradeWithdrawalAmount) {\\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\\n return beforeUpgradeWithdrawalAmount;\\n }\\n\\n /**\\n * @notice Get the XVS stake balance of an account (excluding the pending withdrawals)\\n * @param account The address of the account to check\\n * @return The balance that user staked\\n */\\n function getStakeAmount(address account) internal view returns (uint96) {\\n require(xvsAddress != address(0), \\\"XVSVault::getStakeAmount: xvs address is not set\\\");\\n\\n PoolInfo[] storage poolInfo = poolInfos[xvsAddress];\\n\\n uint256 length = poolInfo.length;\\n for (uint256 pid = 0; pid < length; ++pid) {\\n if (address(poolInfo[pid].token) == address(xvsAddress)) {\\n UserInfo storage user = userInfos[xvsAddress][pid][account];\\n return safe96(user.amount.sub(user.pendingWithdrawals), \\\"XVSVault::getStakeAmount: votes overflow\\\");\\n }\\n }\\n return uint96(0);\\n }\\n\\n /**\\n * @notice Delegate votes from `msg.sender` to `delegatee`\\n * @param delegatee The address to delegate votes to\\n */\\n function delegate(address delegatee) external isActive {\\n return _delegate(msg.sender, delegatee);\\n }\\n\\n /**\\n * @notice Delegates votes from signatory to `delegatee`\\n * @param delegatee The address to delegate votes to\\n * @param nonce The contract state required to match the signature\\n * @param expiry The time at which to expire the signature\\n * @param v The recovery byte of the signature\\n * @param r Half of the ECDSA signature pair\\n * @param s Half of the ECDSA signature pair\\n */\\n function delegateBySig(\\n address delegatee,\\n uint nonce,\\n uint expiry,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external isActive {\\n bytes32 domainSeparator = keccak256(\\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(\\\"XVSVault\\\")), getChainId(), address(this))\\n );\\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\\n bytes32 digest = keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n address signatory = ECDSA.recover(digest, v, r, s);\\n require(nonce == nonces[signatory]++, \\\"XVSVault::delegateBySig: invalid nonce\\\");\\n require(block.timestamp <= expiry, \\\"XVSVault::delegateBySig: signature expired\\\");\\n return _delegate(signatory, delegatee);\\n }\\n\\n /**\\n * @notice Gets the current votes balance for `account`\\n * @param account The address to get votes balance\\n * @return The number of current votes for `account`\\n */\\n function getCurrentVotes(address account) external view returns (uint96) {\\n uint32 nCheckpoints = numCheckpoints[account];\\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\\n }\\n\\n function _delegate(address delegator, address delegatee) internal {\\n address currentDelegate = delegates[delegator];\\n uint96 delegatorBalance = getStakeAmount(delegator);\\n delegates[delegator] = delegatee;\\n\\n emit DelegateChangedV2(delegator, currentDelegate, delegatee);\\n\\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\\n }\\n\\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\\n if (srcRep != dstRep && amount > 0) {\\n if (srcRep != address(0)) {\\n uint32 srcRepNum = numCheckpoints[srcRep];\\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\\n uint96 srcRepNew = sub96(srcRepOld, amount, \\\"XVSVault::_moveVotes: vote amount underflows\\\");\\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\\n }\\n\\n if (dstRep != address(0)) {\\n uint32 dstRepNum = numCheckpoints[dstRep];\\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\\n uint96 dstRepNew = add96(dstRepOld, amount, \\\"XVSVault::_moveVotes: vote amount overflows\\\");\\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\\n }\\n }\\n }\\n\\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\\n uint32 blockNumberOrSecond = safe32(\\n getBlockNumberOrTimestamp(),\\n \\\"XVSVault::_writeCheckpoint: block number or second exceeds 32 bits\\\"\\n );\\n\\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlockOrSecond == blockNumberOrSecond) {\\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\\n } else {\\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumberOrSecond, newVotes);\\n numCheckpoints[delegatee] = nCheckpoints + 1;\\n }\\n\\n emit DelegateVotesChangedV2(delegatee, oldVotes, newVotes);\\n }\\n\\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2 ** 32, errorMessage);\\n return uint32(n);\\n }\\n\\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\\n require(n < 2 ** 96, errorMessage);\\n return uint96(n);\\n }\\n\\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\\n uint96 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function getChainId() internal pure returns (uint) {\\n uint256 chainId;\\n assembly {\\n chainId := chainid()\\n }\\n return chainId;\\n }\\n\\n /**\\n * @notice Determine the xvs stake balance for an account\\n * @param account The address of the account to check\\n * @param blockNumberOrSecond The block number or second to get the vote balance at\\n * @return The balance that user staked\\n */\\n function getPriorVotes(address account, uint256 blockNumberOrSecond) external view returns (uint96) {\\n require(blockNumberOrSecond < getBlockNumberOrTimestamp(), \\\"XVSVault::getPriorVotes: not yet determined\\\");\\n\\n uint32 nCheckpoints = numCheckpoints[account];\\n if (nCheckpoints == 0) {\\n return 0;\\n }\\n\\n // First check most recent balance\\n if (checkpoints[account][nCheckpoints - 1].fromBlockOrSecond <= blockNumberOrSecond) {\\n return checkpoints[account][nCheckpoints - 1].votes;\\n }\\n\\n // Next check implicit zero balance\\n if (checkpoints[account][0].fromBlockOrSecond > blockNumberOrSecond) {\\n return 0;\\n }\\n\\n uint32 lower = 0;\\n uint32 upper = nCheckpoints - 1;\\n while (upper > lower) {\\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\\n Checkpoint memory cp = checkpoints[account][center];\\n if (cp.fromBlockOrSecond == blockNumberOrSecond) {\\n return cp.votes;\\n } else if (cp.fromBlockOrSecond < blockNumberOrSecond) {\\n lower = center;\\n } else {\\n upper = center - 1;\\n }\\n }\\n return checkpoints[account][lower].votes;\\n }\\n\\n /*** Admin Functions ***/\\n\\n function _become(XVSVaultProxy xvsVaultProxy) external {\\n require(msg.sender == xvsVaultProxy.admin(), \\\"only proxy admin can change brains\\\");\\n require(xvsVaultProxy._acceptImplementation() == 0, \\\"change not authorized\\\");\\n }\\n\\n function setXvsStore(address _xvs, address _xvsStore) external onlyAdmin {\\n _ensureNonzeroAddress(_xvs);\\n _ensureNonzeroAddress(_xvsStore);\\n\\n address oldXvsContract = xvsAddress;\\n address oldStore = xvsStore;\\n require(oldXvsContract == address(0), \\\"already initialized\\\");\\n\\n xvsAddress = _xvs;\\n xvsStore = _xvsStore;\\n\\n _notEntered = true;\\n\\n emit StoreUpdated(oldXvsContract, oldStore, _xvs, _xvsStore);\\n }\\n\\n /**\\n * @notice Sets the address of the prime token contract\\n * @param _primeToken address of the prime token contract\\n * @param _primeRewardToken address of reward token\\n * @param _primePoolId pool id for reward\\n */\\n function setPrimeToken(IPrime _primeToken, address _primeRewardToken, uint256 _primePoolId) external onlyAdmin {\\n require(address(_primeToken) != address(0), \\\"prime token cannot be zero address\\\");\\n require(_primeRewardToken != address(0), \\\"reward cannot be zero address\\\");\\n\\n _ensureValidPool(_primeRewardToken, _primePoolId);\\n\\n emit NewPrimeToken(primeToken, _primeToken, primeRewardToken, _primeRewardToken, primePoolId, _primePoolId);\\n\\n primeToken = _primeToken;\\n primeRewardToken = _primeRewardToken;\\n primePoolId = _primePoolId;\\n }\\n\\n /**\\n * @dev Initializes the contract to use either blocks or seconds\\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\\n * @param blocksPerYear_ The number of blocks per year\\n */\\n function initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) external onlyAdmin {\\n _initializeTimeManager(timeBased_, blocksPerYear_);\\n }\\n\\n /**\\n * @notice Sets the address of the access control of this contract\\n * @dev Admin function to set the access control address\\n * @param newAccessControlAddress New address for the access control\\n */\\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\\n _setAccessControlManager(newAccessControlAddress);\\n }\\n\\n /**\\n * @dev Reverts if the provided address is a zero address\\n * @param address_ Address to check\\n */\\n function _ensureNonzeroAddress(address address_) internal pure {\\n require(address_ != address(0), \\\"zero address not allowed\\\");\\n }\\n\\n /**\\n * @dev Transfers the reward to the user, taking into account the rewards store\\n * balance and the previous debt. If there are not enough rewards in the store,\\n * transfers the available funds and records the debt amount in pendingRewardTransfers.\\n * @param rewardToken Reward token address\\n * @param userAddress User address\\n * @param amount Reward amount, in reward tokens\\n */\\n function _transferReward(address rewardToken, address userAddress, uint256 amount) internal {\\n address xvsStore_ = xvsStore;\\n uint256 storeBalance = IBEP20(rewardToken).balanceOf(xvsStore_);\\n uint256 debtDueToFailedTransfers = pendingRewardTransfers[rewardToken][userAddress];\\n uint256 fullAmount = amount.add(debtDueToFailedTransfers);\\n\\n if (fullAmount <= storeBalance) {\\n if (debtDueToFailedTransfers != 0) {\\n pendingRewardTransfers[rewardToken][userAddress] = 0;\\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, 0);\\n }\\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, fullAmount);\\n return;\\n }\\n // Overflow isn't possible due to the check above\\n uint256 newOwedAmount = fullAmount - storeBalance;\\n pendingRewardTransfers[rewardToken][userAddress] = newOwedAmount;\\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, newOwedAmount);\\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, storeBalance);\\n }\\n\\n /**\\n * @dev Computes cumulative reward for all user's shares\\n * @param user UserInfo storage struct\\n * @param pool PoolInfo storage struct\\n */\\n function _cumulativeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\\n return user.amount.sub(user.pendingWithdrawals).mul(pool.accRewardPerShare).div(1e12);\\n }\\n\\n /**\\n * @dev Computes the reward for all user's shares\\n * @param user UserInfo storage struct\\n * @param pool PoolInfo storage struct\\n */\\n function _computeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\\n return _cumulativeReward(user, pool).sub(user.rewardDebt);\\n }\\n}\\n\",\"keccak256\":\"0xb60ac3238f6c088bc105fd784fb15e7e8d3e7c8fd14640f1945563c0ecd1a68c\"},\"contracts/XVSVault/XVSVaultErrorReporter.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\ncontract XVSVaultErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint error, uint info, uint detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint) {\\n emit Failure(uint(err), uint(info), 0);\\n\\n return uint(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\\n emit Failure(uint(err), uint(info), opaqueError);\\n\\n return uint(err);\\n }\\n}\\n\",\"keccak256\":\"0xa79877a281d024f0d03dbf1842a36a972ee6c1aa36ba93e3d646726d40684a26\"},\"contracts/XVSVault/XVSVaultProxy.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"./XVSVaultStorage.sol\\\";\\nimport \\\"./XVSVaultErrorReporter.sol\\\";\\n\\n/**\\n * @title XVS Vault Proxy\\n * @author Venus\\n * @notice XVS Vault Proxy contract\\n */\\ncontract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter {\\n /**\\n * @notice Emitted when pendingXVSVaultImplementation is changed\\n */\\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\\n\\n /**\\n * @notice Emitted when pendingXVSVaultImplementation is accepted, which means XVS Vault implementation is updated\\n */\\n event NewImplementation(address oldImplementation, address newImplementation);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor() public {\\n // Set admin to caller\\n admin = msg.sender;\\n }\\n\\n /*** Admin Functions ***/\\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\\n if (msg.sender != admin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\\n }\\n\\n address oldPendingImplementation = pendingXVSVaultImplementation;\\n\\n pendingXVSVaultImplementation = newPendingImplementation;\\n\\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\\n * @dev Admin function for new implementation to accept it's role as implementation\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptImplementation() public returns (uint) {\\n // Check caller is pendingImplementation\\n if (msg.sender != pendingXVSVaultImplementation) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldImplementation = implementation;\\n address oldPendingImplementation = pendingXVSVaultImplementation;\\n\\n implementation = pendingXVSVaultImplementation;\\n\\n pendingXVSVaultImplementation = address(0);\\n\\n emit NewImplementation(oldImplementation, implementation);\\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\\n // Check caller = admin\\n if (msg.sender != admin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n // Save current value, if any, for inclusion in log\\n address oldPendingAdmin = pendingAdmin;\\n\\n // Store pendingAdmin with value newPendingAdmin\\n pendingAdmin = newPendingAdmin;\\n\\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint) {\\n // Check caller is pendingAdmin\\n if (msg.sender != pendingAdmin) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n // Store admin with value pendingAdmin\\n admin = pendingAdmin;\\n\\n // Clear the pending value\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint(Error.NO_ERROR);\\n }\\n\\n /**\\n * @dev Delegates execution to an implementation contract.\\n * It returns to the external caller whatever the implementation returns\\n * or forwards reverts.\\n */\\n function() external payable {\\n // delegate all other functions to current implementation\\n (bool success, ) = implementation.delegatecall(msg.data);\\n\\n assembly {\\n let free_mem_ptr := mload(0x40)\\n returndatacopy(free_mem_ptr, 0, returndatasize)\\n\\n switch success\\n case 0 {\\n revert(free_mem_ptr, returndatasize)\\n }\\n default {\\n return(free_mem_ptr, returndatasize)\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb39af917833659fe38f2f76924deda420babed8259b27741dc6cb402ade4d124\"},\"contracts/XVSVault/XVSVaultStorage.sol\":{\"content\":\"pragma solidity ^0.5.16;\\n\\nimport \\\"../Utils/SafeMath.sol\\\";\\nimport \\\"../Utils/IBEP20.sol\\\";\\nimport \\\"../Tokens/Prime/IPrime.sol\\\";\\n\\ncontract XVSVaultAdminStorage {\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Active brains of XVS Vault\\n */\\n address public implementation;\\n\\n /**\\n * @notice Pending brains of XVS Vault\\n */\\n address public pendingXVSVaultImplementation;\\n}\\n\\ncontract XVSVaultStorageV1 is XVSVaultAdminStorage {\\n /// @notice Guard variable for re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @notice The reward token store\\n address public xvsStore;\\n\\n /// @notice The xvs token address\\n address public xvsAddress;\\n\\n // Reward tokens created per block or second indentified by reward token address.\\n mapping(address => uint256) public rewardTokenAmountsPerBlockOrSecond;\\n\\n /// @notice Info of each user.\\n struct UserInfo {\\n uint256 amount;\\n uint256 rewardDebt;\\n uint256 pendingWithdrawals;\\n }\\n\\n // Info of each pool.\\n struct PoolInfo {\\n IBEP20 token; // Address of token contract to stake.\\n uint256 allocPoint; // How many allocation points assigned to this pool.\\n uint256 lastRewardBlockOrSecond; // Last block number or second that reward tokens distribution occurs.\\n uint256 accRewardPerShare; // Accumulated per share, times 1e12. See below.\\n uint256 lockPeriod; // Min time between withdrawal request and its execution.\\n }\\n\\n // Infomation about a withdrawal request\\n struct WithdrawalRequest {\\n uint256 amount;\\n uint128 lockedUntil;\\n uint128 afterUpgrade;\\n }\\n\\n // Info of each user that stakes tokens.\\n mapping(address => mapping(uint256 => mapping(address => UserInfo))) internal userInfos;\\n\\n // Info of each pool.\\n mapping(address => PoolInfo[]) public poolInfos;\\n\\n // Total allocation points. Must be the sum of all allocation points in all pools.\\n mapping(address => uint256) public totalAllocPoints;\\n\\n // Info of requested but not yet executed withdrawals\\n mapping(address => mapping(uint256 => mapping(address => WithdrawalRequest[]))) internal withdrawalRequests;\\n\\n /// @notice DEPRECATED A record of each accounts delegate (before the voting power fix)\\n mapping(address => address) private __oldDelegatesSlot;\\n\\n /// @notice A checkpoint for marking number of votes from a given block or second\\n struct Checkpoint {\\n uint32 fromBlockOrSecond;\\n uint96 votes;\\n }\\n\\n /// @notice DEPRECATED A record of votes checkpoints for each account, by index (before the voting power fix)\\n mapping(address => mapping(uint32 => Checkpoint)) private __oldCheckpointsSlot;\\n\\n /// @notice DEPRECATED The number of checkpoints for each account (before the voting power fix)\\n mapping(address => uint32) private __oldNumCheckpointsSlot;\\n\\n /// @notice A record of states for signing / validating signatures\\n mapping(address => uint) public nonces;\\n\\n /// @notice The EIP-712 typehash for the contract's domain\\n bytes32 public constant DOMAIN_TYPEHASH =\\n keccak256(\\\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\\\");\\n\\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\\\");\\n}\\n\\ncontract XVSVaultStorage is XVSVaultStorageV1 {\\n /// @notice A record of each accounts delegate\\n mapping(address => address) public delegates;\\n\\n /// @notice A record of votes checkpoints for each account, by index\\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\\n\\n /// @notice The number of checkpoints for each account\\n mapping(address => uint32) public numCheckpoints;\\n\\n /// @notice Tracks pending withdrawals for all users for a particular reward token and pool id\\n mapping(address => mapping(uint256 => uint256)) public totalPendingWithdrawals;\\n\\n /// @notice pause indicator for Vault\\n bool public vaultPaused;\\n\\n /// @notice if the token is added to any of the pools\\n mapping(address => bool) public isStakedToken;\\n\\n /// @notice Amount we owe to users because of failed transfer attempts\\n mapping(address => mapping(address => uint256)) public pendingRewardTransfers;\\n\\n /// @notice Prime token contract address\\n IPrime public primeToken;\\n\\n /// @notice Reward token for which prime token is issued for staking\\n address public primeRewardToken;\\n\\n /// @notice Pool ID for which prime token is issued for staking\\n uint256 public primePoolId;\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[46] private __gap;\\n}\\n\",\"keccak256\":\"0xb09f9295c41bdac1350a3607f2b4ea326cb295a6d08f4145bc33ff87844cd02b\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905561578980620000336000396000f3fe608060405234801561001057600080fd5b50600436106103785760003560e01c806392e35000116101d3578063c7ad089511610104578063e7a324dc116100a2578063f55401621161007c578063f554016214610732578063f851a4401461073a578063fba1b1f914610742578063fe5a451a1461075557610378565b8063e7a324dc14610701578063e8f2be6f14610709578063f1127ed81461071157610378565b8063dae66bbe116100de578063dae66bbe146106d6578063de0368b2146106e9578063e1d146fb146106f1578063e6a69ab8146106f957610378565b8063c7ad0895146106a8578063cd9b94e7146106b0578063d7ae45e2146106c357610378565b8063add8933711610171578063b6a5fd2f1161014b578063b6a5fd2f1461064f578063c210259614610662578063c3c754a814610682578063c3cda5201461069557610378565b8063add893371461061f578063b4a0bdf314610627578063b4b5ea571461063c57610378565b80639e2b6c4d116101ad5780639e2b6c4d146105d3578063a09eab7a146105e6578063a6997762146105f9578063a9d69a691461060c57610378565b806392e350001461057a57806398e1b31b1461059e578063996cba68146105c057610378565b80635c19a95c116102ad57806373d025d61161024b5780637ecebe00116102255780637ecebe00146105395780638308d7e91461054c5780638456cb591461055f5780638ed7333d1461056757610378565b806373d025d6146104f1578063782d6fe1146105065780637ac924561461052657610378565b80635ff56315116102875780635ff56315146104a35780636857249c146104b65780636dd77cbd146104be5780636fcfff45146104d157610378565b80635c19a95c146104755780635c60da1b146104885780635f14e7001461049057610378565b806324f52bbf1161031a578063358ae036116102f4578063358ae036146104345780633d4180f91461043c5780634298bdbd1461044f578063587cde1e1461046257610378565b806324f52bbf1461040457806326782247146104195780632eda5c6c1461042157610378565b8063115b512f11610356578063115b512f146103c357806319129e5a146103d65780631d504dc6146103e957806320606b70146103fc57610378565b8063046f7da21461037d5780630af13728146103875780630efe6a8b146103b0575b600080fd5b61038561075d565b005b61039a6103953660046140be565b6107e8565b6040516103a791906150ae565b60405180910390f35b6103856103be366004614176565b61082e565b6103856103d1366004614176565b610b23565b6103856103e4366004613fcb565b610ed7565b6103856103f73660046142bd565b610f0d565b61039a61103e565b61040c611055565b6040516103a79190614f4c565b61040c611064565b61039a61042f366004613fcb565b611073565b61040c611092565b61039a61044a366004614007565b6110a1565b61039a61045d366004613fcb565b6110be565b61040c610470366004613fcb565b6110d0565b610385610483366004613fcb565b6110eb565b61040c611118565b61039a61049e36600461408e565b611127565b6103856104b1366004614007565b611144565b61039a611238565b61039a6104cc3660046140be565b61123e565b6104e46104df366004613fcb565b6112f3565b6040516103a7919061545c565b6104f961130b565b6040516103a791906150a0565b61051961051436600461408e565b611314565b6040516103a79190615485565b61038561053436600461408e565b61152a565b61039a610547366004613fcb565b611873565b61038561055a366004614176565b611885565b610385611a2b565b61038561057536600461408e565b611ab0565b61058d61058836600461408e565b611aeb565b6040516103a795949392919061511b565b6105b16105ac3660046140be565b611b40565b6040516103a793929190615441565b6103856105ce366004614041565b611b92565b6103856105e1366004614176565b611d24565b61039a6105f43660046140be565b611e0f565b61038561060736600461427d565b61205f565b61039a61061a3660046140be565b612093565b61040c6120d5565b61062f6120e4565b6040516103a7919061510d565b61051961064a366004613fcb565b6120f3565b61038561065d36600461408e565b612163565b6106756106703660046140be565b612289565b6040516103a7919061508f565b6104f9610690366004613fcb565b612343565b6103856106a33660046141a8565b612358565b6104f96124fc565b61039a6106be366004613fcb565b612505565b61039a6106d1366004613fcb565b612517565b6103856106e436600461429c565b612532565b61040c61263e565b61039a61264d565b61039a612674565b61039a61267c565b61039a612688565b61072461071f36600461422f565b61268e565b6040516103a792919061546a565b61039a6126c3565b61040c6126cb565b610385610750366004614101565b6126da565b61062f6129bf565b61078660405180604001604052806008815260200167726573756d65282960c01b8152506129ce565b60135460ff166107b15760405162461bcd60e51b81526004016107a8906151d8565b60405180910390fd5b6013805460ff1916905560405133907fd2619572a1464e0df0bb351d834fd47f3350984d7bfdb1ab69cfcb0b8e42141590600090a2565b60006107f48484612a70565b506001600160a01b0380841660009081526007602090815260408083208684528252808320938516835292905220600201545b9392505050565b600354600160a01b900460ff166108575760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff16156108875760405162461bcd60e51b81526004016107a8906151c8565b6108918383612a70565b6001600160a01b03831660009081526008602052604081208054849081106108b557fe5b600091825260208083206001600160a01b038816845260078252604080852088865283528085203386529092529220600590910290910191506108f88585612aa7565b610903858533612093565b156109205760405162461bcd60e51b81526004016107a8906152e8565b8054156109955760006109338284612c84565b9050801561099357610946863383612c98565b84866001600160a01b0316336001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946458460405161098a91906150ae565b60405180910390a45b505b81546109b2906001600160a01b031633308663ffffffff612f1116565b80546109c4908463ffffffff612f7216565b81556109d08183612fb4565b600182015560055482546001600160a01b0390811691161415610a3757336000908152600f60209081526040808320548151606081019092526021808352610a3794936001600160a01b0390921692610a329289929061562990830139612fe2565b613011565b6017546001600160a01b038681169116148015610a55575060185484145b15610abd576016546040516337f23cd360e01b81526001600160a01b03909116906337f23cd390610a8a903390600401614f5a565b600060405180830381600087803b158015610aa457600080fd5b505af1158015610ab8573d6000803e3d6000fd5b505050505b83856001600160a01b0316336001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d786604051610b0191906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b179055505050565b600354600160a01b900460ff16610b4c5760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff1615610b7c5760405162461bcd60e51b81526004016107a8906151c8565b610b868383612a70565b60008111610ba65760405162461bcd60e51b81526004016107a890615308565b6001600160a01b0383166000908152600760209081526040808320858452825280832033845290915290206002810154610be6908363ffffffff612f7216565b81541015610c065760405162461bcd60e51b81526004016107a8906153e8565b6001600160a01b0384166000908152600860205260408120805485908110610c2a57fe5b600091825260208083206001600160a01b0389168452600a825260408085208986528352808520338652909252908320600590920201925090610c6c826131a3565b5090508015610c8d5760405162461bcd60e51b81526004016107a8906152e8565b610c978787612aa7565b6000610ca38585612c84565b9050610cb0883383612c98565b6004840154600090610cc8904263ffffffff612f7216565b9050610cd686858984613247565b6001600160a01b03891660009081526012602090815260408083208b8452909152902054610d0a908863ffffffff612f7216565b6001600160a01b038a1660009081526012602090815260408083208c8452909152902055610d388686612fb4565b600187015560055485546001600160a01b0390811691161415610d9b57336000908152600f6020908152604080832054815160608101909252602b808352610d9b946001600160a01b03909216939192610a32928d92906155d690830139612fe2565b6017546001600160a01b038a81169116148015610db9575060185488145b15610e21576016546040516337f23cd360e01b81526001600160a01b03909116906337f23cd390610dee903390600401614f5a565b600060405180830381600087803b158015610e0857600080fd5b505af1158015610e1c573d6000803e3d6000fd5b505050505b87896001600160a01b0316336001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464585604051610e6591906150ae565b60405180910390a487896001600160a01b0316336001600160a01b03167f88a254a0ef28a0b9e957ff600beae69870f6f924065147f3627c3f814e60ec118a604051610eb191906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b17905550505050505050565b6000546001600160a01b03163314610f015760405162461bcd60e51b81526004016107a890615368565b610f0a8161342b565b50565b806001600160a01b031663f851a4406040518163ffffffff1660e01b815260040160206040518083038186803b158015610f4657600080fd5b505afa158015610f5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f7e9190810190613fe9565b6001600160a01b0316336001600160a01b031614610fae5760405162461bcd60e51b81526004016107a8906153f8565b806001600160a01b031663c1e803346040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610fe957600080fd5b505af1158015610ffd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061102191908101906142db565b15610f0a5760405162461bcd60e51b81526004016107a890615378565b60405161104a90614f36565b604051809103902081565b6004546001600160a01b031681565b6001546001600160a01b031681565b6001600160a01b0381166000908152600660205260409020545b919050565b6005546001600160a01b031681565b601560209081526000928352604080842090915290825290205481565b60096020526000908152604090205481565b600f602052600090815260409020546001600160a01b031681565b60135460ff161561110e5760405162461bcd60e51b81526004016107a8906151c8565b610f0a33826134b0565b6002546001600160a01b031681565b601260209081526000928352604080842090915290825290205481565b6000546001600160a01b0316331461116e5760405162461bcd60e51b81526004016107a890615368565b6111778261353f565b6111808161353f565b6005546004546001600160a01b03918216911681156111b15760405162461bcd60e51b81526004016107a8906152a8565b600580546001600160a01b038087166001600160a01b03199283161790925560048054928616929091169190911790556003805460ff60a01b1916600160a01b1790556040517f559f314bb90394a4a9ceb724f365b36a53587d894352c43d12901fd6801014569061122a908490849088908890614fcb565b60405180910390a150505050565b60795481565b600061124a8484612a70565b6001600160a01b038085166000908152600a60209081526040808320878452825280832093861683529290522080545b6000811180156112aa57506112aa82600183038154811061129757fe5b9060005260206000209060020201613565565b156112ea576112df8260018303815481106112c157fe5b6000918252602090912060029091020154849063ffffffff612f7216565b92506000190161127a565b50509392505050565b60116020526000908152604090205463ffffffff1681565b60135460ff1681565b600061131e61264d565b821061133c5760405162461bcd60e51b81526004016107a8906152b8565b6001600160a01b03831660009081526011602052604090205463ffffffff168061136a576000915050611524565b6001600160a01b038416600090815260106020908152604080832063ffffffff6000198601811685529252909120541683106113e6576001600160a01b03841660009081526010602090815260408083206000199490940163ffffffff1683529290522054600160201b90046001600160601b03169050611524565b6001600160a01b038416600090815260106020908152604080832083805290915290205463ffffffff16831015611421576000915050611524565b600060001982015b8163ffffffff168163ffffffff1611156114e457600282820363ffffffff16048103611453613f51565b506001600160a01b038716600090815260106020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b031691810191909152908714156114bf576020015194506115249350505050565b805163ffffffff168711156114d6578193506114dd565b6001820392505b5050611429565b506001600160a01b038516600090815260106020908152604080832063ffffffff909416835292905220546001600160601b03600160201b909104169150505b92915050565b600354600160a01b900460ff166115535760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff16156115835760405162461bcd60e51b81526004016107a8906151c8565b61158d8282612a70565b6001600160a01b03821660009081526008602052604081208054839081106115b157fe5b600091825260208083206001600160a01b038716808552600783526040808620888752845280862033808852908552818720928752600a8552818720898852855281872090875290935291842060059093020193509180611612848461357a565b9092509050811515806116255750600081115b6116415760405162461bcd60e51b81526004016107a890615388565b81158061164c575080155b6116685760405162461bcd60e51b81526004016107a890615188565b8115611781576116788787612aa7565b60006116be85600101546116b264e8d4a510006116a68a600301548a6000015461367190919063ffffffff16565b9063ffffffff6136ab16565b9063ffffffff6136ed16565b6004805460405163135b33cd60e31b81529293506001600160a01b031691639ad99e68916116f2918c913391879101614fa3565b600060405180830381600087803b15801561170c57600080fd5b505af1158015611720573d6000803e3d6000fd5b50508654611737925090508463ffffffff6136ed16565b808655600387015461175a9164e8d4a51000916116a6919063ffffffff61367116565b6001860155855461177b906001600160a01b0316338563ffffffff61372f16565b50611805565b8354611793908263ffffffff6136ed16565b84556001600160a01b03871660009081526012602090815260408083208984529091529020546117c9908263ffffffff6136ed16565b6001600160a01b0380891660009081526012602090815260408083208b845290915290209190915585546118059116338363ffffffff61372f16565b856001600160a01b038816337fe31da05fae6db869f5ea51f4b638aa6884070b6c87f18f63bd2291a12cb2f518611842868663ffffffff612f7216565b60405161184f91906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b1790555050505050565b600e6020526000908152604090205481565b6118c36040518060400160405280601c81526020017f73657428616464726573732c75696e743235362c75696e7432353629000000008152506129ce565b6118cd8383612a70565b6118d683613751565b6001600160a01b0383166000908152600860205260408120805490919061194f9084906119439085908890811061190957fe5b60009182526020808320600160059093020191909101546001600160a01b038b16835260099091526040909120549063ffffffff6136ed16565b9063ffffffff612f7216565b9050600081116119715760405162461bcd60e51b81526004016107a890615408565b600082858154811061197f57fe5b9060005260206000209060050201600101549050838386815481106119a057fe5b9060005260206000209060050201600101819055508160096000886001600160a01b03166001600160a01b031681526020019081526020016000208190555084866001600160a01b03167f6ee09c6cb801194690c195c69f465aaf7c80255cbeafaab9600f47ed79de2ca98387604051611a1b929190615433565b60405180910390a3505050505050565b611a53604051806040016040528060078152602001667061757365282960c81b8152506129ce565b60135460ff1615611a765760405162461bcd60e51b81526004016107a890615268565b6013805460ff1916600117905560405133907fdffada2889ebfab9224c24069d833f3de835d8cf99872d49e7b7ba5fccb7a46f90600090a2565b60135460ff1615611ad35760405162461bcd60e51b81526004016107a8906151c8565b611add8282612a70565b611ae78282612aa7565b5050565b60086020528160005260406000208181548110611b0457fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b039093169550909350919085565b6000806000611b4f8686612a70565b5050506001600160a01b03928316600090815260076020908152604080832094835293815283822092909416815292529020805460018201546002909201549092565b600354600160a01b900460ff16611bbb5760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff1615611beb5760405162461bcd60e51b81526004016107a8906151c8565b611bf58282612a70565b6001600160a01b0382166000908152600860205260408120805483908110611c1957fe5b600091825260208083206001600160a01b0380881685526007835260408086208887528452808620918a1686529252922060059091029091019150611c5e8484612aa7565b611c69848487612093565b15611c865760405162461bcd60e51b81526004016107a8906152e8565b805415611d0a576000611c998284612c84565b90508015611d0857611cab8284612fb4565b6001830155611cbb858783612c98565b83856001600160a01b0316876001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464584604051611cff91906150ae565b60405180910390a45b505b50506003805460ff60a01b1916600160a01b179055505050565b611d4560405180606001604052806033815260200161568c603391396129ce565b611d4f8383612a70565b600081118015611d6257506312cc030081105b611d7e5760405162461bcd60e51b81526004016107a890615398565b6001600160a01b0383166000908152600860205260408120805484908110611da257fe5b9060005260206000209060050201905060008160040154905082826004018190555083856001600160a01b03167f0bcf80c5060ccf99b7a993c57a94b232fc2c5c04bd74c7c7d174595fee6bc31f8386604051611e00929190615433565b60405180910390a35050505050565b6000611e1b8484612a70565b6001600160a01b0384166000908152600860205260408120805485908110611e3f57fe5b600091825260208083206001600160a01b03808a168086526007845260408087208b885285528087208a8416885285528087206003600590970290940195860154918752601285528087208b885290945283862054855494516370a0823160e01b8152959750929590949093611f16939216906370a0823190611ec6903090600401614f4c565b60206040518083038186803b158015611ede57600080fd5b505afa158015611ef2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116b291908101906142db565b90506000611f2261264d565b6001600160a01b038a1660009081526006602052604090205460028701549192509082118015611f5157508215155b15611fe7576000611f6f8760020154846136ed90919063ffffffff16565b6001600160a01b038c1660009081526009602052604081205460018a01549293509091611fb791906116a690611fab868863ffffffff61367116565b9063ffffffff61367116565b9050611fe2611fd5866116a68464e8d4a5100063ffffffff61367116565b879063ffffffff612f7216565b955050505b6001600160a01b03808b166000908152600a602090815260408083208d84528252808320938c16835292905290812090612020826131a3565b91505061204f87600101546116b264e8d4a510006116a68a611fab878e600001546136ed90919063ffffffff16565b9c9b505050505050505050505050565b6000546001600160a01b031633146120895760405162461bcd60e51b81526004016107a890615368565b611ae78282613786565b6001600160a01b038084166000908152600a60209081526040808320868452825280832093851683529290529081206120cb816131a3565b5095945050505050565b6017546001600160a01b031681565b6047546001600160a01b031690565b6001600160a01b03811660009081526011602052604081205463ffffffff168061211e576000610827565b6001600160a01b0383166000908152601060209081526040808320600019850163ffffffff168452909152902054600160201b90046001600160601b03169392505050565b6121846040518060600160405280603081526020016156eb603091396129ce565b60048054604051633d6ac5b360e21b81526001600160a01b039091169163f5ab16cc916121b391869101614f4c565b60206040518083038186803b1580156121cb57600080fd5b505afa1580156121df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612203919081019061425f565b61221f5760405162461bcd60e51b81526004016107a890615358565b61222882613751565b6001600160a01b0382166000818152600660205260409081902080549084905590519091907fad96cee0d692f0250b98e085504f399da6733854908215f6203fe3c69366d9f59061227c9084908690615433565b60405180910390a2505050565b60606122958484612a70565b6001600160a01b038085166000908152600a602090815260408083208784528252808320938616835292815282822080548451818402810184019095528085529092909184015b828210156123365760008481526020908190206040805160608101825260028602909201805483526001908101546001600160801b0380821685870152600160801b909104169183019190915290835290920191016122dc565b5050505090509392505050565b60146020526000908152604090205460ff1681565b60135460ff161561237b5760405162461bcd60e51b81526004016107a8906151c8565b600060405161238990614f36565b604080519182900382208282019091526008825267161594d5985d5b1d60c21b6020909201919091527fddfcc46608a8bd52ebf900f03a24cc97b73a6046cec8c5d0f74a211e376e967a6123db613835565b306040516020016123ef94939291906150ca565b604051602081830303815290604052805190602001209050600060405161241590614f41565b604051908190038120612430918a908a908a906020016150bc565b6040516020818303038152906040528051906020012090506000828260405160200161245d929190614f05565b604051602081830303815290604052805190602001209050600061248382888888613839565b6001600160a01b0381166000908152600e6020526040902080546001810190915590915089146124c55760405162461bcd60e51b81526004016107a890615238565b874211156124e55760405162461bcd60e51b81526004016107a890615218565b6124ef818b6134b0565b505050505b505050505050565b607a5460ff1681565b60066020526000908152604090205481565b6001600160a01b031660009081526008602052604090205490565b6000546001600160a01b0316331461255c5760405162461bcd60e51b81526004016107a890615368565b6001600160a01b0383166125825760405162461bcd60e51b81526004016107a890615228565b6001600160a01b0382166125a85760405162461bcd60e51b81526004016107a8906152c8565b6125b28282612a70565b6016546017546018546040516001600160a01b03808816948116937f8def9436d6e31b89ed00948ba91d0cb6936eada5154cb1b45b55683fb9e492379361260193919092169188918890615024565b60405180910390a3601680546001600160a01b039485166001600160a01b0319918216179091556017805493909416921691909117909155601855565b6003546001600160a01b031681565b607a5460009060ff1661266757612662613863565b61266f565b61266f613867565b905090565b6301e1338081565b60405161104a90614f41565b60185481565b601060209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b6312cc030081565b6000546001600160a01b031681565b6126fb6040518060600160405280602c815260200161571b602c91396129ce565b6127048561353f565b61270d8361353f565b6004546001600160a01b03166127355760405162461bcd60e51b81526004016107a8906151a8565b600084116127555760405162461bcd60e51b81526004016107a8906153a8565b61275e85613751565b6001600160a01b0385166000908152600860205260408120805490915b818110156127d957856001600160a01b031683828154811061279957fe5b60009182526020909120600590910201546001600160a01b031614156127d15760405162461bcd60e51b81526004016107a890615328565b60010161277b565b506001600160a01b03851660009081526014602052604090205460ff16156128135760405162461bcd60e51b81526004016107a890615298565b6001600160a01b03871660009081526009602052604090205461283c908763ffffffff612f7216565b6001600160a01b038089166000908152600960209081526040808320949094556006815290839020879055825160a081018452918816825281018890528391810161288561264d565b8152600060208083018290526040928301889052845460018082018755958352818320855160059092020180546001600160a01b0319166001600160a01b039283161781558583015181880155858501516002820155606086015160038201556080909501516004958601558a81168352601490915290829020805460ff1916851790558254915163fb66fb4d60e01b815291169263fb66fb4d9261292d928c929101615059565b600060405180830381600087803b15801561294757600080fd5b505af115801561295b573d6000803e3d6000fd5b50505050846001600160a01b03166001838054905003886001600160a01b03167fd7fa4bff1cd2253c0789c3291a786a6f6b1a3b4569a75af683a15d52abb6a0bf8988886040516129ae93929190615441565b60405180910390a450505050505050565b6016546001600160a01b031681565b6047546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab90612a019033908690600401614f68565b60206040518083038186803b158015612a1957600080fd5b505afa158015612a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a51919081019061425f565b905080611ae75760405162461bcd60e51b81526004016107a8906151e8565b6001600160a01b0382166000908152600860205260409020548110611ae75760405162461bcd60e51b81526004016107a890615198565b6001600160a01b0382166000908152600860205260408120805483908110612acb57fe5b906000526020600020906005020190508060020154612ae861264d565b11612af35750611ae7565b80546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612b23903090600401614f4c565b60206040518083038186803b158015612b3b57600080fd5b505afa158015612b4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b7391908101906142db565b6001600160a01b0385166000908152601260209081526040808320878452909152902054909150612bab90829063ffffffff6136ed16565b905080612bc957612bba61264d565b82600201819055505050611ae7565b6000612bd361264d565b90506000612bee8460020154836136ed90919063ffffffff16565b6001600160a01b03871660009081526009602090815260408083205460018901546006909352908320549394509192612c3792916116a691611fab90879063ffffffff61367116565b9050612c66612c55856116a68464e8d4a5100063ffffffff61367116565b60038701549063ffffffff612f7216565b6003860155612c7361264d565b856002018190555050505050505050565b600061082783600101546116b28585612fb4565b600480546040516370a0823160e01b81526001600160a01b03918216926000928716916370a0823191612ccd91869101614f4c565b60206040518083038186803b158015612ce557600080fd5b505afa158015612cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612d1d91908101906142db565b6001600160a01b038087166000908152601560209081526040808320938916835292905290812054919250612d58858363ffffffff612f7216565b9050828111612e36578115612dcb576001600160a01b038088166000818152601560209081526040808320948b1680845294909152808220829055517f6bdfd5e51d01475945224d3d37965916fd8df699ef9e8888af4359aa8622216091612dc291879190615418565b60405180910390a35b60405163135b33cd60e31b81526001600160a01b03851690639ad99e6890612dfb908a908a908690600401615009565b600060405180830381600087803b158015612e1557600080fd5b505af1158015612e29573d6000803e3d6000fd5b5050505050505050612f0c565b6001600160a01b038088166000818152601560209081526040808320948b168084529490915290819020868503908190559051909291907f6bdfd5e51d01475945224d3d37965916fd8df699ef9e8888af4359aa8622216090612e9c9087908690615433565b60405180910390a360405163135b33cd60e31b81526001600160a01b03861690639ad99e6890612ed4908b908b908990600401615009565b600060405180830381600087803b158015612eee57600080fd5b505af1158015612f02573d6000803e3d6000fd5b5050505050505050505b505050565b604051612f6c9085906323b872dd60e01b90612f3590879087908790602401615009565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261386b565b50505050565b600061082783836040518060400160405280601b81526020017f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815250613950565b600061082764e8d4a510006116a68460030154611fab876002015488600001546136ed90919063ffffffff16565b600081600160601b84106130095760405162461bcd60e51b81526004016107a89190615167565b509192915050565b816001600160a01b0316836001600160a01b03161415801561303c57506000816001600160601b0316115b15612f0c576001600160a01b038316156130f4576001600160a01b03831660009081526011602052604081205463ffffffff16908161307c5760006130bb565b6001600160a01b0385166000908152601060209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b905060006130e282856040518060600160405280602c81526020016156bf602c9139613980565b90506130f0868484846139bf565b5050505b6001600160a01b03821615612f0c576001600160a01b03821660009081526011602052604081205463ffffffff16908161312f57600061316e565b6001600160a01b0384166000908152601060209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b9050600061319582856040518060600160405280602b81526020016155ab602b9139613b7b565b90506124f4858484846139bf565b805460009081905b8015613241578360018203815481106131c057fe5b6000918252602090912060016002909202018101546001600160801b03600160801b9091041614156132235761321c8460018303815481106131fe57fe5b6000918252602090912060029091020154839063ffffffff612f7216565b9150613238565b6132358460018303815481106112c157fe5b92505b600019016131ab565b50915091565b8254604080516060810182526000808252602080830182815260019484018581528587018a5589845291909220925160028602909301928355905191909201805492516001600160801b03908116600160801b029281166001600160801b0319909416939093179092161790555b6000811180156132f05750818460018303815481106132d057fe5b60009182526020909120600160029092020101546001600160801b031611155b156133775783600182038154811061330457fe5b906000526020600020906002020184828154811061331e57fe5b600091825260209091208254600290920201908155600191820180549290910180546001600160801b0319166001600160801b03938416178082559154600160801b9081900484160291909216179055600019016132b5565b604051806060016040528084815260200161339184613bae565b6001600160801b0316815260200160016001600160801b03168152508482815481106133b957fe5b60009182526020918290208351600292830290910190815591830151600190920180546040909401516001600160801b03199094166001600160801b03938416178316600160801b939094169290920292909217905585015461341c9084612f72565b85600201819055505050505050565b6001600160a01b0381166134515760405162461bcd60e51b81526004016107a890615278565b604780546001600160a01b038381166001600160a01b03198316179092556040519116907f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0906134a49083908590614f88565b60405180910390a15050565b6001600160a01b038083166000908152600f6020526040812054909116906134d784613bd7565b6001600160a01b038581166000818152600f602052604080822080546001600160a01b031916898616908117909155905194955093928616927f0cc323ffec3ea49cbcddc0de1480978126d350c6a45dff33ad2f1cda6ae992619190a4612f6c828483613011565b6001600160a01b038116610f0a5760405162461bcd60e51b81526004016107a8906152d8565b60010154426001600160801b03909116111590565b805460009081905b60008111801561359f575061359f84600183038154811061129757fe5b15613640578360018203815481106135b357fe5b6000918252602090912060016002909202018101546001600160801b03600160801b9091041614156135f8576135f18460018303815481106131fe57fe5b915061360d565b61360a8460018303815481106112c157fe5b92505b8380548061361757fe5b600082815260208120600019928301600281029091018281556001019190915590915501613582565b50613665613654828463ffffffff612f7216565b60028601549063ffffffff6136ed16565b60028501559250929050565b60008261368057506000611524565b8282028284828161368d57fe5b04146108275760405162461bcd60e51b81526004016107a890615318565b600061082783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613ced565b600061082783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613d24565b604051612f0c90849063a9059cbb60e01b90612f359086908690602401615074565b6001600160a01b038116600090815260086020526040812054905b81811015612f0c5761377e8382612aa7565b60010161376c565b607a54610100900460ff16156137ae5760405162461bcd60e51b81526004016107a8906153b8565b811580156137ba575080155b156137d75760405162461bcd60e51b81526004016107a890615338565b8180156137e357508015155b156138005760405162461bcd60e51b81526004016107a890615258565b607a805460ff191683151517905581613819578061381f565b6301e133805b6079555050607a805461ff001916610100179055565b4690565b600080600061384a87878787613d48565b9150915061385781613e28565b5090505b949350505050565b4390565b4290565b61387d826001600160a01b0316613ef1565b6138995760405162461bcd60e51b81526004016107a8906153d8565b60006060836001600160a01b0316836040516138b59190614ef9565b6000604051808303816000865af19150503d80600081146138f2576040519150601f19603f3d011682016040523d82523d6000602084013e6138f7565b606091505b5091509150816139195760405162461bcd60e51b81526004016107a8906153c8565b805115612f6c5780806020019051613934919081019061425f565b612f6c5760405162461bcd60e51b81526004016107a890615208565b600083830182858210156139775760405162461bcd60e51b81526004016107a89190615167565b50949350505050565b6000836001600160601b0316836001600160601b0316111582906139b75760405162461bcd60e51b81526004016107a89190615167565b505050900390565b60006139ea6139cc61264d565b60405180608001604052806042815260200161564a60429139613f2a565b905060008463ffffffff16118015613a3357506001600160a01b038516600090815260106020908152604080832063ffffffff6000198901811685529252909120548282169116145b15613a92576001600160a01b0385166000908152601060209081526040808320600019880163ffffffff168452909152902080546fffffffffffffffffffffffff000000001916600160201b6001600160601b03851602179055613b31565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000818152601083528781208c871682528352878120965187549451909516600160201b026fffffffffffffffffffffffff000000001995871663ffffffff19958616179590951694909417909555938252601190935292909220805460018801909316929091169190911790555b846001600160a01b03167f6adb589fed1e8542fb7a6b10f00a85e02265e77f9ae3ca8ff93b22983e1af9a08484604051613b6c929190615493565b60405180910390a25050505050565b6000838301826001600160601b0380871690831610156139775760405162461bcd60e51b81526004016107a89190615167565b6000600160801b8210613bd35760405162461bcd60e51b81526004016107a890615248565b5090565b6005546000906001600160a01b0316613c025760405162461bcd60e51b81526004016107a8906151f8565b6005546001600160a01b03166000908152600860205260408120805490915b81811015613ce25760055483546001600160a01b0390911690849083908110613c4657fe5b60009182526020909120600590910201546001600160a01b03161415613cda576005546001600160a01b039081166000908152600760209081526040808320858452825280832093891683529290522060028101548154613ccf91613cb1919063ffffffff6136ed16565b60405180606001604052806028815260200161560160289139612fe2565b94505050505061108d565b600101613c21565b506000949350505050565b60008183613d0e5760405162461bcd60e51b81526004016107a89190615167565b506000838581613d1a57fe5b0495945050505050565b600081848411156139b75760405162461bcd60e51b81526004016107a89190615167565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613d7f5750600090506003613e1f565b8460ff16601b14158015613d9757508460ff16601c14155b15613da85750600090506004613e1f565b600060018787878760405160008152602001604052604051613dcd94939291906150f2565b6020604051602081039080840390855afa158015613def573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613e1857506000915060019050613e1f565b9150600090505b94509492505050565b6000816004811115613e3657fe5b1415613e4157610f0a565b6001816004811115613e4f57fe5b1415613e6d5760405162461bcd60e51b81526004016107a890615178565b6002816004811115613e7b57fe5b1415613e995760405162461bcd60e51b81526004016107a8906151b8565b6003816004811115613ea757fe5b1415613ec55760405162461bcd60e51b81526004016107a890615288565b6004816004811115613ed357fe5b1415610f0a5760405162461bcd60e51b81526004016107a8906152f8565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061385b575050151592915050565b600081600160201b84106130095760405162461bcd60e51b81526004016107a89190615167565b604080518082019091526000808252602082015290565b803561152481615569565b805161152481615569565b80356115248161557d565b80516115248161557d565b803561152481615586565b80356115248161558f565b805161152481615586565b803561152481615598565b8035611524816155a1565b600060208284031215613fdd57600080fd5b600061385b8484613f68565b600060208284031215613ffb57600080fd5b600061385b8484613f73565b6000806040838503121561401a57600080fd5b60006140268585613f68565b925050602061403785828601613f68565b9150509250929050565b60008060006060848603121561405657600080fd5b60006140628686613f68565b935050602061407386828701613f68565b925050604061408486828701613f94565b9150509250925092565b600080604083850312156140a157600080fd5b60006140ad8585613f68565b925050602061403785828601613f94565b6000806000606084860312156140d357600080fd5b60006140df8686613f68565b93505060206140f086828701613f94565b925050604061408486828701613f68565b600080600080600060a0868803121561411957600080fd5b60006141258888613f68565b955050602061413688828901613f94565b945050604061414788828901613f9f565b935050606061415888828901613f94565b925050608061416988828901613f94565b9150509295509295909350565b60008060006060848603121561418b57600080fd5b60006141978686613f68565b935050602061407386828701613f94565b60008060008060008060c087890312156141c157600080fd5b60006141cd8989613f68565b96505060206141de89828a01613f94565b95505060406141ef89828a01613f94565b945050606061420089828a01613fc0565b935050608061421189828a01613f94565b92505060a061422289828a01613f94565b9150509295509295509295565b6000806040838503121561424257600080fd5b600061424e8585613f68565b925050602061403785828601613fb5565b60006020828403121561427157600080fd5b600061385b8484613f89565b6000806040838503121561429057600080fd5b60006140ad8585613f7e565b6000806000606084860312156142b157600080fd5b60006140628686613f9f565b6000602082840312156142cf57600080fd5b600061385b8484613f9f565b6000602082840312156142ed57600080fd5b600061385b8484613faa565b60006143058383614e99565b505060600190565b61431681615512565b82525050565b614316816154c1565b6000614330826154b4565b61433a81856154b8565b9350614345836154ae565b8060005b8381101561437357815161435d88826142f9565b9750614368836154ae565b925050600101614349565b509495945050505050565b614316816154cc565b614316816154d1565b61431661439c826154d1565b6154d1565b60006143ac826154b4565b6143b6818561108d565b93506143c6818560208601615533565b9290920192915050565b614316816154d4565b6143168161551d565b60006143ed826154b4565b6143f781856154b8565b9350614407818560208601615533565b6144108161555f565b9093019392505050565b60006144276018836154b8565b7f45434453413a20696e76616c6964207369676e61747572650000000000000000815260200192915050565b60006144606012836154b8565b71696e636f6e73697374656e7420737461746560701b815260200192915050565b600061448e6013836154b8565b727661756c743a20706f6f6c206578697374733f60681b815260200192915050565b60006144bd601f836154b8565b7f53746f726520636f6e7472616374206164647265737320697320656d70747900815260200192915050565b60006144f6601f836154b8565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800815260200192915050565b600061452f600f836154b8565b6e15985d5b1d081a5cc81c185d5cd959608a1b815260200192915050565b600061455a6013836154b8565b7215985d5b1d081a5cc81b9bdd081c185d5cd959606a1b815260200192915050565b6000614589600c836154b8565b6b155b985d5d1a1bdc9a5e995960a21b815260200192915050565b60006145b16030836154b8565b7f5856535661756c743a3a6765745374616b65416d6f756e743a2078767320616481526f191c995cdcc81a5cc81b9bdd081cd95d60821b602082015260400192915050565b6000614603602a836154b8565b7f5361666542455032303a204245503230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b602082015260400192915050565b600061464f602a836154b8565b7f5856535661756c743a3a64656c656761746542795369673a207369676e6174758152691c9948195e1c1a5c995960b21b602082015260400192915050565b600061469b6022836154b8565b7f7072696d6520746f6b656e2063616e6e6f74206265207a65726f206164647265815261737360f01b602082015260400192915050565b60006146df6026836154b8565b7f5856535661756c743a3a64656c656761746542795369673a20696e76616c6964815265206e6f6e636560d01b602082015260400192915050565b600061472760028361108d565b61190160f01b815260020192915050565b60006147456027836154b8565b7f53616665436173743a2076616c756520646f65736e27742066697420696e20318152663238206269747360c81b602082015260400192915050565b600061478e6020836154b8565b7f496e76616c69642074696d6520626173656420636f6e66696775726174696f6e815260200192915050565b60006147c76017836154b8565b7f5661756c7420697320616c726561647920706175736564000000000000000000815260200192915050565b60006148006025836154b8565b7f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164815264647265737360d81b602082015260400192915050565b60006148476022836154b8565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b602082015260400192915050565b600061488b601a836154b8565b7f546f6b656e2065786973747320696e206f7468657220706f6f6c000000000000815260200192915050565b60006148c46013836154b8565b72185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b815260200192915050565b60006148f3602b836154b8565b7f5856535661756c743a3a6765745072696f72566f7465733a206e6f742079657481526a0819195d195c9b5a5b995960aa1b602082015260400192915050565b6000614940601d836154b8565b7f7265776172642063616e6e6f74206265207a65726f2061646472657373000000815260200192915050565b60006149796018836154b8565b7f7a65726f2061646472657373206e6f7420616c6c6f7765640000000000000000815260200192915050565b60006149b2601a836154b8565b7f657865637574652070656e64696e67207769746864726177616c000000000000815260200192915050565b60006149eb6022836154b8565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b602082015260400192915050565b6000614a2f60438361108d565b7f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353681527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208201526263742960e81b604082015260430192915050565b6000614a9a601f836154b8565b7f72657175657374656420616d6f756e742063616e6e6f74206265207a65726f00815260200192915050565b6000614ad36021836154b8565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000614b166012836154b8565b71141bdbdb08185b1c9958591e48185919195960721b815260200192915050565b6000614b446017836154b8565b7f496e76616c696420626c6f636b73207065722079656172000000000000000000815260200192915050565b6000614b7d600a836154b8565b691c994b595b9d195c995960b21b815260200192915050565b6000614ba36014836154b8565b7324b73b30b634b2103932bbb0b932103a37b5b2b760611b815260200192915050565b6000614bd3600e836154b8565b6d37b7363c9030b236b4b71031b0b760911b815260200192915050565b6000614bfd6015836154b8565b7418da185b99d9481b9bdd08185d5d1a1bdc9a5e9959605a1b815260200192915050565b6000614c2e6013836154b8565b726e6f7468696e6720746f20776974686472617760681b815260200192915050565b6000614c5d601a836154b8565b7f496e76616c6964206e6577206c6f636b696e6720706572696f64000000000000815260200192915050565b6000614c96601d836154b8565b7f416c6c6f6320706f696e7473206d757374206e6f74206265207a65726f000000815260200192915050565b6000614ccf601f836154b8565b7f416c726561647920696e697469616c697a65642054696d654d616e6167657200815260200192915050565b6000614d086020836154b8565b7f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564815260200192915050565b6000614d41603a8361108d565b7f44656c65676174696f6e28616464726573732064656c6567617465652c75696e81527f74323536206e6f6e63652c75696e7432353620657870697279290000000000006020820152603a0192915050565b6000614da0601f836154b8565b7f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e747261637400815260200192915050565b6000614dd9601b836154b8565b7f72657175657374656420616d6f756e7420697320696e76616c69640000000000815260200192915050565b6000614e126022836154b8565b7f6f6e6c792070726f78792061646d696e2063616e206368616e676520627261698152616e7360f01b602082015260400192915050565b6000614e56602e836154b8565b7f416c6c6f6320706f696e7473207065722072657761726420746f6b656e206d7581526d7374206e6f74206265207a65726f60901b602082015260400192915050565b80516060830190614eaa8482614387565b506020820151614ebd6020850182614ecc565b506040820151612f6c60408501825b614316816154df565b614316816154f7565b61431681615500565b61431681615528565b61431681615506565b600061082782846143a1565b6000614f108261471a565b9150614f1c8285614390565b602082019150614f2c8284614390565b5060200192915050565b600061152482614a22565b600061152482614d34565b60208101611524828461431c565b60208101611524828461430d565b60408101614f76828561430d565b818103602083015261385b81846143e2565b60408101614f96828561431c565b610827602083018461431c565b60608101614fb1828661431c565b614fbe602083018561430d565b61385b6040830184614387565b60808101614fd9828761431c565b614fe6602083018661431c565b614ff3604083018561431c565b615000606083018461431c565b95945050505050565b60608101615017828661431c565b614fbe602083018561431c565b60808101615032828761431c565b61503f602083018661431c565b61504c6040830185614387565b6150006060830184614387565b60408101615067828561431c565b610827602083018461437e565b60408101615082828561431c565b6108276020830184614387565b602080825281016108278184614325565b60208101611524828461437e565b602081016115248284614387565b608081016150328287614387565b608081016150d88287614387565b6150e56020830186614387565b614ff36040830185614387565b608081016151008287614387565b61503f6020830186614ede565b6020810161152482846143d0565b60a0810161512982886143d0565b6151366020830187614387565b6151436040830186614387565b6151506060830185614387565b61515d6080830184614387565b9695505050505050565b6020808252810161082781846143e2565b602080825281016115248161441a565b6020808252810161152481614453565b6020808252810161152481614481565b60208082528101611524816144b0565b60208082528101611524816144e9565b6020808252810161152481614522565b602080825281016115248161454d565b602080825281016115248161457c565b60208082528101611524816145a4565b60208082528101611524816145f6565b6020808252810161152481614642565b602080825281016115248161468e565b60208082528101611524816146d2565b6020808252810161152481614738565b6020808252810161152481614781565b60208082528101611524816147ba565b60208082528101611524816147f3565b602080825281016115248161483a565b602080825281016115248161487e565b60208082528101611524816148b7565b60208082528101611524816148e6565b6020808252810161152481614933565b602080825281016115248161496c565b60208082528101611524816149a5565b60208082528101611524816149de565b6020808252810161152481614a8d565b6020808252810161152481614ac6565b6020808252810161152481614b09565b6020808252810161152481614b37565b6020808252810161152481614b70565b6020808252810161152481614b96565b6020808252810161152481614bc6565b6020808252810161152481614bf0565b6020808252810161152481614c21565b6020808252810161152481614c50565b6020808252810161152481614c89565b6020808252810161152481614cc2565b6020808252810161152481614cfb565b6020808252810161152481614d93565b6020808252810161152481614dcc565b6020808252810161152481614e05565b6020808252810161152481614e49565b604081016154268285614387565b61082760208301846143d9565b604081016150828285614387565b6060810161544f8286614387565b614fbe6020830185614387565b602081016115248284614ed5565b604081016154788285614ed5565b6108276020830184614ef0565b602081016115248284614ef0565b604081016154a18285614ee7565b6108276020830184614ee7565b60200190565b5190565b90815260200190565b6000611524826154eb565b151590565b90565b6000611524826154c1565b6001600160801b031690565b6001600160a01b031690565b63ffffffff1690565b60ff1690565b6001600160601b031690565b6000611524826154d4565b6000611524826154d1565b600061152482615506565b60005b8381101561554e578181015183820152602001615536565b83811115612f6c5750506000910152565b601f01601f191690565b615572816154c1565b8114610f0a57600080fd5b615572816154cc565b615572816154d1565b615572816154d4565b615572816154f7565b6155728161550056fe5856535661756c743a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f77735856535661756c743a3a726571756573745769746864726177616c3a20766f746573206f766572666c6f775856535661756c743a3a6765745374616b65416d6f756e743a20766f746573206f766572666c6f775856535661756c743a3a6465706f7369743a20766f746573206f766572666c6f775856535661756c743a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206f72207365636f6e64206578636565647320333220626974737365745769746864726177616c4c6f636b696e67506572696f6428616464726573732c75696e743235362c75696e74323536295856535661756c743a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f7773736574526577617264416d6f756e74506572426c6f636b4f725365636f6e6428616464726573732c75696e743235362961646428616464726573732c75696e743235362c616464726573732c75696e743235362c75696e7432353629a365627a7a7231582053ba350123a86f07263e7bddf3bcee0f7cf11e72f5d2678781f0eb1ebd599dc16c6578706572696d656e74616cf564736f6c63430005100040", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103785760003560e01c806392e35000116101d3578063c7ad089511610104578063e7a324dc116100a2578063f55401621161007c578063f554016214610732578063f851a4401461073a578063fba1b1f914610742578063fe5a451a1461075557610378565b8063e7a324dc14610701578063e8f2be6f14610709578063f1127ed81461071157610378565b8063dae66bbe116100de578063dae66bbe146106d6578063de0368b2146106e9578063e1d146fb146106f1578063e6a69ab8146106f957610378565b8063c7ad0895146106a8578063cd9b94e7146106b0578063d7ae45e2146106c357610378565b8063add8933711610171578063b6a5fd2f1161014b578063b6a5fd2f1461064f578063c210259614610662578063c3c754a814610682578063c3cda5201461069557610378565b8063add893371461061f578063b4a0bdf314610627578063b4b5ea571461063c57610378565b80639e2b6c4d116101ad5780639e2b6c4d146105d3578063a09eab7a146105e6578063a6997762146105f9578063a9d69a691461060c57610378565b806392e350001461057a57806398e1b31b1461059e578063996cba68146105c057610378565b80635c19a95c116102ad57806373d025d61161024b5780637ecebe00116102255780637ecebe00146105395780638308d7e91461054c5780638456cb591461055f5780638ed7333d1461056757610378565b806373d025d6146104f1578063782d6fe1146105065780637ac924561461052657610378565b80635ff56315116102875780635ff56315146104a35780636857249c146104b65780636dd77cbd146104be5780636fcfff45146104d157610378565b80635c19a95c146104755780635c60da1b146104885780635f14e7001461049057610378565b806324f52bbf1161031a578063358ae036116102f4578063358ae036146104345780633d4180f91461043c5780634298bdbd1461044f578063587cde1e1461046257610378565b806324f52bbf1461040457806326782247146104195780632eda5c6c1461042157610378565b8063115b512f11610356578063115b512f146103c357806319129e5a146103d65780631d504dc6146103e957806320606b70146103fc57610378565b8063046f7da21461037d5780630af13728146103875780630efe6a8b146103b0575b600080fd5b61038561075d565b005b61039a6103953660046140be565b6107e8565b6040516103a791906150ae565b60405180910390f35b6103856103be366004614176565b61082e565b6103856103d1366004614176565b610b23565b6103856103e4366004613fcb565b610ed7565b6103856103f73660046142bd565b610f0d565b61039a61103e565b61040c611055565b6040516103a79190614f4c565b61040c611064565b61039a61042f366004613fcb565b611073565b61040c611092565b61039a61044a366004614007565b6110a1565b61039a61045d366004613fcb565b6110be565b61040c610470366004613fcb565b6110d0565b610385610483366004613fcb565b6110eb565b61040c611118565b61039a61049e36600461408e565b611127565b6103856104b1366004614007565b611144565b61039a611238565b61039a6104cc3660046140be565b61123e565b6104e46104df366004613fcb565b6112f3565b6040516103a7919061545c565b6104f961130b565b6040516103a791906150a0565b61051961051436600461408e565b611314565b6040516103a79190615485565b61038561053436600461408e565b61152a565b61039a610547366004613fcb565b611873565b61038561055a366004614176565b611885565b610385611a2b565b61038561057536600461408e565b611ab0565b61058d61058836600461408e565b611aeb565b6040516103a795949392919061511b565b6105b16105ac3660046140be565b611b40565b6040516103a793929190615441565b6103856105ce366004614041565b611b92565b6103856105e1366004614176565b611d24565b61039a6105f43660046140be565b611e0f565b61038561060736600461427d565b61205f565b61039a61061a3660046140be565b612093565b61040c6120d5565b61062f6120e4565b6040516103a7919061510d565b61051961064a366004613fcb565b6120f3565b61038561065d36600461408e565b612163565b6106756106703660046140be565b612289565b6040516103a7919061508f565b6104f9610690366004613fcb565b612343565b6103856106a33660046141a8565b612358565b6104f96124fc565b61039a6106be366004613fcb565b612505565b61039a6106d1366004613fcb565b612517565b6103856106e436600461429c565b612532565b61040c61263e565b61039a61264d565b61039a612674565b61039a61267c565b61039a612688565b61072461071f36600461422f565b61268e565b6040516103a792919061546a565b61039a6126c3565b61040c6126cb565b610385610750366004614101565b6126da565b61062f6129bf565b61078660405180604001604052806008815260200167726573756d65282960c01b8152506129ce565b60135460ff166107b15760405162461bcd60e51b81526004016107a8906151d8565b60405180910390fd5b6013805460ff1916905560405133907fd2619572a1464e0df0bb351d834fd47f3350984d7bfdb1ab69cfcb0b8e42141590600090a2565b60006107f48484612a70565b506001600160a01b0380841660009081526007602090815260408083208684528252808320938516835292905220600201545b9392505050565b600354600160a01b900460ff166108575760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff16156108875760405162461bcd60e51b81526004016107a8906151c8565b6108918383612a70565b6001600160a01b03831660009081526008602052604081208054849081106108b557fe5b600091825260208083206001600160a01b038816845260078252604080852088865283528085203386529092529220600590910290910191506108f88585612aa7565b610903858533612093565b156109205760405162461bcd60e51b81526004016107a8906152e8565b8054156109955760006109338284612c84565b9050801561099357610946863383612c98565b84866001600160a01b0316336001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946458460405161098a91906150ae565b60405180910390a45b505b81546109b2906001600160a01b031633308663ffffffff612f1116565b80546109c4908463ffffffff612f7216565b81556109d08183612fb4565b600182015560055482546001600160a01b0390811691161415610a3757336000908152600f60209081526040808320548151606081019092526021808352610a3794936001600160a01b0390921692610a329289929061562990830139612fe2565b613011565b6017546001600160a01b038681169116148015610a55575060185484145b15610abd576016546040516337f23cd360e01b81526001600160a01b03909116906337f23cd390610a8a903390600401614f5a565b600060405180830381600087803b158015610aa457600080fd5b505af1158015610ab8573d6000803e3d6000fd5b505050505b83856001600160a01b0316336001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d786604051610b0191906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b179055505050565b600354600160a01b900460ff16610b4c5760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff1615610b7c5760405162461bcd60e51b81526004016107a8906151c8565b610b868383612a70565b60008111610ba65760405162461bcd60e51b81526004016107a890615308565b6001600160a01b0383166000908152600760209081526040808320858452825280832033845290915290206002810154610be6908363ffffffff612f7216565b81541015610c065760405162461bcd60e51b81526004016107a8906153e8565b6001600160a01b0384166000908152600860205260408120805485908110610c2a57fe5b600091825260208083206001600160a01b0389168452600a825260408085208986528352808520338652909252908320600590920201925090610c6c826131a3565b5090508015610c8d5760405162461bcd60e51b81526004016107a8906152e8565b610c978787612aa7565b6000610ca38585612c84565b9050610cb0883383612c98565b6004840154600090610cc8904263ffffffff612f7216565b9050610cd686858984613247565b6001600160a01b03891660009081526012602090815260408083208b8452909152902054610d0a908863ffffffff612f7216565b6001600160a01b038a1660009081526012602090815260408083208c8452909152902055610d388686612fb4565b600187015560055485546001600160a01b0390811691161415610d9b57336000908152600f6020908152604080832054815160608101909252602b808352610d9b946001600160a01b03909216939192610a32928d92906155d690830139612fe2565b6017546001600160a01b038a81169116148015610db9575060185488145b15610e21576016546040516337f23cd360e01b81526001600160a01b03909116906337f23cd390610dee903390600401614f5a565b600060405180830381600087803b158015610e0857600080fd5b505af1158015610e1c573d6000803e3d6000fd5b505050505b87896001600160a01b0316336001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464585604051610e6591906150ae565b60405180910390a487896001600160a01b0316336001600160a01b03167f88a254a0ef28a0b9e957ff600beae69870f6f924065147f3627c3f814e60ec118a604051610eb191906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b17905550505050505050565b6000546001600160a01b03163314610f015760405162461bcd60e51b81526004016107a890615368565b610f0a8161342b565b50565b806001600160a01b031663f851a4406040518163ffffffff1660e01b815260040160206040518083038186803b158015610f4657600080fd5b505afa158015610f5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f7e9190810190613fe9565b6001600160a01b0316336001600160a01b031614610fae5760405162461bcd60e51b81526004016107a8906153f8565b806001600160a01b031663c1e803346040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610fe957600080fd5b505af1158015610ffd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061102191908101906142db565b15610f0a5760405162461bcd60e51b81526004016107a890615378565b60405161104a90614f36565b604051809103902081565b6004546001600160a01b031681565b6001546001600160a01b031681565b6001600160a01b0381166000908152600660205260409020545b919050565b6005546001600160a01b031681565b601560209081526000928352604080842090915290825290205481565b60096020526000908152604090205481565b600f602052600090815260409020546001600160a01b031681565b60135460ff161561110e5760405162461bcd60e51b81526004016107a8906151c8565b610f0a33826134b0565b6002546001600160a01b031681565b601260209081526000928352604080842090915290825290205481565b6000546001600160a01b0316331461116e5760405162461bcd60e51b81526004016107a890615368565b6111778261353f565b6111808161353f565b6005546004546001600160a01b03918216911681156111b15760405162461bcd60e51b81526004016107a8906152a8565b600580546001600160a01b038087166001600160a01b03199283161790925560048054928616929091169190911790556003805460ff60a01b1916600160a01b1790556040517f559f314bb90394a4a9ceb724f365b36a53587d894352c43d12901fd6801014569061122a908490849088908890614fcb565b60405180910390a150505050565b60795481565b600061124a8484612a70565b6001600160a01b038085166000908152600a60209081526040808320878452825280832093861683529290522080545b6000811180156112aa57506112aa82600183038154811061129757fe5b9060005260206000209060020201613565565b156112ea576112df8260018303815481106112c157fe5b6000918252602090912060029091020154849063ffffffff612f7216565b92506000190161127a565b50509392505050565b60116020526000908152604090205463ffffffff1681565b60135460ff1681565b600061131e61264d565b821061133c5760405162461bcd60e51b81526004016107a8906152b8565b6001600160a01b03831660009081526011602052604090205463ffffffff168061136a576000915050611524565b6001600160a01b038416600090815260106020908152604080832063ffffffff6000198601811685529252909120541683106113e6576001600160a01b03841660009081526010602090815260408083206000199490940163ffffffff1683529290522054600160201b90046001600160601b03169050611524565b6001600160a01b038416600090815260106020908152604080832083805290915290205463ffffffff16831015611421576000915050611524565b600060001982015b8163ffffffff168163ffffffff1611156114e457600282820363ffffffff16048103611453613f51565b506001600160a01b038716600090815260106020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b031691810191909152908714156114bf576020015194506115249350505050565b805163ffffffff168711156114d6578193506114dd565b6001820392505b5050611429565b506001600160a01b038516600090815260106020908152604080832063ffffffff909416835292905220546001600160601b03600160201b909104169150505b92915050565b600354600160a01b900460ff166115535760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff16156115835760405162461bcd60e51b81526004016107a8906151c8565b61158d8282612a70565b6001600160a01b03821660009081526008602052604081208054839081106115b157fe5b600091825260208083206001600160a01b038716808552600783526040808620888752845280862033808852908552818720928752600a8552818720898852855281872090875290935291842060059093020193509180611612848461357a565b9092509050811515806116255750600081115b6116415760405162461bcd60e51b81526004016107a890615388565b81158061164c575080155b6116685760405162461bcd60e51b81526004016107a890615188565b8115611781576116788787612aa7565b60006116be85600101546116b264e8d4a510006116a68a600301548a6000015461367190919063ffffffff16565b9063ffffffff6136ab16565b9063ffffffff6136ed16565b6004805460405163135b33cd60e31b81529293506001600160a01b031691639ad99e68916116f2918c913391879101614fa3565b600060405180830381600087803b15801561170c57600080fd5b505af1158015611720573d6000803e3d6000fd5b50508654611737925090508463ffffffff6136ed16565b808655600387015461175a9164e8d4a51000916116a6919063ffffffff61367116565b6001860155855461177b906001600160a01b0316338563ffffffff61372f16565b50611805565b8354611793908263ffffffff6136ed16565b84556001600160a01b03871660009081526012602090815260408083208984529091529020546117c9908263ffffffff6136ed16565b6001600160a01b0380891660009081526012602090815260408083208b845290915290209190915585546118059116338363ffffffff61372f16565b856001600160a01b038816337fe31da05fae6db869f5ea51f4b638aa6884070b6c87f18f63bd2291a12cb2f518611842868663ffffffff612f7216565b60405161184f91906150ae565b60405180910390a450506003805460ff60a01b1916600160a01b1790555050505050565b600e6020526000908152604090205481565b6118c36040518060400160405280601c81526020017f73657428616464726573732c75696e743235362c75696e7432353629000000008152506129ce565b6118cd8383612a70565b6118d683613751565b6001600160a01b0383166000908152600860205260408120805490919061194f9084906119439085908890811061190957fe5b60009182526020808320600160059093020191909101546001600160a01b038b16835260099091526040909120549063ffffffff6136ed16565b9063ffffffff612f7216565b9050600081116119715760405162461bcd60e51b81526004016107a890615408565b600082858154811061197f57fe5b9060005260206000209060050201600101549050838386815481106119a057fe5b9060005260206000209060050201600101819055508160096000886001600160a01b03166001600160a01b031681526020019081526020016000208190555084866001600160a01b03167f6ee09c6cb801194690c195c69f465aaf7c80255cbeafaab9600f47ed79de2ca98387604051611a1b929190615433565b60405180910390a3505050505050565b611a53604051806040016040528060078152602001667061757365282960c81b8152506129ce565b60135460ff1615611a765760405162461bcd60e51b81526004016107a890615268565b6013805460ff1916600117905560405133907fdffada2889ebfab9224c24069d833f3de835d8cf99872d49e7b7ba5fccb7a46f90600090a2565b60135460ff1615611ad35760405162461bcd60e51b81526004016107a8906151c8565b611add8282612a70565b611ae78282612aa7565b5050565b60086020528160005260406000208181548110611b0457fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b039093169550909350919085565b6000806000611b4f8686612a70565b5050506001600160a01b03928316600090815260076020908152604080832094835293815283822092909416815292529020805460018201546002909201549092565b600354600160a01b900460ff16611bbb5760405162461bcd60e51b81526004016107a890615348565b6003805460ff60a01b1916905560135460ff1615611beb5760405162461bcd60e51b81526004016107a8906151c8565b611bf58282612a70565b6001600160a01b0382166000908152600860205260408120805483908110611c1957fe5b600091825260208083206001600160a01b0380881685526007835260408086208887528452808620918a1686529252922060059091029091019150611c5e8484612aa7565b611c69848487612093565b15611c865760405162461bcd60e51b81526004016107a8906152e8565b805415611d0a576000611c998284612c84565b90508015611d0857611cab8284612fb4565b6001830155611cbb858783612c98565b83856001600160a01b0316876001600160a01b03167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464584604051611cff91906150ae565b60405180910390a45b505b50506003805460ff60a01b1916600160a01b179055505050565b611d4560405180606001604052806033815260200161568c603391396129ce565b611d4f8383612a70565b600081118015611d6257506312cc030081105b611d7e5760405162461bcd60e51b81526004016107a890615398565b6001600160a01b0383166000908152600860205260408120805484908110611da257fe5b9060005260206000209060050201905060008160040154905082826004018190555083856001600160a01b03167f0bcf80c5060ccf99b7a993c57a94b232fc2c5c04bd74c7c7d174595fee6bc31f8386604051611e00929190615433565b60405180910390a35050505050565b6000611e1b8484612a70565b6001600160a01b0384166000908152600860205260408120805485908110611e3f57fe5b600091825260208083206001600160a01b03808a168086526007845260408087208b885285528087208a8416885285528087206003600590970290940195860154918752601285528087208b885290945283862054855494516370a0823160e01b8152959750929590949093611f16939216906370a0823190611ec6903090600401614f4c565b60206040518083038186803b158015611ede57600080fd5b505afa158015611ef2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506116b291908101906142db565b90506000611f2261264d565b6001600160a01b038a1660009081526006602052604090205460028701549192509082118015611f5157508215155b15611fe7576000611f6f8760020154846136ed90919063ffffffff16565b6001600160a01b038c1660009081526009602052604081205460018a01549293509091611fb791906116a690611fab868863ffffffff61367116565b9063ffffffff61367116565b9050611fe2611fd5866116a68464e8d4a5100063ffffffff61367116565b879063ffffffff612f7216565b955050505b6001600160a01b03808b166000908152600a602090815260408083208d84528252808320938c16835292905290812090612020826131a3565b91505061204f87600101546116b264e8d4a510006116a68a611fab878e600001546136ed90919063ffffffff16565b9c9b505050505050505050505050565b6000546001600160a01b031633146120895760405162461bcd60e51b81526004016107a890615368565b611ae78282613786565b6001600160a01b038084166000908152600a60209081526040808320868452825280832093851683529290529081206120cb816131a3565b5095945050505050565b6017546001600160a01b031681565b6047546001600160a01b031690565b6001600160a01b03811660009081526011602052604081205463ffffffff168061211e576000610827565b6001600160a01b0383166000908152601060209081526040808320600019850163ffffffff168452909152902054600160201b90046001600160601b03169392505050565b6121846040518060600160405280603081526020016156eb603091396129ce565b60048054604051633d6ac5b360e21b81526001600160a01b039091169163f5ab16cc916121b391869101614f4c565b60206040518083038186803b1580156121cb57600080fd5b505afa1580156121df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612203919081019061425f565b61221f5760405162461bcd60e51b81526004016107a890615358565b61222882613751565b6001600160a01b0382166000818152600660205260409081902080549084905590519091907fad96cee0d692f0250b98e085504f399da6733854908215f6203fe3c69366d9f59061227c9084908690615433565b60405180910390a2505050565b60606122958484612a70565b6001600160a01b038085166000908152600a602090815260408083208784528252808320938616835292815282822080548451818402810184019095528085529092909184015b828210156123365760008481526020908190206040805160608101825260028602909201805483526001908101546001600160801b0380821685870152600160801b909104169183019190915290835290920191016122dc565b5050505090509392505050565b60146020526000908152604090205460ff1681565b60135460ff161561237b5760405162461bcd60e51b81526004016107a8906151c8565b600060405161238990614f36565b604080519182900382208282019091526008825267161594d5985d5b1d60c21b6020909201919091527fddfcc46608a8bd52ebf900f03a24cc97b73a6046cec8c5d0f74a211e376e967a6123db613835565b306040516020016123ef94939291906150ca565b604051602081830303815290604052805190602001209050600060405161241590614f41565b604051908190038120612430918a908a908a906020016150bc565b6040516020818303038152906040528051906020012090506000828260405160200161245d929190614f05565b604051602081830303815290604052805190602001209050600061248382888888613839565b6001600160a01b0381166000908152600e6020526040902080546001810190915590915089146124c55760405162461bcd60e51b81526004016107a890615238565b874211156124e55760405162461bcd60e51b81526004016107a890615218565b6124ef818b6134b0565b505050505b505050505050565b607a5460ff1681565b60066020526000908152604090205481565b6001600160a01b031660009081526008602052604090205490565b6000546001600160a01b0316331461255c5760405162461bcd60e51b81526004016107a890615368565b6001600160a01b0383166125825760405162461bcd60e51b81526004016107a890615228565b6001600160a01b0382166125a85760405162461bcd60e51b81526004016107a8906152c8565b6125b28282612a70565b6016546017546018546040516001600160a01b03808816948116937f8def9436d6e31b89ed00948ba91d0cb6936eada5154cb1b45b55683fb9e492379361260193919092169188918890615024565b60405180910390a3601680546001600160a01b039485166001600160a01b0319918216179091556017805493909416921691909117909155601855565b6003546001600160a01b031681565b607a5460009060ff1661266757612662613863565b61266f565b61266f613867565b905090565b6301e1338081565b60405161104a90614f41565b60185481565b601060209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b6312cc030081565b6000546001600160a01b031681565b6126fb6040518060600160405280602c815260200161571b602c91396129ce565b6127048561353f565b61270d8361353f565b6004546001600160a01b03166127355760405162461bcd60e51b81526004016107a8906151a8565b600084116127555760405162461bcd60e51b81526004016107a8906153a8565b61275e85613751565b6001600160a01b0385166000908152600860205260408120805490915b818110156127d957856001600160a01b031683828154811061279957fe5b60009182526020909120600590910201546001600160a01b031614156127d15760405162461bcd60e51b81526004016107a890615328565b60010161277b565b506001600160a01b03851660009081526014602052604090205460ff16156128135760405162461bcd60e51b81526004016107a890615298565b6001600160a01b03871660009081526009602052604090205461283c908763ffffffff612f7216565b6001600160a01b038089166000908152600960209081526040808320949094556006815290839020879055825160a081018452918816825281018890528391810161288561264d565b8152600060208083018290526040928301889052845460018082018755958352818320855160059092020180546001600160a01b0319166001600160a01b039283161781558583015181880155858501516002820155606086015160038201556080909501516004958601558a81168352601490915290829020805460ff1916851790558254915163fb66fb4d60e01b815291169263fb66fb4d9261292d928c929101615059565b600060405180830381600087803b15801561294757600080fd5b505af115801561295b573d6000803e3d6000fd5b50505050846001600160a01b03166001838054905003886001600160a01b03167fd7fa4bff1cd2253c0789c3291a786a6f6b1a3b4569a75af683a15d52abb6a0bf8988886040516129ae93929190615441565b60405180910390a450505050505050565b6016546001600160a01b031681565b6047546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab90612a019033908690600401614f68565b60206040518083038186803b158015612a1957600080fd5b505afa158015612a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612a51919081019061425f565b905080611ae75760405162461bcd60e51b81526004016107a8906151e8565b6001600160a01b0382166000908152600860205260409020548110611ae75760405162461bcd60e51b81526004016107a890615198565b6001600160a01b0382166000908152600860205260408120805483908110612acb57fe5b906000526020600020906005020190508060020154612ae861264d565b11612af35750611ae7565b80546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612b23903090600401614f4c565b60206040518083038186803b158015612b3b57600080fd5b505afa158015612b4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612b7391908101906142db565b6001600160a01b0385166000908152601260209081526040808320878452909152902054909150612bab90829063ffffffff6136ed16565b905080612bc957612bba61264d565b82600201819055505050611ae7565b6000612bd361264d565b90506000612bee8460020154836136ed90919063ffffffff16565b6001600160a01b03871660009081526009602090815260408083205460018901546006909352908320549394509192612c3792916116a691611fab90879063ffffffff61367116565b9050612c66612c55856116a68464e8d4a5100063ffffffff61367116565b60038701549063ffffffff612f7216565b6003860155612c7361264d565b856002018190555050505050505050565b600061082783600101546116b28585612fb4565b600480546040516370a0823160e01b81526001600160a01b03918216926000928716916370a0823191612ccd91869101614f4c565b60206040518083038186803b158015612ce557600080fd5b505afa158015612cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250612d1d91908101906142db565b6001600160a01b038087166000908152601560209081526040808320938916835292905290812054919250612d58858363ffffffff612f7216565b9050828111612e36578115612dcb576001600160a01b038088166000818152601560209081526040808320948b1680845294909152808220829055517f6bdfd5e51d01475945224d3d37965916fd8df699ef9e8888af4359aa8622216091612dc291879190615418565b60405180910390a35b60405163135b33cd60e31b81526001600160a01b03851690639ad99e6890612dfb908a908a908690600401615009565b600060405180830381600087803b158015612e1557600080fd5b505af1158015612e29573d6000803e3d6000fd5b5050505050505050612f0c565b6001600160a01b038088166000818152601560209081526040808320948b168084529490915290819020868503908190559051909291907f6bdfd5e51d01475945224d3d37965916fd8df699ef9e8888af4359aa8622216090612e9c9087908690615433565b60405180910390a360405163135b33cd60e31b81526001600160a01b03861690639ad99e6890612ed4908b908b908990600401615009565b600060405180830381600087803b158015612eee57600080fd5b505af1158015612f02573d6000803e3d6000fd5b5050505050505050505b505050565b604051612f6c9085906323b872dd60e01b90612f3590879087908790602401615009565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261386b565b50505050565b600061082783836040518060400160405280601b81526020017f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815250613950565b600061082764e8d4a510006116a68460030154611fab876002015488600001546136ed90919063ffffffff16565b600081600160601b84106130095760405162461bcd60e51b81526004016107a89190615167565b509192915050565b816001600160a01b0316836001600160a01b03161415801561303c57506000816001600160601b0316115b15612f0c576001600160a01b038316156130f4576001600160a01b03831660009081526011602052604081205463ffffffff16908161307c5760006130bb565b6001600160a01b0385166000908152601060209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b905060006130e282856040518060600160405280602c81526020016156bf602c9139613980565b90506130f0868484846139bf565b5050505b6001600160a01b03821615612f0c576001600160a01b03821660009081526011602052604081205463ffffffff16908161312f57600061316e565b6001600160a01b0384166000908152601060209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b9050600061319582856040518060600160405280602b81526020016155ab602b9139613b7b565b90506124f4858484846139bf565b805460009081905b8015613241578360018203815481106131c057fe5b6000918252602090912060016002909202018101546001600160801b03600160801b9091041614156132235761321c8460018303815481106131fe57fe5b6000918252602090912060029091020154839063ffffffff612f7216565b9150613238565b6132358460018303815481106112c157fe5b92505b600019016131ab565b50915091565b8254604080516060810182526000808252602080830182815260019484018581528587018a5589845291909220925160028602909301928355905191909201805492516001600160801b03908116600160801b029281166001600160801b0319909416939093179092161790555b6000811180156132f05750818460018303815481106132d057fe5b60009182526020909120600160029092020101546001600160801b031611155b156133775783600182038154811061330457fe5b906000526020600020906002020184828154811061331e57fe5b600091825260209091208254600290920201908155600191820180549290910180546001600160801b0319166001600160801b03938416178082559154600160801b9081900484160291909216179055600019016132b5565b604051806060016040528084815260200161339184613bae565b6001600160801b0316815260200160016001600160801b03168152508482815481106133b957fe5b60009182526020918290208351600292830290910190815591830151600190920180546040909401516001600160801b03199094166001600160801b03938416178316600160801b939094169290920292909217905585015461341c9084612f72565b85600201819055505050505050565b6001600160a01b0381166134515760405162461bcd60e51b81526004016107a890615278565b604780546001600160a01b038381166001600160a01b03198316179092556040519116907f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa0906134a49083908590614f88565b60405180910390a15050565b6001600160a01b038083166000908152600f6020526040812054909116906134d784613bd7565b6001600160a01b038581166000818152600f602052604080822080546001600160a01b031916898616908117909155905194955093928616927f0cc323ffec3ea49cbcddc0de1480978126d350c6a45dff33ad2f1cda6ae992619190a4612f6c828483613011565b6001600160a01b038116610f0a5760405162461bcd60e51b81526004016107a8906152d8565b60010154426001600160801b03909116111590565b805460009081905b60008111801561359f575061359f84600183038154811061129757fe5b15613640578360018203815481106135b357fe5b6000918252602090912060016002909202018101546001600160801b03600160801b9091041614156135f8576135f18460018303815481106131fe57fe5b915061360d565b61360a8460018303815481106112c157fe5b92505b8380548061361757fe5b600082815260208120600019928301600281029091018281556001019190915590915501613582565b50613665613654828463ffffffff612f7216565b60028601549063ffffffff6136ed16565b60028501559250929050565b60008261368057506000611524565b8282028284828161368d57fe5b04146108275760405162461bcd60e51b81526004016107a890615318565b600061082783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613ced565b600061082783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613d24565b604051612f0c90849063a9059cbb60e01b90612f359086908690602401615074565b6001600160a01b038116600090815260086020526040812054905b81811015612f0c5761377e8382612aa7565b60010161376c565b607a54610100900460ff16156137ae5760405162461bcd60e51b81526004016107a8906153b8565b811580156137ba575080155b156137d75760405162461bcd60e51b81526004016107a890615338565b8180156137e357508015155b156138005760405162461bcd60e51b81526004016107a890615258565b607a805460ff191683151517905581613819578061381f565b6301e133805b6079555050607a805461ff001916610100179055565b4690565b600080600061384a87878787613d48565b9150915061385781613e28565b5090505b949350505050565b4390565b4290565b61387d826001600160a01b0316613ef1565b6138995760405162461bcd60e51b81526004016107a8906153d8565b60006060836001600160a01b0316836040516138b59190614ef9565b6000604051808303816000865af19150503d80600081146138f2576040519150601f19603f3d011682016040523d82523d6000602084013e6138f7565b606091505b5091509150816139195760405162461bcd60e51b81526004016107a8906153c8565b805115612f6c5780806020019051613934919081019061425f565b612f6c5760405162461bcd60e51b81526004016107a890615208565b600083830182858210156139775760405162461bcd60e51b81526004016107a89190615167565b50949350505050565b6000836001600160601b0316836001600160601b0316111582906139b75760405162461bcd60e51b81526004016107a89190615167565b505050900390565b60006139ea6139cc61264d565b60405180608001604052806042815260200161564a60429139613f2a565b905060008463ffffffff16118015613a3357506001600160a01b038516600090815260106020908152604080832063ffffffff6000198901811685529252909120548282169116145b15613a92576001600160a01b0385166000908152601060209081526040808320600019880163ffffffff168452909152902080546fffffffffffffffffffffffff000000001916600160201b6001600160601b03851602179055613b31565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000818152601083528781208c871682528352878120965187549451909516600160201b026fffffffffffffffffffffffff000000001995871663ffffffff19958616179590951694909417909555938252601190935292909220805460018801909316929091169190911790555b846001600160a01b03167f6adb589fed1e8542fb7a6b10f00a85e02265e77f9ae3ca8ff93b22983e1af9a08484604051613b6c929190615493565b60405180910390a25050505050565b6000838301826001600160601b0380871690831610156139775760405162461bcd60e51b81526004016107a89190615167565b6000600160801b8210613bd35760405162461bcd60e51b81526004016107a890615248565b5090565b6005546000906001600160a01b0316613c025760405162461bcd60e51b81526004016107a8906151f8565b6005546001600160a01b03166000908152600860205260408120805490915b81811015613ce25760055483546001600160a01b0390911690849083908110613c4657fe5b60009182526020909120600590910201546001600160a01b03161415613cda576005546001600160a01b039081166000908152600760209081526040808320858452825280832093891683529290522060028101548154613ccf91613cb1919063ffffffff6136ed16565b60405180606001604052806028815260200161560160289139612fe2565b94505050505061108d565b600101613c21565b506000949350505050565b60008183613d0e5760405162461bcd60e51b81526004016107a89190615167565b506000838581613d1a57fe5b0495945050505050565b600081848411156139b75760405162461bcd60e51b81526004016107a89190615167565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613d7f5750600090506003613e1f565b8460ff16601b14158015613d9757508460ff16601c14155b15613da85750600090506004613e1f565b600060018787878760405160008152602001604052604051613dcd94939291906150f2565b6020604051602081039080840390855afa158015613def573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613e1857506000915060019050613e1f565b9150600090505b94509492505050565b6000816004811115613e3657fe5b1415613e4157610f0a565b6001816004811115613e4f57fe5b1415613e6d5760405162461bcd60e51b81526004016107a890615178565b6002816004811115613e7b57fe5b1415613e995760405162461bcd60e51b81526004016107a8906151b8565b6003816004811115613ea757fe5b1415613ec55760405162461bcd60e51b81526004016107a890615288565b6004816004811115613ed357fe5b1415610f0a5760405162461bcd60e51b81526004016107a8906152f8565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061385b575050151592915050565b600081600160201b84106130095760405162461bcd60e51b81526004016107a89190615167565b604080518082019091526000808252602082015290565b803561152481615569565b805161152481615569565b80356115248161557d565b80516115248161557d565b803561152481615586565b80356115248161558f565b805161152481615586565b803561152481615598565b8035611524816155a1565b600060208284031215613fdd57600080fd5b600061385b8484613f68565b600060208284031215613ffb57600080fd5b600061385b8484613f73565b6000806040838503121561401a57600080fd5b60006140268585613f68565b925050602061403785828601613f68565b9150509250929050565b60008060006060848603121561405657600080fd5b60006140628686613f68565b935050602061407386828701613f68565b925050604061408486828701613f94565b9150509250925092565b600080604083850312156140a157600080fd5b60006140ad8585613f68565b925050602061403785828601613f94565b6000806000606084860312156140d357600080fd5b60006140df8686613f68565b93505060206140f086828701613f94565b925050604061408486828701613f68565b600080600080600060a0868803121561411957600080fd5b60006141258888613f68565b955050602061413688828901613f94565b945050604061414788828901613f9f565b935050606061415888828901613f94565b925050608061416988828901613f94565b9150509295509295909350565b60008060006060848603121561418b57600080fd5b60006141978686613f68565b935050602061407386828701613f94565b60008060008060008060c087890312156141c157600080fd5b60006141cd8989613f68565b96505060206141de89828a01613f94565b95505060406141ef89828a01613f94565b945050606061420089828a01613fc0565b935050608061421189828a01613f94565b92505060a061422289828a01613f94565b9150509295509295509295565b6000806040838503121561424257600080fd5b600061424e8585613f68565b925050602061403785828601613fb5565b60006020828403121561427157600080fd5b600061385b8484613f89565b6000806040838503121561429057600080fd5b60006140ad8585613f7e565b6000806000606084860312156142b157600080fd5b60006140628686613f9f565b6000602082840312156142cf57600080fd5b600061385b8484613f9f565b6000602082840312156142ed57600080fd5b600061385b8484613faa565b60006143058383614e99565b505060600190565b61431681615512565b82525050565b614316816154c1565b6000614330826154b4565b61433a81856154b8565b9350614345836154ae565b8060005b8381101561437357815161435d88826142f9565b9750614368836154ae565b925050600101614349565b509495945050505050565b614316816154cc565b614316816154d1565b61431661439c826154d1565b6154d1565b60006143ac826154b4565b6143b6818561108d565b93506143c6818560208601615533565b9290920192915050565b614316816154d4565b6143168161551d565b60006143ed826154b4565b6143f781856154b8565b9350614407818560208601615533565b6144108161555f565b9093019392505050565b60006144276018836154b8565b7f45434453413a20696e76616c6964207369676e61747572650000000000000000815260200192915050565b60006144606012836154b8565b71696e636f6e73697374656e7420737461746560701b815260200192915050565b600061448e6013836154b8565b727661756c743a20706f6f6c206578697374733f60681b815260200192915050565b60006144bd601f836154b8565b7f53746f726520636f6e7472616374206164647265737320697320656d70747900815260200192915050565b60006144f6601f836154b8565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800815260200192915050565b600061452f600f836154b8565b6e15985d5b1d081a5cc81c185d5cd959608a1b815260200192915050565b600061455a6013836154b8565b7215985d5b1d081a5cc81b9bdd081c185d5cd959606a1b815260200192915050565b6000614589600c836154b8565b6b155b985d5d1a1bdc9a5e995960a21b815260200192915050565b60006145b16030836154b8565b7f5856535661756c743a3a6765745374616b65416d6f756e743a2078767320616481526f191c995cdcc81a5cc81b9bdd081cd95d60821b602082015260400192915050565b6000614603602a836154b8565b7f5361666542455032303a204245503230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b602082015260400192915050565b600061464f602a836154b8565b7f5856535661756c743a3a64656c656761746542795369673a207369676e6174758152691c9948195e1c1a5c995960b21b602082015260400192915050565b600061469b6022836154b8565b7f7072696d6520746f6b656e2063616e6e6f74206265207a65726f206164647265815261737360f01b602082015260400192915050565b60006146df6026836154b8565b7f5856535661756c743a3a64656c656761746542795369673a20696e76616c6964815265206e6f6e636560d01b602082015260400192915050565b600061472760028361108d565b61190160f01b815260020192915050565b60006147456027836154b8565b7f53616665436173743a2076616c756520646f65736e27742066697420696e20318152663238206269747360c81b602082015260400192915050565b600061478e6020836154b8565b7f496e76616c69642074696d6520626173656420636f6e66696775726174696f6e815260200192915050565b60006147c76017836154b8565b7f5661756c7420697320616c726561647920706175736564000000000000000000815260200192915050565b60006148006025836154b8565b7f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164815264647265737360d81b602082015260400192915050565b60006148476022836154b8565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b602082015260400192915050565b600061488b601a836154b8565b7f546f6b656e2065786973747320696e206f7468657220706f6f6c000000000000815260200192915050565b60006148c46013836154b8565b72185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b815260200192915050565b60006148f3602b836154b8565b7f5856535661756c743a3a6765745072696f72566f7465733a206e6f742079657481526a0819195d195c9b5a5b995960aa1b602082015260400192915050565b6000614940601d836154b8565b7f7265776172642063616e6e6f74206265207a65726f2061646472657373000000815260200192915050565b60006149796018836154b8565b7f7a65726f2061646472657373206e6f7420616c6c6f7765640000000000000000815260200192915050565b60006149b2601a836154b8565b7f657865637574652070656e64696e67207769746864726177616c000000000000815260200192915050565b60006149eb6022836154b8565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b602082015260400192915050565b6000614a2f60438361108d565b7f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353681527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208201526263742960e81b604082015260430192915050565b6000614a9a601f836154b8565b7f72657175657374656420616d6f756e742063616e6e6f74206265207a65726f00815260200192915050565b6000614ad36021836154b8565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000614b166012836154b8565b71141bdbdb08185b1c9958591e48185919195960721b815260200192915050565b6000614b446017836154b8565b7f496e76616c696420626c6f636b73207065722079656172000000000000000000815260200192915050565b6000614b7d600a836154b8565b691c994b595b9d195c995960b21b815260200192915050565b6000614ba36014836154b8565b7324b73b30b634b2103932bbb0b932103a37b5b2b760611b815260200192915050565b6000614bd3600e836154b8565b6d37b7363c9030b236b4b71031b0b760911b815260200192915050565b6000614bfd6015836154b8565b7418da185b99d9481b9bdd08185d5d1a1bdc9a5e9959605a1b815260200192915050565b6000614c2e6013836154b8565b726e6f7468696e6720746f20776974686472617760681b815260200192915050565b6000614c5d601a836154b8565b7f496e76616c6964206e6577206c6f636b696e6720706572696f64000000000000815260200192915050565b6000614c96601d836154b8565b7f416c6c6f6320706f696e7473206d757374206e6f74206265207a65726f000000815260200192915050565b6000614ccf601f836154b8565b7f416c726561647920696e697469616c697a65642054696d654d616e6167657200815260200192915050565b6000614d086020836154b8565b7f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564815260200192915050565b6000614d41603a8361108d565b7f44656c65676174696f6e28616464726573732064656c6567617465652c75696e81527f74323536206e6f6e63652c75696e7432353620657870697279290000000000006020820152603a0192915050565b6000614da0601f836154b8565b7f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e747261637400815260200192915050565b6000614dd9601b836154b8565b7f72657175657374656420616d6f756e7420697320696e76616c69640000000000815260200192915050565b6000614e126022836154b8565b7f6f6e6c792070726f78792061646d696e2063616e206368616e676520627261698152616e7360f01b602082015260400192915050565b6000614e56602e836154b8565b7f416c6c6f6320706f696e7473207065722072657761726420746f6b656e206d7581526d7374206e6f74206265207a65726f60901b602082015260400192915050565b80516060830190614eaa8482614387565b506020820151614ebd6020850182614ecc565b506040820151612f6c60408501825b614316816154df565b614316816154f7565b61431681615500565b61431681615528565b61431681615506565b600061082782846143a1565b6000614f108261471a565b9150614f1c8285614390565b602082019150614f2c8284614390565b5060200192915050565b600061152482614a22565b600061152482614d34565b60208101611524828461431c565b60208101611524828461430d565b60408101614f76828561430d565b818103602083015261385b81846143e2565b60408101614f96828561431c565b610827602083018461431c565b60608101614fb1828661431c565b614fbe602083018561430d565b61385b6040830184614387565b60808101614fd9828761431c565b614fe6602083018661431c565b614ff3604083018561431c565b615000606083018461431c565b95945050505050565b60608101615017828661431c565b614fbe602083018561431c565b60808101615032828761431c565b61503f602083018661431c565b61504c6040830185614387565b6150006060830184614387565b60408101615067828561431c565b610827602083018461437e565b60408101615082828561431c565b6108276020830184614387565b602080825281016108278184614325565b60208101611524828461437e565b602081016115248284614387565b608081016150328287614387565b608081016150d88287614387565b6150e56020830186614387565b614ff36040830185614387565b608081016151008287614387565b61503f6020830186614ede565b6020810161152482846143d0565b60a0810161512982886143d0565b6151366020830187614387565b6151436040830186614387565b6151506060830185614387565b61515d6080830184614387565b9695505050505050565b6020808252810161082781846143e2565b602080825281016115248161441a565b6020808252810161152481614453565b6020808252810161152481614481565b60208082528101611524816144b0565b60208082528101611524816144e9565b6020808252810161152481614522565b602080825281016115248161454d565b602080825281016115248161457c565b60208082528101611524816145a4565b60208082528101611524816145f6565b6020808252810161152481614642565b602080825281016115248161468e565b60208082528101611524816146d2565b6020808252810161152481614738565b6020808252810161152481614781565b60208082528101611524816147ba565b60208082528101611524816147f3565b602080825281016115248161483a565b602080825281016115248161487e565b60208082528101611524816148b7565b60208082528101611524816148e6565b6020808252810161152481614933565b602080825281016115248161496c565b60208082528101611524816149a5565b60208082528101611524816149de565b6020808252810161152481614a8d565b6020808252810161152481614ac6565b6020808252810161152481614b09565b6020808252810161152481614b37565b6020808252810161152481614b70565b6020808252810161152481614b96565b6020808252810161152481614bc6565b6020808252810161152481614bf0565b6020808252810161152481614c21565b6020808252810161152481614c50565b6020808252810161152481614c89565b6020808252810161152481614cc2565b6020808252810161152481614cfb565b6020808252810161152481614d93565b6020808252810161152481614dcc565b6020808252810161152481614e05565b6020808252810161152481614e49565b604081016154268285614387565b61082760208301846143d9565b604081016150828285614387565b6060810161544f8286614387565b614fbe6020830185614387565b602081016115248284614ed5565b604081016154788285614ed5565b6108276020830184614ef0565b602081016115248284614ef0565b604081016154a18285614ee7565b6108276020830184614ee7565b60200190565b5190565b90815260200190565b6000611524826154eb565b151590565b90565b6000611524826154c1565b6001600160801b031690565b6001600160a01b031690565b63ffffffff1690565b60ff1690565b6001600160601b031690565b6000611524826154d4565b6000611524826154d1565b600061152482615506565b60005b8381101561554e578181015183820152602001615536565b83811115612f6c5750506000910152565b601f01601f191690565b615572816154c1565b8114610f0a57600080fd5b615572816154cc565b615572816154d1565b615572816154d4565b615572816154f7565b6155728161550056fe5856535661756c743a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f77735856535661756c743a3a726571756573745769746864726177616c3a20766f746573206f766572666c6f775856535661756c743a3a6765745374616b65416d6f756e743a20766f746573206f766572666c6f775856535661756c743a3a6465706f7369743a20766f746573206f766572666c6f775856535661756c743a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206f72207365636f6e64206578636565647320333220626974737365745769746864726177616c4c6f636b696e67506572696f6428616464726573732c75696e743235362c75696e74323536295856535661756c743a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f7773736574526577617264416d6f756e74506572426c6f636b4f725365636f6e6428616464726573732c75696e743235362961646428616464726573732c75696e743235362c616464726573732c75696e743235362c75696e7432353629a365627a7a7231582053ba350123a86f07263e7bddf3bcee0f7cf11e72f5d2678781f0eb1ebd599dc16c6578706572696d656e74616cf564736f6c63430005100040", + "devdoc": { + "author": "Venus", + "methods": { + "add(address,uint256,address,uint256,uint256)": { + "details": "This vault DOES NOT support deflationary tokens — it expects that the amount of transferred tokens would equal the actually deposited amount. In practice this means that this vault DOES NOT support USDT and similar tokens (that do not provide these guarantees).", + "params": { + "_allocPoint": "Number of allocation points assigned to this pool", + "_lockPeriod": "A period between withdrawal request and a moment when it's executable", + "_rewardPerBlockOrSecond": "Initial reward per block or second, in terms of _rewardToken", + "_rewardToken": "Reward token address", + "_token": "Staked token" + } + }, + "claim(address,address,uint256)": { + "params": { + "_account": "The account for which to claim rewards", + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address" + } + }, + "delegate(address)": { + "params": { + "delegatee": "The address to delegate votes to" + } + }, + "delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)": { + "params": { + "delegatee": "The address to delegate votes to", + "expiry": "The time at which to expire the signature", + "nonce": "The contract state required to match the signature", + "r": "Half of the ECDSA signature pair", + "s": "Half of the ECDSA signature pair", + "v": "The recovery byte of the signature" + } + }, + "deposit(address,uint256,uint256)": { + "params": { + "_amount": "The amount to deposit to vault", + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address" + } + }, + "executeWithdrawal(address,uint256)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address" + } + }, + "getBlockNumberOrTimestamp()": { + "details": "Function to simply retrieve block number or block timestamp", + "return": "Current block number or block timestamp" + }, + "getCurrentVotes(address)": { + "params": { + "account": "The address to get votes balance" + }, + "return": "The number of current votes for `account`" + }, + "getEligibleWithdrawalAmount(address,uint256,address)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address", + "_user": "The User Address" + }, + "return": "withdrawalAmount Amount that the user can withdraw" + }, + "getPriorVotes(address,uint256)": { + "params": { + "account": "The address of the account to check", + "blockNumberOrSecond": "The block number or second to get the vote balance at" + }, + "return": "The balance that user staked" + }, + "getRequestedAmount(address,uint256,address)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address", + "_user": "The User Address" + }, + "return": "Total amount of requested but not yet executed withdrawals (including both executable and locked ones)" + }, + "getUserInfo(address,uint256,address)": { + "params": { + "_pid": "Pool index", + "_rewardToken": "Reward token address", + "_user": "User address" + }, + "return": "amount Deposited amountrewardDebt Reward debt (technical value used to track past payouts)pendingWithdrawals Requested but not yet executed withdrawals" + }, + "getWithdrawalRequests(address,uint256,address)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address", + "_user": "The User Address" + }, + "return": "An array of withdrawal requests" + }, + "initializeTimeManager(bool,uint256)": { + "details": "Initializes the contract to use either blocks or seconds", + "params": { + "blocksPerYear_": "The number of blocks per year", + "timeBased_": "A boolean indicating whether the contract is based on time or block If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR" + } + }, + "pendingReward(address,uint256,address)": { + "params": { + "_pid": "Pool index", + "_rewardToken": "Reward token address", + "_user": "User address" + }, + "return": "Reward the user is eligible for in this pool, in terms of _rewardToken" + }, + "pendingWithdrawalsBeforeUpgrade(address,uint256,address)": { + "params": { + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address", + "_user": "The address of the user" + }, + "return": "beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade" + }, + "poolLength(address)": { + "params": { + "rewardToken": "Reward token address" + }, + "return": "Number of pools that distribute the specified token as a reward" + }, + "requestWithdrawal(address,uint256,uint256)": { + "params": { + "_amount": "The amount to withdraw from the vault", + "_pid": "The Pool Index", + "_rewardToken": "The Reward Token Address" + } + }, + "rewardTokenAmountsPerBlock(address)": { + "params": { + "_rewardToken": "Reward token address" + }, + "return": "Number of reward tokens created per block or second" + }, + "set(address,uint256,uint256)": { + "params": { + "_allocPoint": "Number of allocation points assigned to this pool", + "_pid": "Pool index", + "_rewardToken": "Reward token address" + } + }, + "setAccessControl(address)": { + "details": "Admin function to set the access control address", + "params": { + "newAccessControlAddress": "New address for the access control" + } + }, + "setPrimeToken(address,address,uint256)": { + "params": { + "_primePoolId": "pool id for reward", + "_primeRewardToken": "address of reward token", + "_primeToken": "address of the prime token contract" + } + }, + "setRewardAmountPerBlockOrSecond(address,uint256)": { + "params": { + "_rewardAmount": "Number of allocation points assigned to this pool", + "_rewardToken": "Reward token address" + } + }, + "setWithdrawalLockingPeriod(address,uint256,uint256)": { + "params": { + "_newPeriod": "New lock period", + "_pid": "Pool index", + "_rewardToken": "Reward token address" + } + }, + "updatePool(address,uint256)": { + "params": { + "_pid": "Pool index", + "_rewardToken": "Reward token address" + } + } + }, + "title": "XVS Vault" + }, + "userdoc": { + "methods": { + "_become(address)": { + "notice": "* Admin Functions **" + }, + "accessControlManager()": { + "notice": "Returns the address of the access control manager contract" + }, + "add(address,uint256,address,uint256,uint256)": { + "notice": "Add a new token pool" + }, + "claim(address,address,uint256)": { + "notice": "Claim rewards for pool" + }, + "constructor": "XVSVault constructor", + "delegate(address)": { + "notice": "Delegate votes from `msg.sender` to `delegatee`" + }, + "delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)": { + "notice": "Delegates votes from signatory to `delegatee`" + }, + "deposit(address,uint256,uint256)": { + "notice": "Deposit XVSVault for XVS allocation" + }, + "executeWithdrawal(address,uint256)": { + "notice": "Execute withdrawal to XVSVault for XVS allocation" + }, + "getCurrentVotes(address)": { + "notice": "Gets the current votes balance for `account`" + }, + "getEligibleWithdrawalAmount(address,uint256,address)": { + "notice": "Get unlocked withdrawal amount" + }, + "getPriorVotes(address,uint256)": { + "notice": "Determine the xvs stake balance for an account" + }, + "getRequestedAmount(address,uint256,address)": { + "notice": "Get requested amount" + }, + "getUserInfo(address,uint256,address)": { + "notice": "Get user info with reward token address and pid" + }, + "getWithdrawalRequests(address,uint256,address)": { + "notice": "Returns the array of withdrawal requests that have not been executed yet" + }, + "pause()": { + "notice": "Pauses vault" + }, + "pendingReward(address,uint256,address)": { + "notice": "View function to see pending XVSs on frontend" + }, + "pendingWithdrawalsBeforeUpgrade(address,uint256,address)": { + "notice": "Gets the total pending withdrawal amount of a user before upgrade" + }, + "poolLength(address)": { + "notice": "Returns the number of pools with the specified reward token" + }, + "requestWithdrawal(address,uint256,uint256)": { + "notice": "Request withdrawal to XVSVault for XVS allocation" + }, + "resume()": { + "notice": "Resume vault" + }, + "rewardTokenAmountsPerBlock(address)": { + "notice": "Returns the number of reward tokens created per block or second" + }, + "set(address,uint256,uint256)": { + "notice": "Update the given pool's reward allocation point" + }, + "setAccessControl(address)": { + "notice": "Sets the address of the access control of this contract" + }, + "setPrimeToken(address,address,uint256)": { + "notice": "Sets the address of the prime token contract" + }, + "setRewardAmountPerBlockOrSecond(address,uint256)": { + "notice": "Update the given reward token's amount per block or second" + }, + "setWithdrawalLockingPeriod(address,uint256,uint256)": { + "notice": "Update the lock period after which a requested withdrawal can be executed" + }, + "updatePool(address,uint256)": { + "notice": "Update reward variables of the given pool to be up-to-date" + } + }, + "notice": "The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS." + }, + "storageLayout": { + "storage": [ + { + "astId": 34484, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "admin", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 34486, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "pendingAdmin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 34488, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "implementation", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 34490, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "pendingXVSVaultImplementation", + "offset": 0, + "slot": "3", + "type": "t_address" + }, + { + "astId": 34495, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "_notEntered", + "offset": 20, + "slot": "3", + "type": "t_bool" + }, + { + "astId": 34497, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "xvsStore", + "offset": 0, + "slot": "4", + "type": "t_address" + }, + { + "astId": 34499, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "xvsAddress", + "offset": 0, + "slot": "5", + "type": "t_address" + }, + { + "astId": 34503, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "rewardTokenAmountsPerBlockOrSecond", + "offset": 0, + "slot": "6", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34536, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "userInfos", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_mapping(t_address,t_struct(UserInfo)34510_storage)))" + }, + { + "astId": 34541, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "poolInfos", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_array(t_struct(PoolInfo)34521_storage)dyn_storage)" + }, + { + "astId": 34545, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "totalAllocPoints", + "offset": 0, + "slot": "9", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34554, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "withdrawalRequests", + "offset": 0, + "slot": "10", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_mapping(t_address,t_array(t_struct(WithdrawalRequest)34528_storage)dyn_storage)))" + }, + { + "astId": 34558, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__oldDelegatesSlot", + "offset": 0, + "slot": "11", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 34569, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__oldCheckpointsSlot", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_address,t_mapping(t_uint32,t_struct(Checkpoint)34563_storage))" + }, + { + "astId": 34573, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__oldNumCheckpointsSlot", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_address,t_uint32)" + }, + { + "astId": 34577, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "nonces", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34594, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "delegates", + "offset": 0, + "slot": "15", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 34600, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "checkpoints", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_mapping(t_uint32,t_struct(Checkpoint)34563_storage))" + }, + { + "astId": 34604, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "numCheckpoints", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_uint32)" + }, + { + "astId": 34610, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "totalPendingWithdrawals", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))" + }, + { + "astId": 34612, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "vaultPaused", + "offset": 0, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34616, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "isStakedToken", + "offset": 0, + "slot": "20", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34622, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "pendingRewardTransfers", + "offset": 0, + "slot": "21", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 34624, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "primeToken", + "offset": 0, + "slot": "22", + "type": "t_contract(IPrime)12297" + }, + { + "astId": 34626, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "primeRewardToken", + "offset": 0, + "slot": "23", + "type": "t_address" + }, + { + "astId": 34628, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "primePoolId", + "offset": 0, + "slot": "24", + "type": "t_uint256" + }, + { + "astId": 34632, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__gap", + "offset": 0, + "slot": "25", + "type": "t_array(t_uint256)46_storage" + }, + { + "astId": 4, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "_accessControlManager", + "offset": 0, + "slot": "71", + "type": "t_contract(IAccessControlManagerV5)1917" + }, + { + "astId": 8, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__gap", + "offset": 0, + "slot": "72", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 1924, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "blocksOrSecondsPerYear", + "offset": 0, + "slot": "121", + "type": "t_uint256" + }, + { + "astId": 1926, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "isTimeBased", + "offset": 0, + "slot": "122", + "type": "t_bool" + }, + { + "astId": 1928, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "isInitialized", + "offset": 1, + "slot": "122", + "type": "t_bool" + }, + { + "astId": 1930, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__deprecatedSlot1", + "offset": 2, + "slot": "122", + "type": "t_bytes8" + }, + { + "astId": 1934, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "__gap", + "offset": 0, + "slot": "123", + "type": "t_array(t_uint256)48_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_struct(PoolInfo)34521_storage)dyn_storage": { + "base": "t_struct(PoolInfo)34521_storage", + "encoding": "dynamic_array", + "label": "struct XVSVaultStorageV1.PoolInfo[]", + "numberOfBytes": "32" + }, + "t_array(t_struct(WithdrawalRequest)34528_storage)dyn_storage": { + "base": "t_struct(WithdrawalRequest)34528_storage", + "encoding": "dynamic_array", + "label": "struct XVSVaultStorageV1.WithdrawalRequest[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)46_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[46]", + "numberOfBytes": "1472" + }, + "t_array(t_uint256)48_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes8": { + "encoding": "inplace", + "label": "bytes8", + "numberOfBytes": "8" + }, + "t_contract(IAccessControlManagerV5)1917": { + "encoding": "inplace", + "label": "contract IAccessControlManagerV5", + "numberOfBytes": "20" + }, + "t_contract(IBEP20)27777": { + "encoding": "inplace", + "label": "contract IBEP20", + "numberOfBytes": "20" + }, + "t_contract(IPrime)12297": { + "encoding": "inplace", + "label": "contract IPrime", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_array(t_struct(PoolInfo)34521_storage)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct XVSVaultStorageV1.PoolInfo[])", + "numberOfBytes": "32", + "value": "t_array(t_struct(PoolInfo)34521_storage)dyn_storage" + }, + "t_mapping(t_address,t_array(t_struct(WithdrawalRequest)34528_storage)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct XVSVaultStorageV1.WithdrawalRequest[])", + "numberOfBytes": "32", + "value": "t_array(t_struct(WithdrawalRequest)34528_storage)dyn_storage" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_mapping(t_address,t_array(t_struct(WithdrawalRequest)34528_storage)dyn_storage)))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint256 => mapping(address => struct XVSVaultStorageV1.WithdrawalRequest[])))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint256,t_mapping(t_address,t_array(t_struct(WithdrawalRequest)34528_storage)dyn_storage))" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_mapping(t_address,t_struct(UserInfo)34510_storage)))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint256 => mapping(address => struct XVSVaultStorageV1.UserInfo)))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint256,t_mapping(t_address,t_struct(UserInfo)34510_storage))" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint256 => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint256,t_uint256)" + }, + "t_mapping(t_address,t_mapping(t_uint32,t_struct(Checkpoint)34563_storage))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint32 => struct XVSVaultStorageV1.Checkpoint))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint32,t_struct(Checkpoint)34563_storage)" + }, + "t_mapping(t_address,t_struct(UserInfo)34510_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct XVSVaultStorageV1.UserInfo)", + "numberOfBytes": "32", + "value": "t_struct(UserInfo)34510_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_uint32)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint32)", + "numberOfBytes": "32", + "value": "t_uint32" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_array(t_struct(WithdrawalRequest)34528_storage)dyn_storage))": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => mapping(address => struct XVSVaultStorageV1.WithdrawalRequest[]))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_array(t_struct(WithdrawalRequest)34528_storage)dyn_storage)" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_struct(UserInfo)34510_storage))": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => mapping(address => struct XVSVaultStorageV1.UserInfo))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_struct(UserInfo)34510_storage)" + }, + "t_mapping(t_uint256,t_uint256)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_uint32,t_struct(Checkpoint)34563_storage)": { + "encoding": "mapping", + "key": "t_uint32", + "label": "mapping(uint32 => struct XVSVaultStorageV1.Checkpoint)", + "numberOfBytes": "32", + "value": "t_struct(Checkpoint)34563_storage" + }, + "t_struct(Checkpoint)34563_storage": { + "encoding": "inplace", + "label": "struct XVSVaultStorageV1.Checkpoint", + "members": [ + { + "astId": 34560, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "fromBlockOrSecond", + "offset": 0, + "slot": "0", + "type": "t_uint32" + }, + { + "astId": 34562, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "votes", + "offset": 4, + "slot": "0", + "type": "t_uint96" + } + ], + "numberOfBytes": "32" + }, + "t_struct(PoolInfo)34521_storage": { + "encoding": "inplace", + "label": "struct XVSVaultStorageV1.PoolInfo", + "members": [ + { + "astId": 34512, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "token", + "offset": 0, + "slot": "0", + "type": "t_contract(IBEP20)27777" + }, + { + "astId": 34514, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "allocPoint", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 34516, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "lastRewardBlockOrSecond", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 34518, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "accRewardPerShare", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 34520, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "lockPeriod", + "offset": 0, + "slot": "4", + "type": "t_uint256" + } + ], + "numberOfBytes": "160" + }, + "t_struct(UserInfo)34510_storage": { + "encoding": "inplace", + "label": "struct XVSVaultStorageV1.UserInfo", + "members": [ + { + "astId": 34505, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "amount", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 34507, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "rewardDebt", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 34509, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "pendingWithdrawals", + "offset": 0, + "slot": "2", + "type": "t_uint256" + } + ], + "numberOfBytes": "96" + }, + "t_struct(WithdrawalRequest)34528_storage": { + "encoding": "inplace", + "label": "struct XVSVaultStorageV1.WithdrawalRequest", + "members": [ + { + "astId": 34523, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "amount", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 34525, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "lockedUntil", + "offset": 0, + "slot": "1", + "type": "t_uint128" + }, + { + "astId": 34527, + "contract": "contracts/XVSVault/XVSVault.sol:XVSVault", + "label": "afterUpgrade", + "offset": 16, + "slot": "1", + "type": "t_uint128" + } + ], + "numberOfBytes": "64" + }, + "t_uint128": { + "encoding": "inplace", + "label": "uint128", + "numberOfBytes": "16" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint32": { + "encoding": "inplace", + "label": "uint32", + "numberOfBytes": "4" + }, + "t_uint96": { + "encoding": "inplace", + "label": "uint96", + "numberOfBytes": "12" + } + } + } +} diff --git a/deployments/opsepolia/solcInputs/1ccea21f99f9d0cf6dcde9df90c8a652.json b/deployments/opsepolia/solcInputs/1ccea21f99f9d0cf6dcde9df90c8a652.json new file mode 100644 index 000000000..b55c16b76 --- /dev/null +++ b/deployments/opsepolia/solcInputs/1ccea21f99f9d0cf6dcde9df90c8a652.json @@ -0,0 +1,348 @@ +{ + "language": "Solidity", + "sources": { + "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\nimport \"./IAccessControlManagerV5.sol\";\n\n/**\n * @title AccessControlledV5\n * @author Venus\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.5.16)\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\n */\ncontract AccessControlledV5 {\n /// @notice Access control manager contract\n IAccessControlManagerV5 private _accessControlManager;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when access control manager contract address is changed\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n /**\n * @notice Returns the address of the access control manager contract\n */\n function accessControlManager() external view returns (IAccessControlManagerV5) {\n return _accessControlManager;\n }\n\n /**\n * @dev Internal function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n */\n function _setAccessControlManager(address accessControlManager_) internal {\n require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n address oldAccessControlManager = address(_accessControlManager);\n _accessControlManager = IAccessControlManagerV5(accessControlManager_);\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n }\n\n /**\n * @notice Reverts if the call is not allowed by AccessControlManager\n * @param signature Method signature\n */\n function _checkAccessAllowed(string memory signature) internal view {\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n if (!isAllowedToCall) {\n revert(\"Unauthorized\");\n }\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"./GovernorBravoInterfaces.sol\";\n\n/**\n * @title GovernorBravoDelegate\n * @notice Venus Governance latest on chain governance includes several new features including variable proposal routes and fine grained pause control.\n * Variable routes for proposals allows for governance paramaters such as voting threshold and timelocks to be customized based on the risk level and\n * impact of the proposal. Added granularity to the pause control mechanism allows governance to pause individual actions on specific markets,\n * which reduces impact on the protocol as a whole. This is particularly useful when applied to isolated pools.\n *\n * The goal of **Governance** is to increase governance efficiency, while mitigating and eliminating malicious or erroneous proposals.\n *\n * ## Details\n *\n * Governance has **3 main contracts**: **GovernanceBravoDelegate, XVSVault, XVS** token.\n *\n * - XVS token is the protocol token used for protocol users to cast their vote on submitted proposals.\n * - XVSVault is the main staking contract for XVS. Users first stake their XVS in the vault and receive voting power proportional to their staked\n * tokens that they can use to vote on proposals. Users also can choose to delegate their voting power to other users.\n *\n * # Governor Bravo\n *\n * `GovernanceBravoDelegate` is main Venus Governance contract. Users interact with it to:\n * - Submit new proposal\n * - Vote on a proposal\n * - Cancel a proposal\n * - Queue a proposal for execution with a timelock executor contract.\n * `GovernanceBravoDelegate` uses the XVSVault to get restrict certain actions based on a user's voting power. The governance rules it inforces are:\n * - A user's voting power must be greater than the `proposalThreshold` to submit a proposal\n * - If a user's voting power drops below certain amount, anyone can cancel the the proposal. The governance guardian and proposal creator can also\n * cancel a proposal at anytime before it is queued for execution.\n *\n * ## Venus Improvement Proposal\n *\n * Venus Governance allows for Venus Improvement Proposals (VIPs) to be categorized based on their impact and risk levels. This allows for optimizing proposals\n * execution to allow for things such as expediting interest rate changes and quickly updating risk parameters, while moving slower on other types of proposals\n * that can prevent a larger risk to the protocol and are not urgent. There are three different types of VIPs with different proposal paramters:\n *\n * - `NORMAL`\n * - `FASTTRACK`\n * - `CRITICAL`\n *\n * When initializing the `GovernorBravo` contract, the parameters for the three routes are set. The parameters are:\n *\n * - `votingDelay`: The delay in blocks between submitting a proposal and when voting begins\n * - `votingPeriod`: The number of blocks where voting will be open\n * - `proposalThreshold`: The number of votes required in order submit a proposal\n *\n * There is also a separate timelock executor contract for each route, which is used to dispatch the VIP for execution, giving even more control over the\n * flow of each type of VIP.\n *\n * ## Voting\n *\n * After a VIP is proposed, voting is opened after the `votingDelay` has passed. For example, if `votingDelay = 0`, then voting will begin in the next block\n * after the proposal has been submitted. After the delay, the proposal state is `ACTIVE` and users can cast their vote `for`, `against`, or `abstain`,\n * weighted by their total voting power (tokens + delegated voting power). Abstaining from a voting allows for a vote to be cast and optionally include a\n * comment, without the incrementing for or against vote count. The total voting power for the user is obtained by calling XVSVault's `getPriorVotes`.\n *\n * `GovernorBravoDelegate` also accepts [EIP-712](https://eips.ethereum.org/EIPS/eip-712) signatures for voting on proposals via the external function\n * `castVoteBySig`.\n *\n * ## Delegating\n *\n * A users voting power includes the amount of staked XVS the have staked as well as the votes delegate to them. Delegating is the process of a user loaning\n * their voting power to another, so that the latter has the combined voting power of both users. This is an important feature because it allows for a user\n * to let another user who they trust propose or vote in their place.\n *\n * The delegation of votes happens through the `XVSVault` contract by calling the `delegate` or `delegateBySig` functions. These same functions can revert\n * vote delegation by calling the same function with a value of `0`.\n */\ncontract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoEvents {\n /// @notice The name of this contract\n string public constant name = \"Venus Governor Bravo\";\n\n /// @notice The minimum setable proposal threshold\n uint public constant MIN_PROPOSAL_THRESHOLD = 150000e18; // 150,000 Xvs\n\n /// @notice The maximum setable proposal threshold\n uint public constant MAX_PROPOSAL_THRESHOLD = 300000e18; //300,000 Xvs\n\n /// @notice The minimum setable voting period\n uint public constant MIN_VOTING_PERIOD = 20 * 60 * 3; // About 3 hours, 3 secs per block\n\n /// @notice The max setable voting period\n uint public constant MAX_VOTING_PERIOD = 20 * 60 * 24 * 14; // About 2 weeks, 3 secs per block\n\n /// @notice The min setable voting delay\n uint public constant MIN_VOTING_DELAY = 1;\n\n /// @notice The max setable voting delay\n uint public constant MAX_VOTING_DELAY = 20 * 60 * 24 * 7; // About 1 week, 3 secs per block\n\n /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed\n uint public constant quorumVotes = 600000e18; // 600,000 = 2% of Xvs\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the ballot struct used by the contract\n bytes32 public constant BALLOT_TYPEHASH = keccak256(\"Ballot(uint256 proposalId,uint8 support)\");\n\n /**\n * @notice Used to initialize the contract during delegator contructor\n * @param xvsVault_ The address of the XvsVault\n * @param proposalConfigs_ Governance configs for each governance route\n * @param timelocks Timelock addresses for each governance route\n */\n function initialize(\n address xvsVault_,\n ProposalConfig[] memory proposalConfigs_,\n TimelockInterface[] memory timelocks,\n address guardian_\n ) public {\n require(address(proposalTimelocks[0]) == address(0), \"GovernorBravo::initialize: cannot initialize twice\");\n require(msg.sender == admin, \"GovernorBravo::initialize: admin only\");\n require(xvsVault_ != address(0), \"GovernorBravo::initialize: invalid xvs address\");\n require(guardian_ != address(0), \"GovernorBravo::initialize: invalid guardian\");\n require(\n timelocks.length == uint8(ProposalType.CRITICAL) + 1,\n \"GovernorBravo::initialize:number of timelocks should match number of governance routes\"\n );\n require(\n proposalConfigs_.length == uint8(ProposalType.CRITICAL) + 1,\n \"GovernorBravo::initialize:number of proposal configs should match number of governance routes\"\n );\n\n xvsVault = XvsVaultInterface(xvsVault_);\n proposalMaxOperations = 10;\n guardian = guardian_;\n\n //Set parameters for each Governance Route\n uint256 arrLength = proposalConfigs_.length;\n for (uint256 i; i < arrLength; ++i) {\n require(\n proposalConfigs_[i].votingPeriod >= MIN_VOTING_PERIOD,\n \"GovernorBravo::initialize: invalid min voting period\"\n );\n require(\n proposalConfigs_[i].votingPeriod <= MAX_VOTING_PERIOD,\n \"GovernorBravo::initialize: invalid max voting period\"\n );\n require(\n proposalConfigs_[i].votingDelay >= MIN_VOTING_DELAY,\n \"GovernorBravo::initialize: invalid min voting delay\"\n );\n require(\n proposalConfigs_[i].votingDelay <= MAX_VOTING_DELAY,\n \"GovernorBravo::initialize: invalid max voting delay\"\n );\n require(\n proposalConfigs_[i].proposalThreshold >= MIN_PROPOSAL_THRESHOLD,\n \"GovernorBravo::initialize: invalid min proposal threshold\"\n );\n require(\n proposalConfigs_[i].proposalThreshold <= MAX_PROPOSAL_THRESHOLD,\n \"GovernorBravo::initialize: invalid max proposal threshold\"\n );\n require(address(timelocks[i]) != address(0), \"GovernorBravo::initialize:invalid timelock address\");\n\n proposalConfigs[i] = proposalConfigs_[i];\n proposalTimelocks[i] = timelocks[i];\n }\n }\n\n /**\n * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold.\n * targets, values, signatures, and calldatas must be of equal length\n * @dev NOTE: Proposals with duplicate set of actions can not be queued for execution. If the proposals consists\n * of duplicate actions, it's recommended to split those actions into separate proposals\n * @param targets Target addresses for proposal calls\n * @param values BNB values for proposal calls\n * @param signatures Function signatures for proposal calls\n * @param calldatas Calldatas for proposal calls\n * @param description String description of the proposal\n * @param proposalType the type of the proposal (e.g NORMAL, FASTTRACK, CRITICAL)\n * @return Proposal id of new proposal\n */\n function propose(\n address[] memory targets,\n uint[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n ProposalType proposalType\n ) public returns (uint) {\n // Reject proposals before initiating as Governor\n require(initialProposalId != 0, \"GovernorBravo::propose: Governor Bravo not active\");\n require(\n xvsVault.getPriorVotes(msg.sender, sub256(block.number, 1)) >=\n proposalConfigs[uint8(proposalType)].proposalThreshold,\n \"GovernorBravo::propose: proposer votes below proposal threshold\"\n );\n require(\n targets.length == values.length &&\n targets.length == signatures.length &&\n targets.length == calldatas.length,\n \"GovernorBravo::propose: proposal function information arity mismatch\"\n );\n require(targets.length != 0, \"GovernorBravo::propose: must provide actions\");\n require(targets.length <= proposalMaxOperations, \"GovernorBravo::propose: too many actions\");\n\n uint latestProposalId = latestProposalIds[msg.sender];\n if (latestProposalId != 0) {\n ProposalState proposersLatestProposalState = state(latestProposalId);\n require(\n proposersLatestProposalState != ProposalState.Active,\n \"GovernorBravo::propose: one live proposal per proposer, found an already active proposal\"\n );\n require(\n proposersLatestProposalState != ProposalState.Pending,\n \"GovernorBravo::propose: one live proposal per proposer, found an already pending proposal\"\n );\n }\n\n uint startBlock = add256(block.number, proposalConfigs[uint8(proposalType)].votingDelay);\n uint endBlock = add256(startBlock, proposalConfigs[uint8(proposalType)].votingPeriod);\n\n proposalCount++;\n Proposal memory newProposal = Proposal({\n id: proposalCount,\n proposer: msg.sender,\n eta: 0,\n targets: targets,\n values: values,\n signatures: signatures,\n calldatas: calldatas,\n startBlock: startBlock,\n endBlock: endBlock,\n forVotes: 0,\n againstVotes: 0,\n abstainVotes: 0,\n canceled: false,\n executed: false,\n proposalType: uint8(proposalType)\n });\n\n proposals[newProposal.id] = newProposal;\n latestProposalIds[newProposal.proposer] = newProposal.id;\n\n emit ProposalCreated(\n newProposal.id,\n msg.sender,\n targets,\n values,\n signatures,\n calldatas,\n startBlock,\n endBlock,\n description,\n uint8(proposalType)\n );\n return newProposal.id;\n }\n\n /**\n * @notice Queues a proposal of state succeeded\n * @param proposalId The id of the proposal to queue\n */\n function queue(uint proposalId) external {\n require(\n state(proposalId) == ProposalState.Succeeded,\n \"GovernorBravo::queue: proposal can only be queued if it is succeeded\"\n );\n Proposal storage proposal = proposals[proposalId];\n uint eta = add256(block.timestamp, proposalTimelocks[uint8(proposal.proposalType)].delay());\n for (uint i; i < proposal.targets.length; ++i) {\n queueOrRevertInternal(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n eta,\n uint8(proposal.proposalType)\n );\n }\n proposal.eta = eta;\n emit ProposalQueued(proposalId, eta);\n }\n\n function queueOrRevertInternal(\n address target,\n uint value,\n string memory signature,\n bytes memory data,\n uint eta,\n uint8 proposalType\n ) internal {\n require(\n !proposalTimelocks[proposalType].queuedTransactions(\n keccak256(abi.encode(target, value, signature, data, eta))\n ),\n \"GovernorBravo::queueOrRevertInternal: identical proposal action already queued at eta\"\n );\n proposalTimelocks[proposalType].queueTransaction(target, value, signature, data, eta);\n }\n\n /**\n * @notice Executes a queued proposal if eta has passed\n * @param proposalId The id of the proposal to execute\n */\n function execute(uint proposalId) external {\n require(\n state(proposalId) == ProposalState.Queued,\n \"GovernorBravo::execute: proposal can only be executed if it is queued\"\n );\n Proposal storage proposal = proposals[proposalId];\n proposal.executed = true;\n for (uint i; i < proposal.targets.length; ++i) {\n proposalTimelocks[uint8(proposal.proposalType)].executeTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n emit ProposalExecuted(proposalId);\n }\n\n /**\n * @notice Cancels a proposal only if sender is the proposer, or proposer delegates dropped below proposal threshold\n * @param proposalId The id of the proposal to cancel\n */\n function cancel(uint proposalId) external {\n require(state(proposalId) != ProposalState.Executed, \"GovernorBravo::cancel: cannot cancel executed proposal\");\n\n Proposal storage proposal = proposals[proposalId];\n require(\n msg.sender == guardian ||\n msg.sender == proposal.proposer ||\n xvsVault.getPriorVotes(proposal.proposer, sub256(block.number, 1)) <\n proposalConfigs[proposal.proposalType].proposalThreshold,\n \"GovernorBravo::cancel: proposer above threshold\"\n );\n\n proposal.canceled = true;\n for (uint i = 0; i < proposal.targets.length; i++) {\n proposalTimelocks[proposal.proposalType].cancelTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n\n emit ProposalCanceled(proposalId);\n }\n\n /**\n * @notice Gets actions of a proposal\n * @param proposalId the id of the proposal\n * @return targets, values, signatures, and calldatas of the proposal actions\n */\n function getActions(\n uint proposalId\n )\n external\n view\n returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas)\n {\n Proposal storage p = proposals[proposalId];\n return (p.targets, p.values, p.signatures, p.calldatas);\n }\n\n /**\n * @notice Gets the receipt for a voter on a given proposal\n * @param proposalId the id of proposal\n * @param voter The address of the voter\n * @return The voting receipt\n */\n function getReceipt(uint proposalId, address voter) external view returns (Receipt memory) {\n return proposals[proposalId].receipts[voter];\n }\n\n /**\n * @notice Gets the state of a proposal\n * @param proposalId The id of the proposal\n * @return Proposal state\n */\n function state(uint proposalId) public view returns (ProposalState) {\n require(\n proposalCount >= proposalId && proposalId > initialProposalId,\n \"GovernorBravo::state: invalid proposal id\"\n );\n Proposal storage proposal = proposals[proposalId];\n if (proposal.canceled) {\n return ProposalState.Canceled;\n } else if (block.number <= proposal.startBlock) {\n return ProposalState.Pending;\n } else if (block.number <= proposal.endBlock) {\n return ProposalState.Active;\n } else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes) {\n return ProposalState.Defeated;\n } else if (proposal.eta == 0) {\n return ProposalState.Succeeded;\n } else if (proposal.executed) {\n return ProposalState.Executed;\n } else if (\n block.timestamp >= add256(proposal.eta, proposalTimelocks[uint8(proposal.proposalType)].GRACE_PERIOD())\n ) {\n return ProposalState.Expired;\n } else {\n return ProposalState.Queued;\n }\n }\n\n /**\n * @notice Cast a vote for a proposal\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n */\n function castVote(uint proposalId, uint8 support) external {\n emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), \"\");\n }\n\n /**\n * @notice Cast a vote for a proposal with a reason\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param reason The reason given for the vote by the voter\n */\n function castVoteWithReason(uint proposalId, uint8 support, string calldata reason) external {\n emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), reason);\n }\n\n /**\n * @notice Cast a vote for a proposal by signature\n * @dev External function that accepts EIP-712 signatures for voting on proposals.\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param v recovery id of ECDSA signature\n * @param r part of the ECDSA sig output\n * @param s part of the ECDSA sig output\n */\n function castVoteBySig(uint proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s) external {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"GovernorBravo::castVoteBySig: invalid signature\");\n emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), \"\");\n }\n\n /**\n * @notice Internal function that caries out voting logic\n * @param voter The voter that is casting their vote\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @return The number of votes cast\n */\n function castVoteInternal(address voter, uint proposalId, uint8 support) internal returns (uint96) {\n require(state(proposalId) == ProposalState.Active, \"GovernorBravo::castVoteInternal: voting is closed\");\n require(support <= 2, \"GovernorBravo::castVoteInternal: invalid vote type\");\n Proposal storage proposal = proposals[proposalId];\n Receipt storage receipt = proposal.receipts[voter];\n require(receipt.hasVoted == false, \"GovernorBravo::castVoteInternal: voter already voted\");\n uint96 votes = xvsVault.getPriorVotes(voter, proposal.startBlock);\n\n if (support == 0) {\n proposal.againstVotes = add256(proposal.againstVotes, votes);\n } else if (support == 1) {\n proposal.forVotes = add256(proposal.forVotes, votes);\n } else if (support == 2) {\n proposal.abstainVotes = add256(proposal.abstainVotes, votes);\n }\n\n receipt.hasVoted = true;\n receipt.support = support;\n receipt.votes = votes;\n\n return votes;\n }\n\n /**\n * @notice Sets the new governance guardian\n * @param newGuardian the address of the new guardian\n */\n function _setGuardian(address newGuardian) external {\n require(msg.sender == guardian || msg.sender == admin, \"GovernorBravo::_setGuardian: admin or guardian only\");\n require(newGuardian != address(0), \"GovernorBravo::_setGuardian: cannot live without a guardian\");\n address oldGuardian = guardian;\n guardian = newGuardian;\n\n emit NewGuardian(oldGuardian, newGuardian);\n }\n\n /**\n * @notice Initiate the GovernorBravo contract\n * @dev Admin only. Sets initial proposal id which initiates the contract, ensuring a continuous proposal id count\n * @param governorAlpha The address for the Governor to continue the proposal id count from\n */\n function _initiate(address governorAlpha) external {\n require(msg.sender == admin, \"GovernorBravo::_initiate: admin only\");\n require(initialProposalId == 0, \"GovernorBravo::_initiate: can only initiate once\");\n proposalCount = GovernorAlphaInterface(governorAlpha).proposalCount();\n initialProposalId = proposalCount;\n for (uint256 i; i < uint8(ProposalType.CRITICAL) + 1; ++i) {\n proposalTimelocks[i].acceptAdmin();\n }\n }\n\n /**\n * @notice Set max proposal operations\n * @dev Admin only.\n * @param proposalMaxOperations_ Max proposal operations\n */\n function _setProposalMaxOperations(uint proposalMaxOperations_) external {\n require(msg.sender == admin, \"GovernorBravo::_setProposalMaxOperations: admin only\");\n uint oldProposalMaxOperations = proposalMaxOperations;\n proposalMaxOperations = proposalMaxOperations_;\n\n emit ProposalMaxOperationsUpdated(oldProposalMaxOperations, proposalMaxOperations_);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) external {\n // Check caller = admin\n require(msg.sender == admin, \"GovernorBravo:_setPendingAdmin: admin only\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n */\n function _acceptAdmin() external {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n require(\n msg.sender == pendingAdmin && msg.sender != address(0),\n \"GovernorBravo:_acceptAdmin: pending admin only\"\n );\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n function add256(uint256 a, uint256 b) internal pure returns (uint) {\n uint c = a + b;\n require(c >= a, \"addition overflow\");\n return c;\n }\n\n function sub256(uint256 a, uint256 b) internal pure returns (uint) {\n require(b <= a, \"subtraction underflow\");\n return a - b;\n }\n\n function getChainIdInternal() internal pure returns (uint) {\n uint chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoInterfaces.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\n/**\n * @title GovernorBravoEvents\n * @author Venus\n * @notice Set of events emitted by the GovernorBravo contracts.\n */\ncontract GovernorBravoEvents {\n /// @notice An event emitted when a new proposal is created\n event ProposalCreated(\n uint id,\n address proposer,\n address[] targets,\n uint[] values,\n string[] signatures,\n bytes[] calldatas,\n uint startBlock,\n uint endBlock,\n string description,\n uint8 proposalType\n );\n\n /// @notice An event emitted when a vote has been cast on a proposal\n /// @param voter The address which casted a vote\n /// @param proposalId The proposal id which was voted on\n /// @param support Support value for the vote. 0=against, 1=for, 2=abstain\n /// @param votes Number of votes which were cast by the voter\n /// @param reason The reason given for the vote by the voter\n event VoteCast(address indexed voter, uint proposalId, uint8 support, uint votes, string reason);\n\n /// @notice An event emitted when a proposal has been canceled\n event ProposalCanceled(uint id);\n\n /// @notice An event emitted when a proposal has been queued in the Timelock\n event ProposalQueued(uint id, uint eta);\n\n /// @notice An event emitted when a proposal has been executed in the Timelock\n event ProposalExecuted(uint id);\n\n /// @notice An event emitted when the voting delay is set\n event VotingDelaySet(uint oldVotingDelay, uint newVotingDelay);\n\n /// @notice An event emitted when the voting period is set\n event VotingPeriodSet(uint oldVotingPeriod, uint newVotingPeriod);\n\n /// @notice Emitted when implementation is changed\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /// @notice Emitted when proposal threshold is set\n event ProposalThresholdSet(uint oldProposalThreshold, uint newProposalThreshold);\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Emitted when pendingAdmin is accepted, which means admin is updated\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /// @notice Emitted when the new guardian address is set\n event NewGuardian(address oldGuardian, address newGuardian);\n\n /// @notice Emitted when the maximum number of operations in one proposal is updated\n event ProposalMaxOperationsUpdated(uint oldMaxOperations, uint newMaxOperations);\n}\n\n/**\n * @title GovernorBravoDelegatorStorage\n * @author Venus\n * @notice Storage layout of the `GovernorBravoDelegator` contract\n */\ncontract GovernorBravoDelegatorStorage {\n /// @notice Administrator for this contract\n address public admin;\n\n /// @notice Pending administrator for this contract\n address public pendingAdmin;\n\n /// @notice Active brains of Governor\n address public implementation;\n}\n\n/**\n * @title GovernorBravoDelegateStorageV1\n * @dev For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a new\n * contract which implements GovernorBravoDelegateStorageV1 and following the naming convention\n * GovernorBravoDelegateStorageVX.\n */\ncontract GovernorBravoDelegateStorageV1 is GovernorBravoDelegatorStorage {\n /// @notice DEPRECATED The delay before voting on a proposal may take place, once proposed, in blocks\n uint public votingDelay;\n\n /// @notice DEPRECATED The duration of voting on a proposal, in blocks\n uint public votingPeriod;\n\n /// @notice DEPRECATED The number of votes required in order for a voter to become a proposer\n uint public proposalThreshold;\n\n /// @notice Initial proposal id set at become\n uint public initialProposalId;\n\n /// @notice The total number of proposals\n uint public proposalCount;\n\n /// @notice The address of the Venus Protocol Timelock\n TimelockInterface public timelock;\n\n /// @notice The address of the Venus governance token\n XvsVaultInterface public xvsVault;\n\n /// @notice The official record of all proposals ever proposed\n mapping(uint => Proposal) public proposals;\n\n /// @notice The latest proposal for each proposer\n mapping(address => uint) public latestProposalIds;\n\n struct Proposal {\n /// @notice Unique id for looking up a proposal\n uint id;\n /// @notice Creator of the proposal\n address proposer;\n /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds\n uint eta;\n /// @notice the ordered list of target addresses for calls to be made\n address[] targets;\n /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made\n uint[] values;\n /// @notice The ordered list of function signatures to be called\n string[] signatures;\n /// @notice The ordered list of calldata to be passed to each call\n bytes[] calldatas;\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\n uint startBlock;\n /// @notice The block at which voting ends: votes must be cast prior to this block\n uint endBlock;\n /// @notice Current number of votes in favor of this proposal\n uint forVotes;\n /// @notice Current number of votes in opposition to this proposal\n uint againstVotes;\n /// @notice Current number of votes for abstaining for this proposal\n uint abstainVotes;\n /// @notice Flag marking whether the proposal has been canceled\n bool canceled;\n /// @notice Flag marking whether the proposal has been executed\n bool executed;\n /// @notice Receipts of ballots for the entire set of voters\n mapping(address => Receipt) receipts;\n /// @notice The type of the proposal\n uint8 proposalType;\n }\n\n /// @notice Ballot receipt record for a voter\n struct Receipt {\n /// @notice Whether or not a vote has been cast\n bool hasVoted;\n /// @notice Whether or not the voter supports the proposal or abstains\n uint8 support;\n /// @notice The number of votes the voter had, which were cast\n uint96 votes;\n }\n\n /// @notice Possible states that a proposal may be in\n enum ProposalState {\n Pending,\n Active,\n Canceled,\n Defeated,\n Succeeded,\n Queued,\n Expired,\n Executed\n }\n\n /// @notice The maximum number of actions that can be included in a proposal\n uint public proposalMaxOperations;\n\n /// @notice A privileged role that can cancel any proposal\n address public guardian;\n}\n\n/**\n * @title GovernorBravoDelegateStorageV2\n * @dev For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a new\n * contract which implements GovernorBravoDelegateStorageV2 and following the naming convention\n * GovernorBravoDelegateStorageVX.\n */\ncontract GovernorBravoDelegateStorageV2 is GovernorBravoDelegateStorageV1 {\n enum ProposalType {\n NORMAL,\n FASTTRACK,\n CRITICAL\n }\n\n struct ProposalConfig {\n /// @notice The delay before voting on a proposal may take place, once proposed, in blocks\n uint256 votingDelay;\n /// @notice The duration of voting on a proposal, in blocks\n uint256 votingPeriod;\n /// @notice The number of votes required in order for a voter to become a proposer\n uint256 proposalThreshold;\n }\n\n /// @notice mapping containing configuration for each proposal type\n mapping(uint => ProposalConfig) public proposalConfigs;\n\n /// @notice mapping containing Timelock addresses for each proposal type\n mapping(uint => TimelockInterface) public proposalTimelocks;\n}\n\n/**\n * @title TimelockInterface\n * @author Venus\n * @notice Interface implemented by the Timelock contract.\n */\ninterface TimelockInterface {\n function delay() external view returns (uint);\n\n function GRACE_PERIOD() external view returns (uint);\n\n function acceptAdmin() external;\n\n function queuedTransactions(bytes32 hash) external view returns (bool);\n\n function queueTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external returns (bytes32);\n\n function cancelTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external;\n\n function executeTransaction(\n address target,\n uint value,\n string calldata signature,\n bytes calldata data,\n uint eta\n ) external payable returns (bytes memory);\n}\n\ninterface XvsVaultInterface {\n function getPriorVotes(address account, uint blockNumber) external view returns (uint96);\n}\n\ninterface GovernorAlphaInterface {\n /// @notice The total number of proposals\n function proposalCount() external returns (uint);\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\n/**\n * @title IAccessControlManagerV5\n * @author Venus\n * @notice Interface implemented by the `AccessControlManagerV5` contract.\n */\ninterface IAccessControlManagerV5 {\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 */\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 /**\n * @notice Gives a function call permission to one single account\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * \t\tMay emit a {RoleGranted} event.\n * @param contractAddress address of contract for which call permissions will be granted\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n */\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n /**\n * @notice Revokes an account's permission to a particular function call\n * @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE\n * \t\tMay emit a {RoleRevoked} event.\n * @param contractAddress address of contract for which call permissions will be revoked\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n */\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) external;\n\n /**\n * @notice Verifies if the given account can call a praticular contract's function\n * @dev Since the contract is calling itself this function, we can get contracts address with msg.sender\n * @param account address (eoa or contract) for which call permissions will be checked\n * @param functionSig signature e.g. \"functionName(uint,bool)\"\n * @return false if the user account cannot call the particular contract function\n *\n */\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) external view returns (bool);\n}\n" + }, + "@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.5.16;\n\ncontract TimeManagerV5 {\n /// @dev The approximate number of seconds per year\n uint256 public constant SECONDS_PER_YEAR = 31_536_000;\n\n /// @notice Number of blocks per year or seconds per year\n uint256 public blocksOrSecondsPerYear;\n\n /// @dev Sets true when block timestamp is used\n bool public isTimeBased;\n\n /// @dev Sets true when contract is initialized\n bool private isInitialized;\n\n /// @notice Deprecated slot for _getCurrentSlot function pointer\n bytes8 private __deprecatedSlot1;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[48] private __gap;\n\n /**\n * @dev Function to simply retrieve block number or block timestamp\n * @return Current block number or block timestamp\n */\n function getBlockNumberOrTimestamp() public view returns (uint256) {\n return isTimeBased ? _getBlockTimestamp() : _getBlockNumber();\n }\n\n /**\n * @dev Initializes the contract to use either blocks or seconds\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\n * @param blocksPerYear_ The number of blocks per year\n */\n function _initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) internal {\n if (isInitialized) revert(\"Already initialized TimeManager\");\n\n if (!timeBased_ && blocksPerYear_ == 0) {\n revert(\"Invalid blocks per year\");\n }\n if (timeBased_ && blocksPerYear_ != 0) {\n revert(\"Invalid time based configuration\");\n }\n\n isTimeBased = timeBased_;\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\n isInitialized = true;\n }\n\n /**\n * @dev Returns the current timestamp in seconds\n * @return The current timestamp\n */\n function _getBlockTimestamp() private view returns (uint256) {\n return block.timestamp;\n }\n\n /**\n * @dev Returns the current block number\n * @return The current block number\n */\n function _getBlockNumber() private view returns (uint256) {\n return block.number;\n }\n}\n" + }, + "contracts/Comptroller/ComptrollerInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerTypes } from \"./ComptrollerStorage.sol\";\n\ncontract ComptrollerInterface {\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n bool public constant isComptroller = true;\n\n /*** Assets You Are In ***/\n\n function enterMarkets(address[] calldata vTokens) external returns (uint[] memory);\n\n function exitMarket(address vToken) external returns (uint);\n\n /*** Policy Hooks ***/\n\n function mintAllowed(address vToken, address minter, uint mintAmount) external returns (uint);\n\n function mintVerify(address vToken, address minter, uint mintAmount, uint mintTokens) external;\n\n function redeemAllowed(address vToken, address redeemer, uint redeemTokens) external returns (uint);\n\n function redeemVerify(address vToken, address redeemer, uint redeemAmount, uint redeemTokens) external;\n\n function borrowAllowed(address vToken, address borrower, uint borrowAmount) external returns (uint);\n\n function borrowVerify(address vToken, address borrower, uint borrowAmount) external;\n\n function repayBorrowAllowed(\n address vToken,\n address payer,\n address borrower,\n uint repayAmount\n ) external returns (uint);\n\n function repayBorrowVerify(\n address vToken,\n address payer,\n address borrower,\n uint repayAmount,\n uint borrowerIndex\n ) external;\n\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint repayAmount\n ) external returns (uint);\n\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint repayAmount,\n uint seizeTokens\n ) external;\n\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) external returns (uint);\n\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) external;\n\n function transferAllowed(address vToken, address src, address dst, uint transferTokens) external returns (uint);\n\n function transferVerify(address vToken, address src, address dst, uint transferTokens) external;\n\n /*** Liquidity/Liquidation Calculations ***/\n\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint repayAmount\n ) external view returns (uint, uint);\n\n function setMintedVAIOf(address owner, uint amount) external returns (uint);\n\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint repayAmount\n ) external view returns (uint, uint);\n\n function getXVSAddress() public view returns (address);\n\n function markets(address) external view returns (bool, uint);\n\n function oracle() external view returns (PriceOracle);\n\n function getAccountLiquidity(address) external view returns (uint, uint, uint);\n\n function getAssetsIn(address) external view returns (VToken[] memory);\n\n function claimVenus(address) external;\n\n function venusAccrued(address) external view returns (uint);\n\n function venusSupplySpeeds(address) external view returns (uint);\n\n function venusBorrowSpeeds(address) external view returns (uint);\n\n function getAllMarkets() external view returns (VToken[] memory);\n\n function venusSupplierIndex(address, address) external view returns (uint);\n\n function venusInitialIndex() external view returns (uint224);\n\n function venusBorrowerIndex(address, address) external view returns (uint);\n\n function venusBorrowState(address) external view returns (uint224, uint32);\n\n function venusSupplyState(address) external view returns (uint224, uint32);\n\n function approvedDelegates(address borrower, address delegate) external view returns (bool);\n\n function vaiController() external view returns (VAIControllerInterface);\n\n function liquidationIncentiveMantissa() external view returns (uint);\n\n function protocolPaused() external view returns (bool);\n\n function actionPaused(address market, ComptrollerTypes.Action action) public view returns (bool);\n\n function mintedVAIs(address user) external view returns (uint);\n\n function vaiMintRate() external view returns (uint);\n}\n\ninterface IVAIVault {\n function updatePendingRewards() external;\n}\n\ninterface IComptroller {\n function liquidationIncentiveMantissa() external view returns (uint);\n\n /*** Treasury Data ***/\n function treasuryAddress() external view returns (address);\n\n function treasuryPercent() external view returns (uint);\n}\n" + }, + "contracts/Comptroller/ComptrollerLensInterface.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\ninterface ComptrollerLensInterface {\n function liquidateCalculateSeizeTokens(\n address comptroller,\n address vTokenBorrowed,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint);\n\n function liquidateVAICalculateSeizeTokens(\n address comptroller,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint);\n\n function getHypotheticalAccountLiquidity(\n address comptroller,\n address account,\n VToken vTokenModify,\n uint redeemTokens,\n uint borrowAmount\n ) external view returns (uint, uint, uint);\n}\n" + }, + "contracts/Comptroller/ComptrollerStorage.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity ^0.5.16;\n\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { PriceOracle } from \"../Oracle/PriceOracle.sol\";\nimport { VAIControllerInterface } from \"../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerLensInterface } from \"./ComptrollerLensInterface.sol\";\nimport { IPrime } from \"../Tokens/Prime/IPrime.sol\";\n\ninterface ComptrollerTypes {\n enum Action {\n MINT,\n REDEEM,\n BORROW,\n REPAY,\n SEIZE,\n LIQUIDATE,\n TRANSFER,\n ENTER_MARKET,\n EXIT_MARKET\n }\n}\n\ncontract UnitrollerAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of Unitroller\n */\n address public comptrollerImplementation;\n\n /**\n * @notice Pending brains of Unitroller\n */\n address public pendingComptrollerImplementation;\n}\n\ncontract ComptrollerV1Storage is ComptrollerTypes, UnitrollerAdminStorage {\n /**\n * @notice Oracle which gives the price of any given asset\n */\n PriceOracle public oracle;\n\n /**\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\n */\n uint256 public closeFactorMantissa;\n\n /**\n * @notice Multiplier representing the discount on collateral that a liquidator receives\n */\n uint256 public liquidationIncentiveMantissa;\n\n /**\n * @notice Max number of assets a single account can participate in (borrow or use as collateral)\n */\n uint256 public maxAssets;\n\n /**\n * @notice Per-account mapping of \"assets you are in\", capped by maxAssets\n */\n mapping(address => VToken[]) public accountAssets;\n\n struct Market {\n /// @notice Whether or not this market is listed\n bool isListed;\n /**\n * @notice Multiplier representing the most one can borrow against their collateral in this market.\n * For instance, 0.9 to allow borrowing 90% of collateral value.\n * Must be between 0 and 1, and stored as a mantissa.\n */\n uint256 collateralFactorMantissa;\n /// @notice Per-market mapping of \"accounts in this asset\"\n mapping(address => bool) accountMembership;\n /// @notice Whether or not this market receives XVS\n bool isVenus;\n }\n\n /**\n * @notice Official mapping of vTokens -> Market metadata\n * @dev Used e.g. to determine if a market is supported\n */\n mapping(address => Market) public markets;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n */\n address public pauseGuardian;\n\n /// @notice Whether minting is paused (deprecated, superseded by actionPaused)\n bool private _mintGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool private _borrowGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool internal transferGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n bool internal seizeGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n mapping(address => bool) internal mintGuardianPaused;\n /// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)\n mapping(address => bool) internal borrowGuardianPaused;\n\n struct VenusMarketState {\n /// @notice The market's last updated venusBorrowIndex or venusSupplyIndex\n uint224 index;\n /// @notice The block number the index was last updated at\n uint32 block;\n }\n\n /// @notice A list of all markets\n VToken[] public allMarkets;\n\n /// @notice The rate at which the flywheel distributes XVS, per block\n uint256 internal venusRate;\n\n /// @notice The portion of venusRate that each market currently receives\n mapping(address => uint256) internal venusSpeeds;\n\n /// @notice The Venus market supply state for each market\n mapping(address => VenusMarketState) public venusSupplyState;\n\n /// @notice The Venus market borrow state for each market\n mapping(address => VenusMarketState) public venusBorrowState;\n\n /// @notice The Venus supply index for each market for each supplier as of the last time they accrued XVS\n mapping(address => mapping(address => uint256)) public venusSupplierIndex;\n\n /// @notice The Venus borrow index for each market for each borrower as of the last time they accrued XVS\n mapping(address => mapping(address => uint256)) public venusBorrowerIndex;\n\n /// @notice The XVS accrued but not yet transferred to each user\n mapping(address => uint256) public venusAccrued;\n\n /// @notice The Address of VAIController\n VAIControllerInterface public vaiController;\n\n /// @notice The minted VAI amount to each user\n mapping(address => uint256) public mintedVAIs;\n\n /// @notice VAI Mint Rate as a percentage\n uint256 public vaiMintRate;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n */\n bool public mintVAIGuardianPaused;\n bool public repayVAIGuardianPaused;\n\n /**\n * @notice Pause/Unpause whole protocol actions\n */\n bool public protocolPaused;\n\n /// @notice The rate at which the flywheel distributes XVS to VAI Minters, per block (deprecated)\n uint256 private venusVAIRate;\n}\n\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\n /// @notice The rate at which the flywheel distributes XVS to VAI Vault, per block\n uint256 public venusVAIVaultRate;\n\n // address of VAI Vault\n address public vaiVaultAddress;\n\n // start block of release to VAI Vault\n uint256 public releaseStartBlock;\n\n // minimum release amount to VAI Vault\n uint256 public minReleaseAmount;\n}\n\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\n address public borrowCapGuardian;\n\n /// @notice Borrow caps enforced by borrowAllowed for each vToken address. Defaults to zero which corresponds to unlimited borrowing.\n mapping(address => uint256) public borrowCaps;\n}\n\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\n /// @notice Treasury Guardian address\n address public treasuryGuardian;\n\n /// @notice Treasury address\n address public treasuryAddress;\n\n /// @notice Fee percent of accrued interest with decimal 18\n uint256 public treasuryPercent;\n}\n\ncontract ComptrollerV5Storage is ComptrollerV4Storage {\n /// @notice The portion of XVS that each contributor receives per block (deprecated)\n mapping(address => uint256) private venusContributorSpeeds;\n\n /// @notice Last block at which a contributor's XVS rewards have been allocated (deprecated)\n mapping(address => uint256) private lastContributorBlock;\n}\n\ncontract ComptrollerV6Storage is ComptrollerV5Storage {\n address public liquidatorContract;\n}\n\ncontract ComptrollerV7Storage is ComptrollerV6Storage {\n ComptrollerLensInterface public comptrollerLens;\n}\n\ncontract ComptrollerV8Storage is ComptrollerV7Storage {\n /// @notice Supply caps enforced by mintAllowed for each vToken address. Defaults to zero which corresponds to minting notAllowed\n mapping(address => uint256) public supplyCaps;\n}\n\ncontract ComptrollerV9Storage is ComptrollerV8Storage {\n /// @notice AccessControlManager address\n address internal accessControl;\n\n /// @notice True if a certain action is paused on a certain market\n mapping(address => mapping(uint256 => bool)) internal _actionPaused;\n}\n\ncontract ComptrollerV10Storage is ComptrollerV9Storage {\n /// @notice The rate at which venus is distributed to the corresponding borrow market (per block)\n mapping(address => uint256) public venusBorrowSpeeds;\n\n /// @notice The rate at which venus is distributed to the corresponding supply market (per block)\n mapping(address => uint256) public venusSupplySpeeds;\n}\n\ncontract ComptrollerV11Storage is ComptrollerV10Storage {\n /// @notice Whether the delegate is allowed to borrow or redeem on behalf of the user\n //mapping(address user => mapping (address delegate => bool approved)) public approvedDelegates;\n mapping(address => mapping(address => bool)) public approvedDelegates;\n}\n\ncontract ComptrollerV12Storage is ComptrollerV11Storage {\n /// @notice Whether forced liquidation is enabled for all users borrowing in a certain market\n mapping(address => bool) public isForcedLiquidationEnabled;\n}\n\ncontract ComptrollerV13Storage is ComptrollerV12Storage {\n struct FacetAddressAndPosition {\n address facetAddress;\n uint96 functionSelectorPosition; // position in _facetFunctionSelectors.functionSelectors array\n }\n\n struct FacetFunctionSelectors {\n bytes4[] functionSelectors;\n uint256 facetAddressPosition; // position of facetAddress in _facetAddresses array\n }\n\n mapping(bytes4 => FacetAddressAndPosition) internal _selectorToFacetAndPosition;\n // maps facet addresses to function selectors\n mapping(address => FacetFunctionSelectors) internal _facetFunctionSelectors;\n // facet addresses\n address[] internal _facetAddresses;\n}\n\ncontract ComptrollerV14Storage is ComptrollerV13Storage {\n /// @notice Prime token address\n IPrime public prime;\n}\n\ncontract ComptrollerV15Storage is ComptrollerV14Storage {\n /// @notice Whether forced liquidation is enabled for the borrows of a user in a market\n mapping(address /* user */ => mapping(address /* market */ => bool)) public isForcedLiquidationEnabledForUser;\n}\n\ncontract ComptrollerV16Storage is ComptrollerV15Storage {\n /// @notice The XVS token contract address\n address internal xvs;\n\n /// @notice The XVS vToken contract address\n address internal xvsVToken;\n}\n" + }, + "contracts/Comptroller/Diamond/Diamond.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\nimport { IDiamondCut } from \"./interfaces/IDiamondCut.sol\";\nimport { Unitroller, ComptrollerV16Storage } from \"../Unitroller.sol\";\n\n/**\n * @title Diamond\n * @author Venus\n * @notice This contract contains functions related to facets\n */\ncontract Diamond is IDiamondCut, ComptrollerV16Storage {\n /// @notice Emitted when functions are added, replaced or removed to facets\n event DiamondCut(IDiamondCut.FacetCut[] _diamondCut);\n\n struct Facet {\n address facetAddress;\n bytes4[] functionSelectors;\n }\n\n /**\n * @notice Call _acceptImplementation to accept the diamond proxy as new implementaion\n * @param unitroller Address of the unitroller\n */\n function _become(Unitroller unitroller) public {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can\");\n require(unitroller._acceptImplementation() == 0, \"not authorized\");\n }\n\n /**\n * @notice To add function selectors to the facet's mapping\n * @dev Allows the contract admin to add function selectors\n * @param diamondCut_ IDiamondCut contains facets address, action and function selectors\n */\n function diamondCut(IDiamondCut.FacetCut[] memory diamondCut_) public {\n require(msg.sender == admin, \"only unitroller admin can\");\n libDiamondCut(diamondCut_);\n }\n\n /**\n * @notice Get all function selectors mapped to the facet address\n * @param facet Address of the facet\n * @return selectors Array of function selectors\n */\n function facetFunctionSelectors(address facet) external view returns (bytes4[] memory) {\n return _facetFunctionSelectors[facet].functionSelectors;\n }\n\n /**\n * @notice Get facet position in the _facetFunctionSelectors through facet address\n * @param facet Address of the facet\n * @return Position of the facet\n */\n function facetPosition(address facet) external view returns (uint256) {\n return _facetFunctionSelectors[facet].facetAddressPosition;\n }\n\n /**\n * @notice Get all facet addresses\n * @return facetAddresses Array of facet addresses\n */\n function facetAddresses() external view returns (address[] memory) {\n return _facetAddresses;\n }\n\n /**\n * @notice Get facet address and position through function selector\n * @param functionSelector function selector\n * @return FacetAddressAndPosition facet address and position\n */\n function facetAddress(\n bytes4 functionSelector\n ) external view returns (ComptrollerV16Storage.FacetAddressAndPosition memory) {\n return _selectorToFacetAndPosition[functionSelector];\n }\n\n /**\n * @notice Get all facets address and their function selector\n * @return facets_ Array of Facet\n */\n function facets() external view returns (Facet[] memory) {\n uint256 facetsLength = _facetAddresses.length;\n Facet[] memory facets_ = new Facet[](facetsLength);\n for (uint256 i; i < facetsLength; ++i) {\n address facet = _facetAddresses[i];\n facets_[i].facetAddress = facet;\n facets_[i].functionSelectors = _facetFunctionSelectors[facet].functionSelectors;\n }\n return facets_;\n }\n\n /**\n * @notice To add function selectors to the facets' mapping\n * @param diamondCut_ IDiamondCut contains facets address, action and function selectors\n */\n function libDiamondCut(IDiamondCut.FacetCut[] memory diamondCut_) internal {\n uint256 diamondCutLength = diamondCut_.length;\n for (uint256 facetIndex; facetIndex < diamondCutLength; ++facetIndex) {\n IDiamondCut.FacetCutAction action = diamondCut_[facetIndex].action;\n if (action == IDiamondCut.FacetCutAction.Add) {\n addFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else if (action == IDiamondCut.FacetCutAction.Replace) {\n replaceFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else if (action == IDiamondCut.FacetCutAction.Remove) {\n removeFunctions(diamondCut_[facetIndex].facetAddress, diamondCut_[facetIndex].functionSelectors);\n } else {\n revert(\"LibDiamondCut: Incorrect FacetCutAction\");\n }\n }\n emit DiamondCut(diamondCut_);\n }\n\n /**\n * @notice Add function selectors to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to add in the mapping\n */\n function addFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n require(functionSelectors.length != 0, \"LibDiamondCut: No selectors in facet to cut\");\n require(facetAddress != address(0), \"LibDiamondCut: Add facet can't be address(0)\");\n uint96 selectorPosition = uint96(_facetFunctionSelectors[facetAddress].functionSelectors.length);\n // add new facet address if it does not exist\n if (selectorPosition == 0) {\n addFacet(facetAddress);\n }\n uint256 functionSelectorsLength = functionSelectors.length;\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n require(oldFacetAddress == address(0), \"LibDiamondCut: Can't add function that already exists\");\n addFunction(selector, selectorPosition, facetAddress);\n ++selectorPosition;\n }\n }\n\n /**\n * @notice Replace facet's address mapping for function selectors i.e selectors already associate to any other existing facet\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to replace in the mapping\n */\n function replaceFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n require(functionSelectors.length != 0, \"LibDiamondCut: No selectors in facet to cut\");\n require(facetAddress != address(0), \"LibDiamondCut: Add facet can't be address(0)\");\n uint96 selectorPosition = uint96(_facetFunctionSelectors[facetAddress].functionSelectors.length);\n // add new facet address if it does not exist\n if (selectorPosition == 0) {\n addFacet(facetAddress);\n }\n uint256 functionSelectorsLength = functionSelectors.length;\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n require(oldFacetAddress != facetAddress, \"LibDiamondCut: Can't replace function with same function\");\n removeFunction(oldFacetAddress, selector);\n addFunction(selector, selectorPosition, facetAddress);\n ++selectorPosition;\n }\n }\n\n /**\n * @notice Remove function selectors to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param functionSelectors Array of function selectors need to remove in the mapping\n */\n function removeFunctions(address facetAddress, bytes4[] memory functionSelectors) internal {\n uint256 functionSelectorsLength = functionSelectors.length;\n require(functionSelectorsLength != 0, \"LibDiamondCut: No selectors in facet to cut\");\n // if function does not exist then do nothing and revert\n require(facetAddress == address(0), \"LibDiamondCut: Remove facet address must be address(0)\");\n for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; ++selectorIndex) {\n bytes4 selector = functionSelectors[selectorIndex];\n address oldFacetAddress = _selectorToFacetAndPosition[selector].facetAddress;\n removeFunction(oldFacetAddress, selector);\n }\n }\n\n /**\n * @notice Add new facet to the proxy\n * @param facetAddress Address of the facet\n */\n function addFacet(address facetAddress) internal {\n enforceHasContractCode(facetAddress, \"Diamond: New facet has no code\");\n _facetFunctionSelectors[facetAddress].facetAddressPosition = _facetAddresses.length;\n _facetAddresses.push(facetAddress);\n }\n\n /**\n * @notice Add function selector to the facet's address mapping\n * @param selector funciton selector need to be added\n * @param selectorPosition funciton selector position\n * @param facetAddress Address of the facet\n */\n function addFunction(bytes4 selector, uint96 selectorPosition, address facetAddress) internal {\n _selectorToFacetAndPosition[selector].functionSelectorPosition = selectorPosition;\n _facetFunctionSelectors[facetAddress].functionSelectors.push(selector);\n _selectorToFacetAndPosition[selector].facetAddress = facetAddress;\n }\n\n /**\n * @notice Remove function selector to the facet's address mapping\n * @param facetAddress Address of the facet\n * @param selector function selectors need to remove in the mapping\n */\n function removeFunction(address facetAddress, bytes4 selector) internal {\n require(facetAddress != address(0), \"LibDiamondCut: Can't remove function that doesn't exist\");\n\n // replace selector with last selector, then delete last selector\n uint256 selectorPosition = _selectorToFacetAndPosition[selector].functionSelectorPosition;\n uint256 lastSelectorPosition = _facetFunctionSelectors[facetAddress].functionSelectors.length - 1;\n // if not the same then replace selector with lastSelector\n if (selectorPosition != lastSelectorPosition) {\n bytes4 lastSelector = _facetFunctionSelectors[facetAddress].functionSelectors[lastSelectorPosition];\n _facetFunctionSelectors[facetAddress].functionSelectors[selectorPosition] = lastSelector;\n _selectorToFacetAndPosition[lastSelector].functionSelectorPosition = uint96(selectorPosition);\n }\n // delete the last selector\n _facetFunctionSelectors[facetAddress].functionSelectors.pop();\n delete _selectorToFacetAndPosition[selector];\n\n // if no more selectors for facet address then delete the facet address\n if (lastSelectorPosition == 0) {\n // replace facet address with last facet address and delete last facet address\n uint256 lastFacetAddressPosition = _facetAddresses.length - 1;\n uint256 facetAddressPosition = _facetFunctionSelectors[facetAddress].facetAddressPosition;\n if (facetAddressPosition != lastFacetAddressPosition) {\n address lastFacetAddress = _facetAddresses[lastFacetAddressPosition];\n _facetAddresses[facetAddressPosition] = lastFacetAddress;\n _facetFunctionSelectors[lastFacetAddress].facetAddressPosition = facetAddressPosition;\n }\n _facetAddresses.pop();\n delete _facetFunctionSelectors[facetAddress];\n }\n }\n\n /**\n * @dev Ensure that the given address has contract code deployed\n * @param _contract The address to check for contract code\n * @param _errorMessage The error message to display if the contract code is not deployed\n */\n function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {\n uint256 contractSize;\n assembly {\n contractSize := extcodesize(_contract)\n }\n require(contractSize != 0, _errorMessage);\n }\n\n // Find facet for function that is called and execute the\n // function if a facet is found and return any value.\n function() external payable {\n address facet = _selectorToFacetAndPosition[msg.sig].facetAddress;\n require(facet != address(0), \"Diamond: Function does not exist\");\n // Execute public function from facet using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the facet\n let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" + }, + "contracts/Comptroller/Diamond/DiamondConsolidated.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"./facets/MarketFacet.sol\";\nimport \"./facets/PolicyFacet.sol\";\nimport \"./facets/RewardFacet.sol\";\nimport \"./facets/SetterFacet.sol\";\nimport \"./Diamond.sol\";\n\n/**\n * @title DiamondConsolidated\n * @author Venus\n * @notice This contract contains the functions defined in the different facets of the Diamond, plus the getters to the public variables.\n * This contract cannot be deployed, due to its size. Its main purpose is to allow the easy generation of an ABI and the typechain to interact with the\n * Unitroller contract in a simple way\n */\ncontract DiamondConsolidated is Diamond, MarketFacet, PolicyFacet, RewardFacet, SetterFacet {}\n" + }, + "contracts/Comptroller/Diamond/facets/FacetBase.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken, ComptrollerErrorReporter, ExponentialNoError } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IVAIVault } from \"../../../Comptroller/ComptrollerInterface.sol\";\nimport { ComptrollerV16Storage } from \"../../../Comptroller/ComptrollerStorage.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\n\nimport { SafeBEP20, IBEP20 } from \"../../../Utils/SafeBEP20.sol\";\n\n/**\n * @title FacetBase\n * @author Venus\n * @notice This facet contract contains functions related to access and checks\n */\ncontract FacetBase is ComptrollerV16Storage, ExponentialNoError, ComptrollerErrorReporter {\n using SafeBEP20 for IBEP20;\n\n /// @notice The initial Venus index for a market\n uint224 public constant venusInitialIndex = 1e36;\n // closeFactorMantissa must be strictly greater than this value\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\n // closeFactorMantissa must not exceed this value\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\n // No collateralFactorMantissa may exceed this value\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\n\n /// @notice Emitted when an account enters a market\n event MarketEntered(VToken indexed vToken, address indexed account);\n\n /// @notice Emitted when XVS is distributed to VAI Vault\n event DistributedVAIVaultVenus(uint256 amount);\n\n /// @notice Reverts if the protocol is paused\n function checkProtocolPauseState() internal view {\n require(!protocolPaused, \"protocol is paused\");\n }\n\n /// @notice Reverts if a certain action is paused on a market\n function checkActionPauseState(address market, Action action) internal view {\n require(!actionPaused(market, action), \"action is paused\");\n }\n\n /// @notice Reverts if the caller is not admin\n function ensureAdmin() internal view {\n require(msg.sender == admin, \"only admin can\");\n }\n\n /// @notice Checks the passed address is nonzero\n function ensureNonzeroAddress(address someone) internal pure {\n require(someone != address(0), \"can't be zero address\");\n }\n\n /// @notice Reverts if the market is not listed\n function ensureListed(Market storage market) internal view {\n require(market.isListed, \"market not listed\");\n }\n\n /// @notice Reverts if the caller is neither admin nor the passed address\n function ensureAdminOr(address privilegedAddress) internal view {\n require(msg.sender == admin || msg.sender == privilegedAddress, \"access denied\");\n }\n\n /// @notice Checks the caller is allowed to call the specified fuction\n function ensureAllowed(string memory functionSig) internal view {\n require(IAccessControlManagerV5(accessControl).isAllowedToCall(msg.sender, functionSig), \"access denied\");\n }\n\n /**\n * @notice Checks if a certain action is paused on a market\n * @param action Action id\n * @param market vToken address\n */\n function actionPaused(address market, Action action) public view returns (bool) {\n return _actionPaused[market][uint256(action)];\n }\n\n /**\n * @notice Get the latest block number\n */\n function getBlockNumber() internal view returns (uint256) {\n return block.number;\n }\n\n /**\n * @notice Get the latest block number with the safe32 check\n */\n function getBlockNumberAsUint32() internal view returns (uint32) {\n return safe32(getBlockNumber(), \"block # > 32 bits\");\n }\n\n /**\n * @notice Transfer XVS to VAI Vault\n */\n function releaseToVault() internal {\n if (releaseStartBlock == 0 || getBlockNumber() < releaseStartBlock) {\n return;\n }\n\n IBEP20 xvs_ = IBEP20(xvs);\n\n uint256 xvsBalance = xvs_.balanceOf(address(this));\n if (xvsBalance == 0) {\n return;\n }\n\n uint256 actualAmount;\n uint256 deltaBlocks = sub_(getBlockNumber(), releaseStartBlock);\n // releaseAmount = venusVAIVaultRate * deltaBlocks\n uint256 releaseAmount_ = mul_(venusVAIVaultRate, deltaBlocks);\n\n if (xvsBalance >= releaseAmount_) {\n actualAmount = releaseAmount_;\n } else {\n actualAmount = xvsBalance;\n }\n\n if (actualAmount < minReleaseAmount) {\n return;\n }\n\n releaseStartBlock = getBlockNumber();\n\n xvs_.safeTransfer(vaiVaultAddress, actualAmount);\n emit DistributedVAIVaultVenus(actualAmount);\n\n IVAIVault(vaiVaultAddress).updatePendingRewards();\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param vTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @dev Note that we calculate the exchangeRateStored for each collateral vToken using stored data,\n * without calculating accumulated interest.\n * @return (possible error code,\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidityInternal(\n address account,\n VToken vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) internal view returns (Error, uint256, uint256) {\n (uint256 err, uint256 liquidity, uint256 shortfall) = comptrollerLens.getHypotheticalAccountLiquidity(\n address(this),\n account,\n vTokenModify,\n redeemTokens,\n borrowAmount\n );\n return (Error(err), liquidity, shortfall);\n }\n\n /**\n * @notice Add the market to the borrower's \"assets in\" for liquidity calculations\n * @param vToken The market to enter\n * @param borrower The address of the account to modify\n * @return Success indicator for whether the market was entered\n */\n function addToMarketInternal(VToken vToken, address borrower) internal returns (Error) {\n checkActionPauseState(address(vToken), Action.ENTER_MARKET);\n Market storage marketToJoin = markets[address(vToken)];\n ensureListed(marketToJoin);\n if (marketToJoin.accountMembership[borrower]) {\n // already joined\n return Error.NO_ERROR;\n }\n // survived the gauntlet, add to list\n // NOTE: we store these somewhat redundantly as a significant optimization\n // this avoids having to iterate through the list for the most common use cases\n // that is, only when we need to perform liquidity checks\n // and not whenever we want to check if an account is in a particular market\n marketToJoin.accountMembership[borrower] = true;\n accountAssets[borrower].push(vToken);\n\n emit MarketEntered(vToken, borrower);\n\n return Error.NO_ERROR;\n }\n\n /**\n * @notice Checks for the user is allowed to redeem tokens\n * @param vToken Address of the market\n * @param redeemer Address of the user\n * @param redeemTokens Amount of tokens to redeem\n * @return Success indicator for redeem is allowed or not\n */\n function redeemAllowedInternal(\n address vToken,\n address redeemer,\n uint256 redeemTokens\n ) internal view returns (uint256) {\n ensureListed(markets[vToken]);\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\n if (!markets[vToken].accountMembership[redeemer]) {\n return uint256(Error.NO_ERROR);\n }\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n redeemer,\n VToken(vToken),\n redeemTokens,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall != 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the XVS address\n * @return The address of XVS token\n */\n function getXVSAddress() external view returns (address) {\n return xvs;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/MarketFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { IMarketFacet } from \"../interfaces/IMarketFacet.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title MarketFacet\n * @author Venus\n * @dev This facet contains all the methods related to the market's management in the pool\n * @notice This facet contract contains functions regarding markets\n */\ncontract MarketFacet is IMarketFacet, FacetBase {\n /// @notice Emitted when an admin supports a market\n event MarketListed(VToken indexed vToken);\n\n /// @notice Emitted when an account exits a market\n event MarketExited(VToken indexed vToken, address indexed account);\n\n /// @notice Emitted when the borrowing or redeeming delegate rights are updated for an account\n event DelegateUpdated(address indexed approver, address indexed delegate, bool approved);\n\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n function isComptroller() public pure returns (bool) {\n return true;\n }\n\n /**\n * @notice Returns the assets an account has entered\n * @param account The address of the account to pull assets for\n * @return A dynamic list with the assets the account has entered\n */\n function getAssetsIn(address account) external view returns (VToken[] memory) {\n return accountAssets[account];\n }\n\n /**\n * @notice Return all of the markets\n * @dev The automatic getter may be used to access an individual market\n * @return The list of market addresses\n */\n function getAllMarkets() external view returns (VToken[] memory) {\n return allMarkets;\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in vToken.liquidateBorrowFresh)\n * @param vTokenBorrowed The address of the borrowed vToken\n * @param vTokenCollateral The address of the collateral vToken\n * @param actualRepayAmount The amount of vTokenBorrowed underlying to convert into vTokenCollateral tokens\n * @return (errorCode, number of vTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256) {\n (uint256 err, uint256 seizeTokens) = comptrollerLens.liquidateCalculateSeizeTokens(\n address(this),\n vTokenBorrowed,\n vTokenCollateral,\n actualRepayAmount\n );\n return (err, seizeTokens);\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in vToken.liquidateBorrowFresh)\n * @param vTokenCollateral The address of the collateral vToken\n * @param actualRepayAmount The amount of vTokenBorrowed underlying to convert into vTokenCollateral tokens\n * @return (errorCode, number of vTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256) {\n (uint256 err, uint256 seizeTokens) = comptrollerLens.liquidateVAICalculateSeizeTokens(\n address(this),\n vTokenCollateral,\n actualRepayAmount\n );\n return (err, seizeTokens);\n }\n\n /**\n * @notice Returns whether the given account is entered in the given asset\n * @param account The address of the account to check\n * @param vToken The vToken to check\n * @return True if the account is in the asset, otherwise false\n */\n function checkMembership(address account, VToken vToken) external view returns (bool) {\n return markets[address(vToken)].accountMembership[account];\n }\n\n /**\n * @notice Add assets to be included in account liquidity calculation\n * @param vTokens The list of addresses of the vToken markets to be enabled\n * @return Success indicator for whether each corresponding market was entered\n */\n function enterMarkets(address[] calldata vTokens) external returns (uint256[] memory) {\n uint256 len = vTokens.length;\n\n uint256[] memory results = new uint256[](len);\n for (uint256 i; i < len; ++i) {\n results[i] = uint256(addToMarketInternal(VToken(vTokens[i]), msg.sender));\n }\n\n return results;\n }\n\n /**\n * @notice Removes asset from sender's account liquidity calculation\n * @dev Sender must not have an outstanding borrow balance in the asset,\n * or be providing necessary collateral for an outstanding borrow\n * @param vTokenAddress The address of the asset to be removed\n * @return Whether or not the account successfully exited the market\n */\n function exitMarket(address vTokenAddress) external returns (uint256) {\n checkActionPauseState(vTokenAddress, Action.EXIT_MARKET);\n\n VToken vToken = VToken(vTokenAddress);\n /* Get sender tokensHeld and amountOwed underlying from the vToken */\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = vToken.getAccountSnapshot(msg.sender);\n require(oErr == 0, \"getAccountSnapshot failed\"); // semi-opaque error code\n\n /* Fail if the sender has a borrow balance */\n if (amountOwed != 0) {\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\n }\n\n /* Fail if the sender is not permitted to redeem all of their tokens */\n uint256 allowed = redeemAllowedInternal(vTokenAddress, msg.sender, tokensHeld);\n if (allowed != 0) {\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\n }\n\n Market storage marketToExit = markets[address(vToken)];\n\n /* Return true if the sender is not already ‘in’ the market */\n if (!marketToExit.accountMembership[msg.sender]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Set vToken account membership to false */\n delete marketToExit.accountMembership[msg.sender];\n\n /* Delete vToken from the account’s list of assets */\n // In order to delete vToken, copy last item in list to location of item to be removed, reduce length by 1\n VToken[] storage userAssetList = accountAssets[msg.sender];\n uint256 len = userAssetList.length;\n uint256 i;\n for (; i < len; ++i) {\n if (userAssetList[i] == vToken) {\n userAssetList[i] = userAssetList[len - 1];\n userAssetList.length--;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(i < len);\n\n emit MarketExited(vToken, msg.sender);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Add the market to the markets mapping and set it as listed\n * @dev Allows a privileged role to add and list markets to the Comptroller\n * @param vToken The address of the market (token) to list\n * @return uint256 0=success, otherwise a failure. (See enum Error for details)\n */\n function _supportMarket(VToken vToken) external returns (uint256) {\n ensureAllowed(\"_supportMarket(address)\");\n\n if (markets[address(vToken)].isListed) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n vToken.isVToken(); // Sanity check to make sure its really a VToken\n\n // Note that isVenus is not in active use anymore\n Market storage newMarket = markets[address(vToken)];\n newMarket.isListed = true;\n newMarket.isVenus = false;\n newMarket.collateralFactorMantissa = 0;\n\n _addMarketInternal(vToken);\n _initializeMarket(address(vToken));\n\n emit MarketListed(vToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Grants or revokes the borrowing or redeeming delegate rights to / from an account\n * If allowed, the delegate will be able to borrow funds on behalf of the sender\n * Upon a delegated borrow, the delegate will receive the funds, and the borrower\n * will see the debt on their account\n * Upon a delegated redeem, the delegate will receive the redeemed amount and the approver\n * will see a deduction in his vToken balance\n * @param delegate The address to update the rights for\n * @param approved Whether to grant (true) or revoke (false) the borrowing or redeeming rights\n */\n function updateDelegate(address delegate, bool approved) external {\n ensureNonzeroAddress(delegate);\n require(approvedDelegates[msg.sender][delegate] != approved, \"Delegation status unchanged\");\n\n _updateDelegate(msg.sender, delegate, approved);\n }\n\n function _updateDelegate(address approver, address delegate, bool approved) internal {\n approvedDelegates[approver][delegate] = approved;\n emit DelegateUpdated(approver, delegate, approved);\n }\n\n function _addMarketInternal(VToken vToken) internal {\n uint256 allMarketsLength = allMarkets.length;\n for (uint256 i; i < allMarketsLength; ++i) {\n require(allMarkets[i] != vToken, \"already added\");\n }\n allMarkets.push(vToken);\n }\n\n function _initializeMarket(address vToken) internal {\n uint32 blockNumber = getBlockNumberAsUint32();\n\n VenusMarketState storage supplyState = venusSupplyState[vToken];\n VenusMarketState storage borrowState = venusBorrowState[vToken];\n\n /*\n * Update market state indices\n */\n if (supplyState.index == 0) {\n // Initialize supply state index with default value\n supplyState.index = venusInitialIndex;\n }\n\n if (borrowState.index == 0) {\n // Initialize borrow state index with default value\n borrowState.index = venusInitialIndex;\n }\n\n /*\n * Update market state block numbers\n */\n supplyState.block = borrowState.block = blockNumber;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/PolicyFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IPolicyFacet } from \"../interfaces/IPolicyFacet.sol\";\n\nimport { XVSRewardsHelper } from \"./XVSRewardsHelper.sol\";\n\n/**\n * @title PolicyFacet\n * @author Venus\n * @dev This facet contains all the hooks used while transferring the assets\n * @notice This facet contract contains all the external pre-hook functions related to vToken\n */\ncontract PolicyFacet is IPolicyFacet, XVSRewardsHelper {\n /// @notice Emitted when a new borrow-side XVS speed is calculated for a market\n event VenusBorrowSpeedUpdated(VToken indexed vToken, uint256 newSpeed);\n\n /// @notice Emitted when a new supply-side XVS speed is calculated for a market\n event VenusSupplySpeedUpdated(VToken indexed vToken, uint256 newSpeed);\n\n /**\n * @notice Checks if the account should be allowed to mint tokens in the given market\n * @param vToken The market to verify the mint against\n * @param minter The account which would get the minted tokens\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function mintAllowed(address vToken, address minter, uint256 mintAmount) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.MINT);\n ensureListed(markets[vToken]);\n\n uint256 supplyCap = supplyCaps[vToken];\n require(supplyCap != 0, \"market supply cap is 0\");\n\n uint256 vTokenSupply = VToken(vToken).totalSupply();\n Exp memory exchangeRate = Exp({ mantissa: VToken(vToken).exchangeRateStored() });\n uint256 nextTotalSupply = mul_ScalarTruncateAddUInt(exchangeRate, vTokenSupply, mintAmount);\n require(nextTotalSupply <= supplyCap, \"market supply cap reached\");\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, minter);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates mint, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being minted\n * @param minter The address minting the tokens\n * @param actualMintAmount The amount of the underlying asset being minted\n * @param mintTokens The number of tokens being minted\n */\n // solhint-disable-next-line no-unused-vars\n function mintVerify(address vToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(minter, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to redeem tokens in the given market\n * @param vToken The market to verify the redeem against\n * @param redeemer The account which would redeem the tokens\n * @param redeemTokens The number of vTokens to exchange for the underlying asset in the market\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function redeemAllowed(address vToken, address redeemer, uint256 redeemTokens) external returns (uint256) {\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.REDEEM);\n\n uint256 allowed = redeemAllowedInternal(vToken, redeemer, redeemTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, redeemer);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates redeem, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being redeemed\n * @param redeemer The address redeeming the tokens\n * @param redeemAmount The amount of the underlying asset being redeemed\n * @param redeemTokens The number of tokens being redeemed\n */\n function redeemVerify(address vToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external {\n require(redeemTokens != 0 || redeemAmount == 0, \"redeemTokens zero\");\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(redeemer, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param vToken The market to verify the borrow against\n * @param borrower The account which would borrow the asset\n * @param borrowAmount The amount of underlying the account would borrow\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function borrowAllowed(address vToken, address borrower, uint256 borrowAmount) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.BORROW);\n\n ensureListed(markets[vToken]);\n\n if (!markets[vToken].accountMembership[borrower]) {\n // only vTokens may call borrowAllowed if borrower not in market\n require(msg.sender == vToken, \"sender must be vToken\");\n\n // attempt to add borrower to the market\n Error err = addToMarketInternal(VToken(vToken), borrower);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n }\n\n if (oracle.getUnderlyingPrice(VToken(vToken)) == 0) {\n return uint256(Error.PRICE_ERROR);\n }\n\n uint256 borrowCap = borrowCaps[vToken];\n // Borrow cap of 0 corresponds to unlimited borrowing\n if (borrowCap != 0) {\n uint256 nextTotalBorrows = add_(VToken(vToken).totalBorrows(), borrowAmount);\n require(nextTotalBorrows < borrowCap, \"market borrow cap reached\");\n }\n\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n borrower,\n VToken(vToken),\n 0,\n borrowAmount\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall != 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n // Keep the flywheel moving\n Exp memory borrowIndex = Exp({ mantissa: VToken(vToken).borrowIndex() });\n updateVenusBorrowIndex(vToken, borrowIndex);\n distributeBorrowerVenus(vToken, borrower, borrowIndex);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates borrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset whose underlying is being borrowed\n * @param borrower The address borrowing the underlying\n * @param borrowAmount The amount of the underlying asset requested to borrow\n */\n // solhint-disable-next-line no-unused-vars\n function borrowVerify(address vToken, address borrower, uint256 borrowAmount) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vToken);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to repay a borrow in the given market\n * @param vToken The market to verify the repay against\n * @param payer The account which would repay the asset\n * @param borrower The account which borrowed the asset\n * @param repayAmount The amount of the underlying asset the account would repay\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function repayBorrowAllowed(\n address vToken,\n address payer, // solhint-disable-line no-unused-vars\n address borrower,\n uint256 repayAmount // solhint-disable-line no-unused-vars\n ) external returns (uint256) {\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.REPAY);\n ensureListed(markets[vToken]);\n\n // Keep the flywheel moving\n Exp memory borrowIndex = Exp({ mantissa: VToken(vToken).borrowIndex() });\n updateVenusBorrowIndex(vToken, borrowIndex);\n distributeBorrowerVenus(vToken, borrower, borrowIndex);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates repayBorrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being repaid\n * @param payer The address repaying the borrow\n * @param borrower The address of the borrower\n * @param actualRepayAmount The amount of underlying being repaid\n */\n function repayBorrowVerify(\n address vToken,\n address payer, // solhint-disable-line no-unused-vars\n address borrower,\n uint256 actualRepayAmount, // solhint-disable-line no-unused-vars\n uint256 borrowerIndex // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vToken);\n }\n }\n\n /**\n * @notice Checks if the liquidation should be allowed to occur\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param repayAmount The amount of underlying being repaid\n */\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external view returns (uint256) {\n checkProtocolPauseState();\n\n // if we want to pause liquidating to vTokenCollateral, we should pause seizing\n checkActionPauseState(vTokenBorrowed, Action.LIQUIDATE);\n\n if (liquidatorContract != address(0) && liquidator != liquidatorContract) {\n return uint256(Error.UNAUTHORIZED);\n }\n\n ensureListed(markets[vTokenCollateral]);\n\n uint256 borrowBalance;\n if (address(vTokenBorrowed) != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n borrowBalance = VToken(vTokenBorrowed).borrowBalanceStored(borrower);\n } else {\n borrowBalance = vaiController.getVAIRepayAmount(borrower);\n }\n\n if (isForcedLiquidationEnabled[vTokenBorrowed] || isForcedLiquidationEnabledForUser[borrower][vTokenBorrowed]) {\n if (repayAmount > borrowBalance) {\n return uint(Error.TOO_MUCH_REPAY);\n }\n return uint(Error.NO_ERROR);\n }\n\n /* The borrower must have shortfall in order to be liquidatable */\n (Error err, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(borrower, VToken(address(0)), 0, 0);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall == 0) {\n return uint256(Error.INSUFFICIENT_SHORTFALL);\n }\n\n // The liquidator may not repay more than what is allowed by the closeFactor\n //-- maxClose = multipy of closeFactorMantissa and borrowBalance\n if (repayAmount > mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance)) {\n return uint256(Error.TOO_MUCH_REPAY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates liquidateBorrow, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param actualRepayAmount The amount of underlying being repaid\n * @param seizeTokens The amount of collateral token that will be seized\n */\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral, // solhint-disable-line no-unused-vars\n address liquidator,\n address borrower,\n uint256 actualRepayAmount, // solhint-disable-line no-unused-vars\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vTokenBorrowed);\n prime.accrueInterestAndUpdateScore(liquidator, vTokenBorrowed);\n }\n }\n\n /**\n * @notice Checks if the seizing of assets should be allowed to occur\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vTokenCollateral, Action.SEIZE);\n\n Market storage market = markets[vTokenCollateral];\n\n // We've added VAIController as a borrowed token list check for seize\n ensureListed(market);\n\n if (!market.accountMembership[borrower]) {\n return uint256(Error.MARKET_NOT_COLLATERAL);\n }\n\n if (address(vTokenBorrowed) != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n\n if (VToken(vTokenCollateral).comptroller() != VToken(vTokenBorrowed).comptroller()) {\n return uint256(Error.COMPTROLLER_MISMATCH);\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vTokenCollateral);\n distributeSupplierVenus(vTokenCollateral, borrower);\n distributeSupplierVenus(vTokenCollateral, liquidator);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates seize, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vTokenCollateral Asset which was used as collateral and will be seized\n * @param vTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed, // solhint-disable-line no-unused-vars\n address liquidator,\n address borrower,\n uint256 seizeTokens // solhint-disable-line no-unused-vars\n ) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(borrower, vTokenCollateral);\n prime.accrueInterestAndUpdateScore(liquidator, vTokenCollateral);\n }\n }\n\n /**\n * @notice Checks if the account should be allowed to transfer tokens in the given market\n * @param vToken The market to verify the transfer against\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of vTokens to transfer\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function transferAllowed(\n address vToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n checkProtocolPauseState();\n checkActionPauseState(vToken, Action.TRANSFER);\n\n // Currently the only consideration is whether or not\n // the src is allowed to redeem this many tokens\n uint256 allowed = redeemAllowedInternal(vToken, src, transferTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n updateVenusSupplyIndex(vToken);\n distributeSupplierVenus(vToken, src);\n distributeSupplierVenus(vToken, dst);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates transfer, accrues interest and updates score in prime. Reverts on rejection. May emit logs.\n * @param vToken Asset being transferred\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of vTokens to transfer\n */\n // solhint-disable-next-line no-unused-vars\n function transferVerify(address vToken, address src, address dst, uint256 transferTokens) external {\n if (address(prime) != address(0)) {\n prime.accrueInterestAndUpdateScore(src, vToken);\n prime.accrueInterestAndUpdateScore(dst, vToken);\n }\n }\n\n /**\n * @notice Determine the current account liquidity wrt collateral requirements\n * @return (possible error code (semi-opaque),\n account liquidity in excess of collateral requirements,\n * account shortfall below collateral requirements)\n */\n function getAccountLiquidity(address account) external view returns (uint256, uint256, uint256) {\n (Error err, uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n VToken(address(0)),\n 0,\n 0\n );\n\n return (uint256(err), liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param vTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code (semi-opaque),\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidity(\n address account,\n address vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) external view returns (uint256, uint256, uint256) {\n (Error err, uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n VToken(vTokenModify),\n redeemTokens,\n borrowAmount\n );\n return (uint256(err), liquidity, shortfall);\n }\n\n // setter functionality\n /**\n * @notice Set XVS speed for a single market\n * @dev Allows the contract admin to set XVS speed for a market\n * @param vTokens The market whose XVS speed to update\n * @param supplySpeeds New XVS speed for supply\n * @param borrowSpeeds New XVS speed for borrow\n */\n function _setVenusSpeeds(\n VToken[] calldata vTokens,\n uint256[] calldata supplySpeeds,\n uint256[] calldata borrowSpeeds\n ) external {\n ensureAdmin();\n\n uint256 numTokens = vTokens.length;\n require(numTokens == supplySpeeds.length && numTokens == borrowSpeeds.length, \"invalid input\");\n\n for (uint256 i; i < numTokens; ++i) {\n ensureNonzeroAddress(address(vTokens[i]));\n setVenusSpeedInternal(vTokens[i], supplySpeeds[i], borrowSpeeds[i]);\n }\n }\n\n function setVenusSpeedInternal(VToken vToken, uint256 supplySpeed, uint256 borrowSpeed) internal {\n ensureListed(markets[address(vToken)]);\n\n if (venusSupplySpeeds[address(vToken)] != supplySpeed) {\n // Supply speed updated so let's update supply state to ensure that\n // 1. XVS accrued properly for the old speed, and\n // 2. XVS accrued at the new speed starts after this block.\n\n updateVenusSupplyIndex(address(vToken));\n // Update speed and emit event\n venusSupplySpeeds[address(vToken)] = supplySpeed;\n emit VenusSupplySpeedUpdated(vToken, supplySpeed);\n }\n\n if (venusBorrowSpeeds[address(vToken)] != borrowSpeed) {\n // Borrow speed updated so let's update borrow state to ensure that\n // 1. XVS accrued properly for the old speed, and\n // 2. XVS accrued at the new speed starts after this block.\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n\n // Update speed and emit event\n venusBorrowSpeeds[address(vToken)] = borrowSpeed;\n emit VenusBorrowSpeedUpdated(vToken, borrowSpeed);\n }\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/RewardFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { IRewardFacet } from \"../interfaces/IRewardFacet.sol\";\nimport { XVSRewardsHelper } from \"./XVSRewardsHelper.sol\";\nimport { SafeBEP20, IBEP20 } from \"../../../Utils/SafeBEP20.sol\";\nimport { VBep20Interface } from \"../../../Tokens/VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title RewardFacet\n * @author Venus\n * @dev This facet contains all the methods related to the reward functionality\n * @notice This facet contract provides the external functions related to all claims and rewards of the protocol\n */\ncontract RewardFacet is IRewardFacet, XVSRewardsHelper {\n /// @notice Emitted when Venus is granted by admin\n event VenusGranted(address indexed recipient, uint256 amount);\n\n /// @notice Emitted when XVS are seized for the holder\n event VenusSeized(address indexed holder, uint256 amount);\n\n using SafeBEP20 for IBEP20;\n\n /**\n * @notice Claim all the xvs accrued by holder in all markets and VAI\n * @param holder The address to claim XVS for\n */\n function claimVenus(address holder) public {\n return claimVenus(holder, allMarkets);\n }\n\n /**\n * @notice Claim all the xvs accrued by holder in the specified markets\n * @param holder The address to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n */\n function claimVenus(address holder, VToken[] memory vTokens) public {\n address[] memory holders = new address[](1);\n holders[0] = holder;\n claimVenus(holders, vTokens, true, true);\n }\n\n /**\n * @notice Claim all xvs accrued by the holders\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n */\n function claimVenus(address[] memory holders, VToken[] memory vTokens, bool borrowers, bool suppliers) public {\n claimVenus(holders, vTokens, borrowers, suppliers, false);\n }\n\n /**\n * @notice Claim all the xvs accrued by holder in all markets, a shorthand for `claimVenus` with collateral set to `true`\n * @param holder The address to claim XVS for\n */\n function claimVenusAsCollateral(address holder) external {\n address[] memory holders = new address[](1);\n holders[0] = holder;\n claimVenus(holders, allMarkets, true, true, true);\n }\n\n /**\n * @notice Transfer XVS to the user with user's shortfall considered\n * @dev Note: If there is not enough XVS, we do not perform the transfer all\n * @param user The address of the user to transfer XVS to\n * @param amount The amount of XVS to (possibly) transfer\n * @param shortfall The shortfall of the user\n * @param collateral Whether or not we will use user's venus reward as collateral to pay off the debt\n * @return The amount of XVS which was NOT transferred to the user\n */\n function grantXVSInternal(\n address user,\n uint256 amount,\n uint256 shortfall,\n bool collateral\n ) internal returns (uint256) {\n // If the user is blacklisted, they can't get XVS rewards\n require(\n user != 0xEF044206Db68E40520BfA82D45419d498b4bc7Bf &&\n user != 0x7589dD3355DAE848FDbF75044A3495351655cB1A &&\n user != 0x33df7a7F6D44307E1e5F3B15975b47515e5524c0 &&\n user != 0x24e77E5b74B30b026E9996e4bc3329c881e24968,\n \"Blacklisted\"\n );\n\n IBEP20 xvs_ = IBEP20(xvs);\n\n if (amount == 0 || amount > xvs_.balanceOf(address(this))) {\n return amount;\n }\n\n if (shortfall == 0) {\n xvs_.safeTransfer(user, amount);\n return 0;\n }\n // If user's bankrupt and doesn't use pending xvs as collateral, don't grant\n // anything, otherwise, we will transfer the pending xvs as collateral to\n // vXVS token and mint vXVS for the user\n //\n // If mintBehalf failed, don't grant any xvs\n require(collateral, \"bankrupt\");\n\n address xvsVToken_ = xvsVToken;\n\n xvs_.safeApprove(xvsVToken_, 0);\n xvs_.safeApprove(xvsVToken_, amount);\n require(VBep20Interface(xvsVToken_).mintBehalf(user, amount) == uint256(Error.NO_ERROR), \"mint behalf error\");\n\n // set venusAccrued[user] to 0\n return 0;\n }\n\n /*** Venus Distribution Admin ***/\n\n /**\n * @notice Transfer XVS to the recipient\n * @dev Allows the contract admin to transfer XVS to any recipient based on the recipient's shortfall\n * Note: If there is not enough XVS, we do not perform the transfer all\n * @param recipient The address of the recipient to transfer XVS to\n * @param amount The amount of XVS to (possibly) transfer\n */\n function _grantXVS(address recipient, uint256 amount) external {\n ensureAdmin();\n uint256 amountLeft = grantXVSInternal(recipient, amount, 0, false);\n require(amountLeft == 0, \"no xvs\");\n emit VenusGranted(recipient, amount);\n }\n\n /**\n * @dev Seize XVS tokens from the specified holders and transfer to recipient\n * @notice Seize XVS rewards allocated to holders\n * @param holders Addresses of the XVS holders\n * @param recipient Address of the XVS token recipient\n * @return The total amount of XVS tokens seized and transferred to recipient\n */\n function seizeVenus(address[] calldata holders, address recipient) external returns (uint256) {\n ensureAllowed(\"seizeVenus(address[],address)\");\n\n uint256 holdersLength = holders.length;\n uint256 totalHoldings;\n\n updateAndDistributeRewardsInternal(holders, allMarkets, true, true);\n for (uint256 j; j < holdersLength; ++j) {\n address holder = holders[j];\n uint256 userHolding = venusAccrued[holder];\n\n if (userHolding != 0) {\n totalHoldings += userHolding;\n delete venusAccrued[holder];\n }\n\n emit VenusSeized(holder, userHolding);\n }\n\n if (totalHoldings != 0) {\n IBEP20(xvs).safeTransfer(recipient, totalHoldings);\n emit VenusGranted(recipient, totalHoldings);\n }\n\n return totalHoldings;\n }\n\n /**\n * @notice Claim all xvs accrued by the holders\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n * @param collateral Whether or not to use XVS earned as collateral, only takes effect when the holder has a shortfall\n */\n function claimVenus(\n address[] memory holders,\n VToken[] memory vTokens,\n bool borrowers,\n bool suppliers,\n bool collateral\n ) public {\n uint256 holdersLength = holders.length;\n\n updateAndDistributeRewardsInternal(holders, vTokens, borrowers, suppliers);\n for (uint256 j; j < holdersLength; ++j) {\n address holder = holders[j];\n\n // If there is a positive shortfall, the XVS reward is accrued,\n // but won't be granted to this holder\n (, , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(holder, VToken(address(0)), 0, 0);\n\n uint256 value = venusAccrued[holder];\n delete venusAccrued[holder];\n\n uint256 returnAmount = grantXVSInternal(holder, value, shortfall, collateral);\n\n // returnAmount can only be positive if balance of xvsAddress is less than grant amount(venusAccrued[holder])\n if (returnAmount != 0) {\n venusAccrued[holder] = returnAmount;\n }\n }\n }\n\n /**\n * @notice Update and distribute tokens\n * @param holders The addresses to claim XVS for\n * @param vTokens The list of markets to claim XVS in\n * @param borrowers Whether or not to claim XVS earned by borrowing\n * @param suppliers Whether or not to claim XVS earned by supplying\n */\n function updateAndDistributeRewardsInternal(\n address[] memory holders,\n VToken[] memory vTokens,\n bool borrowers,\n bool suppliers\n ) internal {\n uint256 j;\n uint256 holdersLength = holders.length;\n uint256 vTokensLength = vTokens.length;\n\n for (uint256 i; i < vTokensLength; ++i) {\n VToken vToken = vTokens[i];\n ensureListed(markets[address(vToken)]);\n if (borrowers) {\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n for (j = 0; j < holdersLength; ++j) {\n distributeBorrowerVenus(address(vToken), holders[j], borrowIndex);\n }\n }\n\n if (suppliers) {\n updateVenusSupplyIndex(address(vToken));\n for (j = 0; j < holdersLength; ++j) {\n distributeSupplierVenus(address(vToken), holders[j]);\n }\n }\n }\n }\n\n /**\n * @notice Returns the XVS vToken address\n * @return The address of XVS vToken\n */\n function getXVSVTokenAddress() external view returns (address) {\n return xvsVToken;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/SetterFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ISetterFacet } from \"../interfaces/ISetterFacet.sol\";\nimport { PriceOracle } from \"../../../Oracle/PriceOracle.sol\";\nimport { ComptrollerLensInterface } from \"../../ComptrollerLensInterface.sol\";\nimport { VAIControllerInterface } from \"../../../Tokens/VAI/VAIControllerInterface.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\nimport { IPrime } from \"../../../Tokens/Prime/IPrime.sol\";\n\n/**\n * @title SetterFacet\n * @author Venus\n * @dev This facet contains all the setters for the states\n * @notice This facet contract contains all the configurational setter functions\n */\ncontract SetterFacet is ISetterFacet, FacetBase {\n /// @notice Emitted when close factor is changed by admin\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\n\n /// @notice Emitted when a collateral factor is changed by admin\n event NewCollateralFactor(\n VToken indexed vToken,\n uint256 oldCollateralFactorMantissa,\n uint256 newCollateralFactorMantissa\n );\n\n /// @notice Emitted when liquidation incentive is changed by admin\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\n\n /// @notice Emitted when price oracle is changed\n event NewPriceOracle(PriceOracle oldPriceOracle, PriceOracle newPriceOracle);\n\n /// @notice Emitted when borrow cap for a vToken is changed\n event NewBorrowCap(VToken indexed vToken, uint256 newBorrowCap);\n\n /// @notice Emitted when VAIController is changed\n event NewVAIController(VAIControllerInterface oldVAIController, VAIControllerInterface newVAIController);\n\n /// @notice Emitted when VAI mint rate is changed by admin\n event NewVAIMintRate(uint256 oldVAIMintRate, uint256 newVAIMintRate);\n\n /// @notice Emitted when protocol state is changed by admin\n event ActionProtocolPaused(bool state);\n\n /// @notice Emitted when treasury guardian is changed\n event NewTreasuryGuardian(address oldTreasuryGuardian, address newTreasuryGuardian);\n\n /// @notice Emitted when treasury address is changed\n event NewTreasuryAddress(address oldTreasuryAddress, address newTreasuryAddress);\n\n /// @notice Emitted when treasury percent is changed\n event NewTreasuryPercent(uint256 oldTreasuryPercent, uint256 newTreasuryPercent);\n\n /// @notice Emitted when liquidator adress is changed\n event NewLiquidatorContract(address oldLiquidatorContract, address newLiquidatorContract);\n\n /// @notice Emitted when ComptrollerLens address is changed\n event NewComptrollerLens(address oldComptrollerLens, address newComptrollerLens);\n\n /// @notice Emitted when supply cap for a vToken is changed\n event NewSupplyCap(VToken indexed vToken, uint256 newSupplyCap);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControl(address oldAccessControlAddress, address newAccessControlAddress);\n\n /// @notice Emitted when pause guardian is changed\n event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);\n\n /// @notice Emitted when an action is paused on a market\n event ActionPausedMarket(VToken indexed vToken, Action indexed action, bool pauseState);\n\n /// @notice Emitted when VAI Vault info is changed\n event NewVAIVaultInfo(address indexed vault_, uint256 releaseStartBlock_, uint256 releaseInterval_);\n\n /// @notice Emitted when Venus VAI Vault rate is changed\n event NewVenusVAIVaultRate(uint256 oldVenusVAIVaultRate, uint256 newVenusVAIVaultRate);\n\n /// @notice Emitted when prime token contract address is changed\n event NewPrimeToken(IPrime oldPrimeToken, IPrime newPrimeToken);\n\n /// @notice Emitted when forced liquidation is enabled or disabled for all users in a market\n event IsForcedLiquidationEnabledUpdated(address indexed vToken, bool enable);\n\n /// @notice Emitted when forced liquidation is enabled or disabled for a user borrowing in a market\n event IsForcedLiquidationEnabledForUserUpdated(address indexed borrower, address indexed vToken, bool enable);\n\n /// @notice Emitted when XVS token address is changed\n event NewXVSToken(address indexed oldXVS, address indexed newXVS);\n\n /// @notice Emitted when XVS vToken address is changed\n event NewXVSVToken(address indexed oldXVSVToken, address indexed newXVSVToken);\n\n /**\n * @notice Compare two addresses to ensure they are different\n * @param oldAddress The original address to compare\n * @param newAddress The new address to compare\n */\n modifier compareAddress(address oldAddress, address newAddress) {\n require(oldAddress != newAddress, \"old address is same as new address\");\n _;\n }\n\n /**\n * @notice Compare two values to ensure they are different\n * @param oldValue The original value to compare\n * @param newValue The new value to compare\n */\n modifier compareValue(uint256 oldValue, uint256 newValue) {\n require(oldValue != newValue, \"old value is same as new value\");\n _;\n }\n\n /**\n * @notice Sets a new price oracle for the comptroller\n * @dev Allows the contract admin to set a new price oracle used by the Comptroller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPriceOracle(\n PriceOracle newOracle\n ) external compareAddress(address(oracle), address(newOracle)) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(address(newOracle));\n\n // Track the old oracle for the comptroller\n PriceOracle oldOracle = oracle;\n\n // Set comptroller's oracle to newOracle\n oracle = newOracle;\n\n // Emit NewPriceOracle(oldOracle, newOracle)\n emit NewPriceOracle(oldOracle, newOracle);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the closeFactor used when liquidating borrows\n * @dev Allows the contract admin to set the closeFactor used to liquidate borrows\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\n * @return uint256 0=success, otherwise will revert\n */\n function _setCloseFactor(\n uint256 newCloseFactorMantissa\n ) external compareValue(closeFactorMantissa, newCloseFactorMantissa) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\n\n //-- Check close factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\n //-- Check close factor >= 0.05\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\n\n if (lessThanExp(highLimit, newCloseFactorExp) || greaterThanExp(lowLimit, newCloseFactorExp)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\n closeFactorMantissa = newCloseFactorMantissa;\n emit NewCloseFactor(oldCloseFactorMantissa, newCloseFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Allows the contract admin to set the address of access control of this contract\n * @param newAccessControlAddress New address for the access control\n * @return uint256 0=success, otherwise will revert\n */\n function _setAccessControl(\n address newAccessControlAddress\n ) external compareAddress(accessControl, newAccessControlAddress) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(newAccessControlAddress);\n\n address oldAccessControlAddress = accessControl;\n\n accessControl = newAccessControlAddress;\n emit NewAccessControl(oldAccessControlAddress, newAccessControlAddress);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the collateralFactor for a market\n * @dev Allows a privileged role to set the collateralFactorMantissa\n * @param vToken The market to set the factor on\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\n * @return uint256 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCollateralFactor(\n VToken vToken,\n uint256 newCollateralFactorMantissa\n )\n external\n compareValue(markets[address(vToken)].collateralFactorMantissa, newCollateralFactorMantissa)\n returns (uint256)\n {\n // Check caller is allowed by access control manager\n ensureAllowed(\"_setCollateralFactor(address,uint256)\");\n ensureNonzeroAddress(address(vToken));\n\n // Verify market is listed\n Market storage market = markets[address(vToken)];\n ensureListed(market);\n\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\n\n //-- Check collateral factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\n }\n\n // If collateral factor != 0, fail if price == 0\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(vToken) == 0) {\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\n }\n\n // Set market's collateral factor to new collateral factor, remember old value\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\n market.collateralFactorMantissa = newCollateralFactorMantissa;\n\n // Emit event with asset, old collateral factor, and new collateral factor\n emit NewCollateralFactor(vToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets liquidationIncentive\n * @dev Allows a privileged role to set the liquidationIncentiveMantissa\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\n * @return uint256 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setLiquidationIncentive(\n uint256 newLiquidationIncentiveMantissa\n ) external compareValue(liquidationIncentiveMantissa, newLiquidationIncentiveMantissa) returns (uint256) {\n ensureAllowed(\"_setLiquidationIncentive(uint256)\");\n\n require(newLiquidationIncentiveMantissa >= 1e18, \"incentive < 1e18\");\n\n // Save current value for use in log\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\n // Set liquidation incentive to new incentive\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\n\n // Emit event with old incentive, new incentive\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Update the address of the liquidator contract\n * @dev Allows the contract admin to update the address of liquidator contract\n * @param newLiquidatorContract_ The new address of the liquidator contract\n */\n function _setLiquidatorContract(\n address newLiquidatorContract_\n ) external compareAddress(liquidatorContract, newLiquidatorContract_) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(newLiquidatorContract_);\n address oldLiquidatorContract = liquidatorContract;\n liquidatorContract = newLiquidatorContract_;\n emit NewLiquidatorContract(oldLiquidatorContract, newLiquidatorContract_);\n }\n\n /**\n * @notice Admin function to change the Pause Guardian\n * @dev Allows the contract admin to change the Pause Guardian\n * @param newPauseGuardian The address of the new Pause Guardian\n * @return uint256 0=success, otherwise a failure. (See enum Error for details)\n */\n function _setPauseGuardian(\n address newPauseGuardian\n ) external compareAddress(pauseGuardian, newPauseGuardian) returns (uint256) {\n ensureAdmin();\n ensureNonzeroAddress(newPauseGuardian);\n\n // Save current value for inclusion in log\n address oldPauseGuardian = pauseGuardian;\n // Store pauseGuardian with value newPauseGuardian\n pauseGuardian = newPauseGuardian;\n\n // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)\n emit NewPauseGuardian(oldPauseGuardian, newPauseGuardian);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the given borrow caps for the given vToken market Borrowing that brings total borrows to or above borrow cap will revert\n * @dev Allows a privileged role to set the borrowing cap for a vToken market. A borrow cap of 0 corresponds to unlimited borrowing\n * @param vTokens The addresses of the markets (tokens) to change the borrow caps for\n * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing\n */\n function _setMarketBorrowCaps(VToken[] calldata vTokens, uint256[] calldata newBorrowCaps) external {\n ensureAllowed(\"_setMarketBorrowCaps(address[],uint256[])\");\n\n uint256 numMarkets = vTokens.length;\n uint256 numBorrowCaps = newBorrowCaps.length;\n\n require(numMarkets != 0 && numMarkets == numBorrowCaps, \"invalid input\");\n\n for (uint256 i; i < numMarkets; ++i) {\n borrowCaps[address(vTokens[i])] = newBorrowCaps[i];\n emit NewBorrowCap(vTokens[i], newBorrowCaps[i]);\n }\n }\n\n /**\n * @notice Set the given supply caps for the given vToken market Supply that brings total Supply to or above supply cap will revert\n * @dev Allows a privileged role to set the supply cap for a vToken. A supply cap of 0 corresponds to Minting NotAllowed\n * @param vTokens The addresses of the markets (tokens) to change the supply caps for\n * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to Minting NotAllowed\n */\n function _setMarketSupplyCaps(VToken[] calldata vTokens, uint256[] calldata newSupplyCaps) external {\n ensureAllowed(\"_setMarketSupplyCaps(address[],uint256[])\");\n\n uint256 numMarkets = vTokens.length;\n uint256 numSupplyCaps = newSupplyCaps.length;\n\n require(numMarkets != 0 && numMarkets == numSupplyCaps, \"invalid input\");\n\n for (uint256 i; i < numMarkets; ++i) {\n supplyCaps[address(vTokens[i])] = newSupplyCaps[i];\n emit NewSupplyCap(vTokens[i], newSupplyCaps[i]);\n }\n }\n\n /**\n * @notice Set whole protocol pause/unpause state\n * @dev Allows a privileged role to pause/unpause protocol\n * @param state The new state (true=paused, false=unpaused)\n * @return bool The updated state of the protocol\n */\n function _setProtocolPaused(bool state) external returns (bool) {\n ensureAllowed(\"_setProtocolPaused(bool)\");\n\n protocolPaused = state;\n emit ActionProtocolPaused(state);\n return state;\n }\n\n /**\n * @notice Pause/unpause certain actions\n * @dev Allows a privileged role to pause/unpause the protocol action state\n * @param markets_ Markets to pause/unpause the actions on\n * @param actions_ List of action ids to pause/unpause\n * @param paused_ The new paused state (true=paused, false=unpaused)\n */\n function _setActionsPaused(address[] calldata markets_, Action[] calldata actions_, bool paused_) external {\n ensureAllowed(\"_setActionsPaused(address[],uint8[],bool)\");\n\n uint256 numMarkets = markets_.length;\n uint256 numActions = actions_.length;\n for (uint256 marketIdx; marketIdx < numMarkets; ++marketIdx) {\n for (uint256 actionIdx; actionIdx < numActions; ++actionIdx) {\n setActionPausedInternal(markets_[marketIdx], actions_[actionIdx], paused_);\n }\n }\n }\n\n /**\n * @dev Pause/unpause an action on a market\n * @param market Market to pause/unpause the action on\n * @param action Action id to pause/unpause\n * @param paused The new paused state (true=paused, false=unpaused)\n */\n function setActionPausedInternal(address market, Action action, bool paused) internal {\n ensureListed(markets[market]);\n _actionPaused[market][uint256(action)] = paused;\n emit ActionPausedMarket(VToken(market), action, paused);\n }\n\n /**\n * @notice Sets a new VAI controller\n * @dev Admin function to set a new VAI controller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setVAIController(\n VAIControllerInterface vaiController_\n ) external compareAddress(address(vaiController), address(vaiController_)) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n ensureNonzeroAddress(address(vaiController_));\n\n VAIControllerInterface oldVaiController = vaiController;\n vaiController = vaiController_;\n emit NewVAIController(oldVaiController, vaiController_);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the VAI mint rate\n * @param newVAIMintRate The new VAI mint rate to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setVAIMintRate(\n uint256 newVAIMintRate\n ) external compareValue(vaiMintRate, newVAIMintRate) returns (uint256) {\n // Check caller is admin\n ensureAdmin();\n uint256 oldVAIMintRate = vaiMintRate;\n vaiMintRate = newVAIMintRate;\n emit NewVAIMintRate(oldVAIMintRate, newVAIMintRate);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the minted VAI amount of the `owner`\n * @param owner The address of the account to set\n * @param amount The amount of VAI to set to the account\n * @return The number of minted VAI by `owner`\n */\n function setMintedVAIOf(address owner, uint256 amount) external returns (uint256) {\n checkProtocolPauseState();\n\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!mintVAIGuardianPaused && !repayVAIGuardianPaused, \"VAI is paused\");\n // Check caller is vaiController\n if (msg.sender != address(vaiController)) {\n return fail(Error.REJECTION, FailureInfo.SET_MINTED_VAI_REJECTION);\n }\n mintedVAIs[owner] = amount;\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the treasury data.\n * @param newTreasuryGuardian The new address of the treasury guardian to be set\n * @param newTreasuryAddress The new address of the treasury to be set\n * @param newTreasuryPercent The new treasury percent to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256) {\n // Check caller is admin\n ensureAdminOr(treasuryGuardian);\n\n require(newTreasuryPercent < 1e18, \"percent >= 100%\");\n ensureNonzeroAddress(newTreasuryGuardian);\n ensureNonzeroAddress(newTreasuryAddress);\n\n address oldTreasuryGuardian = treasuryGuardian;\n address oldTreasuryAddress = treasuryAddress;\n uint256 oldTreasuryPercent = treasuryPercent;\n\n treasuryGuardian = newTreasuryGuardian;\n treasuryAddress = newTreasuryAddress;\n treasuryPercent = newTreasuryPercent;\n\n emit NewTreasuryGuardian(oldTreasuryGuardian, newTreasuryGuardian);\n emit NewTreasuryAddress(oldTreasuryAddress, newTreasuryAddress);\n emit NewTreasuryPercent(oldTreasuryPercent, newTreasuryPercent);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Venus Distribution ***/\n\n /**\n * @dev Set ComptrollerLens contract address\n * @param comptrollerLens_ The new ComptrollerLens contract address to be set\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptrollerLens(\n ComptrollerLensInterface comptrollerLens_\n ) external compareAddress(address(comptrollerLens), address(comptrollerLens_)) returns (uint256) {\n ensureAdmin();\n ensureNonzeroAddress(address(comptrollerLens_));\n address oldComptrollerLens = address(comptrollerLens);\n comptrollerLens = comptrollerLens_;\n emit NewComptrollerLens(oldComptrollerLens, address(comptrollerLens));\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the amount of XVS distributed per block to VAI Vault\n * @param venusVAIVaultRate_ The amount of XVS wei per block to distribute to VAI Vault\n */\n function _setVenusVAIVaultRate(\n uint256 venusVAIVaultRate_\n ) external compareValue(venusVAIVaultRate, venusVAIVaultRate_) {\n ensureAdmin();\n if (vaiVaultAddress != address(0)) {\n releaseToVault();\n }\n uint256 oldVenusVAIVaultRate = venusVAIVaultRate;\n venusVAIVaultRate = venusVAIVaultRate_;\n emit NewVenusVAIVaultRate(oldVenusVAIVaultRate, venusVAIVaultRate_);\n }\n\n /**\n * @notice Set the VAI Vault infos\n * @param vault_ The address of the VAI Vault\n * @param releaseStartBlock_ The start block of release to VAI Vault\n * @param minReleaseAmount_ The minimum release amount to VAI Vault\n */\n function _setVAIVaultInfo(\n address vault_,\n uint256 releaseStartBlock_,\n uint256 minReleaseAmount_\n ) external compareAddress(vaiVaultAddress, vault_) {\n ensureAdmin();\n ensureNonzeroAddress(vault_);\n if (vaiVaultAddress != address(0)) {\n releaseToVault();\n }\n\n vaiVaultAddress = vault_;\n releaseStartBlock = releaseStartBlock_;\n minReleaseAmount = minReleaseAmount_;\n emit NewVAIVaultInfo(vault_, releaseStartBlock_, minReleaseAmount_);\n }\n\n /**\n * @notice Sets the prime token contract for the comptroller\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPrimeToken(IPrime _prime) external returns (uint) {\n ensureAdmin();\n ensureNonzeroAddress(address(_prime));\n\n IPrime oldPrime = prime;\n prime = _prime;\n emit NewPrimeToken(oldPrime, _prime);\n\n return uint(Error.NO_ERROR);\n }\n\n /** @notice Enables forced liquidations for a market. If forced liquidation is enabled,\n * borrows in the market may be liquidated regardless of the account liquidity\n * @dev Allows a privileged role to set enable/disable forced liquidations\n * @param vTokenBorrowed Borrowed vToken\n * @param enable Whether to enable forced liquidations\n */\n function _setForcedLiquidation(address vTokenBorrowed, bool enable) external {\n ensureAllowed(\"_setForcedLiquidation(address,bool)\");\n if (vTokenBorrowed != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n isForcedLiquidationEnabled[vTokenBorrowed] = enable;\n emit IsForcedLiquidationEnabledUpdated(vTokenBorrowed, enable);\n }\n\n /**\n * @notice Enables forced liquidations for user's borrows in a certain market. If forced\n * liquidation is enabled, user's borrows in the market may be liquidated regardless of\n * the account liquidity. Forced liquidation may be enabled for a user even if it is not\n * enabled for the entire market.\n * @param borrower The address of the borrower\n * @param vTokenBorrowed Borrowed vToken\n * @param enable Whether to enable forced liquidations\n */\n function _setForcedLiquidationForUser(address borrower, address vTokenBorrowed, bool enable) external {\n ensureAllowed(\"_setForcedLiquidationForUser(address,address,bool)\");\n if (vTokenBorrowed != address(vaiController)) {\n ensureListed(markets[vTokenBorrowed]);\n }\n isForcedLiquidationEnabledForUser[borrower][vTokenBorrowed] = enable;\n emit IsForcedLiquidationEnabledForUserUpdated(borrower, vTokenBorrowed, enable);\n }\n\n /**\n * @notice Set the address of the XVS token\n * @param xvs_ The address of the XVS token\n */\n function _setXVSToken(address xvs_) external {\n ensureAdmin();\n ensureNonzeroAddress(xvs_);\n\n emit NewXVSToken(xvs, xvs_);\n xvs = xvs_;\n }\n\n /**\n * @notice Set the address of the XVS vToken\n * @param xvsVToken_ The address of the XVS vToken\n */\n function _setXVSVToken(address xvsVToken_) external {\n ensureAdmin();\n ensureNonzeroAddress(xvsVToken_);\n\n address underlying = VToken(xvsVToken_).underlying();\n require(underlying == xvs, \"invalid xvs vtoken address\");\n\n emit NewXVSVToken(xvsVToken, xvsVToken_);\n xvsVToken = xvsVToken_;\n }\n}\n" + }, + "contracts/Comptroller/Diamond/facets/XVSRewardsHelper.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { FacetBase } from \"./FacetBase.sol\";\n\n/**\n * @title XVSRewardsHelper\n * @author Venus\n * @dev This contract contains internal functions used in RewardFacet and PolicyFacet\n * @notice This facet contract contains the shared functions used by the RewardFacet and PolicyFacet\n */\ncontract XVSRewardsHelper is FacetBase {\n /// @notice Emitted when XVS is distributed to a borrower\n event DistributedBorrowerVenus(\n VToken indexed vToken,\n address indexed borrower,\n uint256 venusDelta,\n uint256 venusBorrowIndex\n );\n\n /// @notice Emitted when XVS is distributed to a supplier\n event DistributedSupplierVenus(\n VToken indexed vToken,\n address indexed supplier,\n uint256 venusDelta,\n uint256 venusSupplyIndex\n );\n\n /**\n * @notice Accrue XVS to the market by updating the borrow index\n * @param vToken The market whose borrow index to update\n */\n function updateVenusBorrowIndex(address vToken, Exp memory marketBorrowIndex) internal {\n VenusMarketState storage borrowState = venusBorrowState[vToken];\n uint256 borrowSpeed = venusBorrowSpeeds[vToken];\n uint32 blockNumber = getBlockNumberAsUint32();\n uint256 deltaBlocks = sub_(blockNumber, borrowState.block);\n if (deltaBlocks != 0 && borrowSpeed != 0) {\n uint256 borrowAmount = div_(VToken(vToken).totalBorrows(), marketBorrowIndex);\n uint256 accruedVenus = mul_(deltaBlocks, borrowSpeed);\n Double memory ratio = borrowAmount != 0 ? fraction(accruedVenus, borrowAmount) : Double({ mantissa: 0 });\n borrowState.index = safe224(add_(Double({ mantissa: borrowState.index }), ratio).mantissa, \"224\");\n borrowState.block = blockNumber;\n } else if (deltaBlocks != 0) {\n borrowState.block = blockNumber;\n }\n }\n\n /**\n * @notice Accrue XVS to the market by updating the supply index\n * @param vToken The market whose supply index to update\n */\n function updateVenusSupplyIndex(address vToken) internal {\n VenusMarketState storage supplyState = venusSupplyState[vToken];\n uint256 supplySpeed = venusSupplySpeeds[vToken];\n uint32 blockNumber = getBlockNumberAsUint32();\n\n uint256 deltaBlocks = sub_(blockNumber, supplyState.block);\n if (deltaBlocks != 0 && supplySpeed != 0) {\n uint256 supplyTokens = VToken(vToken).totalSupply();\n uint256 accruedVenus = mul_(deltaBlocks, supplySpeed);\n Double memory ratio = supplyTokens != 0 ? fraction(accruedVenus, supplyTokens) : Double({ mantissa: 0 });\n supplyState.index = safe224(add_(Double({ mantissa: supplyState.index }), ratio).mantissa, \"224\");\n supplyState.block = blockNumber;\n } else if (deltaBlocks != 0) {\n supplyState.block = blockNumber;\n }\n }\n\n /**\n * @notice Calculate XVS accrued by a supplier and possibly transfer it to them\n * @param vToken The market in which the supplier is interacting\n * @param supplier The address of the supplier to distribute XVS to\n */\n function distributeSupplierVenus(address vToken, address supplier) internal {\n if (address(vaiVaultAddress) != address(0)) {\n releaseToVault();\n }\n uint256 supplyIndex = venusSupplyState[vToken].index;\n uint256 supplierIndex = venusSupplierIndex[vToken][supplier];\n // Update supplier's index to the current index since we are distributing accrued XVS\n venusSupplierIndex[vToken][supplier] = supplyIndex;\n if (supplierIndex == 0 && supplyIndex >= venusInitialIndex) {\n // Covers the case where users supplied tokens before the market's supply state index was set.\n // Rewards the user with XVS accrued from the start of when supplier rewards were first\n // set for the market.\n supplierIndex = venusInitialIndex;\n }\n // Calculate change in the cumulative sum of the XVS per vToken accrued\n Double memory deltaIndex = Double({ mantissa: sub_(supplyIndex, supplierIndex) });\n // Multiply of supplierTokens and supplierDelta\n uint256 supplierDelta = mul_(VToken(vToken).balanceOf(supplier), deltaIndex);\n // Addition of supplierAccrued and supplierDelta\n venusAccrued[supplier] = add_(venusAccrued[supplier], supplierDelta);\n emit DistributedSupplierVenus(VToken(vToken), supplier, supplierDelta, supplyIndex);\n }\n\n /**\n * @notice Calculate XVS accrued by a borrower and possibly transfer it to them\n * @dev Borrowers will not begin to accrue until after the first interaction with the protocol\n * @param vToken The market in which the borrower is interacting\n * @param borrower The address of the borrower to distribute XVS to\n */\n function distributeBorrowerVenus(address vToken, address borrower, Exp memory marketBorrowIndex) internal {\n if (address(vaiVaultAddress) != address(0)) {\n releaseToVault();\n }\n uint256 borrowIndex = venusBorrowState[vToken].index;\n uint256 borrowerIndex = venusBorrowerIndex[vToken][borrower];\n // Update borrowers's index to the current index since we are distributing accrued XVS\n venusBorrowerIndex[vToken][borrower] = borrowIndex;\n if (borrowerIndex == 0 && borrowIndex >= venusInitialIndex) {\n // Covers the case where users borrowed tokens before the market's borrow state index was set.\n // Rewards the user with XVS accrued from the start of when borrower rewards were first\n // set for the market.\n borrowerIndex = venusInitialIndex;\n }\n // Calculate change in the cumulative sum of the XVS per borrowed unit accrued\n Double memory deltaIndex = Double({ mantissa: sub_(borrowIndex, borrowerIndex) });\n uint256 borrowerDelta = mul_(div_(VToken(vToken).borrowBalanceStored(borrower), marketBorrowIndex), deltaIndex);\n venusAccrued[borrower] = add_(venusAccrued[borrower], borrowerDelta);\n emit DistributedBorrowerVenus(VToken(vToken), borrower, borrowerDelta, borrowIndex);\n }\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IDiamondCut.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\ninterface IDiamondCut {\n enum FacetCutAction {\n Add,\n Replace,\n Remove\n }\n // Add=0, Replace=1, Remove=2\n\n struct FacetCut {\n address facetAddress;\n FacetCutAction action;\n bytes4[] functionSelectors;\n }\n\n /// @notice Add/replace/remove any number of functions and optionally execute\n /// a function with delegatecall\n /// @param _diamondCut Contains the facet addresses and function selectors\n function diamondCut(FacetCut[] calldata _diamondCut) external;\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IMarketFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\ninterface IMarketFacet {\n function isComptroller() external pure returns (bool);\n\n function liquidateCalculateSeizeTokens(\n address vTokenBorrowed,\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256);\n\n function liquidateVAICalculateSeizeTokens(\n address vTokenCollateral,\n uint256 actualRepayAmount\n ) external view returns (uint256, uint256);\n\n function checkMembership(address account, VToken vToken) external view returns (bool);\n\n function enterMarkets(address[] calldata vTokens) external returns (uint256[] memory);\n\n function exitMarket(address vToken) external returns (uint256);\n\n function _supportMarket(VToken vToken) external returns (uint256);\n\n function getAssetsIn(address account) external view returns (VToken[] memory);\n\n function getAllMarkets() external view returns (VToken[] memory);\n\n function updateDelegate(address delegate, bool allowBorrows) external;\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IPolicyFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\n\ninterface IPolicyFacet {\n function mintAllowed(address vToken, address minter, uint256 mintAmount) external returns (uint256);\n\n function mintVerify(address vToken, address minter, uint256 mintAmount, uint256 mintTokens) external;\n\n function redeemAllowed(address vToken, address redeemer, uint256 redeemTokens) external returns (uint256);\n\n function redeemVerify(address vToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\n\n function borrowAllowed(address vToken, address borrower, uint256 borrowAmount) external returns (uint256);\n\n function borrowVerify(address vToken, address borrower, uint256 borrowAmount) external;\n\n function repayBorrowAllowed(\n address vToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function repayBorrowVerify(\n address vToken,\n address payer,\n address borrower,\n uint256 repayAmount,\n uint256 borrowerIndex\n ) external;\n\n function liquidateBorrowAllowed(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external view returns (uint256);\n\n function liquidateBorrowVerify(\n address vTokenBorrowed,\n address vTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount,\n uint256 seizeTokens\n ) external;\n\n function seizeAllowed(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n function seizeVerify(\n address vTokenCollateral,\n address vTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external;\n\n function transferAllowed(\n address vToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external returns (uint256);\n\n function transferVerify(address vToken, address src, address dst, uint256 transferTokens) external;\n\n function getAccountLiquidity(address account) external view returns (uint256, uint256, uint256);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address vTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount\n ) external view returns (uint256, uint256, uint256);\n\n function _setVenusSpeeds(\n VToken[] calldata vTokens,\n uint256[] calldata supplySpeeds,\n uint256[] calldata borrowSpeeds\n ) external;\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/IRewardFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ComptrollerTypes } from \"../../ComptrollerStorage.sol\";\n\ninterface IRewardFacet {\n function claimVenus(address holder) external;\n\n function claimVenus(address holder, VToken[] calldata vTokens) external;\n\n function claimVenus(address[] calldata holders, VToken[] calldata vTokens, bool borrowers, bool suppliers) external;\n\n function claimVenusAsCollateral(address holder) external;\n\n function _grantXVS(address recipient, uint256 amount) external;\n\n function getXVSAddress() external view returns (address);\n\n function getXVSVTokenAddress() external view returns (address);\n\n function actionPaused(address market, ComptrollerTypes.Action action) external view returns (bool);\n\n function claimVenus(\n address[] calldata holders,\n VToken[] calldata vTokens,\n bool borrowers,\n bool suppliers,\n bool collateral\n ) external;\n function seizeVenus(address[] calldata holders, address recipient) external returns (uint256);\n}\n" + }, + "contracts/Comptroller/Diamond/interfaces/ISetterFacet.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\n\nimport { PriceOracle } from \"../../../Oracle/PriceOracle.sol\";\nimport { VToken } from \"../../../Tokens/VTokens/VToken.sol\";\nimport { ComptrollerTypes } from \"../../ComptrollerStorage.sol\";\nimport { VAIControllerInterface } from \"../../../Tokens/VAI/VAIControllerInterface.sol\";\nimport { ComptrollerLensInterface } from \"../../../Comptroller/ComptrollerLensInterface.sol\";\nimport { IPrime } from \"../../../Tokens/Prime/IPrime.sol\";\n\ninterface ISetterFacet {\n function _setPriceOracle(PriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setAccessControl(address newAccessControlAddress) external returns (uint256);\n\n function _setCollateralFactor(VToken vToken, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _setLiquidatorContract(address newLiquidatorContract_) external;\n\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\n\n function _setMarketBorrowCaps(VToken[] calldata vTokens, uint256[] calldata newBorrowCaps) external;\n\n function _setMarketSupplyCaps(VToken[] calldata vTokens, uint256[] calldata newSupplyCaps) external;\n\n function _setProtocolPaused(bool state) external returns (bool);\n\n function _setActionsPaused(\n address[] calldata markets,\n ComptrollerTypes.Action[] calldata actions,\n bool paused\n ) external;\n\n function _setVAIController(VAIControllerInterface vaiController_) external returns (uint256);\n\n function _setVAIMintRate(uint256 newVAIMintRate) external returns (uint256);\n\n function setMintedVAIOf(address owner, uint256 amount) external returns (uint256);\n\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256);\n\n function _setComptrollerLens(ComptrollerLensInterface comptrollerLens_) external returns (uint256);\n\n function _setVenusVAIVaultRate(uint256 venusVAIVaultRate_) external;\n\n function _setVAIVaultInfo(address vault_, uint256 releaseStartBlock_, uint256 minReleaseAmount_) external;\n\n function _setForcedLiquidation(address vToken, bool enable) external;\n\n function _setPrimeToken(IPrime _prime) external returns (uint);\n\n function _setForcedLiquidationForUser(address borrower, address vTokenBorrowed, bool enable) external;\n\n function _setXVSToken(address xvs_) external;\n\n function _setXVSVToken(address xvsVToken_) external;\n}\n" + }, + "contracts/Comptroller/Unitroller.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerStorage.sol\";\nimport \"../Utils/ErrorReporter.sol\";\n\n/**\n * @title ComptrollerCore\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\n * VTokens should reference this contract as their comptroller.\n */\ncontract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {\n /**\n * @notice Emitted when pendingComptrollerImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingComptrollerImplementation;\n\n pendingComptrollerImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation and pendingImplementation ≠ address(0)\n if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = comptrollerImplementation;\n address oldPendingImplementation = pendingComptrollerImplementation;\n\n comptrollerImplementation = pendingComptrollerImplementation;\n\n pendingComptrollerImplementation = address(0);\n\n emit NewImplementation(oldImplementation, comptrollerImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = comptrollerImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Governance/VTreasury.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/IBEP20.sol\";\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/Ownable.sol\";\n\n/**\n * @title VTreasury\n * @author Venus\n * @notice Protocol treasury that holds tokens owned by Venus\n */\ncontract VTreasury is Ownable {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n // WithdrawTreasuryBEP20 Event\n event WithdrawTreasuryBEP20(address tokenAddress, uint256 withdrawAmount, address withdrawAddress);\n\n // WithdrawTreasuryBNB Event\n event WithdrawTreasuryBNB(uint256 withdrawAmount, address withdrawAddress);\n\n /**\n * @notice To receive BNB\n */\n function() external payable {}\n\n /**\n * @notice Withdraw Treasury BEP20 Tokens, Only owner call it\n * @param tokenAddress The address of treasury token\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n */\n function withdrawTreasuryBEP20(\n address tokenAddress,\n uint256 withdrawAmount,\n address withdrawAddress\n ) external onlyOwner {\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury Token Balance\n uint256 treasuryBalance = IBEP20(tokenAddress).balanceOf(address(this));\n\n // Check Withdraw Amount\n if (withdrawAmount > treasuryBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = treasuryBalance;\n }\n\n // Transfer BEP20 Token to withdrawAddress\n IBEP20(tokenAddress).safeTransfer(withdrawAddress, actualWithdrawAmount);\n\n emit WithdrawTreasuryBEP20(tokenAddress, actualWithdrawAmount, withdrawAddress);\n }\n\n /**\n * @notice Withdraw Treasury BNB, Only owner call it\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n */\n function withdrawTreasuryBNB(uint256 withdrawAmount, address payable withdrawAddress) external payable onlyOwner {\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury BNB Balance\n uint256 bnbBalance = address(this).balance;\n\n // Check Withdraw Amount\n if (withdrawAmount > bnbBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = bnbBalance;\n }\n // Transfer BNB to withdrawAddress\n withdrawAddress.transfer(actualWithdrawAmount);\n\n emit WithdrawTreasuryBNB(actualWithdrawAmount, withdrawAddress);\n }\n}\n" + }, + "contracts/InterestRateModels/InterestRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Venus's InterestRateModel Interface\n * @author Venus\n */\ncontract InterestRateModel {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) external view returns (uint);\n}\n" + }, + "contracts/InterestRateModels/JumpRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Venus's JumpRateModel Contract\n * @author Venus\n */\ncontract JumpRateModel is InterestRateModel {\n using SafeMath for uint;\n\n event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock, uint jumpMultiplierPerBlock, uint kink);\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint public constant blocksPerYear = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint public baseRatePerBlock;\n\n /**\n * @notice The multiplierPerBlock after hitting a specified utilization point\n */\n uint public jumpMultiplierPerBlock;\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n uint public kink;\n\n /**\n * @notice Construct an interest rate model\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\n * @param kink_ The utilization point at which the jump multiplier is applied\n */\n constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) public {\n baseRatePerBlock = baseRatePerYear.div(blocksPerYear);\n multiplierPerBlock = multiplierPerYear.div(blocksPerYear);\n jumpMultiplierPerBlock = jumpMultiplierPerYear.div(blocksPerYear);\n kink = kink_;\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {\n uint util = utilizationRate(cash, borrows, reserves);\n\n if (util <= kink) {\n return util.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n } else {\n uint normalRate = kink.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n uint excessUtil = util.sub(kink);\n return excessUtil.mul(jumpMultiplierPerBlock).div(1e18).add(normalRate);\n }\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) public view returns (uint) {\n uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);\n uint borrowRate = getBorrowRate(cash, borrows, reserves);\n uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);\n return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);\n }\n}\n" + }, + "contracts/InterestRateModels/WhitePaperInterestRateModel.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Venus's WhitePaperInterestRateModel Contract\n * @author Venus\n * @notice The parameterized model described in section 2.4 of the original Venus Protocol whitepaper\n */\ncontract WhitePaperInterestRateModel is InterestRateModel {\n using SafeMath for uint;\n\n event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock);\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint public constant blocksPerYear = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint public baseRatePerBlock;\n\n /**\n * @notice Construct an interest rate model\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n */\n constructor(uint baseRatePerYear, uint multiplierPerYear) public {\n baseRatePerBlock = baseRatePerYear.div(blocksPerYear);\n multiplierPerBlock = multiplierPerYear.div(blocksPerYear);\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {\n uint ur = utilizationRate(cash, borrows, reserves);\n return ur.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint cash,\n uint borrows,\n uint reserves,\n uint reserveFactorMantissa\n ) public view returns (uint) {\n uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);\n uint borrowRate = getBorrowRate(cash, borrows, reserves);\n uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);\n return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);\n }\n}\n" + }, + "contracts/Lens/ComptrollerLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VBep20.sol\";\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { ExponentialNoError } from \"../Utils/ExponentialNoError.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Utils/ErrorReporter.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Comptroller/ComptrollerLensInterface.sol\";\nimport \"../Tokens/VAI/VAIControllerInterface.sol\";\n\n/**\n * @title ComptrollerLens Contract\n * @author Venus\n * @notice The ComptrollerLens contract has functions to get the number of tokens that\n * can be seized through liquidation, hypothetical account liquidity and shortfall of an account.\n */\ncontract ComptrollerLens is ComptrollerLensInterface, ComptrollerErrorReporter, ExponentialNoError {\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountLiquidityLocalVars {\n uint sumCollateral;\n uint sumBorrowPlusEffects;\n uint vTokenBalance;\n uint borrowBalance;\n uint exchangeRateMantissa;\n uint oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n }\n\n /**\n * @notice Computes the number of collateral tokens to be seized in a liquidation event\n * @param comptroller Address of comptroller\n * @param vTokenBorrowed Address of the borrowed vToken\n * @param vTokenCollateral Address of collateral for the borrow\n * @param actualRepayAmount Repayment amount i.e amount to be repaid of total borrowed amount\n * @return A tuple of error code, and tokens to seize\n */\n function liquidateCalculateSeizeTokens(\n address comptroller,\n address vTokenBorrowed,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint) {\n /* Read oracle prices for borrowed and collateral markets */\n uint priceBorrowedMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenBorrowed)\n );\n uint priceCollateralMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenCollateral)\n );\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n uint exchangeRateMantissa = VToken(vTokenCollateral).exchangeRateStored(); // Note: reverts on error\n uint seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n numerator = mul_(\n Exp({ mantissa: ComptrollerInterface(comptroller).liquidationIncentiveMantissa() }),\n Exp({ mantissa: priceBorrowedMantissa })\n );\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n\n return (uint(Error.NO_ERROR), seizeTokens);\n }\n\n /**\n * @notice Computes the number of VAI tokens to be seized in a liquidation event\n * @param comptroller Address of comptroller\n * @param vTokenCollateral Address of collateral for vToken\n * @param actualRepayAmount Repayment amount i.e amount to be repaid of the total borrowed amount\n * @return A tuple of error code, and tokens to seize\n */\n function liquidateVAICalculateSeizeTokens(\n address comptroller,\n address vTokenCollateral,\n uint actualRepayAmount\n ) external view returns (uint, uint) {\n /* Read oracle prices for borrowed and collateral markets */\n uint priceBorrowedMantissa = 1e18; // Note: this is VAI\n uint priceCollateralMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(\n VToken(vTokenCollateral)\n );\n if (priceCollateralMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n uint exchangeRateMantissa = VToken(vTokenCollateral).exchangeRateStored(); // Note: reverts on error\n uint seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n numerator = mul_(\n Exp({ mantissa: ComptrollerInterface(comptroller).liquidationIncentiveMantissa() }),\n Exp({ mantissa: priceBorrowedMantissa })\n );\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n\n return (uint(Error.NO_ERROR), seizeTokens);\n }\n\n /**\n * @notice Computes the hypothetical liquidity and shortfall of an account given a hypothetical borrow\n * A snapshot of the account is taken and the total borrow amount of the account is calculated\n * @param comptroller Address of comptroller\n * @param account Address of the borrowed vToken\n * @param vTokenModify Address of collateral for vToken\n * @param redeemTokens Number of vTokens being redeemed\n * @param borrowAmount Amount borrowed\n * @return Returns a tuple of error code, liquidity, and shortfall\n */\n function getHypotheticalAccountLiquidity(\n address comptroller,\n address account,\n VToken vTokenModify,\n uint redeemTokens,\n uint borrowAmount\n ) external view returns (uint, uint, uint) {\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\n uint oErr;\n\n // For each asset the account is in\n VToken[] memory assets = ComptrollerInterface(comptroller).getAssetsIn(account);\n uint assetsCount = assets.length;\n for (uint i = 0; i < assetsCount; ++i) {\n VToken asset = assets[i];\n\n // Read the balances and exchange rate from the vToken\n (oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = asset.getAccountSnapshot(\n account\n );\n if (oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (uint(Error.SNAPSHOT_ERROR), 0, 0);\n }\n (, uint collateralFactorMantissa) = ComptrollerInterface(comptroller).markets(address(asset));\n vars.collateralFactor = Exp({ mantissa: collateralFactorMantissa });\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = ComptrollerInterface(comptroller).oracle().getUnderlyingPrice(asset);\n if (vars.oraclePriceMantissa == 0) {\n return (uint(Error.PRICE_ERROR), 0, 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> bnb (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n\n // sumCollateral += tokensToDenom * vTokenBalance\n vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.vTokenBalance, vars.sumCollateral);\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n\n // Calculate effects of interacting with vTokenModify\n if (asset == vTokenModify) {\n // redeem effect\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.tokensToDenom,\n redeemTokens,\n vars.sumBorrowPlusEffects\n );\n\n // borrow effect\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n borrowAmount,\n vars.sumBorrowPlusEffects\n );\n }\n }\n\n VAIControllerInterface vaiController = ComptrollerInterface(comptroller).vaiController();\n\n if (address(vaiController) != address(0)) {\n vars.sumBorrowPlusEffects = add_(vars.sumBorrowPlusEffects, vaiController.getVAIRepayAmount(account));\n }\n\n // These are safe, as the underflow condition is checked first\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\n return (uint(Error.NO_ERROR), vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\n } else {\n return (uint(Error.NO_ERROR), 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\n }\n }\n}\n" + }, + "contracts/Lens/SnapshotLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport { VToken } from \"../Tokens/VTokens/VToken.sol\";\nimport { ExponentialNoError } from \"../Utils/ExponentialNoError.sol\";\nimport \"../Utils/SafeMath.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Tokens/VTokens/VBep20.sol\";\n\ncontract SnapshotLens is ExponentialNoError {\n using SafeMath for uint256;\n\n struct AccountSnapshot {\n address account;\n string assetName;\n address vTokenAddress;\n address underlyingAssetAddress;\n uint256 supply;\n uint256 supplyInUsd;\n uint256 collateral;\n uint256 borrows;\n uint256 borrowsInUsd;\n uint256 assetPrice;\n uint256 accruedInterest;\n uint vTokenDecimals;\n uint underlyingDecimals;\n uint exchangeRate;\n bool isACollateral;\n }\n\n /** Snapshot calculation **/\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account snapshot.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountSnapshotLocalVars {\n uint collateral;\n uint vTokenBalance;\n uint borrowBalance;\n uint borrowsInUsd;\n uint balanceOfUnderlying;\n uint supplyInUsd;\n uint exchangeRateMantissa;\n uint oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n bool isACollateral;\n }\n\n function getAccountSnapshot(\n address payable account,\n address comptrollerAddress\n ) public returns (AccountSnapshot[] memory) {\n // For each asset the account is in\n VToken[] memory assets = ComptrollerInterface(comptrollerAddress).getAllMarkets();\n AccountSnapshot[] memory accountSnapshots = new AccountSnapshot[](assets.length);\n for (uint256 i = 0; i < assets.length; ++i) {\n accountSnapshots[i] = getAccountSnapshot(account, comptrollerAddress, assets[i]);\n }\n return accountSnapshots;\n }\n\n function isACollateral(address account, address asset, address comptrollerAddress) public view returns (bool) {\n VToken[] memory assetsAsCollateral = ComptrollerInterface(comptrollerAddress).getAssetsIn(account);\n for (uint256 j = 0; j < assetsAsCollateral.length; ++j) {\n if (address(assetsAsCollateral[j]) == asset) {\n return true;\n }\n }\n\n return false;\n }\n\n function getAccountSnapshot(\n address payable account,\n address comptrollerAddress,\n VToken vToken\n ) public returns (AccountSnapshot memory) {\n AccountSnapshotLocalVars memory vars; // Holds all our calculation results\n uint oErr;\n\n // Read the balances and exchange rate from the vToken\n (oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vToken.getAccountSnapshot(account);\n require(oErr == 0, \"Snapshot Error\");\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n (, uint collateralFactorMantissa) = ComptrollerInterface(comptrollerAddress).markets(address(vToken));\n vars.collateralFactor = Exp({ mantissa: collateralFactorMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = ComptrollerInterface(comptrollerAddress).oracle().getUnderlyingPrice(vToken);\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> bnb (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n\n //Collateral = tokensToDenom * vTokenBalance\n vars.collateral = mul_ScalarTruncate(vars.tokensToDenom, vars.vTokenBalance);\n\n vars.balanceOfUnderlying = vToken.balanceOfUnderlying(account);\n vars.supplyInUsd = mul_ScalarTruncate(vars.oraclePrice, vars.balanceOfUnderlying);\n\n vars.borrowsInUsd = mul_ScalarTruncate(vars.oraclePrice, vars.borrowBalance);\n\n address underlyingAssetAddress;\n uint underlyingDecimals;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n underlyingAssetAddress = address(0);\n underlyingDecimals = 18;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n underlyingAssetAddress = vBep20.underlying();\n underlyingDecimals = EIP20Interface(vBep20.underlying()).decimals();\n }\n\n vars.isACollateral = isACollateral(account, address(vToken), comptrollerAddress);\n\n return\n AccountSnapshot({\n account: account,\n assetName: vToken.name(),\n vTokenAddress: address(vToken),\n underlyingAssetAddress: underlyingAssetAddress,\n supply: vars.balanceOfUnderlying,\n supplyInUsd: vars.supplyInUsd,\n collateral: vars.collateral,\n borrows: vars.borrowBalance,\n borrowsInUsd: vars.borrowsInUsd,\n assetPrice: vars.oraclePriceMantissa,\n accruedInterest: vToken.borrowIndex(),\n vTokenDecimals: vToken.decimals(),\n underlyingDecimals: underlyingDecimals,\n exchangeRate: vToken.exchangeRateCurrent(),\n isACollateral: vars.isACollateral\n });\n }\n\n // utilities\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/Lens/VenusLens.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Tokens/VTokens/VBep20.sol\";\nimport \"../Tokens/VTokens/VToken.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/EIP20Interface.sol\";\nimport \"../Tokens/XVS/XVS.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\nimport \"../Utils/SafeMath.sol\";\nimport { ComptrollerTypes } from \"../Comptroller/ComptrollerStorage.sol\";\n\ncontract VenusLens is ExponentialNoError {\n using SafeMath for uint;\n\n /// @notice Blocks Per Day\n uint public constant BLOCKS_PER_DAY = 28800;\n\n /// @notice Total actions available on VToken\n uint public constant VTOKEN_ACTIONS = 8;\n\n struct VenusMarketState {\n uint224 index;\n uint32 block;\n }\n\n struct VTokenMetadata {\n address vToken;\n uint exchangeRateCurrent;\n uint supplyRatePerBlock;\n uint borrowRatePerBlock;\n uint reserveFactorMantissa;\n uint totalBorrows;\n uint totalReserves;\n uint totalSupply;\n uint totalCash;\n bool isListed;\n uint collateralFactorMantissa;\n address underlyingAssetAddress;\n uint vTokenDecimals;\n uint underlyingDecimals;\n uint venusSupplySpeed;\n uint venusBorrowSpeed;\n uint dailySupplyXvs;\n uint dailyBorrowXvs;\n uint pausedActions;\n }\n\n struct VTokenBalances {\n address vToken;\n uint balanceOf;\n uint borrowBalanceCurrent;\n uint balanceOfUnderlying;\n uint tokenBalance;\n uint tokenAllowance;\n }\n\n struct VTokenUnderlyingPrice {\n address vToken;\n uint underlyingPrice;\n }\n\n struct AccountLimits {\n VToken[] markets;\n uint liquidity;\n uint shortfall;\n }\n\n struct XVSBalanceMetadata {\n uint balance;\n uint votes;\n address delegate;\n }\n\n struct XVSBalanceMetadataExt {\n uint balance;\n uint votes;\n address delegate;\n uint allocated;\n }\n\n struct VenusVotes {\n uint blockNumber;\n uint votes;\n }\n\n struct ClaimVenusLocalVariables {\n uint totalRewards;\n uint224 borrowIndex;\n uint32 borrowBlock;\n uint224 supplyIndex;\n uint32 supplyBlock;\n }\n\n /**\n * @dev Struct for Pending Rewards for per market\n */\n struct PendingReward {\n address vTokenAddress;\n uint256 amount;\n }\n\n /**\n * @dev Struct for Reward of a single reward token.\n */\n struct RewardSummary {\n address distributorAddress;\n address rewardTokenAddress;\n uint256 totalRewards;\n PendingReward[] pendingRewards;\n }\n\n /**\n * @notice Query the metadata of a vToken by its address\n * @param vToken The address of the vToken to fetch VTokenMetadata\n * @return VTokenMetadata struct with vToken supply and borrow information.\n */\n function vTokenMetadata(VToken vToken) public returns (VTokenMetadata memory) {\n uint exchangeRateCurrent = vToken.exchangeRateCurrent();\n address comptrollerAddress = address(vToken.comptroller());\n ComptrollerInterface comptroller = ComptrollerInterface(comptrollerAddress);\n (bool isListed, uint collateralFactorMantissa) = comptroller.markets(address(vToken));\n address underlyingAssetAddress;\n uint underlyingDecimals;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n underlyingAssetAddress = address(0);\n underlyingDecimals = 18;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n underlyingAssetAddress = vBep20.underlying();\n underlyingDecimals = EIP20Interface(vBep20.underlying()).decimals();\n }\n\n uint venusSupplySpeedPerBlock = comptroller.venusSupplySpeeds(address(vToken));\n uint venusBorrowSpeedPerBlock = comptroller.venusBorrowSpeeds(address(vToken));\n\n uint256 pausedActions;\n\n for (uint8 i; i <= VTOKEN_ACTIONS; ++i) {\n uint256 paused = comptroller.actionPaused(address(vToken), ComptrollerTypes.Action(i)) ? 1 : 0;\n pausedActions |= paused << i;\n }\n\n return\n VTokenMetadata({\n vToken: address(vToken),\n exchangeRateCurrent: exchangeRateCurrent,\n supplyRatePerBlock: vToken.supplyRatePerBlock(),\n borrowRatePerBlock: vToken.borrowRatePerBlock(),\n reserveFactorMantissa: vToken.reserveFactorMantissa(),\n totalBorrows: vToken.totalBorrows(),\n totalReserves: vToken.totalReserves(),\n totalSupply: vToken.totalSupply(),\n totalCash: vToken.getCash(),\n isListed: isListed,\n collateralFactorMantissa: collateralFactorMantissa,\n underlyingAssetAddress: underlyingAssetAddress,\n vTokenDecimals: vToken.decimals(),\n underlyingDecimals: underlyingDecimals,\n venusSupplySpeed: venusSupplySpeedPerBlock,\n venusBorrowSpeed: venusBorrowSpeedPerBlock,\n dailySupplyXvs: venusSupplySpeedPerBlock.mul(BLOCKS_PER_DAY),\n dailyBorrowXvs: venusBorrowSpeedPerBlock.mul(BLOCKS_PER_DAY),\n pausedActions: pausedActions\n });\n }\n\n /**\n * @notice Get VTokenMetadata for an array of vToken addresses\n * @param vTokens Array of vToken addresses to fetch VTokenMetadata\n * @return Array of structs with vToken supply and borrow information.\n */\n function vTokenMetadataAll(VToken[] calldata vTokens) external returns (VTokenMetadata[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenMetadata[] memory res = new VTokenMetadata[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenMetadata(vTokens[i]);\n }\n return res;\n }\n\n /**\n * @notice Get amount of XVS distributed daily to an account\n * @param account Address of account to fetch the daily XVS distribution\n * @param comptrollerAddress Address of the comptroller proxy\n * @return Amount of XVS distributed daily to an account\n */\n function getDailyXVS(address payable account, address comptrollerAddress) external returns (uint) {\n ComptrollerInterface comptrollerInstance = ComptrollerInterface(comptrollerAddress);\n VToken[] memory vTokens = comptrollerInstance.getAllMarkets();\n uint dailyXvsPerAccount = 0;\n\n for (uint i = 0; i < vTokens.length; i++) {\n VToken vToken = vTokens[i];\n if (!compareStrings(vToken.symbol(), \"vUST\") && !compareStrings(vToken.symbol(), \"vLUNA\")) {\n VTokenMetadata memory metaDataItem = vTokenMetadata(vToken);\n\n //get balanceOfUnderlying and borrowBalanceCurrent from vTokenBalance\n VTokenBalances memory vTokenBalanceInfo = vTokenBalances(vToken, account);\n\n VTokenUnderlyingPrice memory underlyingPriceResponse = vTokenUnderlyingPrice(vToken);\n uint underlyingPrice = underlyingPriceResponse.underlyingPrice;\n Exp memory underlyingPriceMantissa = Exp({ mantissa: underlyingPrice });\n\n //get dailyXvsSupplyMarket\n uint dailyXvsSupplyMarket = 0;\n uint supplyInUsd = mul_ScalarTruncate(underlyingPriceMantissa, vTokenBalanceInfo.balanceOfUnderlying);\n uint marketTotalSupply = (metaDataItem.totalSupply.mul(metaDataItem.exchangeRateCurrent)).div(1e18);\n uint marketTotalSupplyInUsd = mul_ScalarTruncate(underlyingPriceMantissa, marketTotalSupply);\n\n if (marketTotalSupplyInUsd > 0) {\n dailyXvsSupplyMarket = (metaDataItem.dailySupplyXvs.mul(supplyInUsd)).div(marketTotalSupplyInUsd);\n }\n\n //get dailyXvsBorrowMarket\n uint dailyXvsBorrowMarket = 0;\n uint borrowsInUsd = mul_ScalarTruncate(underlyingPriceMantissa, vTokenBalanceInfo.borrowBalanceCurrent);\n uint marketTotalBorrowsInUsd = mul_ScalarTruncate(underlyingPriceMantissa, metaDataItem.totalBorrows);\n\n if (marketTotalBorrowsInUsd > 0) {\n dailyXvsBorrowMarket = (metaDataItem.dailyBorrowXvs.mul(borrowsInUsd)).div(marketTotalBorrowsInUsd);\n }\n\n dailyXvsPerAccount += dailyXvsSupplyMarket + dailyXvsBorrowMarket;\n }\n }\n\n return dailyXvsPerAccount;\n }\n\n /**\n * @notice Get the current vToken balance (outstanding borrows) for an account\n * @param vToken Address of the token to check the balance of\n * @param account Account address to fetch the balance of\n * @return VTokenBalances with token balance information\n */\n function vTokenBalances(VToken vToken, address payable account) public returns (VTokenBalances memory) {\n uint balanceOf = vToken.balanceOf(account);\n uint borrowBalanceCurrent = vToken.borrowBalanceCurrent(account);\n uint balanceOfUnderlying = vToken.balanceOfUnderlying(account);\n uint tokenBalance;\n uint tokenAllowance;\n\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n tokenBalance = account.balance;\n tokenAllowance = account.balance;\n } else {\n VBep20 vBep20 = VBep20(address(vToken));\n EIP20Interface underlying = EIP20Interface(vBep20.underlying());\n tokenBalance = underlying.balanceOf(account);\n tokenAllowance = underlying.allowance(account, address(vToken));\n }\n\n return\n VTokenBalances({\n vToken: address(vToken),\n balanceOf: balanceOf,\n borrowBalanceCurrent: borrowBalanceCurrent,\n balanceOfUnderlying: balanceOfUnderlying,\n tokenBalance: tokenBalance,\n tokenAllowance: tokenAllowance\n });\n }\n\n /**\n * @notice Get the current vToken balances (outstanding borrows) for all vTokens on an account\n * @param vTokens Addresses of the tokens to check the balance of\n * @param account Account address to fetch the balance of\n * @return VTokenBalances Array with token balance information\n */\n function vTokenBalancesAll(\n VToken[] calldata vTokens,\n address payable account\n ) external returns (VTokenBalances[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenBalances[] memory res = new VTokenBalances[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenBalances(vTokens[i], account);\n }\n return res;\n }\n\n /**\n * @notice Get the price for the underlying asset of a vToken\n * @param vToken address of the vToken\n * @return response struct with underlyingPrice info of vToken\n */\n function vTokenUnderlyingPrice(VToken vToken) public view returns (VTokenUnderlyingPrice memory) {\n ComptrollerInterface comptroller = ComptrollerInterface(address(vToken.comptroller()));\n PriceOracle priceOracle = comptroller.oracle();\n\n return\n VTokenUnderlyingPrice({ vToken: address(vToken), underlyingPrice: priceOracle.getUnderlyingPrice(vToken) });\n }\n\n /**\n * @notice Query the underlyingPrice of an array of vTokens\n * @param vTokens Array of vToken addresses\n * @return array of response structs with underlying price information of vTokens\n */\n function vTokenUnderlyingPriceAll(\n VToken[] calldata vTokens\n ) external view returns (VTokenUnderlyingPrice[] memory) {\n uint vTokenCount = vTokens.length;\n VTokenUnderlyingPrice[] memory res = new VTokenUnderlyingPrice[](vTokenCount);\n for (uint i = 0; i < vTokenCount; i++) {\n res[i] = vTokenUnderlyingPrice(vTokens[i]);\n }\n return res;\n }\n\n /**\n * @notice Query the account liquidity and shortfall of an account\n * @param comptroller Address of comptroller proxy\n * @param account Address of the account to query\n * @return Struct with markets user has entered, liquidity, and shortfall of the account\n */\n function getAccountLimits(\n ComptrollerInterface comptroller,\n address account\n ) public view returns (AccountLimits memory) {\n (uint errorCode, uint liquidity, uint shortfall) = comptroller.getAccountLiquidity(account);\n require(errorCode == 0, \"account liquidity error\");\n\n return AccountLimits({ markets: comptroller.getAssetsIn(account), liquidity: liquidity, shortfall: shortfall });\n }\n\n /**\n * @notice Query the XVSBalance info of an account\n * @param xvs XVS contract address\n * @param account Account address\n * @return Struct with XVS balance and voter details\n */\n function getXVSBalanceMetadata(XVS xvs, address account) external view returns (XVSBalanceMetadata memory) {\n return\n XVSBalanceMetadata({\n balance: xvs.balanceOf(account),\n votes: uint256(xvs.getCurrentVotes(account)),\n delegate: xvs.delegates(account)\n });\n }\n\n /**\n * @notice Query the XVSBalance extended info of an account\n * @param xvs XVS contract address\n * @param comptroller Comptroller proxy contract address\n * @param account Account address\n * @return Struct with XVS balance and voter details and XVS allocation\n */\n function getXVSBalanceMetadataExt(\n XVS xvs,\n ComptrollerInterface comptroller,\n address account\n ) external returns (XVSBalanceMetadataExt memory) {\n uint balance = xvs.balanceOf(account);\n comptroller.claimVenus(account);\n uint newBalance = xvs.balanceOf(account);\n uint accrued = comptroller.venusAccrued(account);\n uint total = add_(accrued, newBalance, \"sum xvs total\");\n uint allocated = sub_(total, balance, \"sub allocated\");\n\n return\n XVSBalanceMetadataExt({\n balance: balance,\n votes: uint256(xvs.getCurrentVotes(account)),\n delegate: xvs.delegates(account),\n allocated: allocated\n });\n }\n\n /**\n * @notice Query the voting power for an account at a specific list of block numbers\n * @param xvs XVS contract address\n * @param account Address of the account\n * @param blockNumbers Array of blocks to query\n * @return Array of VenusVotes structs with block number and vote count\n */\n function getVenusVotes(\n XVS xvs,\n address account,\n uint32[] calldata blockNumbers\n ) external view returns (VenusVotes[] memory) {\n VenusVotes[] memory res = new VenusVotes[](blockNumbers.length);\n for (uint i = 0; i < blockNumbers.length; i++) {\n res[i] = VenusVotes({\n blockNumber: uint256(blockNumbers[i]),\n votes: uint256(xvs.getPriorVotes(account, blockNumbers[i]))\n });\n }\n return res;\n }\n\n /**\n * @dev Queries the current supply to calculate rewards for an account\n * @param supplyState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param comptroller Address of the comptroller proxy\n */\n function updateVenusSupplyIndex(\n VenusMarketState memory supplyState,\n address vToken,\n ComptrollerInterface comptroller\n ) internal view {\n uint supplySpeed = comptroller.venusSupplySpeeds(vToken);\n uint blockNumber = block.number;\n uint deltaBlocks = sub_(blockNumber, uint(supplyState.block));\n if (deltaBlocks > 0 && supplySpeed > 0) {\n uint supplyTokens = VToken(vToken).totalSupply();\n uint venusAccrued = mul_(deltaBlocks, supplySpeed);\n Double memory ratio = supplyTokens > 0 ? fraction(venusAccrued, supplyTokens) : Double({ mantissa: 0 });\n Double memory index = add_(Double({ mantissa: supplyState.index }), ratio);\n supplyState.index = safe224(index.mantissa, \"new index overflows\");\n supplyState.block = safe32(blockNumber, \"block number overflows\");\n } else if (deltaBlocks > 0) {\n supplyState.block = safe32(blockNumber, \"block number overflows\");\n }\n }\n\n /**\n * @dev Queries the current borrow to calculate rewards for an account\n * @param borrowState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param comptroller Address of the comptroller proxy\n */\n function updateVenusBorrowIndex(\n VenusMarketState memory borrowState,\n address vToken,\n Exp memory marketBorrowIndex,\n ComptrollerInterface comptroller\n ) internal view {\n uint borrowSpeed = comptroller.venusBorrowSpeeds(vToken);\n uint blockNumber = block.number;\n uint deltaBlocks = sub_(blockNumber, uint(borrowState.block));\n if (deltaBlocks > 0 && borrowSpeed > 0) {\n uint borrowAmount = div_(VToken(vToken).totalBorrows(), marketBorrowIndex);\n uint venusAccrued = mul_(deltaBlocks, borrowSpeed);\n Double memory ratio = borrowAmount > 0 ? fraction(venusAccrued, borrowAmount) : Double({ mantissa: 0 });\n Double memory index = add_(Double({ mantissa: borrowState.index }), ratio);\n borrowState.index = safe224(index.mantissa, \"new index overflows\");\n borrowState.block = safe32(blockNumber, \"block number overflows\");\n } else if (deltaBlocks > 0) {\n borrowState.block = safe32(blockNumber, \"block number overflows\");\n }\n }\n\n /**\n * @dev Calculate available rewards for an account's supply\n * @param supplyState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param supplier Address of the account supplying\n * @param comptroller Address of the comptroller proxy\n * @return Undistributed earned XVS from supplies\n */\n function distributeSupplierVenus(\n VenusMarketState memory supplyState,\n address vToken,\n address supplier,\n ComptrollerInterface comptroller\n ) internal view returns (uint) {\n Double memory supplyIndex = Double({ mantissa: supplyState.index });\n Double memory supplierIndex = Double({ mantissa: comptroller.venusSupplierIndex(vToken, supplier) });\n if (supplierIndex.mantissa == 0 && supplyIndex.mantissa > 0) {\n supplierIndex.mantissa = comptroller.venusInitialIndex();\n }\n\n Double memory deltaIndex = sub_(supplyIndex, supplierIndex);\n uint supplierTokens = VToken(vToken).balanceOf(supplier);\n uint supplierDelta = mul_(supplierTokens, deltaIndex);\n return supplierDelta;\n }\n\n /**\n * @dev Calculate available rewards for an account's borrows\n * @param borrowState VenusMarketState struct\n * @param vToken Address of a vToken\n * @param borrower Address of the account borrowing\n * @param marketBorrowIndex vToken Borrow index\n * @param comptroller Address of the comptroller proxy\n * @return Undistributed earned XVS from borrows\n */\n function distributeBorrowerVenus(\n VenusMarketState memory borrowState,\n address vToken,\n address borrower,\n Exp memory marketBorrowIndex,\n ComptrollerInterface comptroller\n ) internal view returns (uint) {\n Double memory borrowIndex = Double({ mantissa: borrowState.index });\n Double memory borrowerIndex = Double({ mantissa: comptroller.venusBorrowerIndex(vToken, borrower) });\n if (borrowerIndex.mantissa > 0) {\n Double memory deltaIndex = sub_(borrowIndex, borrowerIndex);\n uint borrowerAmount = div_(VToken(vToken).borrowBalanceStored(borrower), marketBorrowIndex);\n uint borrowerDelta = mul_(borrowerAmount, deltaIndex);\n return borrowerDelta;\n }\n return 0;\n }\n\n /**\n * @notice Calculate the total XVS tokens pending and accrued by a user account\n * @param holder Account to query pending XVS\n * @param comptroller Address of the comptroller\n * @return Reward object contraining the totalRewards and pending rewards for each market\n */\n function pendingRewards(\n address holder,\n ComptrollerInterface comptroller\n ) external view returns (RewardSummary memory) {\n VToken[] memory vTokens = comptroller.getAllMarkets();\n ClaimVenusLocalVariables memory vars;\n RewardSummary memory rewardSummary;\n rewardSummary.distributorAddress = address(comptroller);\n rewardSummary.rewardTokenAddress = comptroller.getXVSAddress();\n rewardSummary.totalRewards = comptroller.venusAccrued(holder);\n rewardSummary.pendingRewards = new PendingReward[](vTokens.length);\n for (uint i; i < vTokens.length; ++i) {\n (vars.borrowIndex, vars.borrowBlock) = comptroller.venusBorrowState(address(vTokens[i]));\n VenusMarketState memory borrowState = VenusMarketState({\n index: vars.borrowIndex,\n block: vars.borrowBlock\n });\n\n (vars.supplyIndex, vars.supplyBlock) = comptroller.venusSupplyState(address(vTokens[i]));\n VenusMarketState memory supplyState = VenusMarketState({\n index: vars.supplyIndex,\n block: vars.supplyBlock\n });\n\n Exp memory borrowIndex = Exp({ mantissa: vTokens[i].borrowIndex() });\n\n PendingReward memory marketReward;\n marketReward.vTokenAddress = address(vTokens[i]);\n\n updateVenusBorrowIndex(borrowState, address(vTokens[i]), borrowIndex, comptroller);\n uint256 borrowReward = distributeBorrowerVenus(\n borrowState,\n address(vTokens[i]),\n holder,\n borrowIndex,\n comptroller\n );\n\n updateVenusSupplyIndex(supplyState, address(vTokens[i]), comptroller);\n uint256 supplyReward = distributeSupplierVenus(supplyState, address(vTokens[i]), holder, comptroller);\n\n marketReward.amount = add_(borrowReward, supplyReward);\n rewardSummary.pendingRewards[i] = marketReward;\n }\n return rewardSummary;\n }\n\n // utilities\n /**\n * @notice Compares if two strings are equal\n * @param a First string to compare\n * @param b Second string to compare\n * @return Boolean depending on if the strings are equal\n */\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/Oracle/PriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\ncontract PriceOracle {\n /// @notice Indicator that this is a PriceOracle contract (for inspection)\n bool public constant isPriceOracle = true;\n\n /**\n * @notice Get the underlying price of a vToken asset\n * @param vToken The vToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(VToken vToken) external view returns (uint);\n}\n" + }, + "contracts/test/BEP20.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\n\n// Mock import\nimport { GovernorBravoDelegate } from \"@venusprotocol/governance-contracts/contracts/Governance/GovernorBravoDelegate.sol\";\n\ninterface BEP20Base {\n event Approval(address indexed owner, address indexed spender, uint256 value);\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function totalSupply() external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function balanceOf(address who) external view returns (uint256);\n}\n\ncontract BEP20 is BEP20Base {\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n\ncontract BEP20NS is BEP20Base {\n function transfer(address to, uint256 value) external;\n\n function transferFrom(address from, address to, uint256 value) external;\n}\n\n/**\n * @title Standard BEP20 token\n * @dev Implementation of the basic standard token.\n * See https://github.com/ethereum/EIPs/issues/20\n */\ncontract StandardToken is BEP20 {\n using SafeMath for uint256;\n\n string public name;\n string public symbol;\n uint8 public decimals;\n uint256 public totalSupply;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public balanceOf;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public {\n totalSupply = _initialAmount;\n balanceOf[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool) {\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n return true;\n }\n\n function approve(address _spender, uint256 amount) external returns (bool) {\n allowance[msg.sender][_spender] = amount;\n emit Approval(msg.sender, _spender, amount);\n return true;\n }\n}\n\n/**\n * @title Non-Standard BEP20 token\n * @dev Version of BEP20 with no return values for `transfer` and `transferFrom`\n * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\ncontract NonStandardToken is BEP20NS {\n using SafeMath for uint256;\n\n string public name;\n uint8 public decimals;\n string public symbol;\n uint256 public totalSupply;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public balanceOf;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public {\n totalSupply = _initialAmount;\n balanceOf[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n }\n\n function transfer(address dst, uint256 amount) external {\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n }\n\n function transferFrom(address src, address dst, uint256 amount) external {\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n }\n\n function approve(address _spender, uint256 amount) external returns (bool) {\n allowance[msg.sender][_spender] = amount;\n emit Approval(msg.sender, _spender, amount);\n return true;\n }\n}\n\ncontract BEP20Harness is StandardToken {\n // To support testing, we can specify addresses for which transferFrom should fail and return false\n mapping(address => bool) public failTransferFromAddresses;\n\n // To support testing, we allow the contract to always fail `transfer`.\n mapping(address => bool) public failTransferToAddresses;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public StandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function harnessSetFailTransferFromAddress(address src, bool _fail) public {\n failTransferFromAddresses[src] = _fail;\n }\n\n function harnessSetFailTransferToAddress(address dst, bool _fail) public {\n failTransferToAddresses[dst] = _fail;\n }\n\n function harnessSetBalance(address _account, uint _amount) public {\n balanceOf[_account] = _amount;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool success) {\n // Added for testing purposes\n if (failTransferToAddresses[dst]) {\n return false;\n }\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool success) {\n // Added for testing purposes\n if (failTransferFromAddresses[src]) {\n return false;\n }\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount, \"Insufficient allowance\");\n balanceOf[src] = balanceOf[src].sub(amount, \"Insufficient balance\");\n balanceOf[dst] = balanceOf[dst].add(amount, \"Balance overflow\");\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/ComptrollerHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerMock.sol\";\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Comptroller/Unitroller.sol\";\n\ncontract ComptrollerHarness is ComptrollerMock {\n address internal xvsAddress;\n address internal vXVSAddress;\n uint public blockNumber;\n\n constructor() public ComptrollerMock() {}\n\n function setVenusSupplyState(address vToken, uint224 index, uint32 blockNumber_) public {\n venusSupplyState[vToken].index = index;\n venusSupplyState[vToken].block = blockNumber_;\n }\n\n function setVenusBorrowState(address vToken, uint224 index, uint32 blockNumber_) public {\n venusBorrowState[vToken].index = index;\n venusBorrowState[vToken].block = blockNumber_;\n }\n\n function setVenusAccrued(address user, uint userAccrued) public {\n venusAccrued[user] = userAccrued;\n }\n\n function setXVSAddress(address xvsAddress_) public {\n xvsAddress = xvsAddress_;\n }\n\n function setXVSVTokenAddress(address vXVSAddress_) public {\n vXVSAddress = vXVSAddress_;\n }\n\n /**\n * @notice Set the amount of XVS distributed per block\n * @param venusRate_ The amount of XVS wei per block to distribute\n */\n function harnessSetVenusRate(uint venusRate_) public {\n venusRate = venusRate_;\n }\n\n /**\n * @notice Recalculate and update XVS speeds for all XVS markets\n */\n function harnessRefreshVenusSpeeds() public {\n VToken[] memory allMarkets_ = allMarkets;\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusSupplyIndex(address(vToken));\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n }\n\n Exp memory totalUtility = Exp({ mantissa: 0 });\n Exp[] memory utilities = new Exp[](allMarkets_.length);\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n if (venusSpeeds[address(vToken)] > 0) {\n Exp memory assetPrice = Exp({ mantissa: oracle.getUnderlyingPrice(vToken) });\n Exp memory utility = mul_(assetPrice, vToken.totalBorrows());\n utilities[i] = utility;\n totalUtility = add_(totalUtility, utility);\n }\n }\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets[i];\n uint newSpeed = totalUtility.mantissa > 0 ? mul_(venusRate, div_(utilities[i], totalUtility)) : 0;\n setVenusSpeedInternal(vToken, newSpeed, newSpeed);\n }\n }\n\n function setVenusBorrowerIndex(address vToken, address borrower, uint index) public {\n venusBorrowerIndex[vToken][borrower] = index;\n }\n\n function setVenusSupplierIndex(address vToken, address supplier, uint index) public {\n venusSupplierIndex[vToken][supplier] = index;\n }\n\n function harnessDistributeAllBorrowerVenus(\n address vToken,\n address borrower,\n uint marketBorrowIndexMantissa\n ) public {\n distributeBorrowerVenus(vToken, borrower, Exp({ mantissa: marketBorrowIndexMantissa }));\n venusAccrued[borrower] = grantXVSInternal(borrower, venusAccrued[borrower], 0, false);\n }\n\n function harnessDistributeAllSupplierVenus(address vToken, address supplier) public {\n distributeSupplierVenus(vToken, supplier);\n venusAccrued[supplier] = grantXVSInternal(supplier, venusAccrued[supplier], 0, false);\n }\n\n function harnessUpdateVenusBorrowIndex(address vToken, uint marketBorrowIndexMantissa) public {\n updateVenusBorrowIndex(vToken, Exp({ mantissa: marketBorrowIndexMantissa }));\n }\n\n function harnessUpdateVenusSupplyIndex(address vToken) public {\n updateVenusSupplyIndex(vToken);\n }\n\n function harnessDistributeBorrowerVenus(address vToken, address borrower, uint marketBorrowIndexMantissa) public {\n distributeBorrowerVenus(vToken, borrower, Exp({ mantissa: marketBorrowIndexMantissa }));\n }\n\n function harnessDistributeSupplierVenus(address vToken, address supplier) public {\n distributeSupplierVenus(vToken, supplier);\n }\n\n function harnessTransferVenus(address user, uint userAccrued, uint threshold) public returns (uint) {\n if (userAccrued > 0 && userAccrued >= threshold) {\n return grantXVSInternal(user, userAccrued, 0, false);\n }\n return userAccrued;\n }\n\n function harnessAddVenusMarkets(address[] memory vTokens) public {\n for (uint i = 0; i < vTokens.length; i++) {\n // temporarily set venusSpeed to 1 (will be fixed by `harnessRefreshVenusSpeeds`)\n setVenusSpeedInternal(VToken(vTokens[i]), 1, 1);\n }\n }\n\n function harnessSetMintedVAIs(address user, uint amount) public {\n mintedVAIs[user] = amount;\n }\n\n function harnessFastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getVenusMarkets() public view returns (address[] memory) {\n uint m = allMarkets.length;\n uint n = 0;\n for (uint i = 0; i < m; i++) {\n if (venusSpeeds[address(allMarkets[i])] > 0) {\n n++;\n }\n }\n\n address[] memory venusMarkets = new address[](n);\n uint k = 0;\n for (uint i = 0; i < m; i++) {\n if (venusSpeeds[address(allMarkets[i])] > 0) {\n venusMarkets[k++] = address(allMarkets[i]);\n }\n }\n return venusMarkets;\n }\n\n function harnessSetReleaseStartBlock(uint startBlock) external {\n releaseStartBlock = startBlock;\n }\n\n function harnessAddVtoken(address vToken) external {\n markets[vToken] = Market({ isListed: true, isVenus: false, collateralFactorMantissa: 0 });\n }\n}\n\ncontract EchoTypesComptroller is UnitrollerAdminStorage {\n function stringy(string memory s) public pure returns (string memory) {\n return s;\n }\n\n function addresses(address a) public pure returns (address) {\n return a;\n }\n\n function booly(bool b) public pure returns (bool) {\n return b;\n }\n\n function listOInts(uint[] memory u) public pure returns (uint[] memory) {\n return u;\n }\n\n function reverty() public pure {\n require(false, \"gotcha sucka\");\n }\n\n function becomeBrains(address payable unitroller) public {\n Unitroller(unitroller)._acceptImplementation();\n }\n}\n" + }, + "contracts/test/ComptrollerMock.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Comptroller/Diamond/facets/MarketFacet.sol\";\nimport \"../Comptroller/Diamond/facets/PolicyFacet.sol\";\nimport \"../Comptroller/Diamond/facets/RewardFacet.sol\";\nimport \"../Comptroller/Diamond/facets/SetterFacet.sol\";\nimport \"../Comptroller/Unitroller.sol\";\n\n// This contract contains all methods of Comptroller implementation in different facets at one place for testing purpose\n// This contract does not have diamond functionality(i.e delegate call to facets methods)\ncontract ComptrollerMock is MarketFacet, PolicyFacet, RewardFacet, SetterFacet {\n constructor() public {\n admin = msg.sender;\n }\n\n function _become(Unitroller unitroller) public {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can\");\n require(unitroller._acceptImplementation() == 0, \"not authorized\");\n }\n\n function _setComptrollerLens(ComptrollerLensInterface comptrollerLens_) external returns (uint) {\n ensureAdmin();\n ensureNonzeroAddress(address(comptrollerLens_));\n address oldComptrollerLens = address(comptrollerLens);\n comptrollerLens = comptrollerLens_;\n emit NewComptrollerLens(oldComptrollerLens, address(comptrollerLens));\n\n return uint(Error.NO_ERROR);\n }\n}\n" + }, + "contracts/test/ComptrollerScenario.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./ComptrollerMock.sol\";\n\ncontract ComptrollerScenario is ComptrollerMock {\n uint public blockNumber;\n address public xvsAddress;\n address public vaiAddress;\n\n constructor() public ComptrollerMock() {}\n\n function setXVSAddress(address xvsAddress_) public {\n xvsAddress = xvsAddress_;\n }\n\n // function getXVSAddress() public view returns (address) {\n // return xvsAddress;\n // }\n\n function setVAIAddress(address vaiAddress_) public {\n vaiAddress = vaiAddress_;\n }\n\n function getVAIAddress() public view returns (address) {\n return vaiAddress;\n }\n\n function membershipLength(VToken vToken) public view returns (uint) {\n return accountAssets[address(vToken)].length;\n }\n\n function fastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n\n return blockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getVenusMarkets() public view returns (address[] memory) {\n uint m = allMarkets.length;\n uint n = 0;\n for (uint i = 0; i < m; i++) {\n if (markets[address(allMarkets[i])].isVenus) {\n n++;\n }\n }\n\n address[] memory venusMarkets = new address[](n);\n uint k = 0;\n for (uint i = 0; i < m; i++) {\n if (markets[address(allMarkets[i])].isVenus) {\n venusMarkets[k++] = address(allMarkets[i]);\n }\n }\n return venusMarkets;\n }\n\n function unlist(VToken vToken) public {\n markets[address(vToken)].isListed = false;\n }\n\n /**\n * @notice Recalculate and update XVS speeds for all XVS markets\n */\n function refreshVenusSpeeds() public {\n VToken[] memory allMarkets_ = allMarkets;\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n Exp memory borrowIndex = Exp({ mantissa: vToken.borrowIndex() });\n updateVenusSupplyIndex(address(vToken));\n updateVenusBorrowIndex(address(vToken), borrowIndex);\n }\n\n Exp memory totalUtility = Exp({ mantissa: 0 });\n Exp[] memory utilities = new Exp[](allMarkets_.length);\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets_[i];\n if (venusSpeeds[address(vToken)] > 0) {\n Exp memory assetPrice = Exp({ mantissa: oracle.getUnderlyingPrice(vToken) });\n Exp memory utility = mul_(assetPrice, vToken.totalBorrows());\n utilities[i] = utility;\n totalUtility = add_(totalUtility, utility);\n }\n }\n\n for (uint i = 0; i < allMarkets_.length; i++) {\n VToken vToken = allMarkets[i];\n uint newSpeed = totalUtility.mantissa > 0 ? mul_(venusRate, div_(utilities[i], totalUtility)) : 0;\n setVenusSpeedInternal(vToken, newSpeed, newSpeed);\n }\n }\n}\n" + }, + "contracts/test/DiamondHarness.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Comptroller/Diamond/Diamond.sol\";\n\ncontract DiamondHarness is Diamond {\n function getFacetAddress(bytes4 sig) public view returns (address) {\n address facet = _selectorToFacetAndPosition[sig].facetAddress;\n require(facet != address(0), \"Diamond: Function does not exist\");\n return facet;\n }\n}\n" + }, + "contracts/test/EvilToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./FaucetToken.sol\";\n\n/**\n * @title The Venus Evil Test Token\n * @author Venus\n * @notice A simple test token that fails certain operations\n */\ncontract EvilToken is FaucetToken {\n bool public fail;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public FaucetToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {\n fail = true;\n }\n\n function setFail(bool _fail) external {\n fail = _fail;\n }\n\n function transfer(address dst, uint256 amount) external returns (bool) {\n if (fail) {\n return false;\n }\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(amount);\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n if (fail) {\n return false;\n }\n balanceOf[src] = balanceOf[src].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(amount);\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount);\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/EvilXDelegator.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegator Contract\n * @notice VTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Venus\n */\ncontract EvilXDelegator is VTokenInterface, VBep20Interface, VDelegatorInterface {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n * @param implementation_ The address of the implementation the contract delegates to\n * @param becomeImplementationData The encoded args for becomeImplementation\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint256 initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,address,uint256,string,string,uint8)\",\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n )\n );\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_, false, becomeImplementationData);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public {\n require(msg.sender == admin, \"VBep20Delegator::_setImplementation: Caller must be admin\");\n\n if (allowResign) {\n delegateToImplementation(abi.encodeWithSignature(\"_resignImplementation()\"));\n }\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n delegateToImplementation(abi.encodeWithSignature(\"_becomeImplementation(bytes)\", becomeImplementationData));\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint256 mintAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"mint(uint256)\", mintAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mintBehalf(address receiver, uint256 mintAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"mintBehalf(address,uint256)\", receiver, mintAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint256 redeemTokens) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"redeem(uint256)\", redeemTokens));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"redeemUnderlying(uint256)\", redeemAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint256 borrowAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrow(uint256)\", borrowAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint256 repayAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"repayBorrow(uint256)\", repayAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"repayBorrowBehalf(address,uint256)\", borrower, repayAmount)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"liquidateBorrow(address,uint256,address)\", borrower, repayAmount, vTokenCollateral)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"transfer(address,uint256)\", dst, amount));\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", src, dst, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"approve(address,uint256)\", spender, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"allowance(address,address)\", owner, spender)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"balanceOf(address)\", owner));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"balanceOfUnderlying(address)\", owner));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint256, uint256, uint256, uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"getAccountSnapshot(address)\", account)\n );\n return abi.decode(data, (uint256, uint256, uint256, uint256));\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"borrowRatePerBlock()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"supplyRatePerBlock()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"totalBorrowsCurrent()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrowBalanceCurrent(address)\", account));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint256) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"borrowBalanceStored(address)\", account)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"exchangeRateCurrent()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"exchangeRateStored()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint256) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"getCash()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves.\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"accrueInterest()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seize(address liquidator, address borrower, uint256 seizeTokens) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"seize(address,address,uint256)\", liquidator, borrower, seizeTokens)\n );\n return abi.decode(data, (uint256));\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setPendingAdmin(address)\", newPendingAdmin)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setComptroller(address)\", newComptroller)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setReserveFactor(uint256)\", newReserveFactorMantissa)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_acceptAdmin()\"));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from admin\n * @param addAmount Amount of reserves to add\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addReserves(uint256 addAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_addReserves(uint256)\", addAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _reduceReserves(uint256 reduceAmount) external returns (uint256) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_reduceReserves(uint256)\", reduceAmount));\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint256) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setInterestRateModel(address)\", newInterestRateModel)\n );\n return abi.decode(data, (uint256));\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /**\n * @notice Delegates execution to the implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToImplementation(bytes memory data) public returns (bytes memory) {\n return delegateTo(implementation, data);\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {\n (bool success, bytes memory returnData) = address(this).staticcall(\n abi.encodeWithSignature(\"delegateToImplementation(bytes)\", data)\n );\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return abi.decode(returnData, (bytes));\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n */\n function() external payable {\n require(msg.value == 0, \"VBep20Delegator:fallback: cannot send value to fallback\");\n\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/test/EvilXToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VBep20Immutable.sol\";\nimport \"../Tokens/VTokens/VBep20Delegator.sol\";\nimport \"../Tokens/VTokens/VBep20Delegate.sol\";\nimport \"./ComptrollerScenario.sol\";\nimport \"../Comptroller/ComptrollerInterface.sol\";\n\ncontract VBep20Scenario is VBep20Immutable {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\n// doTransferOut method of this token supposed to be compromised and contians malicious code which\n// can be used by attacker to compromise the protocol working.\ncontract EvilXToken is VBep20Delegate {\n event Log(string x, address y);\n event Log(string x, uint y);\n event LogLiquidity(uint liquidity);\n\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n address public comptrollerAddress;\n\n mapping(address => bool) public failTransferToAddresses;\n\n function setComptrollerAddress(address _comptrollerAddress) external {\n comptrollerAddress = _comptrollerAddress;\n }\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n super.doTransferOut(to, amount);\n\n // Checking the Liquidity of the user after the tranfer.\n // solhint-disable-next-line no-unused-vars\n (uint errorCode, uint liquidity, uint shortfall) = ComptrollerInterface(comptrollerAddress).getAccountLiquidity(\n msg.sender\n );\n emit LogLiquidity(liquidity);\n return;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessIncrementTotalBorrows(uint addtlBorrow_) public {\n totalBorrows = totalBorrows + addtlBorrow_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n" + }, + "contracts/test/Fauceteer.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/EIP20NonStandardInterface.sol\";\n\n/**\n * @title Fauceteer\n * @author Venus\n * @notice First computer program to be part of The Giving Pledge\n */\ncontract Fauceteer {\n /**\n * @notice Drips some tokens to caller\n * @dev We send 0.01% of our tokens to the caller. Over time, the amount will tend toward and eventually reach zero.\n * @param token The token to drip. Note: if we have no balance in this token, function will revert.\n */\n function drip(EIP20NonStandardInterface token) public {\n uint tokenBalance = token.balanceOf(address(this));\n require(tokenBalance > 0, \"Fauceteer is empty\");\n token.transfer(msg.sender, tokenBalance / 10000); // 0.01%\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n\n require(success, \"Transfer returned false.\");\n }\n}\n" + }, + "contracts/test/FaucetToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./BEP20.sol\";\n\n/**\n * @title The Venus Faucet Test Token\n * @author Venus\n * @notice A simple test token that lets anyone get more of it.\n */\ncontract FaucetToken is StandardToken {\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public StandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n\n/**\n * @title The Venus Faucet Test Token (non-standard)\n * @author Venus\n * @notice A simple test token that lets anyone get more of it.\n */\ncontract FaucetNonStandardToken is NonStandardToken {\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol\n ) public NonStandardToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {}\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n\n/**\n * @title The Venus Faucet Re-Entrant Test Token\n * @author Venus\n * @notice A test token that is malicious and tries to re-enter callers\n */\ncontract FaucetTokenReEntrantHarness {\n using SafeMath for uint256;\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n string public name;\n string public symbol;\n uint8 public decimals;\n uint256 internal totalSupply_;\n mapping(address => mapping(address => uint256)) internal allowance_;\n mapping(address => uint256) internal balanceOf_;\n\n bytes public reEntryCallData;\n string public reEntryFun;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol,\n bytes memory _reEntryCallData,\n string memory _reEntryFun\n ) public {\n totalSupply_ = _initialAmount;\n balanceOf_[msg.sender] = _initialAmount;\n name = _tokenName;\n symbol = _tokenSymbol;\n decimals = _decimalUnits;\n reEntryCallData = _reEntryCallData;\n reEntryFun = _reEntryFun;\n }\n\n modifier reEnter(string memory funName) {\n string memory _reEntryFun = reEntryFun;\n if (compareStrings(_reEntryFun, funName)) {\n reEntryFun = \"\"; // Clear re-entry fun\n (bool success, bytes memory returndata) = msg.sender.call(reEntryCallData);\n assembly {\n if eq(success, 0) {\n revert(add(returndata, 0x20), returndatasize())\n }\n }\n }\n\n _;\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)));\n }\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf_[_owner] += value;\n totalSupply_ += value;\n emit Transfer(address(this), _owner, value);\n }\n\n function totalSupply() public reEnter(\"totalSupply\") returns (uint256) {\n return totalSupply_;\n }\n\n function allowance(address owner, address spender) public reEnter(\"allowance\") returns (uint256 remaining) {\n return allowance_[owner][spender];\n }\n\n function approve(address spender, uint256 amount) public reEnter(\"approve\") returns (bool success) {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n function balanceOf(address owner) public reEnter(\"balanceOf\") returns (uint256 balance) {\n return balanceOf_[owner];\n }\n\n function transfer(address dst, uint256 amount) public reEnter(\"transfer\") returns (bool success) {\n _transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) public reEnter(\"transferFrom\") returns (bool success) {\n _transfer(src, dst, amount);\n _approve(src, msg.sender, allowance_[src][msg.sender].sub(amount));\n return true;\n }\n\n function _approve(address owner, address spender, uint256 amount) internal {\n require(spender != address(0), \"sender should be valid address\");\n require(owner != address(0), \"owner should be valid address\");\n allowance_[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n function _transfer(address src, address dst, uint256 amount) internal {\n require(dst != address(0), \"dst should be valid address\");\n balanceOf_[src] = balanceOf_[src].sub(amount);\n balanceOf_[dst] = balanceOf_[dst].add(amount);\n emit Transfer(src, dst, amount);\n }\n}\n" + }, + "contracts/test/FeeToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./FaucetToken.sol\";\n\n/**\n * @title Fee Token\n * @author Venus\n * @notice A simple test token that charges fees on transfer. Used to mock USDT.\n */\ncontract FeeToken is FaucetToken {\n uint public basisPointFee;\n address public owner;\n\n constructor(\n uint256 _initialAmount,\n string memory _tokenName,\n uint8 _decimalUnits,\n string memory _tokenSymbol,\n uint _basisPointFee,\n address _owner\n ) public FaucetToken(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol) {\n basisPointFee = _basisPointFee;\n owner = _owner;\n }\n\n function transfer(address dst, uint amount) public returns (bool) {\n uint fee = amount.mul(basisPointFee).div(10000);\n uint net = amount.sub(fee);\n balanceOf[owner] = balanceOf[owner].add(fee);\n balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(net);\n emit Transfer(msg.sender, dst, amount);\n return true;\n }\n\n function transferFrom(address src, address dst, uint amount) public returns (bool) {\n uint fee = amount.mul(basisPointFee).div(10000);\n uint net = amount.sub(fee);\n balanceOf[owner] = balanceOf[owner].add(fee);\n balanceOf[src] = balanceOf[src].sub(amount);\n balanceOf[dst] = balanceOf[dst].add(net);\n allowance[src][msg.sender] = allowance[src][msg.sender].sub(amount);\n emit Transfer(src, dst, amount);\n return true;\n }\n}\n" + }, + "contracts/test/FixedPriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Oracle/PriceOracle.sol\";\n\ncontract FixedPriceOracle is PriceOracle {\n uint public price;\n\n constructor(uint _price) public {\n price = _price;\n }\n\n function getUnderlyingPrice(VToken vToken) public view returns (uint) {\n vToken;\n return price;\n }\n\n function assetPrices(address asset) public view returns (uint) {\n asset;\n return price;\n }\n}\n" + }, + "contracts/test/InterestRateModelHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../InterestRateModels/InterestRateModel.sol\";\n\n/**\n * @title An Interest Rate Model for tests that can be instructed to return a failure instead of doing a calculation\n * @author Venus\n */\ncontract InterestRateModelHarness is InterestRateModel {\n uint public constant opaqueBorrowFailureCode = 20;\n bool public failBorrowRate;\n uint public borrowRate;\n\n constructor(uint borrowRate_) public {\n borrowRate = borrowRate_;\n }\n\n function setFailBorrowRate(bool failBorrowRate_) public {\n failBorrowRate = failBorrowRate_;\n }\n\n function setBorrowRate(uint borrowRate_) public {\n borrowRate = borrowRate_;\n }\n\n function getBorrowRate(uint _cash, uint _borrows, uint _reserves) public view returns (uint) {\n _cash; // unused\n _borrows; // unused\n _reserves; // unused\n require(!failBorrowRate, \"INTEREST_RATE_MODEL_ERROR\");\n return borrowRate;\n }\n\n function getSupplyRate(\n uint _cash,\n uint _borrows,\n uint _reserves,\n uint _reserveFactor\n ) external view returns (uint) {\n _cash; // unused\n _borrows; // unused\n _reserves; // unused\n return borrowRate * (1 - _reserveFactor);\n }\n}\n" + }, + "contracts/test/MockDeflationaryToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\n\ncontract DeflatingERC20 {\n using SafeMath for uint;\n\n string public constant name = \"Deflating Test Token\";\n string public constant symbol = \"DTT\";\n uint8 public constant decimals = 18;\n uint public totalSupply;\n mapping(address => uint) public balanceOf;\n mapping(address => mapping(address => uint)) public allowance;\n\n bytes32 public DOMAIN_SEPARATOR;\n // keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;\n mapping(address => uint) public nonces;\n\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n constructor(uint _totalSupply) public {\n uint chainId;\n assembly {\n chainId := chainid()\n }\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n chainId,\n address(this)\n )\n );\n _mint(msg.sender, _totalSupply);\n }\n\n function _mint(address to, uint value) internal {\n totalSupply = totalSupply.add(value);\n balanceOf[to] = balanceOf[to].add(value);\n emit Transfer(address(0), to, value);\n }\n\n function _burn(address from, uint value) internal {\n balanceOf[from] = balanceOf[from].sub(value);\n totalSupply = totalSupply.sub(value);\n emit Transfer(from, address(0), value);\n }\n\n function _approve(address owner, address spender, uint value) private {\n allowance[owner][spender] = value;\n emit Approval(owner, spender, value);\n }\n\n function _transfer(address from, address to, uint value) private {\n uint burnAmount = value / 100;\n _burn(from, burnAmount);\n uint transferAmount = value.sub(burnAmount);\n balanceOf[from] = balanceOf[from].sub(transferAmount);\n balanceOf[to] = balanceOf[to].add(transferAmount);\n emit Transfer(from, to, transferAmount);\n }\n\n function approve(address spender, uint value) external returns (bool) {\n _approve(msg.sender, spender, value);\n return true;\n }\n\n function transfer(address to, uint value) external returns (bool) {\n _transfer(msg.sender, to, value);\n return true;\n }\n\n function transferFrom(address from, address to, uint value) external returns (bool) {\n if (allowance[from][msg.sender] != uint(-1)) {\n allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);\n }\n _transfer(from, to, value);\n return true;\n }\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {\n require(deadline >= block.timestamp, \"EXPIRED\");\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))\n )\n );\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNATURE\");\n _approve(owner, spender, value);\n }\n}\n" + }, + "contracts/test/MockVBNB.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title Venus's vBNB Contract\n * @notice vToken which wraps BNB\n * @author Venus\n */\ncontract MockVBNB is VToken {\n /**\n * @notice Construct a new vBNB money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Send BNB to VBNB to mint\n */\n function() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Reverts upon any failure\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @dev Reverts upon any failure\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow() external payable {\n (uint err, ) = repayBorrowInternal(msg.value);\n requireNoError(err, \"repayBorrow failed\");\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @dev Reverts upon any failure\n * @param borrower The account with the debt being payed off\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower) external payable {\n (uint err, ) = repayBorrowBehalfInternal(borrower, msg.value);\n requireNoError(err, \"repayBorrowBehalf failed\");\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @dev Reverts upon any failure\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(address borrower, VToken vTokenCollateral) external payable {\n (uint err, ) = liquidateBorrowInternal(borrower, msg.value, vTokenCollateral);\n requireNoError(err, \"liquidateBorrow failed\");\n }\n\n function setTotalReserves(uint totalReserves_) external payable {\n totalReserves = totalReserves_;\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Perform the actual transfer in, which is a no-op\n * @param from Address sending the BNB\n * @param amount Amount of BNB being sent\n * @return The actual amount of BNB transferred\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n // Sanity checks\n require(msg.sender == from, \"sender mismatch\");\n require(msg.value == amount, \"value mismatch\");\n return amount;\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n /* Send the BNB, with minimal gas and revert on failure */\n to.transfer(amount);\n }\n\n /**\n * @notice Gets balance of this contract in terms of BNB, before this message\n * @dev This excludes the value of the current message, if any\n * @return The quantity of BNB owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n (MathError err, uint startingBalance) = subUInt(address(this).balance, msg.value);\n require(err == MathError.NO_ERROR, \"cash prior math error\");\n return startingBalance;\n }\n\n function requireNoError(uint errCode, string memory message) internal pure {\n if (errCode == uint(Error.NO_ERROR)) {\n return;\n }\n\n bytes memory fullMessage = new bytes(bytes(message).length + 5);\n uint i;\n\n for (i = 0; i < bytes(message).length; i++) {\n fullMessage[i] = bytes(message)[i];\n }\n\n fullMessage[i + 0] = bytes1(uint8(32));\n fullMessage[i + 1] = bytes1(uint8(40));\n fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10)));\n fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10)));\n fullMessage[i + 4] = bytes1(uint8(41));\n\n require(errCode == uint(Error.NO_ERROR), string(fullMessage));\n }\n\n /**\n * @dev Function to simply retrieve block number\n * This exists mainly for inheriting test contracts to stub this result.\n */\n function getBlockNumber() internal view returns (uint) {\n return block.number;\n }\n\n /**\n * @notice Reduces reserves by transferring to admin\n * @dev Requires fresh interest accrual\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReservesFresh(uint reduceAmount) internal returns (uint) {\n // totalReserves - reduceAmount\n uint totalReservesNew;\n\n // Check caller is admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK);\n }\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != getBlockNumber()) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashPrior() < reduceAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);\n }\n\n // Check reduceAmount ≤ reserves[n] (totalReserves)\n if (reduceAmount > totalReserves) {\n return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n totalReservesNew = totalReserves - reduceAmount;\n\n // Store reserves[n+1] = reserves[n] - reduceAmount\n totalReserves = totalReservesNew;\n\n // // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(admin, reduceAmount);\n\n emit ReservesReduced(admin, reduceAmount, totalReservesNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesReduced event\n function _reduceReserves(uint reduceAmount) external nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.\n return _reduceReservesFresh(reduceAmount);\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n // @custom:event Emits AccrueInterest event\n function accrueInterest() public returns (uint) {\n /* Remember the initial block number */\n uint currentBlockNumber = getBlockNumber();\n uint accrualBlockNumberPrior = accrualBlockNumber;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumberPrior == currentBlockNumber) {\n return uint(Error.NO_ERROR);\n }\n\n /* Read the previous values out of storage */\n uint cashPrior = getCashPrior();\n uint borrowsPrior = totalBorrows;\n uint reservesPrior = totalReserves;\n uint borrowIndexPrior = borrowIndex;\n\n /* Calculate the current borrow interest rate */\n uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior);\n require(borrowRateMantissa <= borrowRateMaxMantissa, \"borrow rate is absurdly high\");\n\n /* Calculate the number of blocks elapsed since the last accrual */\n (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);\n require(mathErr == MathError.NO_ERROR, \"could not calculate block delta\");\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n Exp memory simpleInterestFactor;\n uint interestAccumulated;\n uint totalBorrowsNew;\n uint totalReservesNew;\n uint borrowIndexNew;\n\n (mathErr, simpleInterestFactor) = mulScalar(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n interestAccumulated,\n reservesPrior\n );\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = borrowIndexNew;\n totalBorrows = totalBorrowsNew;\n totalReserves = totalReservesNew;\n\n /* We emit an AccrueInterest event */\n emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);\n\n return uint(Error.NO_ERROR);\n }\n}\n" + }, + "contracts/test/SimplePriceOracle.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Oracle/PriceOracle.sol\";\nimport \"../Tokens/VTokens/VBep20.sol\";\n\ncontract SimplePriceOracle is PriceOracle {\n mapping(address => uint) internal prices;\n event PricePosted(address asset, uint previousPriceMantissa, uint requestedPriceMantissa, uint newPriceMantissa);\n\n function getUnderlyingPrice(VToken vToken) public view returns (uint) {\n if (compareStrings(vToken.symbol(), \"vBNB\")) {\n return 1e18;\n } else if (compareStrings(vToken.symbol(), \"VAI\")) {\n return prices[address(vToken)];\n } else {\n return prices[address(VBep20(address(vToken)).underlying())];\n }\n }\n\n function setUnderlyingPrice(VToken vToken, uint underlyingPriceMantissa) public {\n address asset = address(VBep20(address(vToken)).underlying());\n emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);\n prices[asset] = underlyingPriceMantissa;\n }\n\n function setDirectPrice(address asset, uint price) public {\n emit PricePosted(asset, prices[asset], price, price);\n prices[asset] = price;\n }\n\n // v1 price oracle interface for use as backing of proxy\n function assetPrices(address asset) external view returns (uint) {\n return prices[asset];\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/test/VAIControllerHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VAI/VAIController.sol\";\n\ncontract VAIControllerHarness is VAIController {\n uint public blockNumber;\n uint public blocksPerYear;\n\n constructor() public VAIController() {\n admin = msg.sender;\n }\n\n function setVenusVAIState(uint224 index, uint32 blockNumber_) public {\n venusVAIState.index = index;\n venusVAIState.block = blockNumber_;\n }\n\n function setVAIAddress(address vaiAddress_) public {\n vai = vaiAddress_;\n }\n\n function getVAIAddress() public view returns (address) {\n return vai;\n }\n\n function harnessRepayVAIFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayVAIFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateVAIFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateVAIFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessFastForward(uint blocks) public returns (uint) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function setBlockNumber(uint number) public {\n blockNumber = number;\n }\n\n function setBlocksPerYear(uint number) public {\n blocksPerYear = number;\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBlocksPerYear() public view returns (uint) {\n return blocksPerYear;\n }\n}\n" + }, + "contracts/test/VAIHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VAI/VAI.sol\";\n\ncontract VAIScenario is VAI {\n uint internal blockNumber = 100000;\n\n constructor(uint chainId) public VAI(chainId) {}\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetTotalSupply(uint _totalSupply) public {\n totalSupply = _totalSupply;\n }\n\n function harnessIncrementTotalSupply(uint addtlSupply_) public {\n totalSupply = totalSupply + addtlSupply_;\n }\n\n function harnessSetBalanceOf(address account, uint _amount) public {\n balanceOf[account] = _amount;\n }\n\n function allocateTo(address _owner, uint256 value) public {\n balanceOf[_owner] += value;\n totalSupply += value;\n emit Transfer(address(this), _owner, value);\n }\n}\n" + }, + "contracts/test/VBep20Harness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VBep20Immutable.sol\";\nimport \"../Tokens/VTokens/VBep20Delegator.sol\";\nimport \"../Tokens/VTokens/VBep20Delegate.sol\";\nimport \"./ComptrollerScenario.sol\";\n\ncontract VBep20Harness is VBep20Immutable {\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n mapping(address => bool) public failTransferToAddresses;\n\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n return super.doTransferOut(to, amount);\n }\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n\ncontract VBep20Scenario is VBep20Immutable {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Immutable(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\ncontract VEvil is VBep20Scenario {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n )\n public\n VBep20Scenario(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_\n )\n {}\n\n function evilSeize(VToken treasure, address liquidator, address borrower, uint seizeTokens) public returns (uint) {\n return treasure.seize(liquidator, borrower, seizeTokens);\n }\n}\n\ncontract VBep20DelegatorScenario is VBep20Delegator {\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n )\n public\n VBep20Delegator(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_,\n admin_,\n implementation_,\n becomeImplementationData\n )\n {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n}\n\ncontract VBep20DelegateHarness is VBep20Delegate {\n event Log(string x, address y);\n event Log(string x, uint y);\n\n uint internal blockNumber = 100000;\n uint internal harnessExchangeRate;\n bool internal harnessExchangeRateStored;\n\n mapping(address => bool) public failTransferToAddresses;\n\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n if (harnessExchangeRateStored) {\n return (MathError.NO_ERROR, harnessExchangeRate);\n }\n return super.exchangeRateStoredInternal();\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n require(failTransferToAddresses[to] == false, \"TOKEN_TRANSFER_OUT_FAILED\");\n return super.doTransferOut(to, amount);\n }\n\n function getBlockNumber() internal view returns (uint) {\n return blockNumber;\n }\n\n function getBorrowRateMaxMantissa() public pure returns (uint) {\n return borrowRateMaxMantissa;\n }\n\n function harnessSetBlockNumber(uint newBlockNumber) public {\n blockNumber = newBlockNumber;\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n function harnessSetBalance(address account, uint amount) external {\n accountTokens[account] = amount;\n }\n\n function harnessSetAccrualBlockNumber(uint _accrualblockNumber) public {\n accrualBlockNumber = _accrualblockNumber;\n }\n\n function harnessSetTotalSupply(uint totalSupply_) public {\n totalSupply = totalSupply_;\n }\n\n function harnessSetTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function harnessIncrementTotalBorrows(uint addtlBorrow_) public {\n totalBorrows = totalBorrows + addtlBorrow_;\n }\n\n function harnessSetTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function harnessExchangeRateDetails(uint totalSupply_, uint totalBorrows_, uint totalReserves_) public {\n totalSupply = totalSupply_;\n totalBorrows = totalBorrows_;\n totalReserves = totalReserves_;\n }\n\n function harnessSetExchangeRate(uint exchangeRate) public {\n harnessExchangeRate = exchangeRate;\n harnessExchangeRateStored = true;\n }\n\n function harnessSetFailTransferToAddress(address _to, bool _fail) public {\n failTransferToAddresses[_to] = _fail;\n }\n\n function harnessMintFresh(address account, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintFresh(account, mintAmount);\n return err;\n }\n\n function harnessMintBehalfFresh(address payer, address receiver, uint mintAmount) public returns (uint) {\n (uint err, ) = super.mintBehalfFresh(payer, receiver, mintAmount);\n return err;\n }\n\n function harnessRedeemFresh(\n address payable account,\n uint vTokenAmount,\n uint underlyingAmount\n ) public returns (uint) {\n return super.redeemFresh(account, account, vTokenAmount, underlyingAmount);\n }\n\n function harnessAccountBorrows(address account) public view returns (uint principal, uint interestIndex) {\n BorrowSnapshot memory snapshot = accountBorrows[account];\n return (snapshot.principal, snapshot.interestIndex);\n }\n\n function harnessSetAccountBorrows(address account, uint principal, uint interestIndex) public {\n accountBorrows[account] = BorrowSnapshot({ principal: principal, interestIndex: interestIndex });\n }\n\n function harnessSetBorrowIndex(uint borrowIndex_) public {\n borrowIndex = borrowIndex_;\n }\n\n function harnessBorrowFresh(address payable account, uint borrowAmount) public returns (uint) {\n return borrowFresh(account, account, borrowAmount);\n }\n\n function harnessRepayBorrowFresh(address payer, address account, uint repayAmount) public returns (uint) {\n (uint err, ) = repayBorrowFresh(payer, account, repayAmount);\n return err;\n }\n\n function harnessLiquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VToken vTokenCollateral\n ) public returns (uint) {\n (uint err, ) = liquidateBorrowFresh(liquidator, borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n function harnessReduceReservesFresh(uint amount) public returns (uint) {\n return _reduceReservesFresh(amount);\n }\n\n function harnessSetReserveFactorFresh(uint newReserveFactorMantissa) public returns (uint) {\n return _setReserveFactorFresh(newReserveFactorMantissa);\n }\n\n function harnessSetInterestRateModelFresh(InterestRateModel newInterestRateModel) public returns (uint) {\n return _setInterestRateModelFresh(newInterestRateModel);\n }\n\n function harnessSetInterestRateModel(address newInterestRateModelAddress) public {\n interestRateModel = InterestRateModel(newInterestRateModelAddress);\n }\n\n function harnessCallBorrowAllowed(uint amount) public returns (uint) {\n return comptroller.borrowAllowed(address(this), msg.sender, amount);\n }\n}\n\ncontract VBep20DelegateScenario is VBep20Delegate {\n constructor() public {}\n\n function setTotalBorrows(uint totalBorrows_) public {\n totalBorrows = totalBorrows_;\n }\n\n function setTotalReserves(uint totalReserves_) public {\n totalReserves = totalReserves_;\n }\n\n function getBlockNumber() internal view returns (uint) {\n ComptrollerScenario comptrollerScenario = ComptrollerScenario(address(comptroller));\n return comptrollerScenario.blockNumber();\n }\n}\n\ncontract VBep20DelegateScenarioExtra is VBep20DelegateScenario {\n function iHaveSpoken() public pure returns (string memory) {\n return \"i have spoken\";\n }\n\n function itIsTheWay() public {\n admin = address(1); // make a change to test effect\n }\n\n function babyYoda() public pure {\n revert(\"protect the baby\");\n }\n}\n" + }, + "contracts/test/VBep20MockDelegate.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/VTokens/VToken.sol\";\n\n/**\n * @title Venus's VBep20 Contract\n * @notice VTokens which wrap an EIP-20 underlying\n * @author Venus\n */\ncontract VBep20MockDelegate is VToken, VBep20Interface {\n address public implementation;\n uint internal blockNumber = 100000;\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n */\n function initialize(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n // VToken initialize does the bulk of the work\n super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public {\n // Shh -- currently unused\n data;\n\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _becomeImplementation\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public {\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _resignImplementation\");\n }\n\n function harnessFastForward(uint blocks) public {\n blockNumber += blocks;\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint mintAmount) external returns (uint) {\n (uint err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver the account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n (uint err, ) = mintBehalfInternal(receiver, mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n (uint err, ) = liquidateBorrowInternal(borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n /**\n * @notice The sender adds to reserves.\n * @param addAmount The amount fo underlying token to add as reserves\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addReserves(uint addAmount) external returns (uint) {\n return _addReservesInternal(addAmount);\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n EIP20Interface token = EIP20Interface(underlying);\n return token.balanceOf(address(this));\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);\n uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n token.transferFrom(from, address(this), amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_IN_FAILED\");\n\n // Calculate the amount that was *actually* transferred\n uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address payable to, uint amount) internal {\n EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);\n token.transfer(to, amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a complaint BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_OUT_FAILED\");\n }\n}\n" + }, + "contracts/test/VRTConverterHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/Tokens/VRT/VRTConverter.sol\";\n\ncontract VRTConverterHarness is VRTConverter {\n constructor() public VRTConverter() {\n admin = msg.sender;\n }\n\n function balanceOfUser() public view returns (uint256, address) {\n uint256 vrtBalanceOfUser = vrt.balanceOf(msg.sender);\n return (vrtBalanceOfUser, msg.sender);\n }\n\n function setConversionRatio(uint256 _conversionRatio) public onlyAdmin {\n conversionRatio = _conversionRatio;\n }\n\n function setConversionTimeline(uint256 _conversionStartTime, uint256 _conversionPeriod) public onlyAdmin {\n conversionStartTime = _conversionStartTime;\n conversionPeriod = _conversionPeriod;\n conversionEndTime = conversionStartTime.add(conversionPeriod);\n }\n\n function getXVSRedeemedAmount(uint256 vrtAmount) public view returns (uint256) {\n return vrtAmount.mul(conversionRatio).mul(xvsDecimalsMultiplier).div(1e18).div(vrtDecimalsMultiplier);\n }\n}\n" + }, + "contracts/test/VRTVaultHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/VRTVault/VRTVault.sol\";\n\ncontract VRTVaultHarness is VRTVault {\n uint public blockNumber;\n\n constructor() public VRTVault() {}\n\n function overrideInterestRatePerBlock(uint256 _interestRatePerBlock) public {\n interestRatePerBlock = _interestRatePerBlock;\n }\n\n function balanceOfUser() public view returns (uint256, address) {\n uint256 vrtBalanceOfUser = vrt.balanceOf(msg.sender);\n return (vrtBalanceOfUser, msg.sender);\n }\n\n function harnessFastForward(uint256 blocks) public returns (uint256) {\n blockNumber += blocks;\n return blockNumber;\n }\n\n function setBlockNumber(uint256 number) public {\n blockNumber = number;\n }\n\n function getBlockNumber() public view returns (uint256) {\n return blockNumber;\n }\n}\n" + }, + "contracts/test/XVSHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Tokens/XVS/XVS.sol\";\n\ncontract XVSScenario is XVS {\n constructor(address account) public XVS(account) {}\n\n function transferScenario(address[] calldata destinations, uint256 amount) external returns (bool) {\n for (uint i = 0; i < destinations.length; i++) {\n address dst = destinations[i];\n _transferTokens(msg.sender, dst, uint96(amount));\n }\n return true;\n }\n\n function transferFromScenario(address[] calldata froms, uint256 amount) external returns (bool) {\n for (uint i = 0; i < froms.length; i++) {\n address from = froms[i];\n _transferTokens(from, msg.sender, uint96(amount));\n }\n return true;\n }\n\n function generateCheckpoints(uint count, uint offset) external {\n for (uint i = 1 + offset; i <= count + offset; i++) {\n checkpoints[msg.sender][numCheckpoints[msg.sender]++] = Checkpoint(uint32(i), uint96(i));\n }\n }\n}\n" + }, + "contracts/test/XVSVaultScenario.sol": { + "content": "pragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../XVSVault/XVSVault.sol\";\n\ncontract XVSVaultScenario is XVSVault {\n using SafeMath for uint256;\n\n constructor() public {\n admin = msg.sender;\n }\n\n function pushOldWithdrawalRequest(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests,\n uint _amount,\n uint _lockedUntil\n ) internal {\n uint i = _requests.length;\n _requests.push(WithdrawalRequest(0, 0, 0));\n // Keep it sorted so that the first to get unlocked request is always at the end\n for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) {\n _requests[i] = _requests[i - 1];\n }\n _requests[i] = WithdrawalRequest(_amount, uint128(_lockedUntil), 0);\n _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount);\n }\n\n function requestOldWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant {\n _ensureValidPool(_rewardToken, _pid);\n require(_amount > 0, \"requested amount cannot be zero\");\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n require(user.amount >= user.pendingWithdrawals.add(_amount), \"requested amount is invalid\");\n\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n uint lockedUntil = pool.lockPeriod.add(block.timestamp);\n\n pushOldWithdrawalRequest(user, requests, _amount, lockedUntil);\n\n // Update Delegate Amount\n if (_rewardToken == address(xvsAddress)) {\n _moveDelegates(delegates[msg.sender], address(0), uint96(_amount));\n }\n\n emit RequestedWithdrawal(msg.sender, _rewardToken, _pid, _amount);\n }\n\n function transferReward(address rewardToken, address user, uint256 amount) external {\n _transferReward(rewardToken, user, amount);\n }\n}\n" + }, + "contracts/test/XVSVestingHarness.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../contracts/Tokens/XVS/XVSVesting.sol\";\n\ncontract XVSVestingHarness is XVSVesting {\n address public constant ZERO_ADDRESS = 0x0000000000000000000000000000000000000000;\n\n constructor() public XVSVesting() {\n admin = msg.sender;\n }\n\n uint public blockNumber;\n\n function recoverXVS(address recoveryAddress) public payable {\n uint256 xvsBalance = xvs.balanceOf(address(this));\n xvs.safeTransferFrom(address(this), recoveryAddress, xvsBalance);\n }\n\n function overWriteVRTConversionAddress() public {\n vrtConversionAddress = ZERO_ADDRESS;\n }\n\n function computeWithdrawableAmount(\n uint256 amount,\n uint256 vestingStartTime,\n uint256 withdrawnAmount\n ) public view returns (uint256 vestedAmount, uint256 toWithdraw) {\n (vestedAmount, toWithdraw) = super.calculateWithdrawableAmount(amount, vestingStartTime, withdrawnAmount);\n return (vestedAmount, toWithdraw);\n }\n\n function computeVestedAmount(\n uint256 vestingAmount,\n uint256 vestingStartTime,\n uint256 currentTime\n ) public view returns (uint256) {\n return super.calculateVestedAmount(vestingAmount, vestingStartTime, currentTime);\n }\n\n function getVestingCount(address beneficiary) public view returns (uint256) {\n return vestings[beneficiary].length;\n }\n\n function getVestedAmount(address recipient) public view nonZeroAddress(recipient) returns (uint256) {\n VestingRecord[] memory vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n uint256 totalVestedAmount = 0;\n uint256 currentTime = getCurrentTime();\n\n for (uint i = 0; i < vestingCount; i++) {\n VestingRecord memory vesting = vestingsOfRecipient[i];\n uint256 vestedAmount = calculateVestedAmount(vesting.amount, vesting.startTime, currentTime);\n totalVestedAmount = totalVestedAmount.add(vestedAmount);\n }\n\n return totalVestedAmount;\n }\n}\n" + }, + "contracts/Tokens/EIP20Interface.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title BEP 20 Token Standard Interface\n * https://eips.ethereum.org/EIPS/eip-20\n */\ninterface EIP20Interface {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n /**\n * @notice Get the total number of tokens in circulation\n * @return The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return success whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining The number of tokens allowed to be spent\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/Tokens/EIP20NonStandardInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title EIP20NonStandardInterface\n * @dev Version of BEP20 with no return values for `transfer` and `transferFrom`\n * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\ninterface EIP20NonStandardInterface {\n /**\n * @notice Get the total number of tokens in circulation\n * @return The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance of the owner\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n ///\n /// !!!!!!!!!!!!!!\n /// !!! NOTICE !!! `transfer` does not return a value, in violation of the BEP-20 specification\n /// !!!!!!!!!!!!!!\n ///\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n */\n function transfer(address dst, uint256 amount) external;\n\n ///\n /// !!!!!!!!!!!!!!\n /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the BEP-20 specification\n /// !!!!!!!!!!!!!!\n ///\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n */\n function transferFrom(address src, address dst, uint256 amount) external;\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved\n * @return success Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining The number of tokens allowed to be spent\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/Tokens/Prime/IPrime.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.5.16;\npragma experimental ABIEncoderV2;\n\n/**\n * @title IPrime\n * @author Venus\n * @notice Interface for Prime Token\n */\ninterface IPrime {\n /**\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\n * @param user the account address whose balance was updated\n */\n function xvsUpdated(address user) external;\n\n /**\n * @notice accrues interest and updates score for an user for a specific market\n * @param user the account address for which to accrue interest and update score\n * @param market the market for which to accrue interest and update score\n */\n function accrueInterestAndUpdateScore(address user, address market) external;\n\n /**\n * @notice Distributes income from market since last distribution\n * @param vToken the market for which to distribute the income\n */\n function accrueInterest(address vToken) external;\n\n /**\n * @notice Returns if user is a prime holder\n * @param isPrimeHolder returns if the user is a prime holder\n */\n function isUserPrimeHolder(address user) external view returns (bool isPrimeHolder);\n}\n" + }, + "contracts/Tokens/VAI/lib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.5.16;\n\ncontract LibNote {\n event LogNote(\n bytes4 indexed sig,\n address indexed usr,\n bytes32 indexed arg1,\n bytes32 indexed arg2,\n bytes data\n ) anonymous;\n\n modifier note() {\n _;\n assembly {\n // log an 'anonymous' event with a constant 6 words of calldata\n // and four indexed topics: selector, caller, arg1 and arg2\n let mark := msize() // end of memory ensures zero\n mstore(0x40, add(mark, 288)) // update free memory pointer\n mstore(mark, 0x20) // bytes type data offset\n mstore(add(mark, 0x20), 224) // bytes size (padded)\n calldatacopy(add(mark, 0x40), 0, 224) // bytes payload\n log4(\n mark,\n 288, // calldata\n shl(224, shr(224, calldataload(0))), // msg.sig\n caller(), // msg.sender\n calldataload(4), // arg1\n calldataload(36) // arg2\n )\n }\n }\n}\n" + }, + "contracts/Tokens/VAI/VAI.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n// Copyright (C) 2017, 2018, 2019 dbrock, rain, mrchico\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.5.16;\n\nimport \"./lib.sol\";\n\ncontract VAI is LibNote {\n // --- Auth ---\n mapping(address => uint256) public wards;\n\n function rely(address guy) external note auth {\n wards[guy] = 1;\n }\n\n function deny(address guy) external note auth {\n wards[guy] = 0;\n }\n\n modifier auth() {\n require(wards[msg.sender] == 1, \"VAI/not-authorized\");\n _;\n }\n\n // --- BEP20 Data ---\n string public constant name = \"VAI Stablecoin\";\n string public constant symbol = \"VAI\";\n string public constant version = \"1\";\n uint8 public constant decimals = 18;\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n mapping(address => mapping(address => uint256)) public allowance;\n mapping(address => uint256) public nonces;\n\n event Approval(address indexed src, address indexed guy, uint256 wad);\n event Transfer(address indexed src, address indexed dst, uint256 wad);\n\n // --- Math ---\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x + y) >= x, \"VAI math error\");\n }\n\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x - y) <= x, \"VAI math error\");\n }\n\n // --- EIP712 niceties ---\n bytes32 public DOMAIN_SEPARATOR;\n // bytes32 public constant PERMIT_TYPEHASH = keccak256(\"Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)\");\n bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;\n\n constructor(uint256 chainId_) public {\n wards[msg.sender] = 1;\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(bytes(version)),\n chainId_,\n address(this)\n )\n );\n }\n\n // --- Token ---\n function transfer(address dst, uint256 wad) external returns (bool) {\n return transferFrom(msg.sender, dst, wad);\n }\n\n function transferFrom(address src, address dst, uint256 wad) public returns (bool) {\n require(balanceOf[src] >= wad, \"VAI/insufficient-balance\");\n if (src != msg.sender && allowance[src][msg.sender] != uint256(-1)) {\n require(allowance[src][msg.sender] >= wad, \"VAI/insufficient-allowance\");\n allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);\n }\n balanceOf[src] = sub(balanceOf[src], wad);\n balanceOf[dst] = add(balanceOf[dst], wad);\n emit Transfer(src, dst, wad);\n return true;\n }\n\n function mint(address usr, uint256 wad) external auth {\n balanceOf[usr] = add(balanceOf[usr], wad);\n totalSupply = add(totalSupply, wad);\n emit Transfer(address(0), usr, wad);\n }\n\n function burn(address usr, uint256 wad) external {\n require(balanceOf[usr] >= wad, \"VAI/insufficient-balance\");\n if (usr != msg.sender && allowance[usr][msg.sender] != uint256(-1)) {\n require(allowance[usr][msg.sender] >= wad, \"VAI/insufficient-allowance\");\n allowance[usr][msg.sender] = sub(allowance[usr][msg.sender], wad);\n }\n balanceOf[usr] = sub(balanceOf[usr], wad);\n totalSupply = sub(totalSupply, wad);\n emit Transfer(usr, address(0), wad);\n }\n\n function approve(address usr, uint256 wad) external returns (bool) {\n allowance[msg.sender][usr] = wad;\n emit Approval(msg.sender, usr, wad);\n return true;\n }\n\n // --- Alias ---\n function push(address usr, uint256 wad) external {\n transferFrom(msg.sender, usr, wad);\n }\n\n function pull(address usr, uint256 wad) external {\n transferFrom(usr, msg.sender, wad);\n }\n\n function move(address src, address dst, uint256 wad) external {\n transferFrom(src, dst, wad);\n }\n\n // --- Approve by signature ---\n function permit(\n address holder,\n address spender,\n uint256 nonce,\n uint256 expiry,\n bool allowed,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(abi.encode(PERMIT_TYPEHASH, holder, spender, nonce, expiry, allowed))\n )\n );\n\n require(holder != address(0), \"VAI/invalid-address-0\");\n require(holder == ecrecover(digest, v, r, s), \"VAI/invalid-permit\");\n require(expiry == 0 || now <= expiry, \"VAI/permit-expired\");\n require(nonce == nonces[holder]++, \"VAI/invalid-nonce\");\n uint256 wad = allowed ? uint256(-1) : 0;\n allowance[holder][spender] = wad;\n emit Approval(holder, spender, wad);\n }\n}\n" + }, + "contracts/Tokens/VAI/VAIController.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.5.16;\n\nimport { PriceOracle } from \"../../Oracle/PriceOracle.sol\";\nimport { VAIControllerErrorReporter } from \"../../Utils/ErrorReporter.sol\";\nimport { Exponential } from \"../../Utils/Exponential.sol\";\nimport { ComptrollerInterface } from \"../../Comptroller/ComptrollerInterface.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\nimport { VToken, EIP20Interface } from \"../VTokens/VToken.sol\";\nimport { VAIUnitroller, VAIControllerStorageG4 } from \"./VAIUnitroller.sol\";\nimport { VAIControllerInterface } from \"./VAIControllerInterface.sol\";\nimport { VAI } from \"./VAI.sol\";\nimport { IPrime } from \"../Prime/IPrime.sol\";\nimport { VTokenInterface } from \"../VTokens/VTokenInterfaces.sol\";\n\n/**\n * @title VAI Comptroller\n * @author Venus\n * @notice This is the implementation contract for the VAIUnitroller proxy\n */\ncontract VAIController is VAIControllerInterface, VAIControllerStorageG4, VAIControllerErrorReporter, Exponential {\n /// @notice Initial index used in interest computations\n uint256 public constant INITIAL_VAI_MINT_INDEX = 1e18;\n\n /// @notice Emitted when Comptroller is changed\n event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);\n\n /// @notice Emitted when mint for prime holder is changed\n event MintOnlyForPrimeHolder(bool previousMintEnabledOnlyForPrimeHolder, bool newMintEnabledOnlyForPrimeHolder);\n\n /// @notice Emitted when Prime is changed\n event NewPrime(address oldPrime, address newPrime);\n\n /// @notice Event emitted when VAI is minted\n event MintVAI(address minter, uint256 mintVAIAmount);\n\n /// @notice Event emitted when VAI is repaid\n event RepayVAI(address payer, address borrower, uint256 repayVAIAmount);\n\n /// @notice Event emitted when a borrow is liquidated\n event LiquidateVAI(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address vTokenCollateral,\n uint256 seizeTokens\n );\n\n /// @notice Emitted when treasury guardian is changed\n event NewTreasuryGuardian(address oldTreasuryGuardian, address newTreasuryGuardian);\n\n /// @notice Emitted when treasury address is changed\n event NewTreasuryAddress(address oldTreasuryAddress, address newTreasuryAddress);\n\n /// @notice Emitted when treasury percent is changed\n event NewTreasuryPercent(uint256 oldTreasuryPercent, uint256 newTreasuryPercent);\n\n /// @notice Event emitted when VAIs are minted and fee are transferred\n event MintFee(address minter, uint256 feeAmount);\n\n /// @notice Emiitted when VAI base rate is changed\n event NewVAIBaseRate(uint256 oldBaseRateMantissa, uint256 newBaseRateMantissa);\n\n /// @notice Emiitted when VAI float rate is changed\n event NewVAIFloatRate(uint256 oldFloatRateMantissa, uint256 newFlatRateMantissa);\n\n /// @notice Emiitted when VAI receiver address is changed\n event NewVAIReceiver(address oldReceiver, address newReceiver);\n\n /// @notice Emiitted when VAI mint cap is changed\n event NewVAIMintCap(uint256 oldMintCap, uint256 newMintCap);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControl(address oldAccessControlAddress, address newAccessControlAddress);\n\n /// @notice Emitted when VAI token address is changed by admin\n event NewVaiToken(address oldVaiToken, address newVaiToken);\n\n function initialize() external onlyAdmin {\n require(vaiMintIndex == 0, \"already initialized\");\n\n vaiMintIndex = INITIAL_VAI_MINT_INDEX;\n accrualBlockNumber = getBlockNumber();\n mintCap = uint256(-1);\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n function _become(VAIUnitroller unitroller) external {\n require(msg.sender == unitroller.admin(), \"only unitroller admin can change brains\");\n require(unitroller._acceptImplementation() == 0, \"change not authorized\");\n }\n\n /**\n * @notice The mintVAI function mints and transfers VAI from the protocol to the user, and adds a borrow balance.\n * The amount minted must be less than the user's Account Liquidity and the mint vai limit.\n * @dev If the Comptroller address is not set, minting is a no-op and the function returns the success code.\n * @param mintVAIAmount The amount of the VAI to be minted.\n * @return 0 on success, otherwise an error code\n */\n // solhint-disable-next-line code-complexity\n function mintVAI(uint256 mintVAIAmount) external nonReentrant returns (uint256) {\n if (address(comptroller) == address(0)) {\n return uint256(Error.NO_ERROR);\n }\n\n _ensureNonzeroAmount(mintVAIAmount);\n _ensureNotPaused();\n accrueVAIInterest();\n\n uint256 err;\n address minter = msg.sender;\n address _vai = vai;\n uint256 vaiTotalSupply = EIP20Interface(_vai).totalSupply();\n\n uint256 vaiNewTotalSupply = add_(vaiTotalSupply, mintVAIAmount);\n require(vaiNewTotalSupply <= mintCap, \"mint cap reached\");\n\n uint256 accountMintableVAI;\n (err, accountMintableVAI) = getMintableVAI(minter);\n require(err == uint256(Error.NO_ERROR), \"could not compute mintable amount\");\n\n // check that user have sufficient mintableVAI balance\n require(mintVAIAmount <= accountMintableVAI, \"minting more than allowed\");\n\n // Calculate the minted balance based on interest index\n uint256 totalMintedVAI = comptroller.mintedVAIs(minter);\n\n if (totalMintedVAI > 0) {\n uint256 repayAmount = getVAIRepayAmount(minter);\n uint256 remainedAmount = sub_(repayAmount, totalMintedVAI);\n pastVAIInterest[minter] = add_(pastVAIInterest[minter], remainedAmount);\n totalMintedVAI = repayAmount;\n }\n\n uint256 accountMintVAINew = add_(totalMintedVAI, mintVAIAmount);\n err = comptroller.setMintedVAIOf(minter, accountMintVAINew);\n require(err == uint256(Error.NO_ERROR), \"comptroller rejection\");\n\n uint256 remainedAmount;\n if (treasuryPercent != 0) {\n uint256 feeAmount = div_(mul_(mintVAIAmount, treasuryPercent), 1e18);\n remainedAmount = sub_(mintVAIAmount, feeAmount);\n VAI(_vai).mint(treasuryAddress, feeAmount);\n\n emit MintFee(minter, feeAmount);\n } else {\n remainedAmount = mintVAIAmount;\n }\n\n VAI(_vai).mint(minter, remainedAmount);\n vaiMinterInterestIndex[minter] = vaiMintIndex;\n\n emit MintVAI(minter, remainedAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice The repay function transfers VAI interest into the protocol and burns the rest,\n * reducing the borrower's borrow balance. Before repaying VAI, users must first approve\n * VAIController to access their VAI balance.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAI(uint256 amount) external nonReentrant returns (uint256, uint256) {\n return _repayVAI(msg.sender, amount);\n }\n\n /**\n * @notice The repay on behalf function transfers VAI interest into the protocol and burns the rest,\n * reducing the borrower's borrow balance. Borrowed VAIs are repaid by another user (possibly the borrower).\n * Before repaying VAI, the payer must first approve VAIController to access their VAI balance.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param borrower The account to repay the debt for.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAIBehalf(address borrower, uint256 amount) external nonReentrant returns (uint256, uint256) {\n _ensureNonzeroAddress(borrower);\n return _repayVAI(borrower, amount);\n }\n\n /**\n * @dev Checks the parameters and the protocol state, accrues interest, and invokes repayVAIFresh.\n * @dev If the Comptroller address is not set, repayment is a no-op and the function returns the success code.\n * @param borrower The account to repay the debt for.\n * @param amount The amount of VAI to be repaid.\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function _repayVAI(address borrower, uint256 amount) internal returns (uint256, uint256) {\n if (address(comptroller) == address(0)) {\n return (0, 0);\n }\n _ensureNonzeroAmount(amount);\n _ensureNotPaused();\n\n accrueVAIInterest();\n return repayVAIFresh(msg.sender, borrower, amount);\n }\n\n /**\n * @dev Repay VAI, expecting interest to be accrued\n * @dev Borrowed VAIs are repaid by another user (possibly the borrower).\n * @param payer the account paying off the VAI\n * @param borrower the account with the debt being payed off\n * @param repayAmount the amount of VAI being repaid\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function repayVAIFresh(address payer, address borrower, uint256 repayAmount) internal returns (uint256, uint256) {\n (uint256 burn, uint256 partOfCurrentInterest, uint256 partOfPastInterest) = getVAICalculateRepayAmount(\n borrower,\n repayAmount\n );\n\n VAI _vai = VAI(vai);\n _vai.burn(payer, burn);\n bool success = _vai.transferFrom(payer, receiver, partOfCurrentInterest);\n require(success == true, \"failed to transfer VAI fee\");\n\n uint256 vaiBalanceBorrower = comptroller.mintedVAIs(borrower);\n\n uint256 accountVAINew = sub_(sub_(vaiBalanceBorrower, burn), partOfPastInterest);\n pastVAIInterest[borrower] = sub_(pastVAIInterest[borrower], partOfPastInterest);\n\n uint256 error = comptroller.setMintedVAIOf(borrower, accountVAINew);\n // We have to revert upon error since side-effects already happened at this point\n require(error == uint256(Error.NO_ERROR), \"comptroller rejection\");\n\n uint256 repaidAmount = add_(burn, partOfCurrentInterest);\n emit RepayVAI(payer, borrower, repaidAmount);\n\n return (uint256(Error.NO_ERROR), repaidAmount);\n }\n\n /**\n * @notice The sender liquidates the vai minters collateral. The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of vai to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external nonReentrant returns (uint256, uint256) {\n _ensureNotPaused();\n\n uint256 error = vTokenCollateral.accrueInterest();\n if (error != uint256(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.VAI_LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0);\n }\n\n // liquidateVAIFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateVAIFresh(msg.sender, borrower, repayAmount, vTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral by repay borrowers VAI.\n * The collateral seized is transferred to the liquidator.\n * @dev If the Comptroller address is not set, liquidation is a no-op and the function returns the success code.\n * @param liquidator The address repaying the VAI and seizing collateral\n * @param borrower The borrower of this VAI to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the VAI to repay\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol)\n * @return Actual repayment amount\n */\n function liquidateVAIFresh(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) internal returns (uint256, uint256) {\n if (address(comptroller) != address(0)) {\n accrueVAIInterest();\n\n /* Fail if liquidate not allowed */\n uint256 allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify vTokenCollateral market's block number equals current block number */\n //if (vTokenCollateral.accrualBlockNumber() != accrualBlockNumber) {\n if (vTokenCollateral.accrualBlockNumber() != getBlockNumber()) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == uint256(-1)) {\n return (fail(Error.REJECTION, FailureInfo.VAI_LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayVAI fails */\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayVAIFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.VAI_LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateVAICalculateSeizeTokens(\n address(vTokenCollateral),\n actualRepayAmount\n );\n require(\n amountSeizeError == uint256(Error.NO_ERROR),\n \"VAI_LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\"\n );\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(vTokenCollateral.balanceOf(borrower) >= seizeTokens, \"VAI_LIQUIDATE_SEIZE_TOO_MUCH\");\n\n uint256 seizeError;\n seizeError = vTokenCollateral.seize(liquidator, borrower, seizeTokens);\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint256(Error.NO_ERROR), \"token seizure failed\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateVAI(liquidator, borrower, actualRepayAmount, address(vTokenCollateral), seizeTokens);\n\n /* We call the defense hook */\n comptroller.liquidateBorrowVerify(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n actualRepayAmount,\n seizeTokens\n );\n\n return (uint256(Error.NO_ERROR), actualRepayAmount);\n }\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Sets a new comptroller\n * @dev Admin function to set a new comptroller\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setComptroller(ComptrollerInterface comptroller_) external returns (uint256) {\n // Check caller is admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK);\n }\n\n ComptrollerInterface oldComptroller = comptroller;\n comptroller = comptroller_;\n emit NewComptroller(oldComptroller, comptroller_);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Set the prime token contract address\n * @param prime_ The new address of the prime token contract\n */\n function setPrimeToken(address prime_) external onlyAdmin {\n emit NewPrime(prime, prime_);\n prime = prime_;\n }\n\n /**\n * @notice Set the VAI token contract address\n * @param vai_ The new address of the VAI token contract\n */\n function setVAIToken(address vai_) external onlyAdmin {\n emit NewVaiToken(vai, vai_);\n vai = vai_;\n }\n\n /**\n * @notice Toggle mint only for prime holder\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function toggleOnlyPrimeHolderMint() external returns (uint256) {\n _ensureAllowed(\"toggleOnlyPrimeHolderMint()\");\n\n if (!mintEnabledOnlyForPrimeHolder && prime == address(0)) {\n return uint256(Error.REJECTION);\n }\n\n emit MintOnlyForPrimeHolder(mintEnabledOnlyForPrimeHolder, !mintEnabledOnlyForPrimeHolder);\n mintEnabledOnlyForPrimeHolder = !mintEnabledOnlyForPrimeHolder;\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account total supply balance.\n * Note that `vTokenBalance` is the number of vTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountAmountLocalVars {\n uint256 oErr;\n MathError mErr;\n uint256 sumSupply;\n uint256 marketSupply;\n uint256 sumBorrowPlusEffects;\n uint256 vTokenBalance;\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n uint256 oraclePriceMantissa;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n }\n\n /**\n * @notice Function that returns the amount of VAI a user can mint based on their account liquidy and the VAI mint rate\n * If mintEnabledOnlyForPrimeHolder is true, only Prime holders are able to mint VAI\n * @param minter The account to check mintable VAI\n * @return Error code (0=success, otherwise a failure, see ErrorReporter.sol for details)\n * @return Mintable amount (with 18 decimals)\n */\n // solhint-disable-next-line code-complexity\n function getMintableVAI(address minter) public view returns (uint256, uint256) {\n if (mintEnabledOnlyForPrimeHolder && !IPrime(prime).isUserPrimeHolder(minter)) {\n return (uint256(Error.REJECTION), 0);\n }\n\n PriceOracle oracle = comptroller.oracle();\n VToken[] memory enteredMarkets = comptroller.getAssetsIn(minter);\n\n AccountAmountLocalVars memory vars; // Holds all our calculation results\n\n uint256 accountMintableVAI;\n uint256 i;\n\n /**\n * We use this formula to calculate mintable VAI amount.\n * totalSupplyAmount * VAIMintRate - (totalBorrowAmount + mintedVAIOf)\n */\n uint256 marketsCount = enteredMarkets.length;\n for (i = 0; i < marketsCount; i++) {\n (vars.oErr, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = enteredMarkets[i]\n .getAccountSnapshot(minter);\n if (vars.oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (uint256(Error.SNAPSHOT_ERROR), 0);\n }\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(enteredMarkets[i]);\n if (vars.oraclePriceMantissa == 0) {\n return (uint256(Error.PRICE_ERROR), 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n (vars.mErr, vars.tokensToDenom) = mulExp(vars.exchangeRate, vars.oraclePrice);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n // marketSupply = tokensToDenom * vTokenBalance\n (vars.mErr, vars.marketSupply) = mulScalarTruncate(vars.tokensToDenom, vars.vTokenBalance);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (, uint256 collateralFactorMantissa) = comptroller.markets(address(enteredMarkets[i]));\n (vars.mErr, vars.marketSupply) = mulUInt(vars.marketSupply, collateralFactorMantissa);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, vars.marketSupply) = divUInt(vars.marketSupply, 1e18);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, vars.sumSupply) = addUInt(vars.sumSupply, vars.marketSupply);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n (vars.mErr, vars.sumBorrowPlusEffects) = mulScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n }\n\n uint256 totalMintedVAI = comptroller.mintedVAIs(minter);\n uint256 repayAmount = 0;\n\n if (totalMintedVAI > 0) {\n repayAmount = getVAIRepayAmount(minter);\n }\n\n (vars.mErr, vars.sumBorrowPlusEffects) = addUInt(vars.sumBorrowPlusEffects, repayAmount);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.MATH_ERROR), 0);\n }\n\n (vars.mErr, accountMintableVAI) = mulUInt(vars.sumSupply, comptroller.vaiMintRate());\n require(vars.mErr == MathError.NO_ERROR, \"VAI_MINT_AMOUNT_CALCULATION_FAILED\");\n\n (vars.mErr, accountMintableVAI) = divUInt(accountMintableVAI, 10000);\n require(vars.mErr == MathError.NO_ERROR, \"VAI_MINT_AMOUNT_CALCULATION_FAILED\");\n\n (vars.mErr, accountMintableVAI) = subUInt(accountMintableVAI, vars.sumBorrowPlusEffects);\n if (vars.mErr != MathError.NO_ERROR) {\n return (uint256(Error.REJECTION), 0);\n }\n\n return (uint256(Error.NO_ERROR), accountMintableVAI);\n }\n\n /**\n * @notice Update treasury data\n * @param newTreasuryGuardian New Treasury Guardian address\n * @param newTreasuryAddress New Treasury Address\n * @param newTreasuryPercent New fee percentage for minting VAI that is sent to the treasury\n */\n function _setTreasuryData(\n address newTreasuryGuardian,\n address newTreasuryAddress,\n uint256 newTreasuryPercent\n ) external returns (uint256) {\n // Check caller is admin\n if (!(msg.sender == admin || msg.sender == treasuryGuardian)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_TREASURY_OWNER_CHECK);\n }\n\n require(newTreasuryPercent < 1e18, \"treasury percent cap overflow\");\n\n address oldTreasuryGuardian = treasuryGuardian;\n address oldTreasuryAddress = treasuryAddress;\n uint256 oldTreasuryPercent = treasuryPercent;\n\n treasuryGuardian = newTreasuryGuardian;\n treasuryAddress = newTreasuryAddress;\n treasuryPercent = newTreasuryPercent;\n\n emit NewTreasuryGuardian(oldTreasuryGuardian, newTreasuryGuardian);\n emit NewTreasuryAddress(oldTreasuryAddress, newTreasuryAddress);\n emit NewTreasuryPercent(oldTreasuryPercent, newTreasuryPercent);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Gets yearly VAI interest rate based on the VAI price\n * @return uint256 Yearly VAI interest rate\n */\n function getVAIRepayRate() public view returns (uint256) {\n PriceOracle oracle = comptroller.oracle();\n MathError mErr;\n\n if (baseRateMantissa > 0) {\n if (floatRateMantissa > 0) {\n uint256 oraclePrice = oracle.getUnderlyingPrice(VToken(getVAIAddress()));\n if (1e18 > oraclePrice) {\n uint256 delta;\n uint256 rate;\n\n (mErr, delta) = subUInt(1e18, oraclePrice);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, delta) = mulUInt(delta, floatRateMantissa);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, delta) = divUInt(delta, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n (mErr, rate) = addUInt(delta, baseRateMantissa);\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n return rate;\n } else {\n return baseRateMantissa;\n }\n } else {\n return baseRateMantissa;\n }\n } else {\n return 0;\n }\n }\n\n /**\n * @notice Get interest rate per block\n * @return uint256 Interest rate per bock\n */\n function getVAIRepayRatePerBlock() public view returns (uint256) {\n uint256 yearlyRate = getVAIRepayRate();\n\n MathError mErr;\n uint256 rate;\n\n (mErr, rate) = divUInt(yearlyRate, getBlocksPerYear());\n require(mErr == MathError.NO_ERROR, \"VAI_REPAY_RATE_CALCULATION_FAILED\");\n\n return rate;\n }\n\n /**\n * @notice Get the last updated interest index for a VAI Minter\n * @param minter Address of VAI minter\n * @return uint256 Returns the interest rate index for a minter\n */\n function getVAIMinterInterestIndex(address minter) public view returns (uint256) {\n uint256 storedIndex = vaiMinterInterestIndex[minter];\n // If the user minted VAI before the stability fee was introduced, accrue\n // starting from stability fee launch\n if (storedIndex == 0) {\n return INITIAL_VAI_MINT_INDEX;\n }\n return storedIndex;\n }\n\n /**\n * @notice Get the current total VAI a user needs to repay\n * @param account The address of the VAI borrower\n * @return (uint256) The total amount of VAI the user needs to repay\n */\n function getVAIRepayAmount(address account) public view returns (uint256) {\n MathError mErr;\n uint256 delta;\n\n uint256 amount = comptroller.mintedVAIs(account);\n uint256 interest = pastVAIInterest[account];\n uint256 totalMintedVAI;\n uint256 newInterest;\n\n (mErr, totalMintedVAI) = subUInt(amount, interest);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, delta) = subUInt(vaiMintIndex, getVAIMinterInterestIndex(account));\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, newInterest) = mulUInt(delta, totalMintedVAI);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, newInterest) = divUInt(newInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, amount) = addUInt(amount, newInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_TOTAL_REPAY_AMOUNT_CALCULATION_FAILED\");\n\n return amount;\n }\n\n /**\n * @notice Calculate how much VAI the user needs to repay\n * @param borrower The address of the VAI borrower\n * @param repayAmount The amount of VAI being returned\n * @return Amount of VAI to be burned\n * @return Amount of VAI the user needs to pay in current interest\n * @return Amount of VAI the user needs to pay in past interest\n */\n function getVAICalculateRepayAmount(\n address borrower,\n uint256 repayAmount\n ) public view returns (uint256, uint256, uint256) {\n MathError mErr;\n uint256 totalRepayAmount = getVAIRepayAmount(borrower);\n uint256 currentInterest;\n\n (mErr, currentInterest) = subUInt(totalRepayAmount, comptroller.mintedVAIs(borrower));\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, currentInterest) = addUInt(pastVAIInterest[borrower], currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n uint256 burn;\n uint256 partOfCurrentInterest = currentInterest;\n uint256 partOfPastInterest = pastVAIInterest[borrower];\n\n if (repayAmount >= totalRepayAmount) {\n (mErr, burn) = subUInt(totalRepayAmount, currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n } else {\n uint256 delta;\n\n (mErr, delta) = mulUInt(repayAmount, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_PART_CALCULATION_FAILED\");\n\n (mErr, delta) = divUInt(delta, totalRepayAmount);\n require(mErr == MathError.NO_ERROR, \"VAI_PART_CALCULATION_FAILED\");\n\n uint256 totalMintedAmount;\n (mErr, totalMintedAmount) = subUInt(totalRepayAmount, currentInterest);\n require(mErr == MathError.NO_ERROR, \"VAI_MINTED_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, burn) = mulUInt(totalMintedAmount, delta);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, burn) = divUInt(burn, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_BURN_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfCurrentInterest) = mulUInt(currentInterest, delta);\n require(mErr == MathError.NO_ERROR, \"VAI_CURRENT_INTEREST_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfCurrentInterest) = divUInt(partOfCurrentInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_CURRENT_INTEREST_AMOUNT_CALCULATION_FAILED\");\n\n (mErr, partOfPastInterest) = mulUInt(pastVAIInterest[borrower], delta);\n require(mErr == MathError.NO_ERROR, \"VAI_PAST_INTEREST_CALCULATION_FAILED\");\n\n (mErr, partOfPastInterest) = divUInt(partOfPastInterest, 1e18);\n require(mErr == MathError.NO_ERROR, \"VAI_PAST_INTEREST_CALCULATION_FAILED\");\n }\n\n return (burn, partOfCurrentInterest, partOfPastInterest);\n }\n\n /**\n * @notice Accrue interest on outstanding minted VAI\n */\n function accrueVAIInterest() public {\n MathError mErr;\n uint256 delta;\n\n (mErr, delta) = mulUInt(getVAIRepayRatePerBlock(), getBlockNumber() - accrualBlockNumber);\n require(mErr == MathError.NO_ERROR, \"VAI_INTEREST_ACCRUE_FAILED\");\n\n (mErr, delta) = addUInt(delta, vaiMintIndex);\n require(mErr == MathError.NO_ERROR, \"VAI_INTEREST_ACCRUE_FAILED\");\n\n vaiMintIndex = delta;\n accrualBlockNumber = getBlockNumber();\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _ensureNonzeroAddress(newAccessControlAddress);\n\n address oldAccessControlAddress = accessControl;\n accessControl = newAccessControlAddress;\n emit NewAccessControl(oldAccessControlAddress, accessControl);\n }\n\n /**\n * @notice Set VAI borrow base rate\n * @param newBaseRateMantissa the base rate multiplied by 10**18\n */\n function setBaseRate(uint256 newBaseRateMantissa) external {\n _ensureAllowed(\"setBaseRate(uint256)\");\n\n uint256 old = baseRateMantissa;\n baseRateMantissa = newBaseRateMantissa;\n emit NewVAIBaseRate(old, baseRateMantissa);\n }\n\n /**\n * @notice Set VAI borrow float rate\n * @param newFloatRateMantissa the VAI float rate multiplied by 10**18\n */\n function setFloatRate(uint256 newFloatRateMantissa) external {\n _ensureAllowed(\"setFloatRate(uint256)\");\n\n uint256 old = floatRateMantissa;\n floatRateMantissa = newFloatRateMantissa;\n emit NewVAIFloatRate(old, floatRateMantissa);\n }\n\n /**\n * @notice Set VAI stability fee receiver address\n * @param newReceiver the address of the VAI fee receiver\n */\n function setReceiver(address newReceiver) external onlyAdmin {\n _ensureNonzeroAddress(newReceiver);\n\n address old = receiver;\n receiver = newReceiver;\n emit NewVAIReceiver(old, newReceiver);\n }\n\n /**\n * @notice Set VAI mint cap\n * @param _mintCap the amount of VAI that can be minted\n */\n function setMintCap(uint256 _mintCap) external {\n _ensureAllowed(\"setMintCap(uint256)\");\n\n uint256 old = mintCap;\n mintCap = _mintCap;\n emit NewVAIMintCap(old, _mintCap);\n }\n\n function getBlockNumber() internal view returns (uint256) {\n return block.number;\n }\n\n function getBlocksPerYear() public view returns (uint256) {\n return 10512000; //(24 * 60 * 60 * 365) / 3;\n }\n\n /**\n * @notice Return the address of the VAI token\n * @return The address of VAI\n */\n function getVAIAddress() public view returns (address) {\n return vai;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n function _ensureAllowed(string memory functionSig) private view {\n require(IAccessControlManagerV5(accessControl).isAllowedToCall(msg.sender, functionSig), \"access denied\");\n }\n\n /// @dev Reverts if the protocol is paused\n function _ensureNotPaused() private view {\n require(!comptroller.protocolPaused(), \"protocol is paused\");\n }\n\n /// @dev Reverts if the passed address is zero\n function _ensureNonzeroAddress(address someone) private pure {\n require(someone != address(0), \"can't be zero address\");\n }\n\n /// @dev Reverts if the passed amount is zero\n function _ensureNonzeroAmount(uint256 amount) private pure {\n require(amount > 0, \"amount can't be zero\");\n }\n}\n" + }, + "contracts/Tokens/VAI/VAIControllerInterface.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VTokenInterface } from \"../VTokens/VTokenInterfaces.sol\";\n\ncontract VAIControllerInterface {\n function mintVAI(uint256 mintVAIAmount) external returns (uint256);\n\n function repayVAI(uint256 amount) external returns (uint256, uint256);\n\n function repayVAIBehalf(address borrower, uint256 amount) external returns (uint256, uint256);\n\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint256, uint256);\n\n function getMintableVAI(address minter) external view returns (uint256, uint256);\n\n function getVAIAddress() external view returns (address);\n\n function getVAIRepayAmount(address account) external view returns (uint256);\n}\n" + }, + "contracts/Tokens/VAI/VAIControllerStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { ComptrollerInterface } from \"../../Comptroller/ComptrollerInterface.sol\";\n\ncontract VAIUnitrollerAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of Unitroller\n */\n address public vaiControllerImplementation;\n\n /**\n * @notice Pending brains of Unitroller\n */\n address public pendingVAIControllerImplementation;\n}\n\ncontract VAIControllerStorageG1 is VAIUnitrollerAdminStorage {\n ComptrollerInterface public comptroller;\n\n struct VenusVAIState {\n /// @notice The last updated venusVAIMintIndex\n uint224 index;\n /// @notice The block number the index was last updated at\n uint32 block;\n }\n\n /// @notice The Venus VAI state\n VenusVAIState public venusVAIState;\n\n /// @notice The Venus VAI state initialized\n bool public isVenusVAIInitialized;\n\n /// @notice The Venus VAI minter index as of the last time they accrued XVS\n mapping(address => uint256) public venusVAIMinterIndex;\n}\n\ncontract VAIControllerStorageG2 is VAIControllerStorageG1 {\n /// @notice Treasury Guardian address\n address public treasuryGuardian;\n\n /// @notice Treasury address\n address public treasuryAddress;\n\n /// @notice Fee percent of accrued interest with decimal 18\n uint256 public treasuryPercent;\n\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice The base rate for stability fee\n uint256 public baseRateMantissa;\n\n /// @notice The float rate for stability fee\n uint256 public floatRateMantissa;\n\n /// @notice The address for VAI interest receiver\n address public receiver;\n\n /// @notice Accumulator of the total earned interest rate since the opening of the market. For example: 0.6 (60%)\n uint256 public vaiMintIndex;\n\n /// @notice Block number that interest was last accrued at\n uint256 internal accrualBlockNumber;\n\n /// @notice Global vaiMintIndex as of the most recent balance-changing action for user\n mapping(address => uint256) internal vaiMinterInterestIndex;\n\n /// @notice Tracks the amount of mintedVAI of a user that represents the accrued interest\n mapping(address => uint256) public pastVAIInterest;\n\n /// @notice VAI mint cap\n uint256 public mintCap;\n\n /// @notice Access control manager address\n address public accessControl;\n}\n\ncontract VAIControllerStorageG3 is VAIControllerStorageG2 {\n /// @notice The address of the prime contract. It can be a ZERO address\n address public prime;\n\n /// @notice Tracks if minting is enabled only for prime token holders. Only used if prime is set\n bool public mintEnabledOnlyForPrimeHolder;\n}\n\ncontract VAIControllerStorageG4 is VAIControllerStorageG3 {\n /// @notice The address of the VAI token\n address internal vai;\n}\n" + }, + "contracts/Tokens/VAI/VAIUnitroller.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/ErrorReporter.sol\";\nimport \"./VAIControllerStorage.sol\";\n\n/**\n * @title VAI Unitroller\n * @author Venus\n * @notice This is the proxy contract for the VAIComptroller\n */\ncontract VAIUnitroller is VAIUnitrollerAdminStorage, VAIControllerErrorReporter {\n /**\n * @notice Emitted when pendingVAIControllerImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingVAIControllerImplementation is accepted, which means comptroller implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint256) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingVAIControllerImplementation;\n\n pendingVAIControllerImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIControllerImplementation);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint256) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingVAIControllerImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = vaiControllerImplementation;\n address oldPendingImplementation = pendingVAIControllerImplementation;\n\n vaiControllerImplementation = pendingVAIControllerImplementation;\n\n pendingVAIControllerImplementation = address(0);\n\n emit NewImplementation(oldImplementation, vaiControllerImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIControllerImplementation);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint256 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint256) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = vaiControllerImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/VRT/VRT.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/Tokenlock.sol\";\n\ncontract VRT is Tokenlock {\n /// @notice BEP-20 token name for this token\n string public constant name = \"Venus Reward Token\";\n\n /// @notice BEP-20 token symbol for this token\n string public constant symbol = \"VRT\";\n\n /// @notice BEP-20 token decimals for this token\n uint8 public constant decimals = 18;\n\n /// @notice Total number of tokens in circulation\n uint public constant totalSupply = 30000000000e18; // 30 billion VRT\n\n /// @notice Allowance amounts on behalf of others\n mapping(address => mapping(address => uint96)) internal allowances;\n\n /// @notice Official record of token balances for each account\n mapping(address => uint96) internal balances;\n\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A checkpoint for marking number of votes from a given block\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice The standard BEP-20 transfer event\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /// @notice The standard BEP-20 approval event\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Construct a new VRT token\n * @param account The initial account to grant all the tokens\n */\n constructor(address account) public {\n balances[account] = uint96(totalSupply);\n emit Transfer(address(0), account, totalSupply);\n }\n\n /**\n * @notice Get the number of tokens `spender` is approved to spend on behalf of `account`\n * @param account The address of the account holding the funds\n * @param spender The address of the account spending the funds\n * @return The number of tokens approved\n */\n function allowance(address account, address spender) external view returns (uint) {\n return allowances[account][spender];\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param rawAmount The number of tokens that are approved (2^256-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint rawAmount) external validLock returns (bool) {\n uint96 amount;\n if (rawAmount == uint(-1)) {\n amount = uint96(-1);\n } else {\n amount = safe96(rawAmount, \"VRT::approve: amount exceeds 96 bits\");\n }\n\n allowances[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the number of tokens held by the `account`\n * @param account The address of the account to get the balance of\n * @return The number of tokens held\n */\n function balanceOf(address account) external view returns (uint) {\n return balances[account];\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint rawAmount) external validLock returns (bool) {\n uint96 amount = safe96(rawAmount, \"VRT::transfer: amount exceeds 96 bits\");\n _transferTokens(msg.sender, dst, amount);\n return true;\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint rawAmount) external validLock returns (bool) {\n address spender = msg.sender;\n uint96 spenderAllowance = allowances[src][spender];\n uint96 amount = safe96(rawAmount, \"VRT::approve: amount exceeds 96 bits\");\n\n if (spender != src && spenderAllowance != uint96(-1)) {\n uint96 newAllowance = sub96(\n spenderAllowance,\n amount,\n \"VRT::transferFrom: transfer amount exceeds spender allowance\"\n );\n allowances[src][spender] = newAllowance;\n\n emit Approval(src, spender, newAllowance);\n }\n\n _transferTokens(src, dst, amount);\n return true;\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) public validLock {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public validLock {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"VRT::delegateBySig: invalid signature\");\n require(nonce == nonces[signatory]++, \"VRT::delegateBySig: invalid nonce\");\n require(now <= expiry, \"VRT::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n /**\n * @notice Determine the prior number of votes for an account as of a block number\n * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n * @param account The address of the account to check\n * @param blockNumber The block number to get the vote balance at\n * @return The number of votes the account had as of the given block\n */\n function getPriorVotes(address account, uint blockNumber) public view returns (uint96) {\n require(blockNumber < block.number, \"VRT::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlock > blockNumber) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlock == blockNumber) {\n return cp.votes;\n } else if (cp.fromBlock < blockNumber) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = balances[delegator];\n delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _transferTokens(address src, address dst, uint96 amount) internal {\n require(src != address(0), \"VRT::_transferTokens: cannot transfer from the zero address\");\n require(dst != address(0), \"VRT::_transferTokens: cannot transfer to the zero address\");\n\n balances[src] = sub96(balances[src], amount, \"VRT::_transferTokens: transfer amount exceeds balance\");\n balances[dst] = add96(balances[dst], amount, \"VRT::_transferTokens: transfer amount overflows\");\n emit Transfer(src, dst, amount);\n\n _moveDelegates(delegates[src], delegates[dst], amount);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"VRT::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"VRT::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumber = safe32(block.number, \"VRT::_writeCheckpoint: block number exceeds 32 bits\");\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChanged(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverter.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/IBEP20.sol\";\nimport \"../../Utils/SafeBEP20.sol\";\nimport \"../XVS/IXVSVesting.sol\";\nimport \"./VRTConverterStorage.sol\";\nimport \"./VRTConverterProxy.sol\";\n\n/**\n * @title Venus's VRTConversion Contract\n * @author Venus\n */\ncontract VRTConverter is VRTConverterStorage {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n address public constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;\n\n /// @notice decimal precision for VRT\n uint256 public constant vrtDecimalsMultiplier = 1e18;\n\n /// @notice decimal precision for XVS\n uint256 public constant xvsDecimalsMultiplier = 1e18;\n\n /// @notice Emitted when an admin set conversion info\n event ConversionInfoSet(\n uint256 conversionRatio,\n uint256 conversionStartTime,\n uint256 conversionPeriod,\n uint256 conversionEndTime\n );\n\n /// @notice Emitted when token conversion is done\n event TokenConverted(\n address reedeemer,\n address vrtAddress,\n uint256 vrtAmount,\n address xvsAddress,\n uint256 xvsAmount\n );\n\n /// @notice Emitted when an admin withdraw converted token\n event TokenWithdraw(address token, address to, uint256 amount);\n\n /// @notice Emitted when XVSVestingAddress is set\n event XVSVestingSet(address xvsVestingAddress);\n\n constructor() public {}\n\n function initialize(\n address _vrtAddress,\n address _xvsAddress,\n uint256 _conversionRatio,\n uint256 _conversionStartTime,\n uint256 _conversionPeriod\n ) public {\n require(msg.sender == admin, \"only admin may initialize the VRTConverter\");\n require(initialized == false, \"VRTConverter is already initialized\");\n\n require(_vrtAddress != address(0), \"vrtAddress cannot be Zero\");\n vrt = IBEP20(_vrtAddress);\n\n require(_xvsAddress != address(0), \"xvsAddress cannot be Zero\");\n xvs = IBEP20(_xvsAddress);\n\n require(_conversionRatio > 0, \"conversionRatio cannot be Zero\");\n conversionRatio = _conversionRatio;\n\n require(_conversionStartTime >= block.timestamp, \"conversionStartTime must be time in the future\");\n require(_conversionPeriod > 0, \"_conversionPeriod is invalid\");\n\n conversionStartTime = _conversionStartTime;\n conversionPeriod = _conversionPeriod;\n conversionEndTime = conversionStartTime.add(conversionPeriod);\n emit ConversionInfoSet(conversionRatio, conversionStartTime, conversionPeriod, conversionEndTime);\n\n totalVrtConverted = 0;\n _notEntered = true;\n initialized = true;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @notice sets XVSVestingProxy Address\n * @dev Note: If XVSVestingProxy is not set, then Conversion is not allowed\n * @param _xvsVestingAddress The XVSVestingProxy Address\n */\n function setXVSVesting(address _xvsVestingAddress) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_xvsVestingAddress != address(0), \"xvsVestingAddress cannot be Zero\");\n xvsVesting = IXVSVesting(_xvsVestingAddress);\n emit XVSVestingSet(_xvsVestingAddress);\n }\n\n modifier isInitialized() {\n require(initialized == true, \"VRTConverter is not initialized\");\n _;\n }\n\n function isConversionActive() public view returns (bool) {\n uint256 currentTime = block.timestamp;\n if (currentTime >= conversionStartTime && currentTime <= conversionEndTime) {\n return true;\n }\n return false;\n }\n\n modifier checkForActiveConversionPeriod() {\n uint256 currentTime = block.timestamp;\n require(currentTime >= conversionStartTime, \"Conversion did not start yet\");\n require(currentTime <= conversionEndTime, \"Conversion Period Ended\");\n _;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Transfer VRT and redeem XVS\n * @dev Note: If there is not enough XVS, we do not perform the conversion.\n * @param vrtAmount The amount of VRT\n */\n function convert(uint256 vrtAmount) external isInitialized checkForActiveConversionPeriod nonReentrant {\n require(\n address(xvsVesting) != address(0) && address(xvsVesting) != DEAD_ADDRESS,\n \"XVS-Vesting Address is not set\"\n );\n require(vrtAmount > 0, \"VRT amount must be non-zero\");\n totalVrtConverted = totalVrtConverted.add(vrtAmount);\n\n uint256 redeemAmount = vrtAmount.mul(conversionRatio).mul(xvsDecimalsMultiplier).div(1e18).div(\n vrtDecimalsMultiplier\n );\n\n emit TokenConverted(msg.sender, address(vrt), vrtAmount, address(xvs), redeemAmount);\n vrt.safeTransferFrom(msg.sender, DEAD_ADDRESS, vrtAmount);\n xvsVesting.deposit(msg.sender, redeemAmount);\n }\n\n /*** Admin Functions ***/\n function _become(VRTConverterProxy vrtConverterProxy) public {\n require(msg.sender == vrtConverterProxy.admin(), \"only proxy admin can change brains\");\n vrtConverterProxy._acceptImplementation();\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverterProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VRTConverterStorage.sol\";\n\ncontract VRTConverterProxy is VRTConverterAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means VRTConverter implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(\n address implementation_,\n address _vrtAddress,\n address _xvsAddress,\n uint256 _conversionRatio,\n uint256 _conversionStartTime,\n uint256 _conversionPeriod\n ) public nonZeroAddress(implementation_) nonZeroAddress(_vrtAddress) nonZeroAddress(_xvsAddress) {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,uint256,uint256,uint256)\",\n _vrtAddress,\n _xvsAddress,\n _conversionRatio,\n _conversionStartTime,\n _conversionPeriod\n )\n );\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"VRTConverterProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"VRTConverterProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal nonZeroAddress(callee) returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(\n address newPendingImplementation\n ) public nonZeroAddress(newPendingImplementation) {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRTConverter. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public nonZeroAddress(newPendingAdmin) {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n require(newPendingAdmin != pendingAdmin, \"New pendingAdmin can not be same as the previous one\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/VRT/VRTConverterStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/SafeMath.sol\";\nimport \"../../Utils/IBEP20.sol\";\nimport \"../XVS/IXVSVesting.sol\";\n\ncontract VRTConverterAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VRTConverter\n */\n address public implementation;\n\n /**\n * @notice Pending brains of VRTConverter\n */\n address public pendingImplementation;\n}\n\ncontract VRTConverterStorage is VRTConverterAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice indicator to check if the contract is initialized\n bool public initialized;\n\n /// @notice The VRT TOKEN!\n IBEP20 public vrt;\n\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice XVSVesting Contract reference\n IXVSVesting public xvsVesting;\n\n /// @notice Conversion ratio from VRT to XVS with decimal 18\n uint256 public conversionRatio;\n\n /// @notice total VRT converted to XVS\n uint256 public totalVrtConverted;\n\n /// @notice Conversion Start time in EpochSeconds\n uint256 public conversionStartTime;\n\n /// @notice ConversionPeriod in Seconds\n uint256 public conversionPeriod;\n\n /// @notice Conversion End time in EpochSeconds\n uint256 public conversionEndTime;\n}\n" + }, + "contracts/Tokens/VTokens/VBep20.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VToken, VBep20Interface, ComptrollerInterface, InterestRateModel, VTokenInterface } from \"./VToken.sol\";\nimport { EIP20Interface } from \"../EIP20Interface.sol\";\nimport { EIP20NonStandardInterface } from \"../EIP20NonStandardInterface.sol\";\n\n/**\n * @title Venus's VBep20 Contract\n * @notice vTokens which wrap an EIP-20 underlying\n * @author Venus\n */\ncontract VBep20 is VToken, VBep20Interface {\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint(uint mintAmount) external returns (uint) {\n (uint err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits MintBehalf event\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n (uint err, ) = mintBehalfInternal(receiver, mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The user on behalf of whom to redeem\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemBehalf(address redeemer, uint redeemTokens) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemInternal(redeemer, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer, on behalf of whom to redeem\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlyingBehalf(address redeemer, uint redeemAmount) external returns (uint) {\n require(comptroller.approvedDelegates(redeemer, msg.sender), \"not an approved delegate\");\n\n return redeemUnderlyingInternal(redeemer, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender borrows assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the borrower using `comptroller.updateDelegate`\n * @param borrower The borrower, on behalf of whom to borrow.\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrowBehalf(address borrower, uint borrowAmount) external returns (uint) {\n require(comptroller.approvedDelegates(borrower, msg.sender), \"not an approved delegate\");\n return borrowInternal(borrower, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow(uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n (uint err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n (uint err, ) = liquidateBorrowInternal(borrower, repayAmount, vTokenCollateral);\n return err;\n }\n\n /**\n * @notice The sender adds to reserves.\n * @param addAmount The amount of underlying tokens to add as reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesAdded event\n function _addReserves(uint addAmount) external returns (uint) {\n return _addReservesInternal(addAmount);\n }\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n */\n function initialize(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n // VToken initialize does the bulk of the work\n super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n EIP20NonStandardInterface(underlying).transferFrom(from, address(this), amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_IN_FAILED\");\n\n // Calculate the amount that was *actually* transferred\n uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard BEP-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address payable to, uint amount) internal {\n EIP20NonStandardInterface(underlying).transfer(to, amount);\n\n bool success;\n assembly {\n switch returndatasize()\n case 0 {\n // This is a non-standard BEP-20\n success := not(0) // set success to true\n }\n case 32 {\n // This is a compliant BEP-20\n returndatacopy(0, 0, 32)\n success := mload(0) // Set `success = returndata` of external call\n }\n default {\n // This is an excessively non-compliant BEP-20, revert.\n revert(0, 0)\n }\n }\n require(success, \"TOKEN_TRANSFER_OUT_FAILED\");\n }\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Delegate.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport { VBep20 } from \"./VBep20.sol\";\nimport { VDelegateInterface } from \"./VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegate Contract\n * @notice VTokens which wrap an EIP-20 underlying and are delegated to\n * @author Venus\n */\ncontract VBep20Delegate is VBep20, VDelegateInterface {\n /**\n * @notice Construct an empty delegate\n */\n constructor() public {}\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public {\n // Shh -- currently unused\n data;\n\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _becomeImplementation\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public {\n // Shh -- we don't ever want this hook to be marked pure\n if (false) {\n implementation = address(0);\n }\n\n require(msg.sender == admin, \"only the admin may call _resignImplementation\");\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Delegator.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VTokenInterfaces.sol\";\n\n/**\n * @title Venus's VBep20Delegator Contract\n * @notice vTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Venus\n */\ncontract VBep20Delegator is VTokenInterface, VBep20Interface, VDelegatorInterface {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n * @param implementation_ The address of the implementation the contract delegates to\n * @param becomeImplementationData The encoded args for becomeImplementation\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_,\n address implementation_,\n bytes memory becomeImplementationData\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\n \"initialize(address,address,address,uint256,string,string,uint8)\",\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n )\n );\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_, false, becomeImplementationData);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n */\n function() external payable {\n require(msg.value == 0, \"VBep20Delegator:fallback: cannot send value to fallback\");\n\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mint(uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"mint(uint256)\", mintAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function mintBehalf(address receiver, uint mintAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"mintBehalf(address,uint256)\", receiver, mintAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying asset\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeem(uint redeemTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"redeem(uint256)\", redeemTokens));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"redeemUnderlying(uint256)\", redeemAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrow(uint borrowAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrow(uint256)\", borrowAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrow(uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"repayBorrow(uint256)\", repayAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrower\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"repayBorrowBehalf(address,uint256)\", borrower, repayAmount)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"liquidateBorrow(address,uint256,address)\", borrower, repayAmount, vTokenCollateral)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint amount) external returns (bool) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"transfer(address,uint256)\", dst, amount));\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", src, dst, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"approve(address,uint256)\", spender, amount)\n );\n return abi.decode(data, (bool));\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"balanceOfUnderlying(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"totalBorrowsCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"borrowBalanceCurrent(address)\", account));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * It's absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"seize(address,address,uint256)\", liquidator, borrower, seizeTokens)\n );\n return abi.decode(data, (uint));\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setPendingAdmin(address)\", newPendingAdmin)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setReserveFactor(uint256)\", newReserveFactorMantissa)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accepts transfer of admin rights. `msg.sender` must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _acceptAdmin() external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_acceptAdmin()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from admin\n * @param addAmount Amount of reserves to add\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReserves(uint addAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_addReserves(uint256)\", addAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to admin\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReserves(uint reduceAmount) external returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"_reduceReserves(uint256)\", reduceAmount));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"getCash()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"allowance(address,address)\", owner, spender)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"balanceOf(address)\", owner));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Get a snapshot of the account's balances and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"getAccountSnapshot(address)\", account)\n );\n return abi.decode(data, (uint, uint, uint, uint));\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"borrowRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"supplyRatePerBlock()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n // @custom:access Only callable by admin\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public {\n require(msg.sender == admin, \"VBep20Delegator::_setImplementation: Caller must be admin\");\n\n if (allowResign) {\n delegateToImplementation(abi.encodeWithSignature(\"_resignImplementation()\"));\n }\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n delegateToImplementation(abi.encodeWithSignature(\"_becomeImplementation(bytes)\", becomeImplementationData));\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"exchangeRateCurrent()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves.\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public returns (uint) {\n bytes memory data = delegateToImplementation(abi.encodeWithSignature(\"accrueInterest()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setComptroller(address)\", newComptroller)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using `_setInterestRateModelFresh`\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) {\n bytes memory data = delegateToImplementation(\n abi.encodeWithSignature(\"_setInterestRateModel(address)\", newInterestRateModel)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Delegates execution to the implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToImplementation(bytes memory data) public returns (bytes memory) {\n return delegateTo(implementation, data);\n }\n\n /**\n * @notice Delegates execution to an implementation contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {\n (bool success, bytes memory returnData) = address(this).staticcall(\n abi.encodeWithSignature(\"delegateToImplementation(bytes)\", data)\n );\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return abi.decode(returnData, (bytes));\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n bytes memory data = delegateToViewImplementation(\n abi.encodeWithSignature(\"borrowBalanceStored(address)\", account)\n );\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n bytes memory data = delegateToViewImplementation(abi.encodeWithSignature(\"exchangeRateStored()\"));\n return abi.decode(data, (uint));\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBep20Immutable.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VBep20.sol\";\n\n/**\n * @title Venus's VBep20Immutable Contract\n * @notice VTokens which wrap an EIP-20 underlying and are immutable\n * @author Venus\n */\ncontract VBep20Immutable is VBep20 {\n /**\n * @notice Construct a new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n address underlying_,\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // Initialize the market\n initialize(\n underlying_,\n comptroller_,\n interestRateModel_,\n initialExchangeRateMantissa_,\n name_,\n symbol_,\n decimals_\n );\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n}\n" + }, + "contracts/Tokens/VTokens/VBNB.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VToken.sol\";\n\n/**\n * @title Venus's vBNB Contract\n * @notice vToken which wraps BNB\n * @author Venus\n */\ncontract VBNB is VToken {\n /**\n * @notice Construct a new vBNB money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ BEP-20 name of this token\n * @param symbol_ BEP-20 symbol of this token\n * @param decimals_ BEP-20 decimal precision of this token\n * @param admin_ Address of the administrator of this token\n */\n constructor(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address payable admin_\n ) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);\n\n // Set the proper admin now that initialization is done\n admin = admin_;\n }\n\n /**\n * @notice Send BNB to VBNB to mint\n */\n function() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Reverts upon any failure\n */\n // @custom:event Emits Transfer event\n // @custom:event Emits Mint event\n function mint() external payable {\n (uint err, ) = mintInternal(msg.value);\n requireNoError(err, \"mint failed\");\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeem(uint redeemTokens) external returns (uint) {\n return redeemInternal(msg.sender, msg.sender, redeemTokens);\n }\n\n /**\n * @notice Sender redeems vTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Redeem event on success\n // @custom:event Emits Transfer event on success\n // @custom:event Emits RedeemFee when fee is charged by the treasury\n function redeemUnderlying(uint redeemAmount) external returns (uint) {\n return redeemUnderlyingInternal(msg.sender, msg.sender, redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Borrow event on success\n function borrow(uint borrowAmount) external returns (uint) {\n return borrowInternal(msg.sender, msg.sender, borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @dev Reverts upon any failure\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrow() external payable {\n (uint err, ) = repayBorrowInternal(msg.value);\n requireNoError(err, \"repayBorrow failed\");\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @dev Reverts upon any failure\n * @param borrower The account with the debt being payed off\n */\n // @custom:event Emits RepayBorrow event on success\n function repayBorrowBehalf(address borrower) external payable {\n (uint err, ) = repayBorrowBehalfInternal(borrower, msg.value);\n requireNoError(err, \"repayBorrowBehalf failed\");\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @dev Reverts upon any failure\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n */\n // @custom:event Emit LiquidateBorrow event on success\n function liquidateBorrow(address borrower, VToken vTokenCollateral) external payable {\n (uint err, ) = liquidateBorrowInternal(borrower, msg.value, vTokenCollateral);\n requireNoError(err, \"liquidateBorrow failed\");\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Perform the actual transfer in, which is a no-op\n * @param from Address sending the BNB\n * @param amount Amount of BNB being sent\n * @return The actual amount of BNB transferred\n */\n function doTransferIn(address from, uint amount) internal returns (uint) {\n // Sanity checks\n require(msg.sender == from, \"sender mismatch\");\n require(msg.value == amount, \"value mismatch\");\n return amount;\n }\n\n function doTransferOut(address payable to, uint amount) internal {\n /* Send the BNB, with minimal gas and revert on failure */\n to.transfer(amount);\n }\n\n /**\n * @notice Gets balance of this contract in terms of BNB, before this message\n * @dev This excludes the value of the current message, if any\n * @return The quantity of BNB owned by this contract\n */\n function getCashPrior() internal view returns (uint) {\n (MathError err, uint startingBalance) = subUInt(address(this).balance, msg.value);\n require(err == MathError.NO_ERROR, \"cash prior math error\");\n return startingBalance;\n }\n\n function requireNoError(uint errCode, string memory message) internal pure {\n if (errCode == uint(Error.NO_ERROR)) {\n return;\n }\n\n bytes memory fullMessage = new bytes(bytes(message).length + 5);\n uint i;\n\n for (i = 0; i < bytes(message).length; i++) {\n fullMessage[i] = bytes(message)[i];\n }\n\n fullMessage[i + 0] = bytes1(uint8(32));\n fullMessage[i + 1] = bytes1(uint8(40));\n fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10)));\n fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10)));\n fullMessage[i + 4] = bytes1(uint8(41));\n\n require(errCode == uint(Error.NO_ERROR), string(fullMessage));\n }\n}\n" + }, + "contracts/Tokens/VTokens/VToken.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../Utils/ErrorReporter.sol\";\nimport \"../../Utils/Exponential.sol\";\nimport \"../../Tokens/EIP20Interface.sol\";\nimport \"../../Tokens/EIP20NonStandardInterface.sol\";\nimport \"../../InterestRateModels/InterestRateModel.sol\";\nimport \"./VTokenInterfaces.sol\";\nimport { IAccessControlManagerV5 } from \"@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV5.sol\";\n\n/**\n * @title Venus's vToken Contract\n * @notice Abstract base for vTokens\n * @author Venus\n */\ncontract VToken is VTokenInterface, Exponential, TokenErrorReporter {\n struct MintLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint mintTokens;\n uint totalSupplyNew;\n uint accountTokensNew;\n uint actualMintAmount;\n }\n\n struct RedeemLocalVars {\n MathError mathErr;\n uint exchangeRateMantissa;\n uint redeemTokens;\n uint redeemAmount;\n uint totalSupplyNew;\n uint accountTokensNew;\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint repayAmount;\n uint borrowerIndex;\n uint accountBorrows;\n uint accountBorrowsNew;\n uint totalBorrowsNew;\n uint actualRepayAmount;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transfer(address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n // @custom:event Emits Transfer event\n function transferFrom(address src, address dst, uint256 amount) external nonReentrant returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n // @custom:event Emits Approval event on successful approve\n function approve(address spender, uint256 amount) external returns (bool) {\n transferAllowances[msg.sender][spender] = amount;\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @dev This also accrues interest in a transaction\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external returns (uint) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n ensureNoMathError(mErr);\n return balance;\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return totalBorrows;\n }\n\n /**\n * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex\n * @param account The address whose balance should be calculated after updating borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) external nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return borrowBalanceStored(account);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another vToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed vToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits Transfer event\n function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewPendingAdmin event with old and new admin addresses\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {\n // Check caller = admin\n ensureAdmin(msg.sender);\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewAdmin event on successful acceptance\n // @custom:event Emits NewPendingAdmin event with null new pending admin\n function _acceptAdmin() external returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using `_setReserveFactorFresh`\n * @dev Governor function to accrue interest and set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewReserveFactor event\n function _setReserveFactor(uint newReserveFactorMantissa_) external nonReentrant returns (uint) {\n ensureAllowed(\"_setReserveFactor(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed.\n return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);\n }\n // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to.\n return _setReserveFactorFresh(newReserveFactorMantissa_);\n }\n\n /**\n * @notice Sets the address of the access control manager of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlManagerAddress New address for the access control\n * @return uint 0=success, otherwise will revert\n */\n function setAccessControlManager(address newAccessControlManagerAddress) external returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ensureNonZeroAddress(newAccessControlManagerAddress);\n\n emit NewAccessControlManager(accessControlManager, newAccessControlManagerAddress);\n accessControlManager = newAccessControlManagerAddress;\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces reserves by transferring to protocol share reserve\n * @param reduceAmount_ Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits ReservesReduced event\n function _reduceReserves(uint reduceAmount_) external nonReentrant returns (uint) {\n ensureAllowed(\"_reduceReserves(uint256)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // If reserves were reduced in accrueInterest\n if (reduceReservesBlockNumber == block.number) return (uint(Error.NO_ERROR));\n // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.\n return _reduceReservesFresh(reduceAmount_);\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) external view returns (uint256) {\n return accountTokens[owner];\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {\n uint vTokenBalance = accountTokens[account];\n uint borrowBalance;\n uint exchangeRateMantissa;\n\n MathError mErr;\n\n (mErr, borrowBalance) = borrowBalanceStoredInternal(account);\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n (mErr, exchangeRateMantissa) = exchangeRateStoredInternal();\n if (mErr != MathError.NO_ERROR) {\n return (uint(Error.MATH_ERROR), 0, 0, 0);\n }\n\n return (uint(Error.NO_ERROR), vTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this vToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() external view returns (uint) {\n return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this vToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() external view returns (uint) {\n return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves);\n }\n\n /**\n * @notice Get cash balance of this vToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view returns (uint) {\n return getCashPrior();\n }\n\n /**\n * @notice Governance function to set new threshold of block difference after which funds will be sent to the protocol share reserve\n * @param newReduceReservesBlockDelta_ block difference value\n */\n function setReduceReservesBlockDelta(uint256 newReduceReservesBlockDelta_) external {\n require(newReduceReservesBlockDelta_ > 0, \"Invalid Input\");\n ensureAllowed(\"setReduceReservesBlockDelta(uint256)\");\n emit NewReduceReservesBlockDelta(reduceReservesBlockDelta, newReduceReservesBlockDelta_);\n reduceReservesBlockDelta = newReduceReservesBlockDelta_;\n }\n\n /**\n * @notice Sets protocol share reserve contract address\n * @param protcolShareReserve_ The address of protocol share reserve contract\n */\n function setProtocolShareReserve(address payable protcolShareReserve_) external {\n // Check caller is admin\n ensureAdmin(msg.sender);\n ensureNonZeroAddress(protcolShareReserve_);\n emit NewProtocolShareReserve(protocolShareReserve, protcolShareReserve_);\n protocolShareReserve = protcolShareReserve_;\n }\n\n /**\n * @notice Initialize the money market\n * @param comptroller_ The address of the Comptroller\n * @param interestRateModel_ The address of the interest rate model\n * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18\n * @param name_ EIP-20 name of this token\n * @param symbol_ EIP-20 symbol of this token\n * @param decimals_ EIP-20 decimal precision of this token\n */\n function initialize(\n ComptrollerInterface comptroller_,\n InterestRateModel interestRateModel_,\n uint initialExchangeRateMantissa_,\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public {\n ensureAdmin(msg.sender);\n require(accrualBlockNumber == 0 && borrowIndex == 0, \"market may only be initialized once\");\n\n // Set initial exchange rate\n initialExchangeRateMantissa = initialExchangeRateMantissa_;\n require(initialExchangeRateMantissa > 0, \"initial exchange rate must be greater than zero.\");\n\n // Set the comptroller\n uint err = _setComptroller(comptroller_);\n require(err == uint(Error.NO_ERROR), \"setting comptroller failed\");\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = mantissaOne;\n\n // Set the interest rate model (depends on block number / borrow index)\n err = _setInterestRateModelFresh(interestRateModel_);\n require(err == uint(Error.NO_ERROR), \"setting interest rate model failed\");\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public nonReentrant returns (uint) {\n require(accrueInterest() == uint(Error.NO_ERROR), \"accrue interest failed\");\n return exchangeRateStored();\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage and\n * reduce spread reserves to protocol share reserve\n * if currentBlock - reduceReservesBlockNumber >= blockDelta\n */\n // @custom:event Emits AccrueInterest event\n function accrueInterest() public returns (uint) {\n /* Remember the initial block number */\n uint currentBlockNumber = block.number;\n uint accrualBlockNumberPrior = accrualBlockNumber;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumberPrior == currentBlockNumber) {\n return uint(Error.NO_ERROR);\n }\n\n /* Read the previous values out of storage */\n uint cashPrior = getCashPrior();\n uint borrowsPrior = totalBorrows;\n uint reservesPrior = totalReserves;\n uint borrowIndexPrior = borrowIndex;\n\n /* Calculate the current borrow interest rate */\n uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior);\n require(borrowRateMantissa <= borrowRateMaxMantissa, \"borrow rate is absurdly high\");\n\n /* Calculate the number of blocks elapsed since the last accrual */\n (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);\n ensureNoMathError(mathErr);\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n Exp memory simpleInterestFactor;\n uint interestAccumulated;\n uint totalBorrowsNew;\n uint totalReservesNew;\n uint borrowIndexNew;\n\n (mathErr, simpleInterestFactor) = mulScalar(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n interestAccumulated,\n reservesPrior\n );\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior);\n if (mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n uint(mathErr)\n );\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = borrowIndexNew;\n totalBorrows = totalBorrowsNew;\n totalReserves = totalReservesNew;\n\n (mathErr, blockDelta) = subUInt(currentBlockNumber, reduceReservesBlockNumber);\n ensureNoMathError(mathErr);\n if (blockDelta >= reduceReservesBlockDelta) {\n reduceReservesBlockNumber = currentBlockNumber;\n if (cashPrior < totalReservesNew) {\n _reduceReservesFresh(cashPrior);\n } else {\n _reduceReservesFresh(totalReservesNew);\n }\n }\n\n /* We emit an AccrueInterest event */\n emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new comptroller for the market\n * @dev Admin function to set a new comptroller\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // @custom:event Emits NewComptroller event\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {\n // Check caller is admin\n ensureAdmin(msg.sender);\n\n ComptrollerInterface oldComptroller = comptroller;\n // Ensure invoke comptroller.isComptroller() returns true\n require(newComptroller.isComptroller(), \"marker method returned false\");\n\n // Set market's comptroller to newComptroller\n comptroller = newComptroller;\n\n // Emit NewComptroller(oldComptroller, newComptroller)\n emit NewComptroller(oldComptroller, newComptroller);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Governance function to accrue interest and update the interest rate model\n * @param newInterestRateModel_ The new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModel(InterestRateModel newInterestRateModel_) public returns (uint) {\n ensureAllowed(\"_setInterestRateModel(address)\");\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed\n return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);\n }\n // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.\n return _setInterestRateModelFresh(newInterestRateModel_);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the VToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateStored() public view returns (uint) {\n (MathError err, uint result) = exchangeRateStoredInternal();\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return The calculated balance\n */\n function borrowBalanceStored(address account) public view returns (uint) {\n (MathError err, uint result) = borrowBalanceStoredInternal(account);\n ensureNoMathError(err);\n return result;\n }\n\n /**\n * @notice Transfers `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) {\n /* Fail if transfer not allowed */\n uint allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint startingAllowance = 0;\n if (spender == src) {\n startingAllowance = uint(-1);\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint allowanceNew;\n uint srvTokensNew;\n uint dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srvTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srvTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != uint(-1)) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mint failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n /**\n * @notice User supplies assets into the market and receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) {\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens, vars.accountTokensNew);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender supplies assets into the market and receiver receives vTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param receiver The address of the account which is receiving the vTokens\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfInternal(address receiver, uint mintAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted mintBehalf failed\n return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);\n }\n // mintBelahfFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintBehalfFresh(msg.sender, receiver, mintAmount);\n }\n\n /**\n * @notice Payer supplies assets into the market and receiver receives vTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param payer The address of the account which is paying the underlying token\n * @param receiver The address of the account which is receiving vToken\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintBehalfFresh(address payer, address receiver, uint mintAmount) internal returns (uint, uint) {\n ensureNonZeroAddress(receiver);\n /* Fail if mint not allowed */\n uint allowed = comptroller.mintAllowed(address(this), receiver, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n if (vars.mathErr != MathError.NO_ERROR) {\n return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the payer and the mintAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the vToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(payer, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of vTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n /*\n * We calculate the new total supply of vTokens and receiver token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[receiver] + mintTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[receiver], vars.mintTokens);\n ensureNoMathError(vars.mathErr);\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[receiver] = vars.accountTokensNew;\n\n /* We emit a MintBehalf event, and a Transfer event */\n emit MintBehalf(payer, receiver, vars.actualMintAmount, vars.mintTokens, vars.accountTokensNew);\n emit Transfer(address(this), receiver, vars.mintTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.mintVerify(address(this), receiver, vars.actualMintAmount, vars.mintTokens);\n\n return (uint(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokens The number of vTokens to redeem into underlying\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemInternal(\n address redeemer,\n address payable receiver,\n uint redeemTokens\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems underlying assets on behalf of some other address. This function is only available\n * for senders, explicitly marked as delegates of the supplier using `comptroller.updateDelegate`\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens, if called by a delegate\n * @param redeemAmount The amount of underlying to receive from redeeming vTokens\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function redeemUnderlyingInternal(\n address redeemer,\n address payable receiver,\n uint redeemAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed\n return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);\n }\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(redeemer, receiver, 0, redeemAmount);\n }\n\n /**\n * @notice Redeemer redeems vTokens in exchange for the underlying assets, transferred to the receiver. Redeemer and receiver can be the same\n * address, or different addresses if the receiver was previously approved by the redeemer as a valid delegate (see MarketFacet.updateDelegate)\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param receiver The receiver of the tokens\n * @param redeemTokensIn The number of vTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming vTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n // solhint-disable-next-line code-complexity\n function redeemFresh(\n address redeemer,\n address payable receiver,\n uint redeemTokensIn,\n uint redeemAmountIn\n ) internal returns (uint) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"one of redeemTokensIn or redeemAmountIn must be zero\");\n\n RedeemLocalVars memory vars;\n\n /* exchangeRate = invoke Exchange Rate Stored() */\n (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();\n ensureNoMathError(vars.mathErr);\n\n /* If redeemTokensIn > 0: */\n if (redeemTokensIn > 0) {\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n ensureNoMathError(vars.mathErr);\n } else {\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(\n redeemAmountIn,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n ensureNoMathError(vars.mathErr);\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n ensureNoMathError(vars.mathErr);\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashPrior() < vars.redeemAmount) {\n revert(\"math error\");\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the receiver and the redeemAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n\n uint feeAmount;\n uint remainedAmount;\n if (IComptroller(address(comptroller)).treasuryPercent() != 0) {\n (vars.mathErr, feeAmount) = mulUInt(\n vars.redeemAmount,\n IComptroller(address(comptroller)).treasuryPercent()\n );\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, feeAmount) = divUInt(feeAmount, 1e18);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, remainedAmount) = subUInt(vars.redeemAmount, feeAmount);\n ensureNoMathError(vars.mathErr);\n\n doTransferOut(address(uint160(IComptroller(address(comptroller)).treasuryAddress())), feeAmount);\n\n emit RedeemFee(redeemer, feeAmount, vars.redeemTokens);\n } else {\n remainedAmount = vars.redeemAmount;\n }\n\n doTransferOut(receiver, remainedAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, remainedAmount, vars.redeemTokens, vars.accountTokensNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function borrowInternal(\n address borrower,\n address payable receiver,\n uint borrowAmount\n ) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED);\n }\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(borrower, receiver, borrowAmount);\n }\n\n /**\n * @notice Receiver gets the borrow on behalf of the borrower address\n * @dev Before calling this function, ensure that the interest has been accrued\n * @param borrower The borrower, on behalf of whom to borrow\n * @param receiver The account that would receive the funds (can be the same as the borrower)\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint Returns 0 on success, otherwise revert (see ErrorReporter.sol for details).\n */\n function borrowFresh(address borrower, address payable receiver, uint borrowAmount) internal returns (uint) {\n /* Revert if borrow not allowed */\n uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n revert(\"math error\");\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n revert(\"math error\");\n }\n\n /* Revert if protocol has insufficient underlying cash */\n if (getCashPrior() < borrowAmount) {\n revert(\"math error\");\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n ensureNoMathError(vars.mathErr);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the receiver and the borrowAmount.\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(receiver, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to another borrowing account\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed\n return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0);\n }\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer The account paying off the borrow\n * @param borrower The account with the debt being payed off\n * @param repayAmount The amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) {\n /* Fail if repayBorrow not allowed */\n uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (\n failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed),\n 0\n );\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower);\n if (vars.mathErr != MathError.NO_ERROR) {\n return (\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n uint(vars.mathErr)\n ),\n 0\n );\n }\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == uint(-1)) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n ensureNoMathError(vars.mathErr);\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal nonReentrant returns (uint, uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0);\n }\n\n error = vTokenCollateral.accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed\n return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0);\n }\n\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, vTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this vToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param vTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n // solhint-disable-next-line code-complexity\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) internal returns (uint, uint) {\n /* Fail if liquidate not allowed */\n uint allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify vTokenCollateral market's block number equals current block number */\n if (vTokenCollateral.accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == uint(-1)) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n address(vTokenCollateral),\n actualRepayAmount\n );\n require(amountSeizeError == uint(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(vTokenCollateral.balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint seizeError;\n if (address(vTokenCollateral) == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = vTokenCollateral.seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint(Error.NO_ERROR), \"token seizure failed\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(vTokenCollateral), seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.liquidateBorrowVerify(\n address(this),\n address(vTokenCollateral),\n liquidator,\n borrower,\n actualRepayAmount,\n seizeTokens\n );\n\n return (uint(Error.NO_ERROR), actualRepayAmount);\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another vToken.\n * Its absolutely critical to use msg.sender as the seizer vToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed vToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of vTokens to seize\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint seizeTokens\n ) internal returns (uint) {\n /* Fail if seize not allowed */\n uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n MathError mathErr;\n uint borrowerTokensNew;\n uint liquidatorTokensNew;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr));\n }\n\n (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens);\n if (mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountTokens[borrower] = borrowerTokensNew;\n accountTokens[liquidator] = liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, seizeTokens);\n\n /* We call the defense and prime accrue interest hook */\n comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new reserve factor for the protocol (requires fresh interest accrual)\n * @dev Governance function to set a new reserve factor\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) {\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa > reserveFactorMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and adds reserves by transferring from `msg.sender`\n * @param addAmount Amount of addition to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) {\n uint error = accrueInterest();\n if (error != uint(Error.NO_ERROR)) {\n // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.\n return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED);\n }\n\n // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to.\n (error, ) = _addReservesFresh(addAmount);\n return error;\n }\n\n /**\n * @notice Add reserves by transferring from caller\n * @dev Requires fresh interest accrual\n * @param addAmount Amount of addition to reserves\n * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees\n */\n function _addReservesFresh(uint addAmount) internal returns (uint, uint) {\n // totalReserves + actualAddAmount\n uint totalReservesNew;\n uint actualAddAmount;\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the caller and the addAmount\n * Note: The vToken must handle variations between BEP-20 and BNB underlying.\n * On success, the vToken holds an additional addAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n\n actualAddAmount = doTransferIn(msg.sender, addAmount);\n\n totalReservesNew = totalReserves + actualAddAmount;\n\n /* Revert on overflow */\n require(totalReservesNew >= totalReserves, \"add reserves unexpected overflow\");\n\n // Store reserves[n+1] = reserves[n] + actualAddAmount\n totalReserves = totalReservesNew;\n\n /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */\n emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew);\n\n /* Return (NO_ERROR, actualAddAmount) */\n return (uint(Error.NO_ERROR), actualAddAmount);\n }\n\n /**\n * @notice Reduces reserves by transferring to protocol share reserve contract\n * @dev Requires fresh interest accrual\n * @param reduceAmount Amount of reduction to reserves\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _reduceReservesFresh(uint reduceAmount) internal returns (uint) {\n if (reduceAmount == 0) {\n return uint(Error.NO_ERROR);\n }\n\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashPrior() < reduceAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE);\n }\n\n // Check reduceAmount ≤ reserves[n] (totalReserves)\n if (reduceAmount > totalReserves) {\n return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n // totalReserves - reduceAmount\n uint totalReservesNew = totalReserves - reduceAmount;\n\n // Store reserves[n+1] = reserves[n] - reduceAmount\n totalReserves = totalReservesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(protocolShareReserve, reduceAmount);\n\n IProtocolShareReserveV5(protocolShareReserve).updateAssetsState(\n address(comptroller),\n underlying,\n IProtocolShareReserveV5.IncomeType.SPREAD\n );\n\n emit ReservesReduced(protocolShareReserve, reduceAmount, totalReservesNew);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice updates the interest rate model (requires fresh interest accrual)\n * @dev Governance function to update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint Returns 0 on success, otherwise returns a failure code (see ErrorReporter.sol for details).\n */\n function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) {\n // Used to store old model for use in the event that is emitted on success\n InterestRateModel oldInterestRateModel;\n // We fail gracefully unless market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n // Track the market's current interest rate model\n oldInterestRateModel = interestRateModel;\n\n // Ensure invoke newInterestRateModel.isInterestRateModel() returns true\n require(newInterestRateModel.isInterestRateModel(), \"marker method returned false\");\n\n // Set the interest rate model to newInterestRateModel\n interestRateModel = newInterestRateModel;\n\n // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel)\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee.\n * This may revert due to insufficient balance or insufficient allowance.\n */\n function doTransferIn(address from, uint amount) internal returns (uint);\n\n /**\n * @dev Performs a transfer out, ideally returning an explanatory error code upon failure rather than reverting.\n * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract.\n * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions.\n */\n function doTransferOut(address payable to, uint amount) internal;\n\n /**\n * @notice Return the borrow balance of account based on stored data\n * @param account The address whose balance should be calculated\n * @return Tuple of error code and the calculated balance or 0 if error code is non-zero\n */\n function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint) {\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint principalTimesIndex;\n uint result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, borrowIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, result);\n }\n\n /**\n * @notice Calculates the exchange rate from the underlying to the vToken\n * @dev This function does not accrue interest before calculating the exchange rate\n * @return Tuple of error code and calculated exchange rate scaled by 1e18\n */\n function exchangeRateStoredInternal() internal view returns (MathError, uint) {\n uint _totalSupply = totalSupply;\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return (MathError.NO_ERROR, initialExchangeRateMantissa);\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply\n */\n uint totalCash = getCashPrior();\n uint cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(totalCash, totalBorrows, totalReserves);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n if (mathErr != MathError.NO_ERROR) {\n return (mathErr, 0);\n }\n\n return (MathError.NO_ERROR, exchangeRate.mantissa);\n }\n }\n\n function ensureAllowed(string memory functionSig) private view {\n require(\n IAccessControlManagerV5(accessControlManager).isAllowedToCall(msg.sender, functionSig),\n \"access denied\"\n );\n }\n\n function ensureAdmin(address caller_) private view {\n require(caller_ == admin, \"Unauthorized\");\n }\n\n function ensureNoMathError(MathError mErr) private pure {\n require(mErr == MathError.NO_ERROR, \"math error\");\n }\n\n function ensureNonZeroAddress(address address_) private pure {\n require(address_ != address(0), \"zero address\");\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying owned by this contract\n */\n function getCashPrior() internal view returns (uint);\n}\n" + }, + "contracts/Tokens/VTokens/VTokenInterfaces.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Comptroller/ComptrollerInterface.sol\";\nimport \"../../InterestRateModels/InterestRateModel.sol\";\n\ninterface IProtocolShareReserveV5 {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType kind) external;\n}\n\ncontract VTokenStorageBase {\n /**\n * @notice Container for borrow balance information\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\n */\n struct BorrowSnapshot {\n uint principal;\n uint interestIndex;\n }\n\n /**\n * @dev Guard variable for re-entrancy checks\n */\n bool internal _notEntered;\n\n /**\n * @notice EIP-20 token name for this token\n */\n string public name;\n\n /**\n * @notice EIP-20 token symbol for this token\n */\n string public symbol;\n\n /**\n * @notice EIP-20 token decimals for this token\n */\n uint8 public decimals;\n\n /**\n * @notice Maximum borrow rate that can ever be applied (.0005% / block)\n */\n\n uint internal constant borrowRateMaxMantissa = 0.0005e16;\n\n /**\n * @notice Maximum fraction of interest that can be set aside for reserves\n */\n uint internal constant reserveFactorMaxMantissa = 1e18;\n\n /**\n * @notice Administrator for this contract\n */\n address payable public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address payable public pendingAdmin;\n\n /**\n * @notice Contract which oversees inter-vToken operations\n */\n ComptrollerInterface public comptroller;\n\n /**\n * @notice Model which tells what the current interest rate should be\n */\n InterestRateModel public interestRateModel;\n\n /**\n * @notice Initial exchange rate used when minting the first VTokens (used when totalSupply = 0)\n */\n uint internal initialExchangeRateMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for reserves\n */\n uint public reserveFactorMantissa;\n\n /**\n * @notice Block number that interest was last accrued at\n */\n uint public accrualBlockNumber;\n\n /**\n * @notice Accumulator of the total earned interest rate since the opening of the market\n */\n uint public borrowIndex;\n\n /**\n * @notice Total amount of outstanding borrows of the underlying in this market\n */\n uint public totalBorrows;\n\n /**\n * @notice Total amount of reserves of the underlying held in this market\n */\n uint public totalReserves;\n\n /**\n * @notice Total number of tokens in circulation\n */\n uint public totalSupply;\n\n /**\n * @notice Official record of token balances for each account\n */\n mapping(address => uint) internal accountTokens;\n\n /**\n * @notice Approved token transfer amounts on behalf of others\n */\n mapping(address => mapping(address => uint)) internal transferAllowances;\n\n /**\n * @notice Mapping of account addresses to outstanding borrow balances\n */\n mapping(address => BorrowSnapshot) internal accountBorrows;\n\n /**\n * @notice Underlying asset for this VToken\n */\n address public underlying;\n\n /**\n * @notice Implementation address for this contract\n */\n address public implementation;\n\n /**\n * @notice delta block after which reserves will be reduced\n */\n uint public reduceReservesBlockDelta;\n\n /**\n * @notice last block number at which reserves were reduced\n */\n uint public reduceReservesBlockNumber;\n\n /**\n * @notice address of protocol share reserve contract\n */\n address payable public protocolShareReserve;\n\n /**\n * @notice address of accessControlManager\n */\n\n address public accessControlManager;\n}\n\ncontract VTokenStorage is VTokenStorageBase {\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\ncontract VTokenInterface is VTokenStorage {\n /**\n * @notice Indicator that this is a vToken contract (for inspection)\n */\n bool public constant isVToken = true;\n\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows);\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint mintAmount, uint mintTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are minted behalf by payer to receiver\n */\n event MintBehalf(address payer, address receiver, uint mintAmount, uint mintTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint redeemAmount, uint redeemTokens, uint256 totalSupply);\n\n /**\n * @notice Event emitted when tokens are redeemed and fee is transferred\n */\n event RedeemFee(address redeemer, uint feeAmount, uint redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint repayAmount,\n address vTokenCollateral,\n uint seizeTokens\n );\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Event emitted when pendingAdmin is accepted, which means admin has been updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @notice Event emitted when comptroller is changed\n */\n event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address protocolShareReserve, uint reduceAmount, uint newTotalReserves);\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint amount);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint amount);\n\n /**\n * @notice Event emitted when block delta for reduce reserves get updated\n */\n event NewReduceReservesBlockDelta(uint256 oldReduceReservesBlockDelta, uint256 newReduceReservesBlockDelta);\n\n /**\n * @notice Event emitted when address of ProtocolShareReserve contract get updated\n */\n event NewProtocolShareReserve(address indexed oldProtocolShareReserve, address indexed newProtocolShareReserve);\n\n /**\n * @notice Failure event\n */\n event Failure(uint error, uint info, uint detail);\n\n /// @notice Emitted when access control address is changed by admin\n event NewAccessControlManager(address oldAccessControlAddress, address newAccessControlAddress);\n\n /*** User Interface ***/\n\n function transfer(address dst, uint amount) external returns (bool);\n\n function transferFrom(address src, address dst, uint amount) external returns (bool);\n\n function approve(address spender, uint amount) external returns (bool);\n\n function balanceOfUnderlying(address owner) external returns (uint);\n\n function totalBorrowsCurrent() external returns (uint);\n\n function borrowBalanceCurrent(address account) external returns (uint);\n\n function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint);\n\n /*** Admin Function ***/\n function _setPendingAdmin(address payable newPendingAdmin) external returns (uint);\n\n /*** Admin Function ***/\n function _acceptAdmin() external returns (uint);\n\n /*** Admin Function ***/\n function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint);\n\n /*** Admin Function ***/\n function _reduceReserves(uint reduceAmount) external returns (uint);\n\n function balanceOf(address owner) external view returns (uint);\n\n function allowance(address owner, address spender) external view returns (uint);\n\n function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint);\n\n function borrowRatePerBlock() external view returns (uint);\n\n function supplyRatePerBlock() external view returns (uint);\n\n function getCash() external view returns (uint);\n\n function exchangeRateCurrent() public returns (uint);\n\n function accrueInterest() public returns (uint);\n\n /*** Admin Function ***/\n function _setComptroller(ComptrollerInterface newComptroller) public returns (uint);\n\n /*** Admin Function ***/\n function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint);\n\n function borrowBalanceStored(address account) public view returns (uint);\n\n function exchangeRateStored() public view returns (uint);\n}\n\ncontract VBep20Interface {\n /*** User Interface ***/\n\n function mint(uint mintAmount) external returns (uint);\n\n function mintBehalf(address receiver, uint mintAmount) external returns (uint);\n\n function redeem(uint redeemTokens) external returns (uint);\n\n function redeemUnderlying(uint redeemAmount) external returns (uint);\n\n function borrow(uint borrowAmount) external returns (uint);\n\n function repayBorrow(uint repayAmount) external returns (uint);\n\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);\n\n function liquidateBorrow(\n address borrower,\n uint repayAmount,\n VTokenInterface vTokenCollateral\n ) external returns (uint);\n\n /*** Admin Functions ***/\n\n function _addReserves(uint addAmount) external returns (uint);\n}\n\ncontract VDelegatorInterface {\n /**\n * @notice Emitted when implementation is changed\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementation(\n address implementation_,\n bool allowResign,\n bytes memory becomeImplementationData\n ) public;\n}\n\ncontract VDelegateInterface {\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @dev Should revert if any issues arise which make it unfit for delegation\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes memory data) public;\n\n /**\n * @notice Called by the delegator on a delegate to forfeit its responsibility\n */\n function _resignImplementation() public;\n}\n" + }, + "contracts/Tokens/XVS/IXVSVesting.sol": { + "content": "pragma solidity ^0.5.16;\n\ninterface IXVSVesting {\n /// @param _recipient Address of the Vesting. recipient entitled to claim the vested funds\n /// @param _amount Total number of tokens Vested\n function deposit(address _recipient, uint256 _amount) external;\n}\n" + }, + "contracts/Tokens/XVS/XVS.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/Tokenlock.sol\";\n\ncontract XVS is Tokenlock {\n /// @notice BEP-20 token name for this token\n string public constant name = \"Venus\";\n\n /// @notice BEP-20 token symbol for this token\n string public constant symbol = \"XVS\";\n\n /// @notice BEP-20 token decimals for this token\n uint8 public constant decimals = 18;\n\n /// @notice Total number of tokens in circulation\n uint public constant totalSupply = 30000000e18; // 30 million XVS\n\n /// @notice Allowance amounts on behalf of others\n mapping(address => mapping(address => uint96)) internal allowances;\n\n /// @notice Official record of token balances for each account\n mapping(address => uint96) internal balances;\n\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A checkpoint for marking number of votes from a given block\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice The standard BEP-20 transfer event\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /// @notice The standard BEP-20 approval event\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Construct a new XVS token\n * @param account The initial account to grant all the tokens\n */\n constructor(address account) public {\n balances[account] = uint96(totalSupply);\n emit Transfer(address(0), account, totalSupply);\n }\n\n /**\n * @notice Get the number of tokens `spender` is approved to spend on behalf of `account`\n * @param account The address of the account holding the funds\n * @param spender The address of the account spending the funds\n * @return The number of tokens approved\n */\n function allowance(address account, address spender) external view returns (uint) {\n return allowances[account][spender];\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * @param spender The address of the account which may transfer tokens\n * @param rawAmount The number of tokens that are approved (2^256-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint rawAmount) external validLock returns (bool) {\n uint96 amount;\n if (rawAmount == uint(-1)) {\n amount = uint96(-1);\n } else {\n amount = safe96(rawAmount, \"XVS::approve: amount exceeds 96 bits\");\n }\n\n allowances[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the number of tokens held by the `account`\n * @param account The address of the account to get the balance of\n * @return The number of tokens held\n */\n function balanceOf(address account) external view returns (uint) {\n return balances[account];\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint rawAmount) external validLock returns (bool) {\n uint96 amount = safe96(rawAmount, \"XVS::transfer: amount exceeds 96 bits\");\n _transferTokens(msg.sender, dst, amount);\n return true;\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param rawAmount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(address src, address dst, uint rawAmount) external validLock returns (bool) {\n address spender = msg.sender;\n uint96 spenderAllowance = allowances[src][spender];\n uint96 amount = safe96(rawAmount, \"XVS::approve: amount exceeds 96 bits\");\n\n if (spender != src && spenderAllowance != uint96(-1)) {\n uint96 newAllowance = sub96(\n spenderAllowance,\n amount,\n \"XVS::transferFrom: transfer amount exceeds spender allowance\"\n );\n allowances[src][spender] = newAllowance;\n\n emit Approval(src, spender, newAllowance);\n }\n\n _transferTokens(src, dst, amount);\n return true;\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) public validLock {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public validLock {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"XVS::delegateBySig: invalid signature\");\n require(nonce == nonces[signatory]++, \"XVS::delegateBySig: invalid nonce\");\n require(now <= expiry, \"XVS::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n /**\n * @notice Determine the prior number of votes for an account as of a block number\n * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n * @param account The address of the account to check\n * @param blockNumber The block number to get the vote balance at\n * @return The number of votes the account had as of the given block\n */\n function getPriorVotes(address account, uint blockNumber) public view returns (uint96) {\n require(blockNumber < block.number, \"XVS::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlock > blockNumber) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlock == blockNumber) {\n return cp.votes;\n } else if (cp.fromBlock < blockNumber) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = balances[delegator];\n delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _transferTokens(address src, address dst, uint96 amount) internal {\n require(src != address(0), \"XVS::_transferTokens: cannot transfer from the zero address\");\n require(dst != address(0), \"XVS::_transferTokens: cannot transfer to the zero address\");\n\n balances[src] = sub96(balances[src], amount, \"XVS::_transferTokens: transfer amount exceeds balance\");\n balances[dst] = add96(balances[dst], amount, \"XVS::_transferTokens: transfer amount overflows\");\n emit Transfer(src, dst, amount);\n\n _moveDelegates(delegates[src], delegates[dst], amount);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"XVS::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"XVS::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumber = safe32(block.number, \"XVS::_writeCheckpoint: block number exceeds 32 bits\");\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChanged(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVesting.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/IBEP20.sol\";\nimport \"../../Utils/SafeBEP20.sol\";\nimport \"./XVSVestingStorage.sol\";\nimport \"./XVSVestingProxy.sol\";\n\n/**\n * @title Venus's XVSVesting Contract\n * @author Venus\n */\ncontract XVSVesting is XVSVestingStorage {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice total vesting period for 1 year in seconds\n uint256 public constant TOTAL_VESTING_TIME = 365 * 24 * 60 * 60;\n\n /// @notice decimal precision for XVS\n uint256 public constant xvsDecimalsMultiplier = 1e18;\n\n /// @notice Emitted when XVSVested is claimed by recipient\n event VestedTokensClaimed(address recipient, uint256 amountClaimed);\n\n /// @notice Emitted when vrtConversionAddress is set\n event VRTConversionSet(address vrtConversionAddress);\n\n /// @notice Emitted when XVS is deposited for vesting\n event XVSVested(address indexed recipient, uint256 startTime, uint256 amount, uint256 withdrawnAmount);\n\n /// @notice Emitted when XVS is withdrawn by recipient\n event XVSWithdrawn(address recipient, uint256 amount);\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n constructor() public {}\n\n /**\n * @notice initialize XVSVestingStorage\n * @param _xvsAddress The XVSToken address\n */\n function initialize(address _xvsAddress) public {\n require(msg.sender == admin, \"only admin may initialize the XVSVesting\");\n require(initialized == false, \"XVSVesting is already initialized\");\n require(_xvsAddress != address(0), \"_xvsAddress cannot be Zero\");\n xvs = IBEP20(_xvsAddress);\n\n _notEntered = true;\n initialized = true;\n }\n\n modifier isInitialized() {\n require(initialized == true, \"XVSVesting is not initialized\");\n _;\n }\n\n /**\n * @notice sets VRTConverter Address\n * @dev Note: If VRTConverter is not set, then Vesting is not allowed\n * @param _vrtConversionAddress The VRTConverterProxy Address\n */\n function setVRTConverter(address _vrtConversionAddress) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_vrtConversionAddress != address(0), \"vrtConversionAddress cannot be Zero\");\n vrtConversionAddress = _vrtConversionAddress;\n emit VRTConversionSet(_vrtConversionAddress);\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier onlyVrtConverter() {\n require(msg.sender == vrtConversionAddress, \"only VRTConversion Address can call the function\");\n _;\n }\n\n modifier vestingExistCheck(address recipient) {\n require(vestings[recipient].length > 0, \"recipient doesnot have any vestingRecord\");\n _;\n }\n\n /**\n * @notice Deposit XVS for Vesting\n * @param recipient The vesting recipient\n * @param depositAmount XVS amount for deposit\n */\n function deposit(\n address recipient,\n uint depositAmount\n ) external isInitialized onlyVrtConverter nonZeroAddress(recipient) {\n require(depositAmount > 0, \"Deposit amount must be non-zero\");\n\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n\n VestingRecord memory vesting = VestingRecord({\n recipient: recipient,\n startTime: getCurrentTime(),\n amount: depositAmount,\n withdrawnAmount: 0\n });\n\n vestingsOfRecipient.push(vesting);\n\n emit XVSVested(recipient, vesting.startTime, vesting.amount, vesting.withdrawnAmount);\n }\n\n /**\n * @notice Withdraw Vested XVS of recipient\n */\n function withdraw() external isInitialized vestingExistCheck(msg.sender) {\n address recipient = msg.sender;\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n uint256 totalWithdrawableAmount = 0;\n\n for (uint i = 0; i < vestingCount; ++i) {\n VestingRecord storage vesting = vestingsOfRecipient[i];\n (, uint256 toWithdraw) = calculateWithdrawableAmount(\n vesting.amount,\n vesting.startTime,\n vesting.withdrawnAmount\n );\n if (toWithdraw > 0) {\n totalWithdrawableAmount = totalWithdrawableAmount.add(toWithdraw);\n vesting.withdrawnAmount = vesting.withdrawnAmount.add(toWithdraw);\n }\n }\n\n if (totalWithdrawableAmount > 0) {\n uint256 xvsBalance = xvs.balanceOf(address(this));\n require(xvsBalance >= totalWithdrawableAmount, \"Insufficient XVS for withdrawal\");\n emit XVSWithdrawn(recipient, totalWithdrawableAmount);\n xvs.safeTransfer(recipient, totalWithdrawableAmount);\n }\n }\n\n /**\n * @notice get Withdrawable XVS Amount\n * @param recipient The vesting recipient\n * @dev returns A tuple with totalWithdrawableAmount , totalVestedAmount and totalWithdrawnAmount\n */\n function getWithdrawableAmount(\n address recipient\n )\n public\n view\n isInitialized\n nonZeroAddress(recipient)\n vestingExistCheck(recipient)\n returns (uint256 totalWithdrawableAmount, uint256 totalVestedAmount, uint256 totalWithdrawnAmount)\n {\n VestingRecord[] storage vestingsOfRecipient = vestings[recipient];\n uint256 vestingCount = vestingsOfRecipient.length;\n\n for (uint i = 0; i < vestingCount; i++) {\n VestingRecord storage vesting = vestingsOfRecipient[i];\n (uint256 vestedAmount, uint256 toWithdraw) = calculateWithdrawableAmount(\n vesting.amount,\n vesting.startTime,\n vesting.withdrawnAmount\n );\n totalVestedAmount = totalVestedAmount.add(vestedAmount);\n totalWithdrawableAmount = totalWithdrawableAmount.add(toWithdraw);\n totalWithdrawnAmount = totalWithdrawnAmount.add(vesting.withdrawnAmount);\n }\n\n return (totalWithdrawableAmount, totalVestedAmount, totalWithdrawnAmount);\n }\n\n /**\n * @notice get Withdrawable XVS Amount\n * @param amount Amount deposited for vesting\n * @param vestingStartTime time in epochSeconds at the time of vestingDeposit\n * @param withdrawnAmount XVSAmount withdrawn from VestedAmount\n * @dev returns A tuple with vestedAmount and withdrawableAmount\n */\n function calculateWithdrawableAmount(\n uint256 amount,\n uint256 vestingStartTime,\n uint256 withdrawnAmount\n ) internal view returns (uint256, uint256) {\n uint256 vestedAmount = calculateVestedAmount(amount, vestingStartTime, getCurrentTime());\n uint toWithdraw = vestedAmount.sub(withdrawnAmount);\n return (vestedAmount, toWithdraw);\n }\n\n /**\n * @notice calculate total vested amount\n * @param vestingAmount Amount deposited for vesting\n * @param vestingStartTime time in epochSeconds at the time of vestingDeposit\n * @param currentTime currentTime in epochSeconds\n * @return Total XVS amount vested\n */\n function calculateVestedAmount(\n uint256 vestingAmount,\n uint256 vestingStartTime,\n uint256 currentTime\n ) internal view returns (uint256) {\n if (currentTime < vestingStartTime) {\n return 0;\n } else if (currentTime > vestingStartTime.add(TOTAL_VESTING_TIME)) {\n return vestingAmount;\n } else {\n return (vestingAmount.mul(currentTime.sub(vestingStartTime))).div(TOTAL_VESTING_TIME);\n }\n }\n\n /**\n * @notice current block timestamp\n * @return blocktimestamp\n */\n function getCurrentTime() public view returns (uint256) {\n return block.timestamp;\n }\n\n /*** Admin Functions ***/\n function _become(XVSVestingProxy xvsVestingProxy) public {\n require(msg.sender == xvsVestingProxy.admin(), \"only proxy admin can change brains\");\n xvsVestingProxy._acceptImplementation();\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVestingProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./XVSVestingStorage.sol\";\n\ncontract XVSVestingProxy is XVSVestingAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means XVSVesting implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(\n address implementation_,\n address _xvsAddress\n ) public nonZeroAddress(implementation_) nonZeroAddress(_xvsAddress) {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(implementation_, abi.encodeWithSignature(\"initialize(address)\", _xvsAddress));\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"XVSVestingProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"XVSVestingProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal nonZeroAddress(callee) returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(\n address newPendingImplementation\n ) public nonZeroAddress(newPendingImplementation) {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRT Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) public nonZeroAddress(newPendingAdmin) {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n require(newPendingAdmin != pendingAdmin, \"New pendingAdmin can not be same as the previous one\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/Tokens/XVS/XVSVestingStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../../Utils/SafeMath.sol\";\nimport \"../../Utils/IBEP20.sol\";\n\ncontract XVSVestingAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of XVSVesting\n */\n address public implementation;\n\n /**\n * @notice Pending brains of XVSVesting\n */\n address public pendingImplementation;\n}\n\ncontract XVSVestingStorage is XVSVestingAdminStorage {\n struct VestingRecord {\n address recipient;\n uint256 startTime;\n uint256 amount;\n uint256 withdrawnAmount;\n }\n\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice indicator to check if the contract is initialized\n bool public initialized;\n\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice VRTConversion Contract Address\n address public vrtConversionAddress;\n\n /// @notice mapping of VestingRecord(s) for user(s)\n mapping(address => VestingRecord[]) public vestings;\n}\n" + }, + "contracts/Utils/Address.sol": { + "content": "pragma solidity ^0.5.5;\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 function isContract(address account) internal view returns (bool) {\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n // for accounts without code, i.e. `keccak256('')`\n bytes32 codehash;\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n codehash := extcodehash(account)\n }\n return (codehash != accountHash && codehash != 0x0);\n }\n\n /**\n * @dev Converts an `address` into `address payable`. Note that this is\n * simply a type cast: the actual underlying value is not changed.\n *\n * _Available since v2.4.0._\n */\n function toPayable(address account) internal pure returns (address payable) {\n return address(uint160(account));\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 * _Available since v2.4.0._\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-call-value\n // solium-disable-next-line security/no-call-value\n (bool success, ) = recipient.call.value(amount)(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n}\n" + }, + "contracts/Utils/CarefulMath.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Careful Math\n * @author Venus\n * @notice Derived from OpenZeppelin's SafeMath library\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\n */\ncontract CarefulMath {\n /**\n * @dev Possible error codes that we can return\n */\n enum MathError {\n NO_ERROR,\n DIVISION_BY_ZERO,\n INTEGER_OVERFLOW,\n INTEGER_UNDERFLOW\n }\n\n /**\n * @dev Multiplies two numbers, returns an error on overflow.\n */\n function mulUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (a == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n uint c = a * b;\n\n if (c / a != b) {\n return (MathError.INTEGER_OVERFLOW, 0);\n } else {\n return (MathError.NO_ERROR, c);\n }\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function divUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (b == 0) {\n return (MathError.DIVISION_BY_ZERO, 0);\n }\n\n return (MathError.NO_ERROR, a / b);\n }\n\n /**\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\n */\n function subUInt(uint a, uint b) internal pure returns (MathError, uint) {\n if (b <= a) {\n return (MathError.NO_ERROR, a - b);\n } else {\n return (MathError.INTEGER_UNDERFLOW, 0);\n }\n }\n\n /**\n * @dev Adds two numbers, returns an error on overflow.\n */\n function addUInt(uint a, uint b) internal pure returns (MathError, uint) {\n uint c = a + b;\n\n if (c >= a) {\n return (MathError.NO_ERROR, c);\n } else {\n return (MathError.INTEGER_OVERFLOW, 0);\n }\n }\n\n /**\n * @dev add a and b and then subtract c\n */\n function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) {\n (MathError err0, uint sum) = addUInt(a, b);\n\n if (err0 != MathError.NO_ERROR) {\n return (err0, 0);\n }\n\n return subUInt(sum, c);\n }\n}\n" + }, + "contracts/Utils/Context.sol": { + "content": "pragma solidity ^0.5.16;\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 GSN 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 */\ncontract Context {\n // Empty internal constructor, to prevent people from mistakenly deploying\n // an instance of this contract, which should be used via inheritance.\n constructor() internal {}\n\n function _msgSender() internal view returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n" + }, + "contracts/Utils/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// Adapted from OpenZeppelin Contracts v4.3.2 (utils/cryptography/ECDSA.sol)\n\n// SPDX-Copyright-Text: OpenZeppelin, 2021\n// SPDX-Copyright-Text: Venus, 2021\n\npragma solidity ^0.5.16;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\ncontract ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n}\n" + }, + "contracts/Utils/ErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract ComptrollerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n COMPTROLLER_MISMATCH,\n INSUFFICIENT_SHORTFALL,\n INSUFFICIENT_LIQUIDITY,\n INVALID_CLOSE_FACTOR,\n INVALID_COLLATERAL_FACTOR,\n INVALID_LIQUIDATION_INCENTIVE,\n MARKET_NOT_ENTERED, // no longer possible\n MARKET_NOT_LISTED,\n MARKET_ALREADY_LISTED,\n MATH_ERROR,\n NONZERO_BORROW_BALANCE,\n PRICE_ERROR,\n REJECTION,\n SNAPSHOT_ERROR,\n TOO_MANY_ASSETS,\n TOO_MUCH_REPAY,\n INSUFFICIENT_BALANCE_FOR_VAI,\n MARKET_NOT_COLLATERAL\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n EXIT_MARKET_BALANCE_OWED,\n EXIT_MARKET_REJECTION,\n SET_CLOSE_FACTOR_OWNER_CHECK,\n SET_CLOSE_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_NO_EXISTS,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\n SET_IMPLEMENTATION_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\n SET_MAX_ASSETS_OWNER_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_PRICE_ORACLE_OWNER_CHECK,\n SUPPORT_MARKET_EXISTS,\n SUPPORT_MARKET_OWNER_CHECK,\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\n SET_VAI_MINT_RATE_CHECK,\n SET_VAICONTROLLER_OWNER_CHECK,\n SET_MINTED_VAI_REJECTION,\n SET_TREASURY_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n\ncontract TokenErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n BAD_INPUT,\n COMPTROLLER_REJECTION,\n COMPTROLLER_CALCULATION_ERROR,\n INTEREST_RATE_MODEL_ERROR,\n INVALID_ACCOUNT_PAIR,\n INVALID_CLOSE_AMOUNT_REQUESTED,\n INVALID_COLLATERAL_FACTOR,\n MATH_ERROR,\n MARKET_NOT_FRESH,\n MARKET_NOT_LISTED,\n TOKEN_INSUFFICIENT_ALLOWANCE,\n TOKEN_INSUFFICIENT_BALANCE,\n TOKEN_INSUFFICIENT_CASH,\n TOKEN_TRANSFER_IN_FAILED,\n TOKEN_TRANSFER_OUT_FAILED,\n TOKEN_PRICE_ERROR\n }\n\n /*\n * Note: FailureInfo (but not Error) is kept in alphabetical order\n * This is because FailureInfo grows significantly faster, and\n * the order of Error has some meaning, while the order of FailureInfo\n * is entirely arbitrary.\n */\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n BORROW_ACCRUE_INTEREST_FAILED,\n BORROW_CASH_NOT_AVAILABLE,\n BORROW_FRESHNESS_CHECK,\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n BORROW_MARKET_NOT_LISTED,\n BORROW_COMPTROLLER_REJECTION,\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n LIQUIDATE_COMPTROLLER_REJECTION,\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n LIQUIDATE_FRESHNESS_CHECK,\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_ACCRUE_INTEREST_FAILED,\n MINT_COMPTROLLER_REJECTION,\n MINT_EXCHANGE_CALCULATION_FAILED,\n MINT_EXCHANGE_RATE_READ_FAILED,\n MINT_FRESHNESS_CHECK,\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n MINT_TRANSFER_IN_FAILED,\n MINT_TRANSFER_IN_NOT_POSSIBLE,\n REDEEM_ACCRUE_INTEREST_FAILED,\n REDEEM_COMPTROLLER_REJECTION,\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\n REDEEM_EXCHANGE_RATE_READ_FAILED,\n REDEEM_FRESHNESS_CHECK,\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\n REDUCE_RESERVES_ADMIN_CHECK,\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\n REDUCE_RESERVES_FRESH_CHECK,\n REDUCE_RESERVES_VALIDATION,\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_COMPTROLLER_REJECTION,\n REPAY_BORROW_FRESHNESS_CHECK,\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COMPTROLLER_OWNER_CHECK,\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\n SET_MAX_ASSETS_OWNER_CHECK,\n SET_ORACLE_MARKET_NOT_LISTED,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\n SET_RESERVE_FACTOR_ADMIN_CHECK,\n SET_RESERVE_FACTOR_FRESH_CHECK,\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\n TRANSFER_COMPTROLLER_REJECTION,\n TRANSFER_NOT_ALLOWED,\n TRANSFER_NOT_ENOUGH,\n TRANSFER_TOO_MUCH,\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\n ADD_RESERVES_FRESH_CHECK,\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE,\n TOKEN_GET_UNDERLYING_PRICE_ERROR,\n REPAY_VAI_COMPTROLLER_REJECTION,\n REPAY_VAI_FRESHNESS_CHECK,\n VAI_MINT_EXCHANGE_CALCULATION_FAILED,\n SFT_MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n\ncontract VAIControllerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED, // The sender is not authorized to perform this action.\n REJECTION, // The action would violate the comptroller, vaicontroller policy.\n SNAPSHOT_ERROR, // The comptroller could not get the account borrows and exchange rate from the market.\n PRICE_ERROR, // The comptroller could not obtain a required price of an asset.\n MATH_ERROR, // A math calculation error occurred.\n INSUFFICIENT_BALANCE_FOR_VAI // Caller does not have sufficient balance to mint VAI.\n }\n\n enum FailureInfo {\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_COMPTROLLER_OWNER_CHECK,\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n VAI_MINT_REJECTION,\n VAI_BURN_REJECTION,\n VAI_LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n VAI_LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n VAI_LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n VAI_LIQUIDATE_COMPTROLLER_REJECTION,\n VAI_LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n VAI_LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n VAI_LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n VAI_LIQUIDATE_FRESHNESS_CHECK,\n VAI_LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n VAI_LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n VAI_LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n VAI_LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n VAI_LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n VAI_LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n VAI_LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_FEE_CALCULATION_FAILED,\n SET_TREASURY_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/Utils/Exponential.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./CarefulMath.sol\";\nimport \"./ExponentialNoError.sol\";\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Venus\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract Exponential is CarefulMath, ExponentialNoError {\n /**\n * @dev Creates an exponential from numerator and denominator values.\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\n * or if `denom` is zero.\n */\n function getExp(uint num, uint denom) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint scaledNumerator) = mulUInt(num, expScale);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n (MathError err1, uint rational) = divUInt(scaledNumerator, denom);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\n }\n\n /**\n * @dev Adds two exponentials, returning a new exponential.\n */\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint result) = addUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Subtracts two exponentials, returning a new exponential.\n */\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint result) = subUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, returning a new Exp.\n */\n function mulScalar(Exp memory a, uint scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mulScalarTruncate(Exp memory a, uint scalar) internal pure returns (MathError, uint) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(product));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) internal pure returns (MathError, uint) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return addUInt(truncate(product), addend);\n }\n\n /**\n * @dev Divide an Exp by a scalar, returning a new Exp.\n */\n function divScalar(Exp memory a, uint scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\n }\n\n /**\n * @dev Divide a scalar by an Exp, returning a new Exp.\n */\n function divScalarByExp(uint scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\n /*\n We are doing this as:\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\n\n How it works:\n Exp = a / b;\n Scalar = s;\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\n */\n (MathError err0, uint numerator) = mulUInt(expScale, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n return getExp(numerator, divisor.mantissa);\n }\n\n /**\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\n */\n function divScalarByExpTruncate(uint scalar, Exp memory divisor) internal pure returns (MathError, uint) {\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(fraction));\n }\n\n /**\n * @dev Multiplies two exponentials, returning a new exponential.\n */\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n // We add half the scale before dividing so that we get rounding instead of truncation.\n // See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\n (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale);\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\n assert(err2 == MathError.NO_ERROR);\n\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\n }\n\n /**\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\n */\n function mulExp(uint a, uint b) internal pure returns (MathError, Exp memory) {\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\n }\n\n /**\n * @dev Multiplies three exponentials, returning a new exponential.\n */\n function mulExp3(Exp memory a, Exp memory b, Exp memory c) internal pure returns (MathError, Exp memory) {\n (MathError err, Exp memory ab) = mulExp(a, b);\n if (err != MathError.NO_ERROR) {\n return (err, ab);\n }\n return mulExp(ab, c);\n }\n\n /**\n * @dev Divides two exponentials, returning a new exponential.\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\n */\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n return getExp(a.mantissa, b.mantissa);\n }\n}\n" + }, + "contracts/Utils/ExponentialNoError.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract ExponentialNoError {\n uint internal constant expScale = 1e18;\n uint internal constant doubleScale = 1e36;\n uint internal constant halfExpScale = expScale / 2;\n uint internal constant mantissaOne = expScale;\n\n struct Exp {\n uint mantissa;\n }\n\n struct Double {\n uint mantissa;\n }\n\n /**\n * @dev Truncates the given exp to a whole number value.\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\n */\n function truncate(Exp memory exp) internal pure returns (uint) {\n // Note: We are not using careful math here as we're performing a division that cannot fail\n return exp.mantissa / expScale;\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mul_ScalarTruncate(Exp memory a, uint scalar) internal pure returns (uint) {\n Exp memory product = mul_(a, scalar);\n return truncate(product);\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mul_ScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) internal pure returns (uint) {\n Exp memory product = mul_(a, scalar);\n return add_(truncate(product), addend);\n }\n\n /**\n * @dev Checks if first Exp is less than second Exp.\n */\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa < right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp <= right Exp.\n */\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa <= right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp > right Exp.\n */\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa > right.mantissa;\n }\n\n /**\n * @dev returns true if Exp is exactly zero\n */\n function isZeroExp(Exp memory value) internal pure returns (bool) {\n return value.mantissa == 0;\n }\n\n function safe224(uint n, string memory errorMessage) internal pure returns (uint224) {\n require(n < 2 ** 224, errorMessage);\n return uint224(n);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(uint a, uint b) internal pure returns (uint) {\n return add_(a, b, \"addition overflow\");\n }\n\n function add_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n uint c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(uint a, uint b) internal pure returns (uint) {\n return sub_(a, b, \"subtraction underflow\");\n }\n\n function sub_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\n }\n\n function mul_(Exp memory a, uint b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint a, Exp memory b) internal pure returns (uint) {\n return mul_(a, b.mantissa) / expScale;\n }\n\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\n }\n\n function mul_(Double memory a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint a, Double memory b) internal pure returns (uint) {\n return mul_(a, b.mantissa) / doubleScale;\n }\n\n function mul_(uint a, uint b) internal pure returns (uint) {\n return mul_(a, b, \"multiplication overflow\");\n }\n\n function mul_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n if (a == 0 || b == 0) {\n return 0;\n }\n uint c = a * b;\n require(c / a == b, errorMessage);\n return c;\n }\n\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\n }\n\n function div_(Exp memory a, uint b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint a, Exp memory b) internal pure returns (uint) {\n return div_(mul_(a, expScale), b.mantissa);\n }\n\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\n }\n\n function div_(Double memory a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint a, Double memory b) internal pure returns (uint) {\n return div_(mul_(a, doubleScale), b.mantissa);\n }\n\n function div_(uint a, uint b) internal pure returns (uint) {\n return div_(a, b, \"divide by zero\");\n }\n\n function div_(uint a, uint b, string memory errorMessage) internal pure returns (uint) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n function fraction(uint a, uint b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\n }\n}\n" + }, + "contracts/Utils/IBEP20.sol": { + "content": "pragma solidity ^0.5.0;\n\n/**\n * @dev Interface of the BEP20 standard as defined in the EIP. Does not include\n * the optional functions; to access them see {BEP20Detailed}.\n */\ninterface IBEP20 {\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 `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\n\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" + }, + "contracts/Utils/Ownable.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\ncontract 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() internal {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view 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 onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = 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 onlyOwner {\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n */\n function _transferOwnership(address newOwner) internal {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n}\n" + }, + "contracts/Utils/Owned.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract Owned {\n address public owner;\n\n event OwnershipTransferred(address indexed _from, address indexed _to);\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Should be owner\");\n _;\n }\n\n function transferOwnership(address newOwner) public onlyOwner {\n owner = newOwner;\n emit OwnershipTransferred(owner, newOwner);\n }\n}\n" + }, + "contracts/Utils/SafeBEP20.sol": { + "content": "pragma solidity ^0.5.0;\n\nimport \"./SafeMath.sol\";\nimport \"./IBEP20.sol\";\nimport \"./Address.sol\";\n\n/**\n * @title SafeBEP20\n * @dev Wrappers around BEP20 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 SafeBEP20 for BEP20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeBEP20 {\n using SafeMath for uint256;\n using Address for address;\n\n function safeTransfer(IBEP20 token, address to, uint256 value) internal {\n callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(IBEP20 token, address from, address to, uint256 value) internal {\n callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n function safeApprove(IBEP20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeBEP20: approve from non-zero to non-zero allowance\"\n );\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(IBEP20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).sub(\n value,\n \"SafeBEP20: decreased allowance below zero\"\n );\n callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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(IBEP20 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.\n\n // A Solidity high level call has three parts:\n // 1. The target address is checked to verify it contains contract code\n // 2. The call itself is made, and success asserted\n // 3. The return value is decoded, which in turn checks the size of the returned data.\n // solhint-disable-next-line max-line-length\n require(address(token).isContract(), \"SafeBEP20: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = address(token).call(data);\n require(success, \"SafeBEP20: low-level call failed\");\n\n if (returndata.length > 0) {\n // Return data is optional\n // solhint-disable-next-line max-line-length\n require(abi.decode(returndata, (bool)), \"SafeBEP20: BEP20 operation did not succeed\");\n }\n }\n}\n" + }, + "contracts/Utils/SafeCast.sol": { + "content": "pragma solidity ^0.5.16;\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 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 < 2 ** 128, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(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 < 2 ** 64, \"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 < 2 ** 32, \"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 < 2 ** 16, \"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 < 2 ** 8, \"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 >= -2 ** 127 && value < 2 ** 127, \"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 >= -2 ** 63 && value < 2 ** 63, \"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 >= -2 ** 31 && value < 2 ** 31, \"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 >= -2 ** 15 && value < 2 ** 15, \"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 >= -2 ** 7 && value < 2 ** 7, \"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 require(value < 2 ** 255, \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "contracts/Utils/SafeMath.sol": { + "content": "pragma solidity ^0.5.16;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return add(a, b, \"SafeMath: addition overflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, errorMessage);\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0, errorMessage);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return mod(a, b, \"SafeMath: modulo by zero\");\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts with custom message when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b != 0, errorMessage);\n return a % b;\n }\n}\n" + }, + "contracts/Utils/Tokenlock.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./Owned.sol\";\n\ncontract Tokenlock is Owned {\n /// @notice Indicates if token is locked\n uint8 internal isLocked = 0;\n\n event Freezed();\n event UnFreezed();\n\n modifier validLock() {\n require(isLocked == 0, \"Token is locked\");\n _;\n }\n\n function freeze() public onlyOwner {\n isLocked = 1;\n\n emit Freezed();\n }\n\n function unfreeze() public onlyOwner {\n isLocked = 0;\n\n emit UnFreezed();\n }\n}\n" + }, + "contracts/VAIVault/VAIVault.sol": { + "content": "pragma solidity 0.5.16;\n\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./VAIVaultStorage.sol\";\nimport \"./VAIVaultErrorReporter.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\nimport { VAIVaultProxy } from \"./VAIVaultProxy.sol\";\n\n/**\n * @title VAI Vault\n * @author Venus\n * @notice The VAI Vault is configured for users to stake VAI And receive XVS as a reward.\n */\ncontract VAIVault is VAIVaultStorage, AccessControlledV5 {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice Event emitted when VAI deposit\n event Deposit(address indexed user, uint256 amount);\n\n /// @notice Event emitted when VAI withrawal\n event Withdraw(address indexed user, uint256 amount);\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @dev Prevents functions to execute when vault is paused.\n */\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @notice Pause vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Deposit VAI to VAIVault for XVS allocation\n * @param _amount The amount to deposit to vault\n */\n function deposit(uint256 _amount) external nonReentrant isActive {\n UserInfo storage user = userInfo[msg.sender];\n\n updateVault();\n\n // Transfer pending tokens to user\n updateAndPayOutPending(msg.sender);\n\n // Transfer in the amounts from user\n if (_amount > 0) {\n vai.safeTransferFrom(address(msg.sender), address(this), _amount);\n user.amount = user.amount.add(_amount);\n }\n\n user.rewardDebt = user.amount.mul(accXVSPerShare).div(1e18);\n emit Deposit(msg.sender, _amount);\n }\n\n /**\n * @notice Withdraw VAI from VAIVault\n * @param _amount The amount to withdraw from vault\n */\n function withdraw(uint256 _amount) external nonReentrant isActive {\n _withdraw(msg.sender, _amount);\n }\n\n /**\n * @notice Claim XVS from VAIVault\n */\n function claim() external nonReentrant isActive {\n _withdraw(msg.sender, 0);\n }\n\n /**\n * @notice Claim XVS from VAIVault\n * @param account The account for which to claim XVS\n */\n function claim(address account) external nonReentrant isActive {\n _withdraw(account, 0);\n }\n\n /**\n * @notice Low level withdraw function\n * @param account The account to withdraw from vault\n * @param _amount The amount to withdraw from vault\n */\n function _withdraw(address account, uint256 _amount) internal {\n UserInfo storage user = userInfo[account];\n require(user.amount >= _amount, \"withdraw: not good\");\n\n updateVault();\n updateAndPayOutPending(account); // Update balances of account this is not withdrawal but claiming XVS farmed\n\n if (_amount > 0) {\n user.amount = user.amount.sub(_amount);\n vai.safeTransfer(address(account), _amount);\n }\n user.rewardDebt = user.amount.mul(accXVSPerShare).div(1e18);\n\n emit Withdraw(account, _amount);\n }\n\n /**\n * @notice View function to see pending XVS on frontend\n * @param _user The user to see pending XVS\n * @return Amount of XVS the user can claim\n */\n function pendingXVS(address _user) public view returns (uint256) {\n UserInfo storage user = userInfo[_user];\n\n return user.amount.mul(accXVSPerShare).div(1e18).sub(user.rewardDebt);\n }\n\n /**\n * @notice Update and pay out pending XVS to user\n * @param account The user to pay out\n */\n function updateAndPayOutPending(address account) internal {\n uint256 pending = pendingXVS(account);\n\n if (pending > 0) {\n safeXVSTransfer(account, pending);\n }\n }\n\n /**\n * @notice Safe XVS transfer function, just in case if rounding error causes pool to not have enough XVS\n * @param _to The address that XVS to be transfered\n * @param _amount The amount that XVS to be transfered\n */\n function safeXVSTransfer(address _to, uint256 _amount) internal {\n uint256 xvsBal = xvs.balanceOf(address(this));\n\n if (_amount > xvsBal) {\n xvs.transfer(_to, xvsBal);\n xvsBalance = xvs.balanceOf(address(this));\n } else {\n xvs.transfer(_to, _amount);\n xvsBalance = xvs.balanceOf(address(this));\n }\n }\n\n /**\n * @notice Function that updates pending rewards\n */\n function updatePendingRewards() public isActive {\n uint256 newRewards = xvs.balanceOf(address(this)).sub(xvsBalance);\n\n if (newRewards > 0) {\n xvsBalance = xvs.balanceOf(address(this)); // If there is no change the balance didn't change\n pendingRewards = pendingRewards.add(newRewards);\n }\n }\n\n /**\n * @notice Update reward variables to be up-to-date\n */\n function updateVault() internal {\n updatePendingRewards();\n\n uint256 vaiBalance = vai.balanceOf(address(this));\n if (vaiBalance == 0) {\n // avoids division by 0 errors\n return;\n }\n\n accXVSPerShare = accXVSPerShare.add(pendingRewards.mul(1e18).div(vaiBalance));\n pendingRewards = 0;\n }\n\n /*** Admin Functions ***/\n\n function _become(VAIVaultProxy vaiVaultProxy) external {\n require(msg.sender == vaiVaultProxy.admin(), \"only proxy admin can change brains\");\n require(vaiVaultProxy._acceptImplementation() == 0, \"change not authorized\");\n }\n\n function setVenusInfo(address _xvs, address _vai) external onlyAdmin {\n require(_xvs != address(0) && _vai != address(0), \"addresses must not be zero\");\n require(address(xvs) == address(0) && address(vai) == address(0), \"addresses already set\");\n xvs = IBEP20(_xvs);\n vai = IBEP20(_vai);\n\n _notEntered = true;\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract VAIVaultErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VAIVaultStorage.sol\";\nimport \"./VAIVaultErrorReporter.sol\";\n\n/**\n * @title VAI Vault Proxy\n * @author Venus\n * @notice Proxy contract for the VAI Vault\n */\ncontract VAIVaultProxy is VAIVaultAdminStorage, VAIVaultErrorReporter {\n /**\n * @notice Emitted when pendingVAIVaultImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingVAIVaultImplementation is accepted, which means VAI Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingVAIVaultImplementation;\n\n pendingVAIVaultImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of VAI Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingVAIVaultImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = vaiVaultImplementation;\n address oldPendingImplementation = pendingVAIVaultImplementation;\n\n vaiVaultImplementation = pendingVAIVaultImplementation;\n\n pendingVAIVaultImplementation = address(0);\n\n emit NewImplementation(oldImplementation, vaiVaultImplementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingVAIVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = vaiVaultImplementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/VAIVault/VAIVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\n\ncontract VAIVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VAI Vault\n */\n address public vaiVaultImplementation;\n\n /**\n * @notice Pending brains of VAI Vault\n */\n address public pendingVAIVaultImplementation;\n}\n\ncontract VAIVaultStorage is VAIVaultAdminStorage {\n /// @notice The XVS TOKEN!\n IBEP20 public xvs;\n\n /// @notice The VAI TOKEN!\n IBEP20 public vai;\n\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice XVS balance of vault\n uint256 public xvsBalance;\n\n /// @notice Accumulated XVS per share\n uint256 public accXVSPerShare;\n\n //// pending rewards awaiting anyone to update\n uint256 public pendingRewards;\n\n /// @notice Info of each user.\n struct UserInfo {\n uint256 amount;\n uint256 rewardDebt;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => UserInfo) public userInfo;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "contracts/VRTVault/VRTVault.sol": { + "content": "pragma solidity 0.5.16;\n\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./VRTVaultStorage.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\n\ninterface IVRTVaultProxy {\n function _acceptImplementation() external;\n\n function admin() external returns (address);\n}\n\ncontract VRTVault is VRTVaultStorage, AccessControlledV5 {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The upper bound for lastAccruingBlock. Close to year 3,000, considering 3 seconds per block. Used to avoid a value absurdly high\n uint256 public constant MAX_LAST_ACCRUING_BLOCK = 9999999999;\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n /// @notice Event emitted on VRT deposit\n event Deposit(address indexed user, uint256 amount);\n\n /// @notice Event emitted when accruedInterest and VRT PrincipalAmount is withrawn\n event Withdraw(\n address indexed user,\n uint256 withdrawnAmount,\n uint256 totalPrincipalAmount,\n uint256 accruedInterest\n );\n\n /// @notice Event emitted when Admin withdraw BEP20 token from contract\n event WithdrawToken(address indexed tokenAddress, address indexed receiver, uint256 amount);\n\n /// @notice Event emitted when accruedInterest is claimed\n event Claim(address indexed user, uint256 interestAmount);\n\n /// @notice Event emitted when lastAccruingBlock state variable changes\n event LastAccruingBlockChanged(uint256 oldLastAccruingBlock, uint256 newLastAccruingBlock);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin allowed\");\n _;\n }\n\n function initialize(address _vrtAddress, uint256 _interestRatePerBlock) public {\n require(msg.sender == admin, \"only admin may initialize the Vault\");\n require(_vrtAddress != address(0), \"vrtAddress cannot be Zero\");\n require(interestRatePerBlock == 0, \"Vault may only be initialized once\");\n\n // Set initial exchange rate\n interestRatePerBlock = _interestRatePerBlock;\n require(interestRatePerBlock > 0, \"interestRate Per Block must be greater than zero.\");\n\n // Set the VRT\n vrt = IBEP20(_vrtAddress);\n _notEntered = true;\n }\n\n modifier isInitialized() {\n require(interestRatePerBlock > 0, \"Vault is not initialized\");\n _;\n }\n\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n modifier nonZeroAddress(address _address) {\n require(_address != address(0), \"Address cannot be Zero\");\n _;\n }\n\n modifier userHasPosition(address userAddress) {\n UserInfo storage user = userInfo[userAddress];\n require(user.userAddress != address(0), \"User does not have any position in the Vault.\");\n _;\n }\n\n /**\n * @notice Pause vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Deposit VRT to VRTVault for a fixed-interest-rate\n * @param depositAmount The amount to deposit to vault\n */\n function deposit(uint256 depositAmount) external nonReentrant isInitialized isActive {\n require(depositAmount > 0, \"Deposit amount must be non-zero\");\n\n address userAddress = msg.sender;\n UserInfo storage user = userInfo[userAddress];\n\n if (user.userAddress == address(0)) {\n user.userAddress = userAddress;\n user.totalPrincipalAmount = depositAmount;\n } else {\n // accrue Interest and transfer to the user\n uint256 accruedInterest = computeAccruedInterest(user.totalPrincipalAmount, user.accrualStartBlockNumber);\n\n user.totalPrincipalAmount = user.totalPrincipalAmount.add(depositAmount);\n\n if (accruedInterest > 0) {\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(\n vrtBalance >= accruedInterest,\n \"Failed to transfer accruedInterest, Insufficient VRT in Vault.\"\n );\n emit Claim(userAddress, accruedInterest);\n vrt.safeTransfer(user.userAddress, accruedInterest);\n }\n }\n\n uint256 currentBlock_ = getBlockNumber();\n if (lastAccruingBlock > currentBlock_) {\n user.accrualStartBlockNumber = currentBlock_;\n } else {\n user.accrualStartBlockNumber = lastAccruingBlock;\n }\n emit Deposit(userAddress, depositAmount);\n vrt.safeTransferFrom(userAddress, address(this), depositAmount);\n }\n\n /**\n * @notice get accruedInterest of the user's VRTDeposits in the Vault\n * @param userAddress Address of User in the the Vault\n * @return The interest accrued, in VRT\n */\n function getAccruedInterest(\n address userAddress\n ) public view nonZeroAddress(userAddress) isInitialized returns (uint256) {\n UserInfo storage user = userInfo[userAddress];\n if (user.accrualStartBlockNumber == 0) {\n return 0;\n }\n\n return computeAccruedInterest(user.totalPrincipalAmount, user.accrualStartBlockNumber);\n }\n\n /**\n * @notice get accruedInterest of the user's VRTDeposits in the Vault\n * @param totalPrincipalAmount of the User\n * @param accrualStartBlockNumber of the User\n * @return The interest accrued, in VRT\n */\n function computeAccruedInterest(\n uint256 totalPrincipalAmount,\n uint256 accrualStartBlockNumber\n ) internal view isInitialized returns (uint256) {\n uint256 blockNumber = getBlockNumber();\n uint256 _lastAccruingBlock = lastAccruingBlock;\n\n if (blockNumber > _lastAccruingBlock) {\n blockNumber = _lastAccruingBlock;\n }\n\n if (accrualStartBlockNumber == 0 || accrualStartBlockNumber >= blockNumber) {\n return 0;\n }\n\n // Number of blocks since deposit\n uint256 blockDelta = blockNumber.sub(accrualStartBlockNumber);\n uint256 accruedInterest = (totalPrincipalAmount.mul(interestRatePerBlock).mul(blockDelta)).div(1e18);\n return accruedInterest;\n }\n\n /**\n * @notice claim the accruedInterest of the user's VRTDeposits in the Vault\n */\n function claim() external nonReentrant isInitialized userHasPosition(msg.sender) isActive {\n _claim(msg.sender);\n }\n\n /**\n * @notice claim the accruedInterest of the user's VRTDeposits in the Vault\n * @param account The account for which to claim rewards\n */\n function claim(address account) external nonReentrant isInitialized userHasPosition(account) isActive {\n _claim(account);\n }\n\n /**\n * @notice Low level claim function\n * @param account The account for which to claim rewards\n */\n function _claim(address account) internal {\n uint256 accruedInterest = getAccruedInterest(account);\n if (accruedInterest > 0) {\n UserInfo storage user = userInfo[account];\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(vrtBalance >= accruedInterest, \"Failed to transfer VRT, Insufficient VRT in Vault.\");\n emit Claim(account, accruedInterest);\n uint256 currentBlock_ = getBlockNumber();\n if (lastAccruingBlock > currentBlock_) {\n user.accrualStartBlockNumber = currentBlock_;\n } else {\n user.accrualStartBlockNumber = lastAccruingBlock;\n }\n vrt.safeTransfer(user.userAddress, accruedInterest);\n }\n }\n\n /**\n * @notice withdraw accruedInterest and totalPrincipalAmount of the user's VRTDeposit in the Vault\n */\n function withdraw() external nonReentrant isInitialized userHasPosition(msg.sender) isActive {\n address userAddress = msg.sender;\n uint256 accruedInterest = getAccruedInterest(userAddress);\n\n UserInfo storage user = userInfo[userAddress];\n\n uint256 totalPrincipalAmount = user.totalPrincipalAmount;\n uint256 vrtForWithdrawal = accruedInterest.add(totalPrincipalAmount);\n user.totalPrincipalAmount = 0;\n user.accrualStartBlockNumber = getBlockNumber();\n\n uint256 vrtBalance = vrt.balanceOf(address(this));\n require(vrtBalance >= vrtForWithdrawal, \"Failed to transfer VRT, Insufficient VRT in Vault.\");\n\n emit Withdraw(userAddress, vrtForWithdrawal, totalPrincipalAmount, accruedInterest);\n vrt.safeTransfer(user.userAddress, vrtForWithdrawal);\n }\n\n /**\n * @notice withdraw BEP20 tokens from the contract to a recipient address.\n * @param tokenAddress address of the BEP20 token\n * @param receiver recipient of the BEP20 token\n * @param amount tokenAmount\n */\n function withdrawBep20(\n address tokenAddress,\n address receiver,\n uint256 amount\n ) external isInitialized nonZeroAddress(tokenAddress) nonZeroAddress(receiver) {\n _checkAccessAllowed(\"withdrawBep20(address,address,uint256)\");\n require(amount > 0, \"amount is invalid\");\n IBEP20 token = IBEP20(tokenAddress);\n require(amount <= token.balanceOf(address(this)), \"Insufficient amount in Vault\");\n emit WithdrawToken(tokenAddress, receiver, amount);\n token.safeTransfer(receiver, amount);\n }\n\n function setLastAccruingBlock(uint256 _lastAccruingBlock) external {\n _checkAccessAllowed(\"setLastAccruingBlock(uint256)\");\n require(_lastAccruingBlock < MAX_LAST_ACCRUING_BLOCK, \"_lastAccruingBlock is absurdly high\");\n\n uint256 oldLastAccruingBlock = lastAccruingBlock;\n uint256 currentBlock = getBlockNumber();\n if (oldLastAccruingBlock != 0) {\n require(currentBlock < oldLastAccruingBlock, \"Cannot change at this point\");\n }\n if (oldLastAccruingBlock == 0 || _lastAccruingBlock < oldLastAccruingBlock) {\n // Must be in future\n require(currentBlock < _lastAccruingBlock, \"Invalid _lastAccruingBlock interest have been accumulated\");\n }\n lastAccruingBlock = _lastAccruingBlock;\n emit LastAccruingBlockChanged(oldLastAccruingBlock, _lastAccruingBlock);\n }\n\n function getBlockNumber() public view returns (uint256) {\n return block.number;\n }\n\n /*** Admin Functions ***/\n\n function _become(IVRTVaultProxy vrtVaultProxy) external {\n require(msg.sender == vrtVaultProxy.admin(), \"only proxy admin can change brains\");\n vrtVaultProxy._acceptImplementation();\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n}\n" + }, + "contracts/VRTVault/VRTVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./VRTVaultStorage.sol\";\n\ncontract VRTVaultProxy is VRTVaultAdminStorage {\n /**\n * @notice Emitted when pendingImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingImplementation is accepted, which means VRT Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(address implementation_, address vrtAddress_, uint256 interestRatePerBlock_) public {\n // Creator of the contract is admin during initialization\n admin = msg.sender;\n\n // New implementations always get set via the settor (post-initialize)\n _setImplementation(implementation_);\n\n // First delegate gets to initialize the delegator (i.e. storage contract)\n delegateTo(\n implementation_,\n abi.encodeWithSignature(\"initialize(address,uint256)\", vrtAddress_, interestRatePerBlock_)\n );\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n */\n function _setImplementation(address implementation_) public {\n require(msg.sender == admin, \"VRTVaultProxy::_setImplementation: admin only\");\n require(implementation_ != address(0), \"VRTVaultProxy::_setImplementation: invalid implementation address\");\n\n address oldImplementation = implementation;\n implementation = implementation_;\n\n emit NewImplementation(oldImplementation, implementation);\n }\n\n /**\n * @notice Internal method to delegate execution to another contract\n * @dev It returns to the external caller whatever the implementation returns or forwards reverts\n * @param callee The contract to delegatecall\n * @param data The raw data to delegatecall\n * @return The returned bytes from the delegatecall\n */\n function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = callee.delegatecall(data);\n assembly {\n if eq(success, 0) {\n revert(add(returnData, 0x20), returndatasize)\n }\n }\n return returnData;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public {\n require(msg.sender == admin, \"Only admin can set Pending Implementation\");\n\n address oldPendingImplementation = pendingImplementation;\n\n pendingImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Accepts new implementation of VRT Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n */\n function _acceptImplementation() public {\n // Check caller is pendingImplementation\n require(\n msg.sender == pendingImplementation,\n \"only address marked as pendingImplementation can accept Implementation\"\n );\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingImplementation;\n\n implementation = pendingImplementation;\n\n pendingImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) public {\n // Check caller = admin\n require(msg.sender == admin, \"only admin can set pending admin\");\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @dev return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public {\n // Check caller is pendingAdmin\n require(msg.sender == pendingAdmin, \"only address marked as pendingAdmin can accept as Admin\");\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/VRTVault/VRTVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\n\ncontract VRTVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of VRT Vault\n */\n address public implementation;\n\n /**\n * @notice Pending brains of VAI Vault\n */\n address public pendingImplementation;\n}\n\ncontract VRTVaultStorage is VRTVaultAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool public _notEntered;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /// @notice The VRT TOKEN!\n IBEP20 public vrt;\n\n /// @notice interestRate for accrual - per Block\n uint256 public interestRatePerBlock;\n\n /// @notice Info of each user.\n struct UserInfo {\n address userAddress;\n uint256 accrualStartBlockNumber;\n uint256 totalPrincipalAmount;\n uint256 lastWithdrawnBlockNumber;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => UserInfo) public userInfo;\n\n /// @notice block number after which no interest will be accrued\n uint256 public lastAccruingBlock;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "contracts/XVSVault/XVSStore.sol": { + "content": "pragma solidity 0.5.16;\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\n\n/**\n * @title XVS Store\n * @author Venus\n * @notice XVS Store responsible for distributing XVS rewards\n */\ncontract XVSStore {\n using SafeMath for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The Admin Address\n address public admin;\n\n /// @notice The pending admin address\n address public pendingAdmin;\n\n /// @notice The Owner Address\n address public owner;\n\n /// @notice The reward tokens\n mapping(address => bool) public rewardTokens;\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Event emitted when admin changed\n event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);\n\n /// @notice Event emitted when owner changed\n event OwnerTransferred(address indexed oldOwner, address indexed newOwner);\n\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"only owner can\");\n _;\n }\n\n /**\n * @notice Safely transfer rewards. Only active reward tokens can be sent using this function.\n * Only callable by owner\n * @dev Safe reward token transfer function, just in case if rounding error causes pool to not have enough tokens.\n * @param token Reward token to transfer\n * @param _to Destination address of the reward\n * @param _amount Amount to transfer\n */\n function safeRewardTransfer(address token, address _to, uint256 _amount) external onlyOwner {\n require(rewardTokens[token] == true, \"only reward token can\");\n\n if (address(token) != address(0)) {\n uint256 tokenBalance = IBEP20(token).balanceOf(address(this));\n if (_amount > tokenBalance) {\n IBEP20(token).safeTransfer(_to, tokenBalance);\n } else {\n IBEP20(token).safeTransfer(_to, _amount);\n }\n }\n }\n\n /**\n * @notice Allows the admin to propose a new admin\n * Only callable admin\n * @param _admin Propose an account as admin of the XVS store\n */\n function setPendingAdmin(address _admin) external onlyAdmin {\n address oldPendingAdmin = pendingAdmin;\n pendingAdmin = _admin;\n emit NewPendingAdmin(oldPendingAdmin, _admin);\n }\n\n /**\n * @notice Allows an account that is pending as admin to accept the role\n * nly calllable by the pending admin\n */\n function acceptAdmin() external {\n require(msg.sender == pendingAdmin, \"only pending admin\");\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n admin = pendingAdmin;\n pendingAdmin = address(0);\n\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n emit AdminTransferred(oldAdmin, admin);\n }\n\n /**\n * @notice Set the contract owner\n * @param _owner The address of the owner to set\n * Only callable admin\n */\n function setNewOwner(address _owner) external onlyAdmin {\n require(_owner != address(0), \"new owner is the zero address\");\n address oldOwner = owner;\n owner = _owner;\n emit OwnerTransferred(oldOwner, _owner);\n }\n\n /**\n * @notice Set or disable a reward token\n * @param _tokenAddress The address of a token to set as active or inactive\n * @param status Set whether a reward token is active or not\n */\n function setRewardToken(address _tokenAddress, bool status) external {\n require(msg.sender == admin || msg.sender == owner, \"only admin or owner can\");\n rewardTokens[_tokenAddress] = status;\n }\n\n /**\n * @notice Security function to allow the owner of the contract to withdraw from the contract\n * @param _tokenAddress Reward token address to withdraw\n * @param _amount Amount of token to withdraw\n */\n function emergencyRewardWithdraw(address _tokenAddress, uint256 _amount) external onlyOwner {\n IBEP20(_tokenAddress).safeTransfer(address(msg.sender), _amount);\n }\n}\n" + }, + "contracts/XVSVault/XVSVault.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\npragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\nimport \"../Utils/ECDSA.sol\";\nimport \"../Utils/SafeBEP20.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"./XVSVaultStorage.sol\";\nimport \"../Tokens/Prime/IPrime.sol\";\nimport \"../Utils/SafeCast.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV5.sol\";\nimport \"@venusprotocol/solidity-utilities/contracts/TimeManagerV5.sol\";\n\nimport { XVSStore } from \"./XVSStore.sol\";\nimport { XVSVaultProxy } from \"./XVSVaultProxy.sol\";\n\n/**\n * @title XVS Vault\n * @author Venus\n * @notice The XVS Vault allows XVS holders to lock their XVS to recieve voting rights in Venus governance and are rewarded with XVS.\n */\ncontract XVSVault is XVSVaultStorage, ECDSA, AccessControlledV5, TimeManagerV5 {\n using SafeMath for uint256;\n using SafeCast for uint256;\n using SafeBEP20 for IBEP20;\n\n /// @notice The upper bound for the lock period in a pool, 10 years\n uint256 public constant MAX_LOCK_PERIOD = 60 * 60 * 24 * 365 * 10;\n\n /// @notice Event emitted when deposit\n event Deposit(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when execute withrawal\n event ExecutedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when request withrawal\n event RequestedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChangedV2(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChangedV2(address indexed delegate, uint previousBalance, uint newBalance);\n\n /// @notice An event emitted when the reward store address is updated\n event StoreUpdated(address oldXvs, address oldStore, address newXvs, address newStore);\n\n /// @notice An event emitted when the withdrawal locking period is updated for a pool\n event WithdrawalLockingPeriodUpdated(address indexed rewardToken, uint indexed pid, uint oldPeriod, uint newPeriod);\n\n /// @notice An event emitted when the reward amount per block or second is modified for a pool\n event RewardAmountUpdated(address indexed rewardToken, uint oldReward, uint newReward);\n\n /// @notice An event emitted when a new pool is added\n event PoolAdded(\n address indexed rewardToken,\n uint indexed pid,\n address indexed token,\n uint allocPoints,\n uint rewardPerBlockOrSecond,\n uint lockPeriod\n );\n\n /// @notice An event emitted when a pool allocation points are updated\n event PoolUpdated(address indexed rewardToken, uint indexed pid, uint oldAllocPoints, uint newAllocPoints);\n\n /// @notice Event emitted when reward claimed\n event Claim(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount);\n\n /// @notice Event emitted when vault is paused\n event VaultPaused(address indexed admin);\n\n /// @notice Event emitted when vault is resumed after pause\n event VaultResumed(address indexed admin);\n\n /// @notice Event emitted when protocol logs a debt to a user due to insufficient funds for pending reward distribution\n event VaultDebtUpdated(\n address indexed rewardToken,\n address indexed userAddress,\n uint256 oldOwedAmount,\n uint256 newOwedAmount\n );\n\n /// @notice Emitted when prime token contract address is changed\n event NewPrimeToken(\n IPrime indexed oldPrimeToken,\n IPrime indexed newPrimeToken,\n address oldPrimeRewardToken,\n address newPrimeRewardToken,\n uint256 oldPrimePoolId,\n uint256 newPrimePoolId\n );\n\n /**\n * @notice XVSVault constructor\n */\n constructor() public {\n admin = msg.sender;\n }\n\n modifier onlyAdmin() {\n require(msg.sender == admin, \"only admin can\");\n _;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n require(_notEntered, \"re-entered\");\n _notEntered = false;\n _;\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n\n /**\n * @dev Prevents functions to execute when vault is paused.\n */\n modifier isActive() {\n require(!vaultPaused, \"Vault is paused\");\n _;\n }\n\n /**\n * @notice Pauses vault\n */\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!vaultPaused, \"Vault is already paused\");\n vaultPaused = true;\n emit VaultPaused(msg.sender);\n }\n\n /**\n * @notice Resume vault\n */\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(vaultPaused, \"Vault is not paused\");\n vaultPaused = false;\n emit VaultResumed(msg.sender);\n }\n\n /**\n * @notice Returns the number of pools with the specified reward token\n * @param rewardToken Reward token address\n * @return Number of pools that distribute the specified token as a reward\n */\n function poolLength(address rewardToken) external view returns (uint256) {\n return poolInfos[rewardToken].length;\n }\n\n /**\n * @notice Returns the number of reward tokens created per block or second\n * @param _rewardToken Reward token address\n * @return Number of reward tokens created per block or second\n */\n function rewardTokenAmountsPerBlock(address _rewardToken) external view returns (uint256) {\n return rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n }\n\n /**\n * @notice Add a new token pool\n * @dev This vault DOES NOT support deflationary tokens — it expects that\n * the amount of transferred tokens would equal the actually deposited\n * amount. In practice this means that this vault DOES NOT support USDT\n * and similar tokens (that do not provide these guarantees).\n * @param _rewardToken Reward token address\n * @param _allocPoint Number of allocation points assigned to this pool\n * @param _token Staked token\n * @param _rewardPerBlockOrSecond Initial reward per block or second, in terms of _rewardToken\n * @param _lockPeriod A period between withdrawal request and a moment when it's executable\n */\n function add(\n address _rewardToken,\n uint256 _allocPoint,\n IBEP20 _token,\n uint256 _rewardPerBlockOrSecond,\n uint256 _lockPeriod\n ) external {\n _checkAccessAllowed(\"add(address,uint256,address,uint256,uint256)\");\n _ensureNonzeroAddress(_rewardToken);\n _ensureNonzeroAddress(address(_token));\n require(address(xvsStore) != address(0), \"Store contract address is empty\");\n require(_allocPoint > 0, \"Alloc points must not be zero\");\n\n massUpdatePools(_rewardToken);\n\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\n\n uint256 length = poolInfo.length;\n for (uint256 pid = 0; pid < length; ++pid) {\n require(poolInfo[pid].token != _token, \"Pool already added\");\n }\n\n // We use balanceOf to get the supply amount, so shouldn't be possible to\n // configure pools with different reward token but the same staked token\n require(!isStakedToken[address(_token)], \"Token exists in other pool\");\n\n totalAllocPoints[_rewardToken] = totalAllocPoints[_rewardToken].add(_allocPoint);\n\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardPerBlockOrSecond;\n\n poolInfo.push(\n PoolInfo({\n token: _token,\n allocPoint: _allocPoint,\n lastRewardBlockOrSecond: getBlockNumberOrTimestamp(),\n accRewardPerShare: 0,\n lockPeriod: _lockPeriod\n })\n );\n isStakedToken[address(_token)] = true;\n\n XVSStore(xvsStore).setRewardToken(_rewardToken, true);\n\n emit PoolAdded(\n _rewardToken,\n poolInfo.length - 1,\n address(_token),\n _allocPoint,\n _rewardPerBlockOrSecond,\n _lockPeriod\n );\n }\n\n /**\n * @notice Update the given pool's reward allocation point\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _allocPoint Number of allocation points assigned to this pool\n */\n function set(address _rewardToken, uint256 _pid, uint256 _allocPoint) external {\n _checkAccessAllowed(\"set(address,uint256,uint256)\");\n _ensureValidPool(_rewardToken, _pid);\n\n massUpdatePools(_rewardToken);\n\n PoolInfo[] storage poolInfo = poolInfos[_rewardToken];\n uint256 newTotalAllocPoints = totalAllocPoints[_rewardToken].sub(poolInfo[_pid].allocPoint).add(_allocPoint);\n require(newTotalAllocPoints > 0, \"Alloc points per reward token must not be zero\");\n\n uint256 oldAllocPoints = poolInfo[_pid].allocPoint;\n poolInfo[_pid].allocPoint = _allocPoint;\n totalAllocPoints[_rewardToken] = newTotalAllocPoints;\n\n emit PoolUpdated(_rewardToken, _pid, oldAllocPoints, _allocPoint);\n }\n\n /**\n * @notice Update the given reward token's amount per block or second\n * @param _rewardToken Reward token address\n * @param _rewardAmount Number of allocation points assigned to this pool\n */\n function setRewardAmountPerBlockOrSecond(address _rewardToken, uint256 _rewardAmount) external {\n _checkAccessAllowed(\"setRewardAmountPerBlockOrSecond(address,uint256)\");\n require(XVSStore(xvsStore).rewardTokens(_rewardToken), \"Invalid reward token\");\n massUpdatePools(_rewardToken);\n uint256 oldReward = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n rewardTokenAmountsPerBlockOrSecond[_rewardToken] = _rewardAmount;\n\n emit RewardAmountUpdated(_rewardToken, oldReward, _rewardAmount);\n }\n\n /**\n * @notice Update the lock period after which a requested withdrawal can be executed\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _newPeriod New lock period\n */\n function setWithdrawalLockingPeriod(address _rewardToken, uint256 _pid, uint256 _newPeriod) external {\n _checkAccessAllowed(\"setWithdrawalLockingPeriod(address,uint256,uint256)\");\n _ensureValidPool(_rewardToken, _pid);\n require(_newPeriod > 0 && _newPeriod < MAX_LOCK_PERIOD, \"Invalid new locking period\");\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n uint256 oldPeriod = pool.lockPeriod;\n pool.lockPeriod = _newPeriod;\n\n emit WithdrawalLockingPeriodUpdated(_rewardToken, _pid, oldPeriod, _newPeriod);\n }\n\n /**\n * @notice Deposit XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _amount The amount to deposit to vault\n */\n function deposit(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n _updatePool(_rewardToken, _pid);\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, msg.sender) == 0, \"execute pending withdrawal\");\n\n if (user.amount > 0) {\n uint256 pending = _computeReward(user, pool);\n if (pending > 0) {\n _transferReward(_rewardToken, msg.sender, pending);\n emit Claim(msg.sender, _rewardToken, _pid, pending);\n }\n }\n pool.token.safeTransferFrom(msg.sender, address(this), _amount);\n user.amount = user.amount.add(_amount);\n user.rewardDebt = _cumulativeReward(user, pool);\n\n // Update Delegate Amount\n if (address(pool.token) == xvsAddress) {\n _moveDelegates(address(0), delegates[msg.sender], safe96(_amount, \"XVSVault::deposit: votes overflow\"));\n }\n\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\n primeToken.xvsUpdated(msg.sender);\n }\n\n emit Deposit(msg.sender, _rewardToken, _pid, _amount);\n }\n\n /**\n * @notice Claim rewards for pool\n * @param _account The account for which to claim rewards\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n */\n function claim(address _account, address _rewardToken, uint256 _pid) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][_account];\n _updatePool(_rewardToken, _pid);\n require(pendingWithdrawalsBeforeUpgrade(_rewardToken, _pid, _account) == 0, \"execute pending withdrawal\");\n\n if (user.amount > 0) {\n uint256 pending = _computeReward(user, pool);\n\n if (pending > 0) {\n user.rewardDebt = _cumulativeReward(user, pool);\n\n _transferReward(_rewardToken, _account, pending);\n emit Claim(_account, _rewardToken, _pid, pending);\n }\n }\n }\n\n /**\n * @notice Pushes withdrawal request to the requests array and updates\n * the pending withdrawals amount. The requests are always sorted\n * by unlock time (descending) so that the earliest to execute requests\n * are always at the end of the array.\n * @param _user The user struct storage pointer\n * @param _requests The user's requests array storage pointer\n * @param _amount The amount being requested\n */\n function pushWithdrawalRequest(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests,\n uint _amount,\n uint _lockedUntil\n ) internal {\n uint i = _requests.length;\n _requests.push(WithdrawalRequest(0, 0, 1));\n // Keep it sorted so that the first to get unlocked request is always at the end\n for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) {\n _requests[i] = _requests[i - 1];\n }\n _requests[i] = WithdrawalRequest(_amount, _lockedUntil.toUint128(), 1);\n _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount);\n }\n\n /**\n * @notice Pops the requests with unlock time < now from the requests\n * array and deducts the computed amount from the user's pending\n * withdrawals counter. Assumes that the requests array is sorted\n * by unclock time (descending).\n * @dev This function **removes** the eligible requests from the requests\n * array. If this function is called, the withdrawal should actually\n * happen (or the transaction should be reverted).\n * @param _user The user struct storage pointer\n * @param _requests The user's requests array storage pointer\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade (this amount should be\n * sent to the user, otherwise the state would be inconsistent).\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade (this amount should be\n * sent to the user, otherwise the state would be inconsistent).\n */\n function popEligibleWithdrawalRequests(\n UserInfo storage _user,\n WithdrawalRequest[] storage _requests\n ) internal returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\n // Since the requests are sorted by their unlock time, we can just\n // pop them from the array and stop at the first not-yet-eligible one\n for (uint i = _requests.length; i > 0 && isUnlocked(_requests[i - 1]); --i) {\n if (_requests[i - 1].afterUpgrade == 1) {\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n } else {\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n }\n\n _requests.pop();\n }\n _user.pendingWithdrawals = _user.pendingWithdrawals.sub(\n afterUpgradeWithdrawalAmount.add(beforeUpgradeWithdrawalAmount)\n );\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\n }\n\n /**\n * @notice Checks if the request is eligible for withdrawal.\n * @param _request The request struct storage pointer\n * @return True if the request is eligible for withdrawal, false otherwise\n */\n function isUnlocked(WithdrawalRequest storage _request) private view returns (bool) {\n return _request.lockedUntil <= block.timestamp;\n }\n\n /**\n * @notice Execute withdrawal to XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n */\n function executeWithdrawal(address _rewardToken, uint256 _pid) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n\n uint256 beforeUpgradeWithdrawalAmount;\n uint256 afterUpgradeWithdrawalAmount;\n\n (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount) = popEligibleWithdrawalRequests(user, requests);\n require(beforeUpgradeWithdrawalAmount > 0 || afterUpgradeWithdrawalAmount > 0, \"nothing to withdraw\");\n\n // Having both old-style and new-style requests is not allowed and shouldn't be possible\n require(beforeUpgradeWithdrawalAmount == 0 || afterUpgradeWithdrawalAmount == 0, \"inconsistent state\");\n\n if (beforeUpgradeWithdrawalAmount > 0) {\n _updatePool(_rewardToken, _pid);\n uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub(user.rewardDebt);\n XVSStore(xvsStore).safeRewardTransfer(_rewardToken, msg.sender, pending);\n user.amount = user.amount.sub(beforeUpgradeWithdrawalAmount);\n user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12);\n pool.token.safeTransfer(address(msg.sender), beforeUpgradeWithdrawalAmount);\n } else {\n user.amount = user.amount.sub(afterUpgradeWithdrawalAmount);\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].sub(\n afterUpgradeWithdrawalAmount\n );\n pool.token.safeTransfer(address(msg.sender), afterUpgradeWithdrawalAmount);\n }\n\n emit ExecutedWithdrawal(\n msg.sender,\n _rewardToken,\n _pid,\n beforeUpgradeWithdrawalAmount.add(afterUpgradeWithdrawalAmount)\n );\n }\n\n /**\n * @notice Returns before and after upgrade pending withdrawal amount\n * @param _requests The user's requests array storage pointer\n * @return beforeUpgradeWithdrawalAmount The amount eligible for withdrawal before upgrade\n * @return afterUpgradeWithdrawalAmount The amount eligible for withdrawal after upgrade\n */\n function getRequestedWithdrawalAmount(\n WithdrawalRequest[] storage _requests\n ) internal view returns (uint beforeUpgradeWithdrawalAmount, uint afterUpgradeWithdrawalAmount) {\n for (uint i = _requests.length; i > 0; --i) {\n if (_requests[i - 1].afterUpgrade == 1) {\n afterUpgradeWithdrawalAmount = afterUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n } else {\n beforeUpgradeWithdrawalAmount = beforeUpgradeWithdrawalAmount.add(_requests[i - 1].amount);\n }\n }\n return (beforeUpgradeWithdrawalAmount, afterUpgradeWithdrawalAmount);\n }\n\n /**\n * @notice Request withdrawal to XVSVault for XVS allocation\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _amount The amount to withdraw from the vault\n */\n function requestWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant isActive {\n _ensureValidPool(_rewardToken, _pid);\n require(_amount > 0, \"requested amount cannot be zero\");\n UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender];\n require(user.amount >= user.pendingWithdrawals.add(_amount), \"requested amount is invalid\");\n\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender];\n\n uint beforeUpgradeWithdrawalAmount;\n\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\n require(beforeUpgradeWithdrawalAmount == 0, \"execute pending withdrawal\");\n\n _updatePool(_rewardToken, _pid);\n uint256 pending = _computeReward(user, pool);\n _transferReward(_rewardToken, msg.sender, pending);\n\n uint lockedUntil = pool.lockPeriod.add(block.timestamp);\n\n pushWithdrawalRequest(user, requests, _amount, lockedUntil);\n totalPendingWithdrawals[_rewardToken][_pid] = totalPendingWithdrawals[_rewardToken][_pid].add(_amount);\n user.rewardDebt = _cumulativeReward(user, pool);\n\n // Update Delegate Amount\n if (address(pool.token) == xvsAddress) {\n _moveDelegates(\n delegates[msg.sender],\n address(0),\n safe96(_amount, \"XVSVault::requestWithdrawal: votes overflow\")\n );\n }\n\n if (primeRewardToken == _rewardToken && _pid == primePoolId) {\n primeToken.xvsUpdated(msg.sender);\n }\n\n emit Claim(msg.sender, _rewardToken, _pid, pending);\n emit RequestedWithdrawal(msg.sender, _rewardToken, _pid, _amount);\n }\n\n /**\n * @notice Get unlocked withdrawal amount\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return withdrawalAmount Amount that the user can withdraw\n */\n function getEligibleWithdrawalAmount(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (uint withdrawalAmount) {\n _ensureValidPool(_rewardToken, _pid);\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n // Since the requests are sorted by their unlock time, we can take\n // the entries from the end of the array and stop at the first\n // not-yet-eligible one\n for (uint i = requests.length; i > 0 && isUnlocked(requests[i - 1]); --i) {\n withdrawalAmount = withdrawalAmount.add(requests[i - 1].amount);\n }\n return withdrawalAmount;\n }\n\n /**\n * @notice Get requested amount\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return Total amount of requested but not yet executed withdrawals (including both executable and locked ones)\n */\n function getRequestedAmount(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\n _ensureValidPool(_rewardToken, _pid);\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n return user.pendingWithdrawals;\n }\n\n /**\n * @notice Returns the array of withdrawal requests that have not been executed yet\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The User Address\n * @return An array of withdrawal requests\n */\n function getWithdrawalRequests(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (WithdrawalRequest[] memory) {\n _ensureValidPool(_rewardToken, _pid);\n return withdrawalRequests[_rewardToken][_pid][_user];\n }\n\n /**\n * @notice View function to see pending XVSs on frontend\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _user User address\n * @return Reward the user is eligible for in this pool, in terms of _rewardToken\n */\n function pendingReward(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) {\n _ensureValidPool(_rewardToken, _pid);\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n uint256 accRewardPerShare = pool.accRewardPerShare;\n uint256 supply = pool.token.balanceOf(address(this)).sub(totalPendingWithdrawals[_rewardToken][_pid]);\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\n uint256 rewardTokenPerBlockOrSecond = rewardTokenAmountsPerBlockOrSecond[_rewardToken];\n if (curBlockNumberOrSecond > pool.lastRewardBlockOrSecond && supply != 0) {\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\n uint256 reward = multiplier.mul(rewardTokenPerBlockOrSecond).mul(pool.allocPoint).div(\n totalAllocPoints[_rewardToken]\n );\n accRewardPerShare = accRewardPerShare.add(reward.mul(1e12).div(supply));\n }\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n (, uint256 afterUpgradeWithdrawalAmount) = getRequestedWithdrawalAmount(requests);\n return user.amount.sub(afterUpgradeWithdrawalAmount).mul(accRewardPerShare).div(1e12).sub(user.rewardDebt);\n }\n\n // Update reward variables for all pools. Be careful of gas spending!\n function massUpdatePools(address _rewardToken) internal {\n uint256 length = poolInfos[_rewardToken].length;\n for (uint256 pid = 0; pid < length; ++pid) {\n _updatePool(_rewardToken, pid);\n }\n }\n\n /**\n * @notice Update reward variables of the given pool to be up-to-date\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n */\n function updatePool(address _rewardToken, uint256 _pid) external isActive {\n _ensureValidPool(_rewardToken, _pid);\n _updatePool(_rewardToken, _pid);\n }\n\n // Update reward variables of the given pool to be up-to-date.\n function _updatePool(address _rewardToken, uint256 _pid) internal {\n PoolInfo storage pool = poolInfos[_rewardToken][_pid];\n if (getBlockNumberOrTimestamp() <= pool.lastRewardBlockOrSecond) {\n return;\n }\n uint256 supply = pool.token.balanceOf(address(this));\n supply = supply.sub(totalPendingWithdrawals[_rewardToken][_pid]);\n if (supply == 0) {\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\n return;\n }\n uint256 curBlockNumberOrSecond = getBlockNumberOrTimestamp();\n uint256 multiplier = curBlockNumberOrSecond.sub(pool.lastRewardBlockOrSecond);\n uint256 reward = multiplier.mul(rewardTokenAmountsPerBlockOrSecond[_rewardToken]).mul(pool.allocPoint).div(\n totalAllocPoints[_rewardToken]\n );\n pool.accRewardPerShare = pool.accRewardPerShare.add(reward.mul(1e12).div(supply));\n pool.lastRewardBlockOrSecond = getBlockNumberOrTimestamp();\n }\n\n function _ensureValidPool(address rewardToken, uint256 pid) internal view {\n require(pid < poolInfos[rewardToken].length, \"vault: pool exists?\");\n }\n\n /**\n * @notice Get user info with reward token address and pid\n * @param _rewardToken Reward token address\n * @param _pid Pool index\n * @param _user User address\n * @return amount Deposited amount\n * @return rewardDebt Reward debt (technical value used to track past payouts)\n * @return pendingWithdrawals Requested but not yet executed withdrawals\n */\n function getUserInfo(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals) {\n _ensureValidPool(_rewardToken, _pid);\n UserInfo storage user = userInfos[_rewardToken][_pid][_user];\n amount = user.amount;\n rewardDebt = user.rewardDebt;\n pendingWithdrawals = user.pendingWithdrawals;\n }\n\n /**\n * @notice Gets the total pending withdrawal amount of a user before upgrade\n * @param _rewardToken The Reward Token Address\n * @param _pid The Pool Index\n * @param _user The address of the user\n * @return beforeUpgradeWithdrawalAmount Total pending withdrawal amount in requests made before the vault upgrade\n */\n function pendingWithdrawalsBeforeUpgrade(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) public view returns (uint256 beforeUpgradeWithdrawalAmount) {\n WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user];\n (beforeUpgradeWithdrawalAmount, ) = getRequestedWithdrawalAmount(requests);\n return beforeUpgradeWithdrawalAmount;\n }\n\n /**\n * @notice Get the XVS stake balance of an account (excluding the pending withdrawals)\n * @param account The address of the account to check\n * @return The balance that user staked\n */\n function getStakeAmount(address account) internal view returns (uint96) {\n require(xvsAddress != address(0), \"XVSVault::getStakeAmount: xvs address is not set\");\n\n PoolInfo[] storage poolInfo = poolInfos[xvsAddress];\n\n uint256 length = poolInfo.length;\n for (uint256 pid = 0; pid < length; ++pid) {\n if (address(poolInfo[pid].token) == address(xvsAddress)) {\n UserInfo storage user = userInfos[xvsAddress][pid][account];\n return safe96(user.amount.sub(user.pendingWithdrawals), \"XVSVault::getStakeAmount: votes overflow\");\n }\n }\n return uint96(0);\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) external isActive {\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(\n address delegatee,\n uint nonce,\n uint expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external isActive {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(\"XVSVault\")), getChainId(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ECDSA.recover(digest, v, r, s);\n require(nonce == nonces[signatory]++, \"XVSVault::delegateBySig: invalid nonce\");\n require(block.timestamp <= expiry, \"XVSVault::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) external view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n function _delegate(address delegator, address delegatee) internal {\n address currentDelegate = delegates[delegator];\n uint96 delegatorBalance = getStakeAmount(delegator);\n delegates[delegator] = delegatee;\n\n emit DelegateChangedV2(delegator, currentDelegate, delegatee);\n\n _moveDelegates(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"XVSVault::_moveVotes: vote amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"XVSVault::_moveVotes: vote amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {\n uint32 blockNumberOrSecond = safe32(\n getBlockNumberOrTimestamp(),\n \"XVSVault::_writeCheckpoint: block number or second exceeds 32 bits\"\n );\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlockOrSecond == blockNumberOrSecond) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumberOrSecond, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChangedV2(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2 ** 32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2 ** 96, errorMessage);\n return uint96(n);\n }\n\n function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function getChainId() internal pure returns (uint) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n\n /**\n * @notice Determine the xvs stake balance for an account\n * @param account The address of the account to check\n * @param blockNumberOrSecond The block number or second to get the vote balance at\n * @return The balance that user staked\n */\n function getPriorVotes(address account, uint256 blockNumberOrSecond) external view returns (uint96) {\n require(blockNumberOrSecond < getBlockNumberOrTimestamp(), \"XVSVault::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlockOrSecond <= blockNumberOrSecond) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlockOrSecond > blockNumberOrSecond) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlockOrSecond == blockNumberOrSecond) {\n return cp.votes;\n } else if (cp.fromBlockOrSecond < blockNumberOrSecond) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n /*** Admin Functions ***/\n\n function _become(XVSVaultProxy xvsVaultProxy) external {\n require(msg.sender == xvsVaultProxy.admin(), \"only proxy admin can change brains\");\n require(xvsVaultProxy._acceptImplementation() == 0, \"change not authorized\");\n }\n\n function setXvsStore(address _xvs, address _xvsStore) external onlyAdmin {\n _ensureNonzeroAddress(_xvs);\n _ensureNonzeroAddress(_xvsStore);\n\n address oldXvsContract = xvsAddress;\n address oldStore = xvsStore;\n require(oldXvsContract == address(0), \"already initialized\");\n\n xvsAddress = _xvs;\n xvsStore = _xvsStore;\n\n _notEntered = true;\n\n emit StoreUpdated(oldXvsContract, oldStore, _xvs, _xvsStore);\n }\n\n /**\n * @notice Sets the address of the prime token contract\n * @param _primeToken address of the prime token contract\n * @param _primeRewardToken address of reward token\n * @param _primePoolId pool id for reward\n */\n function setPrimeToken(IPrime _primeToken, address _primeRewardToken, uint256 _primePoolId) external onlyAdmin {\n require(address(_primeToken) != address(0), \"prime token cannot be zero address\");\n require(_primeRewardToken != address(0), \"reward cannot be zero address\");\n\n _ensureValidPool(_primeRewardToken, _primePoolId);\n\n emit NewPrimeToken(primeToken, _primeToken, primeRewardToken, _primeRewardToken, primePoolId, _primePoolId);\n\n primeToken = _primeToken;\n primeRewardToken = _primeRewardToken;\n primePoolId = _primePoolId;\n }\n\n /**\n * @dev Initializes the contract to use either blocks or seconds\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\n * @param blocksPerYear_ The number of blocks per year\n */\n function initializeTimeManager(bool timeBased_, uint256 blocksPerYear_) external onlyAdmin {\n _initializeTimeManager(timeBased_, blocksPerYear_);\n }\n\n /**\n * @notice Sets the address of the access control of this contract\n * @dev Admin function to set the access control address\n * @param newAccessControlAddress New address for the access control\n */\n function setAccessControl(address newAccessControlAddress) external onlyAdmin {\n _setAccessControlManager(newAccessControlAddress);\n }\n\n /**\n * @dev Reverts if the provided address is a zero address\n * @param address_ Address to check\n */\n function _ensureNonzeroAddress(address address_) internal pure {\n require(address_ != address(0), \"zero address not allowed\");\n }\n\n /**\n * @dev Transfers the reward to the user, taking into account the rewards store\n * balance and the previous debt. If there are not enough rewards in the store,\n * transfers the available funds and records the debt amount in pendingRewardTransfers.\n * @param rewardToken Reward token address\n * @param userAddress User address\n * @param amount Reward amount, in reward tokens\n */\n function _transferReward(address rewardToken, address userAddress, uint256 amount) internal {\n address xvsStore_ = xvsStore;\n uint256 storeBalance = IBEP20(rewardToken).balanceOf(xvsStore_);\n uint256 debtDueToFailedTransfers = pendingRewardTransfers[rewardToken][userAddress];\n uint256 fullAmount = amount.add(debtDueToFailedTransfers);\n\n if (fullAmount <= storeBalance) {\n if (debtDueToFailedTransfers != 0) {\n pendingRewardTransfers[rewardToken][userAddress] = 0;\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, 0);\n }\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, fullAmount);\n return;\n }\n // Overflow isn't possible due to the check above\n uint256 newOwedAmount = fullAmount - storeBalance;\n pendingRewardTransfers[rewardToken][userAddress] = newOwedAmount;\n emit VaultDebtUpdated(rewardToken, userAddress, debtDueToFailedTransfers, newOwedAmount);\n XVSStore(xvsStore_).safeRewardTransfer(rewardToken, userAddress, storeBalance);\n }\n\n /**\n * @dev Computes cumulative reward for all user's shares\n * @param user UserInfo storage struct\n * @param pool PoolInfo storage struct\n */\n function _cumulativeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\n return user.amount.sub(user.pendingWithdrawals).mul(pool.accRewardPerShare).div(1e12);\n }\n\n /**\n * @dev Computes the reward for all user's shares\n * @param user UserInfo storage struct\n * @param pool PoolInfo storage struct\n */\n function _computeReward(UserInfo storage user, PoolInfo storage pool) internal view returns (uint256) {\n return _cumulativeReward(user, pool).sub(user.rewardDebt);\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultErrorReporter.sol": { + "content": "pragma solidity ^0.5.16;\n\ncontract XVSVaultErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint error, uint info, uint detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint) {\n emit Failure(uint(err), uint(info), 0);\n\n return uint(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {\n emit Failure(uint(err), uint(info), opaqueError);\n\n return uint(err);\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultProxy.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"./XVSVaultStorage.sol\";\nimport \"./XVSVaultErrorReporter.sol\";\n\n/**\n * @title XVS Vault Proxy\n * @author Venus\n * @notice XVS Vault Proxy contract\n */\ncontract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter {\n /**\n * @notice Emitted when pendingXVSVaultImplementation is changed\n */\n event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);\n\n /**\n * @notice Emitted when pendingXVSVaultImplementation is accepted, which means XVS Vault implementation is updated\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor() public {\n // Set admin to caller\n admin = msg.sender;\n }\n\n /*** Admin Functions ***/\n function _setPendingImplementation(address newPendingImplementation) public returns (uint) {\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);\n }\n\n address oldPendingImplementation = pendingXVSVaultImplementation;\n\n pendingXVSVaultImplementation = newPendingImplementation;\n\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation\n * @dev Admin function for new implementation to accept it's role as implementation\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptImplementation() public returns (uint) {\n // Check caller is pendingImplementation\n if (msg.sender != pendingXVSVaultImplementation) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldImplementation = implementation;\n address oldPendingImplementation = pendingXVSVaultImplementation;\n\n implementation = pendingXVSVaultImplementation;\n\n pendingXVSVaultImplementation = address(0);\n\n emit NewImplementation(oldImplementation, implementation);\n emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint) {\n // Check caller = admin\n if (msg.sender != admin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint) {\n // Check caller is pendingAdmin\n if (msg.sender != pendingAdmin) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint(Error.NO_ERROR);\n }\n\n /**\n * @dev Delegates execution to an implementation contract.\n * It returns to the external caller whatever the implementation returns\n * or forwards reverts.\n */\n function() external payable {\n // delegate all other functions to current implementation\n (bool success, ) = implementation.delegatecall(msg.data);\n\n assembly {\n let free_mem_ptr := mload(0x40)\n returndatacopy(free_mem_ptr, 0, returndatasize)\n\n switch success\n case 0 {\n revert(free_mem_ptr, returndatasize)\n }\n default {\n return(free_mem_ptr, returndatasize)\n }\n }\n }\n}\n" + }, + "contracts/XVSVault/XVSVaultStorage.sol": { + "content": "pragma solidity ^0.5.16;\n\nimport \"../Utils/SafeMath.sol\";\nimport \"../Utils/IBEP20.sol\";\nimport \"../Tokens/Prime/IPrime.sol\";\n\ncontract XVSVaultAdminStorage {\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Active brains of XVS Vault\n */\n address public implementation;\n\n /**\n * @notice Pending brains of XVS Vault\n */\n address public pendingXVSVaultImplementation;\n}\n\ncontract XVSVaultStorageV1 is XVSVaultAdminStorage {\n /// @notice Guard variable for re-entrancy checks\n bool internal _notEntered;\n\n /// @notice The reward token store\n address public xvsStore;\n\n /// @notice The xvs token address\n address public xvsAddress;\n\n // Reward tokens created per block or second indentified by reward token address.\n mapping(address => uint256) public rewardTokenAmountsPerBlockOrSecond;\n\n /// @notice Info of each user.\n struct UserInfo {\n uint256 amount;\n uint256 rewardDebt;\n uint256 pendingWithdrawals;\n }\n\n // Info of each pool.\n struct PoolInfo {\n IBEP20 token; // Address of token contract to stake.\n uint256 allocPoint; // How many allocation points assigned to this pool.\n uint256 lastRewardBlockOrSecond; // Last block number or second that reward tokens distribution occurs.\n uint256 accRewardPerShare; // Accumulated per share, times 1e12. See below.\n uint256 lockPeriod; // Min time between withdrawal request and its execution.\n }\n\n // Infomation about a withdrawal request\n struct WithdrawalRequest {\n uint256 amount;\n uint128 lockedUntil;\n uint128 afterUpgrade;\n }\n\n // Info of each user that stakes tokens.\n mapping(address => mapping(uint256 => mapping(address => UserInfo))) internal userInfos;\n\n // Info of each pool.\n mapping(address => PoolInfo[]) public poolInfos;\n\n // Total allocation points. Must be the sum of all allocation points in all pools.\n mapping(address => uint256) public totalAllocPoints;\n\n // Info of requested but not yet executed withdrawals\n mapping(address => mapping(uint256 => mapping(address => WithdrawalRequest[]))) internal withdrawalRequests;\n\n /// @notice DEPRECATED A record of each accounts delegate (before the voting power fix)\n mapping(address => address) private __oldDelegatesSlot;\n\n /// @notice A checkpoint for marking number of votes from a given block or second\n struct Checkpoint {\n uint32 fromBlockOrSecond;\n uint96 votes;\n }\n\n /// @notice DEPRECATED A record of votes checkpoints for each account, by index (before the voting power fix)\n mapping(address => mapping(uint32 => Checkpoint)) private __oldCheckpointsSlot;\n\n /// @notice DEPRECATED The number of checkpoints for each account (before the voting power fix)\n mapping(address => uint32) private __oldNumCheckpointsSlot;\n\n /// @notice A record of states for signing / validating signatures\n mapping(address => uint) public nonces;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n}\n\ncontract XVSVaultStorage is XVSVaultStorageV1 {\n /// @notice A record of each accounts delegate\n mapping(address => address) public delegates;\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice Tracks pending withdrawals for all users for a particular reward token and pool id\n mapping(address => mapping(uint256 => uint256)) public totalPendingWithdrawals;\n\n /// @notice pause indicator for Vault\n bool public vaultPaused;\n\n /// @notice if the token is added to any of the pools\n mapping(address => bool) public isStakedToken;\n\n /// @notice Amount we owe to users because of failed transfer attempts\n mapping(address => mapping(address => uint256)) public pendingRewardTransfers;\n\n /// @notice Prime token contract address\n IPrime public primeToken;\n\n /// @notice Reward token for which prime token is issued for staking\n address public primeRewardToken;\n\n /// @notice Pool ID for which prime token is issued for staking\n uint256 public primePoolId;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[46] private __gap;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "storageLayout", + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/deployments/opsepolia/solcInputs/7584667b44eb77970ba8d274006d81ae.json b/deployments/opsepolia/solcInputs/7584667b44eb77970ba8d274006d81ae.json new file mode 100644 index 000000000..7f7c8eae5 --- /dev/null +++ b/deployments/opsepolia/solcInputs/7584667b44eb77970ba8d274006d81ae.json @@ -0,0 +1,331 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n function __Ownable2Step_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable2Step_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() public virtual {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling 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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\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 function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\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 _requireNotPaused();\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 _requirePaused();\n _;\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 Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.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 */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _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 making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.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 \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\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-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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 IERC20Upgradeable {\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(address from, address to, uint256 amount) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) 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(IERC20Upgradeable token, address spender, uint256 value) 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 /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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(IERC20Upgradeable 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 require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\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 cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\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 * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(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 (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@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/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (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 Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling 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/access/Ownable2Step.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() public virtual {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\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/interfaces/IERC1967.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n *\n * _Available since v4.8.3._\n */\ninterface IERC1967 {\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Emitted when the beacon is changed.\n */\n event BeaconUpgraded(address indexed beacon);\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" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (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 initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\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/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/IERC1967.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 */\nabstract contract ERC1967Upgrade is IERC1967 {\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 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(address newImplementation, bytes memory data, bool forceCall) 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(address newImplementation, bytes memory data, bool forceCall) 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 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 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(address newBeacon, bytes memory data, bool forceCall) 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/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/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.3) (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(ITransparentUpgradeableProxy 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(ITransparentUpgradeableProxy 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(ITransparentUpgradeableProxy 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(ITransparentUpgradeableProxy 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 ITransparentUpgradeableProxy 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 (last updated v4.9.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}\n * does not implement this interface directly, and some of its functions are implemented by an internal dispatch\n * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not\n * include them in the ABI so this interface must be used to interact with it.\n */\ninterface ITransparentUpgradeableProxy is IERC1967 {\n function admin() external view returns (address);\n\n function implementation() external view returns (address);\n\n function changeAdmin(address) external;\n\n function upgradeTo(address) external;\n\n function upgradeToAndCall(address, bytes memory) external payable;\n}\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 *\n * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not\n * inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch\n * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to\n * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the\n * implementation.\n *\n * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler\n * will not check that there are no selector conflicts, due to the note above. A selector clash between any new function\n * and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could\n * render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.\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(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {\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 * CAUTION: This modifier is deprecated, as it could cause issues if the modified function has arguments, and the\n * implementation provides a function with the same selector.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior\n */\n function _fallback() internal virtual override {\n if (msg.sender == _getAdmin()) {\n bytes memory ret;\n bytes4 selector = msg.sig;\n if (selector == ITransparentUpgradeableProxy.upgradeTo.selector) {\n ret = _dispatchUpgradeTo();\n } else if (selector == ITransparentUpgradeableProxy.upgradeToAndCall.selector) {\n ret = _dispatchUpgradeToAndCall();\n } else if (selector == ITransparentUpgradeableProxy.changeAdmin.selector) {\n ret = _dispatchChangeAdmin();\n } else if (selector == ITransparentUpgradeableProxy.admin.selector) {\n ret = _dispatchAdmin();\n } else if (selector == ITransparentUpgradeableProxy.implementation.selector) {\n ret = _dispatchImplementation();\n } else {\n revert(\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n }\n assembly {\n return(add(ret, 0x20), mload(ret))\n }\n } else {\n super._fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\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 _dispatchAdmin() private returns (bytes memory) {\n _requireZeroValue();\n\n address admin = _getAdmin();\n return abi.encode(admin);\n }\n\n /**\n * @dev Returns the current implementation.\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 _dispatchImplementation() private returns (bytes memory) {\n _requireZeroValue();\n\n address implementation = _implementation();\n return abi.encode(implementation);\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _dispatchChangeAdmin() private returns (bytes memory) {\n _requireZeroValue();\n\n address newAdmin = abi.decode(msg.data[4:], (address));\n _changeAdmin(newAdmin);\n\n return \"\";\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n */\n function _dispatchUpgradeTo() private returns (bytes memory) {\n _requireZeroValue();\n\n address newImplementation = abi.decode(msg.data[4:], (address));\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n\n return \"\";\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 function _dispatchUpgradeToAndCall() private returns (bytes memory) {\n (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));\n _upgradeToAndCall(newImplementation, data, true);\n\n return \"\";\n }\n\n /**\n * @dev Returns the current admin.\n *\n * CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to\n * emulate some proxy functions being non-payable while still allowing value to pass through.\n */\n function _requireZeroValue() private {\n require(msg.value == 0);\n }\n}\n" + }, + "@openzeppelin/contracts/security/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\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 */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _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 making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of 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 * 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 default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual 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(address from, address to, uint256 amount) 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 `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * 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(address from, address to, uint256 amount) 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\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 unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\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 // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\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(address owner, address spender, uint256 amount) 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(address owner, address spender, uint256 amount) 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(address from, address to, uint256 amount) 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(address from, address to, uint256 amount) internal virtual {}\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/extensions/IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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(address from, address to, uint256 amount) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.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 /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.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(IERC20 token, address spender, uint256 value) 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 /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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 require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\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 cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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 * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(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 (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@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/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\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 * ```solidity\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`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\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 /// @solidity memory-safe-assembly\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 /// @solidity memory-safe-assembly\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 /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\n\nimport \"./IAccessControlManagerV8.sol\";\n\n/**\n * @title AccessControlledV8\n * @author Venus\n * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)\n * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.\n */\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\n /// @notice Access control manager contract\n IAccessControlManagerV8 private _accessControlManager;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when access control manager contract address is changed\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n /// @notice Thrown when the action is prohibited by AccessControlManager\n error Unauthorized(address sender, address calledContract, string methodSignature);\n\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\n __Ownable2Step_init();\n __AccessControlled_init_unchained(accessControlManager_);\n }\n\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Sets the address of AccessControlManager\n * @dev Admin function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n * @custom:event Emits NewAccessControlManager event\n * @custom:access Only Governance\n */\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Returns the address of the access control manager contract\n */\n function accessControlManager() external view returns (IAccessControlManagerV8) {\n return _accessControlManager;\n }\n\n /**\n * @dev Internal function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n */\n function _setAccessControlManager(address accessControlManager_) internal {\n require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n address oldAccessControlManager = address(_accessControlManager);\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n }\n\n /**\n * @notice Reverts if the call is not allowed by AccessControlManager\n * @param signature Method signature\n */\n function _checkAccessAllowed(string memory signature) internal view {\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n if (!isAllowedToCall) {\n revert Unauthorized(msg.sender, address(this), signature);\n }\n }\n}\n" + }, + "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport \"@openzeppelin/contracts/access/IAccessControl.sol\";\n\n/**\n * @title IAccessControlManagerV8\n * @author Venus\n * @notice Interface implemented by the `AccessControlManagerV8` contract.\n */\ninterface IAccessControlManagerV8 is IAccessControl {\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) external;\n\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) external view returns (bool);\n}\n" + }, + "@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface OracleInterface {\n function getPrice(address asset) external view returns (uint256);\n}\n\ninterface ResilientOracleInterface is OracleInterface {\n function updatePrice(address vToken) external;\n\n function updateAssetPrice(address asset) external;\n\n function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface TwapInterface is OracleInterface {\n function updateTwap(address asset) external returns (uint256);\n}\n\ninterface BoundValidatorInterface {\n function validatePriceWithAnchorPrice(\n address asset,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool);\n}\n" + }, + "@venusprotocol/solidity-utilities/contracts/constants.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\nuint256 constant EXP_SCALE = 1e18;\n\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\nuint256 constant MANTISSA_ONE = EXP_SCALE;\n\n/// @dev The approximate number of seconds per year\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\n" + }, + "@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/**\n * @title MaxLoopsLimitHelper\n * @author Venus\n * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.\n */\nabstract contract MaxLoopsLimitHelper {\n // Limit for the loops to avoid the DOS\n uint256 public maxLoopsLimit;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when max loops limit is set\n event MaxLoopsLimitUpdated(uint256 oldMaxLoopsLimit, uint256 newmaxLoopsLimit);\n\n /// @notice Thrown an error on maxLoopsLimit exceeds for any loop\n error MaxLoopsLimitExceeded(uint256 loopsLimit, uint256 requiredLoops);\n\n /**\n * @notice Set the limit for the loops can iterate to avoid the DOS\n * @param limit Limit for the max loops can execute at a time\n */\n function _setMaxLoopsLimit(uint256 limit) internal {\n require(limit > maxLoopsLimit, \"Comptroller: Invalid maxLoopsLimit\");\n\n uint256 oldMaxLoopsLimit = maxLoopsLimit;\n maxLoopsLimit = limit;\n\n emit MaxLoopsLimitUpdated(oldMaxLoopsLimit, limit);\n }\n\n /**\n * @notice Compare the maxLoopsLimit with number of the times loop iterate\n * @param len Length of the loops iterate\n * @custom:error MaxLoopsLimitExceeded error is thrown when loops length exceeds maxLoopsLimit\n */\n function _ensureMaxLoops(uint256 len) internal view {\n if (len > maxLoopsLimit) {\n revert MaxLoopsLimitExceeded(maxLoopsLimit, len);\n }\n }\n}\n" + }, + "@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { SECONDS_PER_YEAR } from \"./constants.sol\";\n\nabstract contract TimeManagerV8 {\n /// @notice Stores blocksPerYear if isTimeBased is true else secondsPerYear is stored\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n uint256 public immutable blocksOrSecondsPerYear;\n\n /// @notice Acknowledges if a contract is time based or not\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n bool public immutable isTimeBased;\n\n /// @notice Stores the current block timestamp or block number depending on isTimeBased\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n function() view returns (uint256) private immutable _getCurrentSlot;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[48] private __gap;\n\n /// @notice Thrown when blocks per year is invalid\n error InvalidBlocksPerYear();\n\n /// @notice Thrown when time based but blocks per year is provided\n error InvalidTimeBasedConfiguration();\n\n /**\n * @param timeBased_ A boolean indicating whether the contract is based on time or block\n * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR\n * @param blocksPerYear_ The number of blocks per year\n * @custom:error InvalidBlocksPerYear is thrown if blocksPerYear entered is zero and timeBased is false\n * @custom:error InvalidTimeBasedConfiguration is thrown if blocksPerYear entered is non zero and timeBased is true\n * @custom:oz-upgrades-unsafe-allow constructor\n */\n constructor(bool timeBased_, uint256 blocksPerYear_) {\n if (!timeBased_ && blocksPerYear_ == 0) {\n revert InvalidBlocksPerYear();\n }\n\n if (timeBased_ && blocksPerYear_ != 0) {\n revert InvalidTimeBasedConfiguration();\n }\n\n isTimeBased = timeBased_;\n blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;\n _getCurrentSlot = timeBased_ ? _getBlockTimestamp : _getBlockNumber;\n }\n\n /**\n * @dev Function to simply retrieve block number or block timestamp\n * @return Current block number or block timestamp\n */\n function getBlockNumberOrTimestamp() public view virtual returns (uint256) {\n return _getCurrentSlot();\n }\n\n /**\n * @dev Returns the current timestamp in seconds\n * @return The current timestamp\n */\n function _getBlockTimestamp() private view returns (uint256) {\n return block.timestamp;\n }\n\n /**\n * @dev Returns the current block number\n * @return The current block number\n */\n function _getBlockNumber() private view returns (uint256) {\n return block.number;\n }\n}\n" + }, + "@venusprotocol/solidity-utilities/contracts/validators.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\nerror ZeroAddressNotAllowed();\n\n/// @notice Thrown if the supplied value is 0 where it is not allowed\nerror ZeroValueNotAllowed();\n\n/// @notice Checks if the provided address is nonzero, reverts otherwise\n/// @param address_ Address to check\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\nfunction ensureNonzeroAddress(address address_) pure {\n if (address_ == address(0)) {\n revert ZeroAddressNotAllowed();\n }\n}\n\n/// @notice Checks if the provided value is nonzero, reverts otherwise\n/// @param value_ Value to check\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\nfunction ensureNonzeroValue(uint256 value_) pure {\n if (value_ == 0) {\n revert ZeroValueNotAllowed();\n }\n}\n" + }, + "contracts/Admin/VBNBAdmin.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IProtocolShareReserve, IWBNB, VBNBAdminStorage, VTokenInterface } from \"./VBNBAdminStorage.sol\";\n\n/**\n * @title VBNBAdmin\n * @author Venus\n * @notice This contract is the \"admin\" of the vBNB market, reducing the reserves of the market, sending them to the `ProtocolShareReserve` contract,\n * and allowing the executions of the rest of the privileged functions in the vBNB contract (after checking if the sender has the required permissions).\n */\ncontract VBNBAdmin is ReentrancyGuardUpgradeable, AccessControlledV8, VBNBAdminStorage {\n using SafeERC20Upgradeable for IWBNB;\n\n /// @notice address of vBNB\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n VTokenInterface public immutable vBNB;\n\n /// @notice address of WBNB contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IWBNB public immutable WBNB;\n\n /// @notice Emitted when PSR is updated\n event ProtocolShareReserveUpdated(\n IProtocolShareReserve indexed oldProtocolShareReserve,\n IProtocolShareReserve indexed newProtocolShareReserve\n );\n\n /// @notice Emitted reserves are reduced\n event ReservesReduced(uint256 reduceAmount);\n\n /// @param _vBNB Address of the vBNB contract\n /// @param _WBNB Address of the WBNB token\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(VTokenInterface _vBNB, IWBNB _WBNB) {\n require(address(_WBNB) != address(0), \"WBNB address invalid\");\n require(address(_vBNB) != address(0), \"vBNB address invalid\");\n\n vBNB = _vBNB;\n WBNB = _WBNB;\n\n // Note that the contract is upgradeable. Use initialize() or reinitializers\n // to set the state variables.\n _disableInitializers();\n }\n\n /// @notice Used to initialize non-immutable variables\n function initialize(\n IProtocolShareReserve _protocolShareReserve,\n address accessControlManager\n ) external initializer {\n require(address(_protocolShareReserve) != address(0), \"PSR address invalid\");\n protocolShareReserve = _protocolShareReserve;\n\n __ReentrancyGuard_init();\n __AccessControlled_init(accessControlManager);\n }\n\n /**\n * @notice PSR setter.\n * @param protocolShareReserve_ Address of the PSR contract\n * @custom:access Only owner (Governance)\n * @custom:event Emits ProtocolShareReserveUpdated event.\n */\n function setProtocolShareReserve(IProtocolShareReserve protocolShareReserve_) external onlyOwner {\n require(address(protocolShareReserve_) != address(0), \"PSR address invalid\");\n emit ProtocolShareReserveUpdated(protocolShareReserve, protocolShareReserve_);\n protocolShareReserve = protocolShareReserve_;\n }\n\n /**\n * @notice Reduce reserves of vBNB, wrap them and send them to the PSR contract\n * @param reduceAmount amount of reserves to reduce\n * @custom:event Emits ReservesReduced event.\n */\n function reduceReserves(uint reduceAmount) external nonReentrant {\n require(vBNB._reduceReserves(reduceAmount) == 0, \"reduceReserves failed\");\n _wrapBNB();\n\n uint256 balance = WBNB.balanceOf(address(this));\n WBNB.safeTransfer(address(protocolShareReserve), balance);\n protocolShareReserve.updateAssetsState(\n vBNB.comptroller(),\n address(WBNB),\n IProtocolShareReserve.IncomeType.SPREAD\n );\n\n emit ReservesReduced(reduceAmount);\n }\n\n /**\n * @notice Sets the interest rate model of the vBNB contract\n * @param newInterestRateModel Address of the new interest rate model\n * @custom:access Controlled by ACM\n */\n function setInterestRateModel(address newInterestRateModel) public returns (uint256) {\n _checkAccessAllowed(\"setInterestRateModel(address)\");\n return vBNB._setInterestRateModel(newInterestRateModel);\n }\n\n /**\n * @notice Wraps BNB into WBNB\n */\n function _wrapBNB() internal {\n uint256 bnbBalance = address(this).balance;\n WBNB.deposit{ value: bnbBalance }();\n }\n\n /**\n * @notice Invoked when BNB is sent to this contract\n * @custom:access Only vBNB is considered a valid sender\n */\n receive() external payable {\n require(msg.sender == address(vBNB), \"only vBNB can send BNB to this contract\");\n }\n\n /**\n * @notice Invoked when called function does not exist in the contract. The function will be executed in the vBNB contract.\n * @custom:access Only owner (Governance)\n */\n fallback(bytes calldata data) external payable onlyOwner returns (bytes memory) {\n (bool ok, bytes memory res) = address(vBNB).call{ value: msg.value }(data);\n require(ok, \"call failed\");\n return res;\n }\n}\n" + }, + "contracts/Admin/VBNBAdminStorage.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ninterface VTokenInterface {\n function _reduceReserves(uint reduceAmount) external returns (uint);\n\n function _acceptAdmin() external returns (uint);\n\n function comptroller() external returns (address);\n\n function _setInterestRateModel(address newInterestRateModel) external returns (uint);\n}\n\ninterface IWBNB is IERC20Upgradeable {\n function deposit() external payable;\n}\n\ninterface IProtocolShareReserve {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType incomeType) external;\n}\n\ncontract VBNBAdminStorage {\n /// @notice address of protocol share reserve contract\n IProtocolShareReserve public protocolShareReserve;\n\n /// @dev gap to prevent collision in inheritence\n uint256[49] private __gap;\n}\n" + }, + "contracts/DelegateBorrowers/MoveDebtDelegate.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { Ownable2StepUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\n\nimport { approveOrRevert } from \"../lib/approveOrRevert.sol\";\nimport { IVBep20, IComptroller } from \"../InterfacesV8.sol\";\n\ncontract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable {\n /// @dev VToken return value signalling about successful execution\n uint256 internal constant NO_ERROR = 0;\n\n /// @notice A wildcard indicating that repayment is allowed for _any_ user in the market\n address public constant ANY_USER = address(1);\n\n /// @notice User to borrow on behalf of\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable newBorrower;\n\n /// @notice Whether to allow borrowing from the corresponding vToken\n mapping(address => bool) public borrowAllowed;\n\n /// @notice Whether to allow repaying to the corresponding vToken on behalf of\n /// a certain user. Use ANY_USER to check if repayment is allowed for any user.\n mapping(address => mapping(address => bool)) public repaymentAllowed;\n\n /// @notice Emitted when vToken is allowed or denied to be borrowed from\n event BorrowAllowedSet(address indexed vTokenToBorrow, bool allowed);\n\n /// @notice Emitted when vToken is allowed or denied to be borrowed from\n event RepaymentAllowedSet(address indexed vTokenToRepay, address indexed originalBorrower, bool allowed);\n\n /// @notice Emitted if debt is swapped successfully\n event DebtMoved(\n address indexed originalBorrower,\n address indexed vTokenRepaid,\n uint256 repaidAmount,\n address newBorrower,\n address indexed vTokenBorrowed,\n uint256 borrowedAmount\n );\n\n /// @notice Emitted when the owner transfers tokens, accidentially sent to this contract,\n /// to their account\n event SweptTokens(address indexed token, uint256 amount);\n\n /// @notice Thrown if VTokens' comptrollers are not equal\n error ComptrollerMismatch();\n\n /// @notice Thrown if repayment fails with an error code\n error RepaymentFailed(uint256 errorCode);\n\n /// @notice Thrown if borrow fails with an error code\n error BorrowFailed(uint256 errorCode);\n\n /// @notice Thrown if borrowing from the corresponding vToken is not allowed\n error BorrowNotAllowed(address vToken);\n\n /// @notice Thrown if repaying the debts of the borrower to the corresponding vToken is not allowed\n error RepaymentNotAllowed(address vToken, address borrower);\n\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param newBorrower_ User to borrow on behalf of\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address newBorrower_) {\n newBorrower = newBorrower_;\n _disableInitializers();\n }\n\n function initialize() external initializer {\n __Ownable2Step_init();\n __ReentrancyGuard_init();\n }\n\n /**\n * @notice Repays originalBorrower's borrow in vTokenToRepay.underlying() and borrows\n * vTokenToBorrow.underlying() on behalf of newBorrower.\n *\n * @param originalBorrower The address of the borrower, whose debt to repay\n * @param vTokenToRepay VToken to repay to on behalf of originalBorrower\n * @param repayAmount The amount to repay in terms of vTokenToRepay.underlying()\n * @param vTokenToBorrow VToken to borrow from\n */\n function moveDebt(\n IVBep20 vTokenToRepay,\n address originalBorrower,\n uint256 repayAmount,\n IVBep20 vTokenToBorrow\n ) external nonReentrant {\n if (!borrowAllowed[address(vTokenToBorrow)]) {\n revert BorrowNotAllowed(address(vTokenToBorrow));\n }\n\n mapping(address => bool) storage repaymentAllowedFor = repaymentAllowed[address(vTokenToRepay)];\n if (!repaymentAllowedFor[ANY_USER] && !repaymentAllowedFor[originalBorrower]) {\n revert RepaymentNotAllowed(address(vTokenToRepay), originalBorrower);\n }\n\n uint256 actualRepaymentAmount = _repay(vTokenToRepay, originalBorrower, repayAmount);\n uint256 amountToBorrow = _convert(vTokenToRepay, vTokenToBorrow, actualRepaymentAmount);\n _borrow(vTokenToBorrow, amountToBorrow);\n emit DebtMoved(\n originalBorrower,\n address(vTokenToRepay),\n actualRepaymentAmount,\n newBorrower,\n address(vTokenToBorrow),\n amountToBorrow\n );\n }\n\n /**\n * @notice Allows or denies borrowing from the corresponding vToken\n * @param vTokenToBorrow VToken to borrow from\n * @param allow Whether to allow borrowing from the corresponding vToken\n */\n function setBorrowAllowed(address vTokenToBorrow, bool allow) external onlyOwner {\n ensureNonzeroAddress(vTokenToBorrow);\n if (borrowAllowed[vTokenToBorrow] != allow) {\n borrowAllowed[vTokenToBorrow] = allow;\n emit BorrowAllowedSet(vTokenToBorrow, allow);\n }\n }\n\n /**\n * @notice Allows or denies repaying the debts of originalBorrower to the corresponding vToken\n * @param vTokenToRepay VToken to repay to\n * @param originalBorrower The address of the borrower, whose debt to repay (or ANY_USER to allow\n * repayments for all users in the market, e.g. if the market is going to be deprecated soon)\n * @param allow Whether to allow repaying to the corresponding vToken on behalf of originalBorrower\n */\n function setRepaymentAllowed(address vTokenToRepay, address originalBorrower, bool allow) external onlyOwner {\n ensureNonzeroAddress(vTokenToRepay);\n ensureNonzeroAddress(originalBorrower);\n if (repaymentAllowed[vTokenToRepay][originalBorrower] != allow) {\n repaymentAllowed[vTokenToRepay][originalBorrower] = allow;\n emit RepaymentAllowedSet(vTokenToRepay, originalBorrower, allow);\n }\n }\n\n /**\n * @notice Transfers tokens, accidentially sent to this contract, to the owner\n * @param token ERC-20 token to sweep\n */\n function sweepTokens(IERC20Upgradeable token) external onlyOwner {\n uint256 amount = token.balanceOf(address(this));\n token.safeTransfer(owner(), amount);\n emit SweptTokens(address(token), amount);\n }\n\n /**\n * @dev Transfers the funds from the sender and repays a borrow in vToken on behalf of the borrower\n * @param vTokenToRepay VToken to repay to\n * @param borrower The address of the borrower, whose debt to repay\n * @param repayAmount The amount to repay in terms of underlying\n */\n function _repay(\n IVBep20 vTokenToRepay,\n address borrower,\n uint256 repayAmount\n ) internal returns (uint256 actualRepaymentAmount) {\n IERC20Upgradeable underlying = IERC20Upgradeable(vTokenToRepay.underlying());\n uint256 balanceBefore = underlying.balanceOf(address(this));\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n uint256 balanceAfter = underlying.balanceOf(address(this));\n uint256 repayAmountMinusFee = balanceAfter - balanceBefore;\n\n uint256 borrowBalanceBefore = vTokenToRepay.borrowBalanceCurrent(borrower);\n approveOrRevert(underlying, address(vTokenToRepay), repayAmountMinusFee);\n uint256 err = vTokenToRepay.repayBorrowBehalf(borrower, repayAmountMinusFee);\n if (err != NO_ERROR) {\n revert RepaymentFailed(err);\n }\n approveOrRevert(underlying, address(vTokenToRepay), 0);\n uint256 borrowBalanceAfter = vTokenToRepay.borrowBalanceCurrent(borrower);\n return borrowBalanceBefore - borrowBalanceAfter;\n }\n\n /**\n * @dev Borrows in vToken on behalf of the borrower and transfers the funds to the sender\n * @param vTokenToBorrow VToken to borrow from\n * @param borrowAmount The amount to borrow in terms of underlying\n */\n function _borrow(IVBep20 vTokenToBorrow, uint256 borrowAmount) internal {\n IERC20Upgradeable underlying = IERC20Upgradeable(vTokenToBorrow.underlying());\n uint256 balanceBefore = underlying.balanceOf(address(this));\n uint256 err = vTokenToBorrow.borrowBehalf(newBorrower, borrowAmount);\n if (err != NO_ERROR) {\n revert BorrowFailed(err);\n }\n uint256 balanceAfter = underlying.balanceOf(address(this));\n uint256 actualBorrowedAmount = balanceAfter - balanceBefore;\n underlying.safeTransfer(msg.sender, actualBorrowedAmount);\n }\n\n /**\n * @dev Converts the value expressed in convertFrom.underlying() to a value\n * in convertTo.underlying(), using the oracle price\n * @param convertFrom VToken to convert from\n * @param convertTo VToken to convert to\n * @param amount The amount in convertFrom.underlying()\n */\n function _convert(IVBep20 convertFrom, IVBep20 convertTo, uint256 amount) internal view returns (uint256) {\n IComptroller comptroller = convertFrom.comptroller();\n if (comptroller != convertTo.comptroller()) {\n revert ComptrollerMismatch();\n }\n ResilientOracleInterface oracle = comptroller.oracle();\n\n // Decimals are accounted for in the oracle contract\n uint256 scaledUsdValue = oracle.getUnderlyingPrice(address(convertFrom)) * amount; // the USD value here has 36 decimals\n return scaledUsdValue / oracle.getUnderlyingPrice(address(convertTo));\n }\n}\n" + }, + "contracts/DelegateBorrowers/SwapDebtDelegate.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { Ownable2StepUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\n\nimport { approveOrRevert } from \"../lib/approveOrRevert.sol\";\nimport { IVBep20, IComptroller } from \"../InterfacesV8.sol\";\n\ncontract SwapDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable {\n /// @dev VToken return value signalling about successful execution\n uint256 internal constant NO_ERROR = 0;\n\n /// @notice Emitted if debt is swapped successfully\n event DebtSwapped(\n address indexed borrower,\n address indexed vTokenRepaid,\n uint256 repaidAmount,\n address indexed vTokenBorrowed,\n uint256 borrowedAmount\n );\n\n /// @notice Emitted when the owner transfers tokens, accidentially sent to this contract,\n /// to their account\n event SweptTokens(address indexed token, uint256 amount);\n\n /// @notice Thrown if VTokens' comptrollers are not equal\n error ComptrollerMismatch();\n\n /// @notice Thrown if repayment fails with an error code\n error RepaymentFailed(uint256 errorCode);\n\n /// @notice Thrown if borrow fails with an error code\n error BorrowFailed(uint256 errorCode);\n\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n function initialize() external initializer {\n __Ownable2Step_init();\n __ReentrancyGuard_init();\n }\n\n /**\n * @notice Repays a borrow in repayTo.underlying() and borrows borrowFrom.underlying()\n * @param borrower The address of the borrower, whose debt to swap\n * @param repayTo VToken to repay the debt to\n * @param borrowFrom VToken to borrow from\n * @param repayAmount The amount to repay in terms of repayTo.underlying()\n */\n function swapDebt(\n address borrower,\n IVBep20 repayTo,\n IVBep20 borrowFrom,\n uint256 repayAmount\n ) external onlyOwner nonReentrant {\n uint256 actualRepaymentAmount = _repay(repayTo, borrower, repayAmount);\n uint256 amountToBorrow = _convert(repayTo, borrowFrom, actualRepaymentAmount);\n _borrow(borrowFrom, borrower, amountToBorrow);\n emit DebtSwapped(borrower, address(repayTo), actualRepaymentAmount, address(borrowFrom), amountToBorrow);\n }\n\n /**\n * @notice Transfers tokens, accidentially sent to this contract, to the owner\n * @param token ERC-20 token to sweep\n */\n function sweepTokens(IERC20Upgradeable token) external onlyOwner {\n uint256 amount = token.balanceOf(address(this));\n token.safeTransfer(owner(), amount);\n emit SweptTokens(address(token), amount);\n }\n\n /**\n * @dev Transfers the funds from the sender and repays a borrow in vToken on behalf of the borrower\n * @param vToken VToken to repay the debt to\n * @param borrower The address of the borrower, whose debt to repay\n * @param repayAmount The amount to repay in terms of underlying\n */\n function _repay(\n IVBep20 vToken,\n address borrower,\n uint256 repayAmount\n ) internal returns (uint256 actualRepaymentAmount) {\n IERC20Upgradeable underlying = IERC20Upgradeable(vToken.underlying());\n uint256 balanceBefore = underlying.balanceOf(address(this));\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n uint256 balanceAfter = underlying.balanceOf(address(this));\n uint256 repayAmountMinusFee = balanceAfter - balanceBefore;\n\n underlying.safeApprove(address(vToken), 0);\n underlying.safeApprove(address(vToken), repayAmountMinusFee);\n uint256 borrowBalanceBefore = vToken.borrowBalanceCurrent(borrower);\n uint256 err = vToken.repayBorrowBehalf(borrower, repayAmountMinusFee);\n if (err != NO_ERROR) {\n revert RepaymentFailed(err);\n }\n uint256 borrowBalanceAfter = vToken.borrowBalanceCurrent(borrower);\n return borrowBalanceBefore - borrowBalanceAfter;\n }\n\n /**\n * @dev Borrows in vToken on behalf of the borrower and transfers the funds to the sender\n * @param vToken VToken to borrow from\n * @param borrower The address of the borrower, who will own the borrow\n * @param borrowAmount The amount to borrow in terms of underlying\n */\n function _borrow(IVBep20 vToken, address borrower, uint256 borrowAmount) internal {\n IERC20Upgradeable underlying = IERC20Upgradeable(vToken.underlying());\n uint256 balanceBefore = underlying.balanceOf(address(this));\n uint256 err = vToken.borrowBehalf(borrower, borrowAmount);\n if (err != NO_ERROR) {\n revert BorrowFailed(err);\n }\n uint256 balanceAfter = underlying.balanceOf(address(this));\n uint256 actualBorrowedAmount = balanceAfter - balanceBefore;\n underlying.safeTransfer(msg.sender, actualBorrowedAmount);\n }\n\n /**\n * @dev Converts the value expressed in convertFrom.underlying() to a value\n * in convertTo.underlying(), using the oracle price\n * @param convertFrom VToken to convert from\n * @param convertTo VToken to convert to\n * @param amount The amount in convertFrom.underlying()\n */\n function _convert(IVBep20 convertFrom, IVBep20 convertTo, uint256 amount) internal view returns (uint256) {\n IComptroller comptroller = convertFrom.comptroller();\n if (comptroller != convertTo.comptroller()) {\n revert ComptrollerMismatch();\n }\n ResilientOracleInterface oracle = comptroller.oracle();\n\n // Decimals are accounted for in the oracle contract\n uint256 scaledUsdValue = oracle.getUnderlyingPrice(address(convertFrom)) * amount; // the USD value here has 36 decimals\n return scaledUsdValue / oracle.getUnderlyingPrice(address(convertTo));\n }\n}\n" + }, + "contracts/Governance/TokenRedeemer.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { ReentrancyGuard } from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\n\nimport { IVAIController, IVToken, IVBep20, IVBNB } from \"../InterfacesV8.sol\";\nimport { Currency, CurrencyLibrary } from \"../lib/Currency.sol\";\n\ncontract TokenRedeemer is ReentrancyGuard, Ownable2Step {\n using CurrencyLibrary for Currency;\n\n struct Repayment {\n address borrower;\n uint256 amount;\n }\n\n IVBNB public immutable VBNB;\n\n error AccrueInterestFailed(uint256 errCode);\n error RedeemFailed(uint256 errCode);\n error RepaymentFailed(uint256 errCode);\n error NativeTokenTransferFailed();\n\n constructor(address owner_, IVBNB vBNB) {\n ensureNonzeroAddress(owner_);\n VBNB = vBNB;\n _transferOwnership(owner_);\n }\n\n receive() external payable {}\n\n function redeemAndTransfer(IVToken vToken, address destination) external nonReentrant onlyOwner {\n Currency underlying = _underlying(vToken);\n uint256 err = vToken.redeem(vToken.balanceOf(address(this)));\n if (err != 0) {\n revert RedeemFailed(err);\n }\n underlying.transferAll(destination);\n }\n\n function redeemUnderlyingAndTransfer(\n IVToken vToken,\n address destination,\n uint256 amount,\n address receiver\n ) external nonReentrant onlyOwner {\n Currency underlying = _underlying(vToken);\n underlying.transferAll(receiver); // Just in case there were some underlying tokens on the contract\n uint256 err = vToken.redeemUnderlying(amount);\n if (err != 0) {\n revert RedeemFailed(err);\n }\n underlying.transferAll(destination);\n Currency.wrap(address(vToken)).transferAll(receiver);\n }\n\n function redeemUnderlyingAndRepayBorrowBehalf(\n IVToken vToken,\n address borrower,\n uint256 amount,\n address receiver\n ) external nonReentrant onlyOwner {\n Currency underlying = _underlying(vToken);\n\n uint256 err = vToken.redeemUnderlying(amount);\n if (err != 0) {\n revert RedeemFailed(err);\n }\n\n underlying.approve(address(vToken), amount);\n\n _repay(vToken, borrower, amount);\n\n underlying.approve(address(vToken), 0);\n\n underlying.transferAll(receiver);\n Currency.wrap(address(vToken)).transferAll(receiver);\n }\n\n function redeemAndBatchRepay(\n IVToken vToken,\n Repayment[] calldata requestedRepayments,\n address receiver\n ) external nonReentrant onlyOwner {\n _accrueInterest(vToken);\n\n (uint256 totalBorrowedAmount, Repayment[] memory repayments) = _getAmountsToRepay(vToken, requestedRepayments);\n _redeemUpTo(vToken, totalBorrowedAmount);\n\n Currency underlying = _underlying(vToken);\n uint256 balance = underlying.balanceOfSelf();\n underlying.approve(address(vToken), totalBorrowedAmount);\n uint256 repaymentsCount = repayments.length;\n // The code below assumes no fees on transfer\n if (balance >= totalBorrowedAmount) {\n // If we're doing a full repayment, we can optimize it by skipping the balance checks\n for (uint256 i = 0; i < repaymentsCount; ++i) {\n Repayment memory repayment = repayments[i];\n _repay(vToken, repayment.borrower, repayment.amount);\n }\n } else {\n // Otherwise, we have to check and update the balance on every iteration\n for (uint256 i = 0; i < repaymentsCount && balance != 0; ++i) {\n Repayment memory repayment = repayments[i];\n _repay(vToken, repayment.borrower, _min(repayment.amount, balance));\n balance = underlying.balanceOfSelf();\n }\n }\n underlying.approve(address(vToken), 0);\n\n underlying.transferAll(receiver);\n Currency.wrap(address(vToken)).transferAll(receiver);\n }\n\n function batchRepayVAI(\n IVAIController vaiController,\n Repayment[] calldata requestedRepayments,\n address receiver\n ) external nonReentrant onlyOwner {\n vaiController.accrueVAIInterest();\n Currency vai = Currency.wrap(vaiController.getVAIAddress());\n uint256 balance = vai.balanceOfSelf();\n vai.approve(address(vaiController), type(uint256).max);\n uint256 repaymentsCount = requestedRepayments.length;\n for (uint256 i = 0; i < repaymentsCount && balance != 0; ++i) {\n Repayment calldata requestedRepayment = requestedRepayments[i];\n uint256 repaymentCap = requestedRepayment.amount;\n uint256 debt = vaiController.getVAIRepayAmount(requestedRepayment.borrower);\n uint256 amount = _min(repaymentCap, debt);\n _repayVAI(vaiController, requestedRepayment.borrower, _min(amount, balance));\n balance = vai.balanceOfSelf();\n }\n vai.approve(address(vaiController), 0);\n vai.transferAll(receiver);\n }\n\n function sweepTokens(address token, address destination) external onlyOwner {\n Currency.wrap(token).transferAll(destination);\n }\n\n function _accrueInterest(IVToken vToken) internal {\n uint256 err = vToken.accrueInterest();\n if (err != 0) {\n revert AccrueInterestFailed(err);\n }\n }\n\n function _redeemUpTo(IVToken vToken, uint256 amount) internal {\n uint256 unredeemedUnderlying = vToken.balanceOfUnderlying(address(this));\n if (unredeemedUnderlying > 0) {\n uint256 err = vToken.redeemUnderlying(_min(amount, unredeemedUnderlying));\n if (err != 0) {\n revert RedeemFailed(err);\n }\n }\n }\n\n function _repay(IVToken vToken, address borrower, uint256 amount) internal {\n if (amount == 0) {\n return;\n }\n if (_isVBNB(vToken)) {\n IVBNB(address(vToken)).repayBorrowBehalf{ value: amount }(borrower);\n } else {\n uint256 err = IVBep20(address(vToken)).repayBorrowBehalf(borrower, amount);\n if (err != 0) {\n revert RepaymentFailed(err);\n }\n }\n }\n\n function _repayVAI(IVAIController vaiController, address borrower, uint256 amount) internal {\n if (amount == 0) {\n return;\n }\n (uint256 err, ) = vaiController.repayVAIBehalf(borrower, amount);\n if (err != 0) {\n revert RepaymentFailed(err);\n }\n }\n\n function _getAmountsToRepay(\n IVToken vToken,\n Repayment[] calldata requestedRepayments\n ) internal view returns (uint256, Repayment[] memory) {\n uint256 repaymentsCount = requestedRepayments.length;\n Repayment[] memory actualRepayments = new Repayment[](repaymentsCount);\n uint256 totalAmountToRepay = 0;\n for (uint256 i = 0; i < repaymentsCount; ++i) {\n Repayment calldata requestedRepayment = requestedRepayments[i];\n uint256 repaymentCap = requestedRepayment.amount;\n uint256 debt = vToken.borrowBalanceStored(requestedRepayment.borrower);\n uint256 amountToRepay = _min(repaymentCap, debt);\n totalAmountToRepay += amountToRepay;\n actualRepayments[i] = Repayment({ borrower: requestedRepayment.borrower, amount: amountToRepay });\n }\n return (totalAmountToRepay, actualRepayments);\n }\n\n function _underlying(IVToken vToken) internal view returns (Currency) {\n if (_isVBNB(vToken)) {\n return CurrencyLibrary.NATIVE;\n }\n return Currency.wrap(IVBep20(address(vToken)).underlying());\n }\n\n function _isVBNB(IVToken vToken) internal view returns (bool) {\n return address(vToken) == address(VBNB);\n }\n\n function _min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n}\n" + }, + "contracts/Governance/VTreasuryV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { SafeERC20, IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport { ReentrancyGuard } from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\n/**\n * @title VTreasuryV8\n * @author Venus\n * @notice Protocol treasury that holds tokens owned by Venus\n */\ncontract VTreasuryV8 is Ownable2Step, ReentrancyGuard {\n using SafeERC20 for IERC20;\n\n // WithdrawTreasuryToken Event\n event WithdrawTreasuryToken(address indexed tokenAddress, uint256 withdrawAmount, address indexed withdrawAddress);\n\n // WithdrawTreasuryNative Event\n event WithdrawTreasuryNative(uint256 withdrawAmount, address indexed withdrawAddress);\n\n /// @notice Thrown if the supplied address is a zero address where it is not allowed\n error ZeroAddressNotAllowed();\n\n /**\n * @notice To receive Native when msg.data is not empty\n */\n fallback() external payable {}\n\n /**\n * @notice To receive Native when msg.data is empty\n */\n receive() external payable {}\n\n /**\n * @notice Withdraw Treasury Tokens, Only owner call it\n * @param tokenAddress The address of treasury token\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n * @custom:error ZeroAddressNotAllowed thrown when token or withdrawAddress is zero.\n */\n function withdrawTreasuryToken(\n address tokenAddress,\n uint256 withdrawAmount,\n address withdrawAddress\n ) external onlyOwner nonReentrant {\n ensureNonzeroAddress(tokenAddress);\n ensureNonzeroAddress(withdrawAddress);\n require(withdrawAmount > 0, \"withdrawAmount must not be zero\");\n\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury Token Balance\n uint256 treasuryBalance = IERC20(tokenAddress).balanceOf(address(this));\n\n // Check Withdraw Amount\n if (withdrawAmount > treasuryBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = treasuryBalance;\n }\n\n // Transfer Token to withdrawAddress\n IERC20(tokenAddress).safeTransfer(withdrawAddress, actualWithdrawAmount);\n\n emit WithdrawTreasuryToken(tokenAddress, actualWithdrawAmount, withdrawAddress);\n }\n\n /**\n * @notice Withdraw Treasury Native, Only owner call it\n * @param withdrawAmount The withdraw amount to owner\n * @param withdrawAddress The withdraw address\n * @custom:error ZeroAddressNotAllowed thrown when withdrawAddress is zero.\n */\n function withdrawTreasuryNative(\n uint256 withdrawAmount,\n address payable withdrawAddress\n ) external payable onlyOwner nonReentrant {\n ensureNonzeroAddress(withdrawAddress);\n require(withdrawAmount > 0, \"withdrawAmount must not be zero\");\n uint256 actualWithdrawAmount = withdrawAmount;\n // Get Treasury Native Balance\n uint256 nativeBalance = address(this).balance;\n\n // Check Withdraw Amount\n if (withdrawAmount > nativeBalance) {\n // Update actualWithdrawAmount\n actualWithdrawAmount = nativeBalance;\n }\n // Transfer the native token to withdrawAddress\n (bool sent, ) = withdrawAddress.call{ value: actualWithdrawAmount }(\"\");\n require(sent, \"Call failed\");\n emit WithdrawTreasuryNative(actualWithdrawAmount, withdrawAddress);\n }\n\n /// @notice Checks if the provided address is nonzero, reverts otherwise\n /// @param address_ Address to check\n /// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\n function ensureNonzeroAddress(address address_) internal pure {\n if (address_ == address(0)) {\n revert ZeroAddressNotAllowed();\n }\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport 'hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol';\n" + }, + "contracts/hardhat-dependency-compiler/hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport 'hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol';\n" + }, + "contracts/InterestRateModels/InterestRateModelV8.sol": { + "content": "pragma solidity 0.8.25;\n\n/**\n * @title Venus's InterestRateModelV8 Interface\n * @author Venus\n */\nabstract contract InterestRateModelV8 {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) external view virtual returns (uint256);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amnount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) external view virtual returns (uint256);\n}\n" + }, + "contracts/InterestRateModels/TwoKinksInterestRateModel.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { InterestRateModelV8 } from \"./InterestRateModelV8.sol\";\n\n/**\n * @title TwoKinksInterestRateModel\n * @author Venus\n * @notice An interest rate model with two different slope increase or decrease each after a certain utilization threshold called **kink** is reached.\n */\ncontract TwoKinksInterestRateModel is InterestRateModelV8 {\n int256 public constant BLOCKS_PER_YEAR = (60 * 60 * 24 * 365) / 3; // (assuming 3s blocks)\n\n ////////////////////// SLOPE 1 //////////////////////\n\n /**\n * @notice The multiplier of utilization rate per block that gives the slope 1 of the interest rate scaled by EXP_SCALE\n */\n int256 public immutable MULTIPLIER_PER_BLOCK;\n\n /**\n * @notice The base interest rate per block which is the y-intercept when utilization rate is 0 scaled by EXP_SCALE\n */\n int256 public immutable BASE_RATE_PER_BLOCK;\n\n ////////////////////// SLOPE 2 //////////////////////\n\n /**\n * @notice The utilization point at which the multiplier2 is applied\n */\n int256 public immutable KINK_1;\n\n /**\n * @notice The multiplier of utilization rate per block that gives the slope 2 of the interest rate scaled by EXP_SCALE\n */\n int256 public immutable MULTIPLIER_2_PER_BLOCK;\n\n /**\n * @notice The base interest rate per block which is the y-intercept when utilization rate hits KINK_1 scaled by EXP_SCALE\n */\n int256 public immutable BASE_RATE_2_PER_BLOCK;\n\n /**\n * @notice The maximum kink interest rate scaled by EXP_SCALE\n */\n int256 public immutable RATE_1;\n\n ////////////////////// SLOPE 3 //////////////////////\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n int256 public immutable KINK_2;\n\n /**\n * @notice The multiplier of utilization rate per block that gives the slope 3 of interest rate scaled by EXP_SCALE\n */\n int256 public immutable JUMP_MULTIPLIER_PER_BLOCK;\n\n /**\n * @notice The maximum kink interest rate scaled by EXP_SCALE\n */\n int256 public immutable RATE_2;\n\n /// @notice Base unit for computations, usually used in scaling (multiplications, divisions)\n uint256 internal constant EXP_SCALE = 1e18;\n\n /**\n * @notice Thrown when a negative value is not allowed\n */\n error NegativeValueNotAllowed();\n\n /**\n * @notice Thrown when the kink points are not in the correct order\n */\n error InvalidKink();\n\n /**\n * @notice Construct an interest rate model\n * @param baseRatePerYear_ The approximate target base APR, as a mantissa (scaled by EXP_SCALE)\n * @param multiplierPerYear_ The rate of increase or decrease in interest rate wrt utilization (scaled by EXP_SCALE)\n * @param kink1_ The utilization point at which the multiplier2 is applied\n * @param multiplier2PerYear_ The rate of increase or decrease in interest rate wrt utilization after hitting KINK_1 (scaled by EXP_SCALE)\n * @param baseRate2PerYear_ The additional base APR after hitting KINK_1, as a mantissa (scaled by EXP_SCALE)\n * @param kink2_ The utilization point at which the jump multiplier is applied\n * @param jumpMultiplierPerYear_ The multiplier after hitting KINK_2\n */\n constructor(\n int256 baseRatePerYear_,\n int256 multiplierPerYear_,\n int256 kink1_,\n int256 multiplier2PerYear_,\n int256 baseRate2PerYear_,\n int256 kink2_,\n int256 jumpMultiplierPerYear_\n ) {\n if (baseRatePerYear_ < 0 || baseRate2PerYear_ < 0) {\n revert NegativeValueNotAllowed();\n }\n\n if (kink2_ <= kink1_ || kink1_ <= 0) {\n revert InvalidKink();\n }\n\n BASE_RATE_PER_BLOCK = baseRatePerYear_ / BLOCKS_PER_YEAR;\n MULTIPLIER_PER_BLOCK = multiplierPerYear_ / BLOCKS_PER_YEAR;\n KINK_1 = kink1_;\n MULTIPLIER_2_PER_BLOCK = multiplier2PerYear_ / BLOCKS_PER_YEAR;\n BASE_RATE_2_PER_BLOCK = baseRate2PerYear_ / BLOCKS_PER_YEAR;\n KINK_2 = kink2_;\n JUMP_MULTIPLIER_PER_BLOCK = jumpMultiplierPerYear_ / BLOCKS_PER_YEAR;\n\n int256 expScale = int256(EXP_SCALE);\n RATE_1 = (((KINK_1 * MULTIPLIER_PER_BLOCK) / expScale) + BASE_RATE_PER_BLOCK);\n\n int256 slope2Util;\n unchecked {\n slope2Util = KINK_2 - KINK_1;\n }\n RATE_2 = ((slope2Util * MULTIPLIER_2_PER_BLOCK) / expScale) + BASE_RATE_2_PER_BLOCK;\n }\n\n /**\n * @notice Calculates the current borrow rate per slot (block)\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per slot (block) as a mantissa (scaled by EXP_SCALE)\n */\n function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) external view override returns (uint256) {\n return _getBorrowRate(cash, borrows, reserves);\n }\n\n /**\n * @notice Calculates the current supply rate per slot (block)\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per slot (block) as a mantissa (scaled by EXP_SCALE)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual override returns (uint256) {\n uint256 oneMinusReserveFactor = EXP_SCALE - reserveFactorMantissa;\n uint256 borrowRate = _getBorrowRate(cash, borrows, reserves);\n uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / EXP_SCALE;\n return (utilizationRate(cash, borrows, reserves) * rateToPool) / EXP_SCALE;\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The utilization rate as a mantissa between [0, EXP_SCALE]\n */\n function utilizationRate(uint256 cash, uint256 borrows, uint256 reserves) public pure returns (uint256) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n uint256 rate = (borrows * EXP_SCALE) / (cash + borrows - reserves);\n\n if (rate > EXP_SCALE) {\n rate = EXP_SCALE;\n }\n\n return rate;\n }\n\n /**\n * @notice Calculates the current borrow rate per slot (block), with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per slot (block) as a mantissa (scaled by EXP_SCALE)\n */\n function _getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) internal view returns (uint256) {\n int256 util = int256(utilizationRate(cash, borrows, reserves));\n int256 expScale = int256(EXP_SCALE);\n\n if (util < KINK_1) {\n return _minCap(((util * MULTIPLIER_PER_BLOCK) / expScale) + BASE_RATE_PER_BLOCK);\n } else if (util < KINK_2) {\n int256 slope2Util;\n unchecked {\n slope2Util = util - KINK_1;\n }\n int256 rate2 = ((slope2Util * MULTIPLIER_2_PER_BLOCK) / expScale) + BASE_RATE_2_PER_BLOCK;\n\n return _minCap(RATE_1 + rate2);\n } else {\n int256 slope3Util;\n unchecked {\n slope3Util = util - KINK_2;\n }\n int256 rate3 = ((slope3Util * JUMP_MULTIPLIER_PER_BLOCK) / expScale);\n\n return _minCap(RATE_1 + RATE_2 + rate3);\n }\n }\n\n /**\n * @notice Returns 0 if number is less than 0, otherwise returns the input\n * @param number The first number\n * @return The maximum of 0 and input number\n */\n function _minCap(int256 number) internal pure returns (uint256) {\n int256 zero;\n return uint256(number > zero ? number : zero);\n }\n}\n" + }, + "contracts/InterfacesV8.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\n\ninterface IVToken is IERC20Upgradeable {\n function accrueInterest() external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrowBalanceCurrent(address borrower) external returns (uint256);\n\n function balanceOfUnderlying(address owner) external returns (uint256);\n\n function comptroller() external view returns (IComptroller);\n\n function borrowBalanceStored(address account) external view returns (uint256);\n}\n\ninterface IVBep20 is IVToken {\n function borrowBehalf(address borrower, uint256 borrowAmount) external returns (uint256);\n\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\n\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external returns (uint256);\n\n function underlying() external view returns (address);\n}\n\ninterface IVBNB is IVToken {\n function repayBorrowBehalf(address borrower) external payable;\n\n function liquidateBorrow(address borrower, IVToken vTokenCollateral) external payable;\n}\n\ninterface IVAIController {\n function accrueVAIInterest() external;\n\n function liquidateVAI(\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external returns (uint256, uint256);\n\n function repayVAIBehalf(address borrower, uint256 amount) external returns (uint256, uint256);\n\n function getVAIAddress() external view returns (address);\n\n function getVAIRepayAmount(address borrower) external view returns (uint256);\n}\n\ninterface IComptroller {\n enum Action {\n MINT,\n REDEEM,\n BORROW,\n REPAY,\n SEIZE,\n LIQUIDATE,\n TRANSFER,\n ENTER_MARKET,\n EXIT_MARKET\n }\n\n function _setActionsPaused(address[] calldata markets_, Action[] calldata actions_, bool paused_) external;\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function vaiController() external view returns (IVAIController);\n\n function liquidatorContract() external view returns (address);\n\n function oracle() external view returns (ResilientOracleInterface);\n\n function actionPaused(address market, Action action) external view returns (bool);\n\n function markets(address) external view returns (bool, uint256, bool);\n\n function isForcedLiquidationEnabled(address) external view returns (bool);\n}\n\ninterface ILiquidator {\n function restrictLiquidation(address borrower) external;\n\n function unrestrictLiquidation(address borrower) external;\n\n function addToAllowlist(address borrower, address liquidator) external;\n\n function removeFromAllowlist(address borrower, address liquidator) external;\n\n function liquidateBorrow(\n address vToken,\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external payable;\n\n function setTreasuryPercent(uint256 newTreasuryPercentMantissa) external;\n\n function treasuryPercentMantissa() external view returns (uint256);\n}\n\ninterface IProtocolShareReserve {\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType kind) external;\n}\n\ninterface IWBNB is IERC20Upgradeable {\n function deposit() external payable;\n}\n" + }, + "contracts/lib/approveOrRevert.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.25;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\n/// @notice Thrown if a contract is unable to approve a transfer\nerror ApproveFailed();\n\n/// @notice Approves a transfer, ensuring that it is successful. This function supports non-compliant\n/// tokens like the ones that don't return a boolean value on success. Thus, such approve call supports\n/// three different kinds of tokens:\n/// * Compliant tokens that revert on failure\n/// * Compliant tokens that return false on failure\n/// * Non-compliant tokens that don't return a value\n/// @param token The contract address of the token which will be transferred\n/// @param spender The spender contract address\n/// @param amount The value of the transfer\nfunction approveOrRevert(IERC20Upgradeable token, address spender, uint256 amount) {\n bytes memory callData = abi.encodeCall(token.approve, (spender, amount));\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory result) = address(token).call(callData);\n\n if (!success || (result.length != 0 && !abi.decode(result, (bool)))) {\n revert ApproveFailed();\n }\n}\n" + }, + "contracts/lib/Currency.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n// This library is heavily inspired by Uniswap v4 Currency lib\n// (https://github.com/Uniswap/v4-core/blob/b230769238879e1d4f58ffa57a4696b0c390d188/src/types/Currency.sol)\n// Contrary to the implementation above, this library does not\n// use assembly to save gas. It rather relies on OpenZeppelin's\n// SafeERC20 to simplify the review and audits. This might change\n// in future if it's more heavily used by Venus contracts.\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ntype Currency is address;\n\nlibrary CurrencyLibrary {\n using CurrencyLibrary for Currency;\n\n /// @notice Thrown when a native transfer fails\n error NativeTransferFailed();\n\n Currency public constant NATIVE = Currency.wrap(0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB);\n\n /**\n * @dev If currency is a token, invokes SafeERC20.forceApprove to allow spender\n * to spend the amount of tokens on behalf of the current contract. Otherwise,\n * does nothing.\n * @param currency Currency\n * @param spender The account approved to spend the tokens\n * @param amount The approved amount\n */\n function approve(Currency currency, address spender, uint256 amount) internal {\n if (!currency.isNative()) {\n // I'd rather use approveOrRevert instead of forceApprove\n // once we migrate to OZ v5: force-approve does approve(0)\n // before approving the amount, and it's not always\n // desirable. The users will need to pay gas unnecessarily,\n // and using just approve() is safe as long as we revert on\n // errors (approveOrRevert handles that) and reset the approvals\n // after transfers (which is a best practice recommended by\n // auditors anyway).\n SafeERC20.forceApprove(IERC20(Currency.unwrap(currency)), spender, amount);\n }\n }\n\n /**\n * @dev Transfers an amount of currency to the receiver. If currency is a token,\n * uses SafeERC20.safeTransfer, otherwise transfers the native currency using\n * the recommended approach (`receiver.call{value: amount}(\"\")`).\n * @param currency Currency\n * @param receiver The account that would receive the tokens\n * @param amount The amount to transfer\n */\n function transfer(Currency currency, address receiver, uint256 amount) internal {\n if (currency.isNative()) {\n (bool success, ) = receiver.call{ value: amount }(\"\");\n if (!success) {\n revert NativeTransferFailed();\n }\n } else {\n SafeERC20.safeTransfer(IERC20(Currency.unwrap(currency)), receiver, amount);\n }\n }\n\n function transferAll(Currency currency, address receiver) internal {\n uint256 balance = currency.balanceOfSelf();\n if (balance > 0) {\n currency.transfer(receiver, balance);\n }\n }\n\n function balanceOfSelf(Currency currency) internal view returns (uint256) {\n if (currency.isNative()) {\n return address(this).balance;\n }\n return IERC20(Currency.unwrap(currency)).balanceOf(address(this));\n }\n\n function isNative(Currency currency) internal pure returns (bool) {\n return Currency.unwrap(currency) == Currency.unwrap(NATIVE);\n }\n}\n" + }, + "contracts/Liquidator/BUSDLiquidator.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.25;\n\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport { Ownable2StepUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\nimport { MANTISSA_ONE } from \"@venusprotocol/solidity-utilities/contracts/constants.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\n\nimport { approveOrRevert } from \"../lib/approveOrRevert.sol\";\nimport { ILiquidator, IComptroller, IVToken, IVBep20, IVBNB, IVAIController } from \"../InterfacesV8.sol\";\n\n/**\n * @title BUSDLiquidator\n * @author Venus\n * @notice A custom contract for force-liquidating BUSD debts\n */\ncontract BUSDLiquidator is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using SafeERC20Upgradeable for IVToken;\n\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IVBep20 public immutable vBUSD;\n\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IComptroller public immutable comptroller;\n\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable treasury;\n\n /// @notice The liquidator's share, scaled by 1e18 (e.g. 1.02 * 1e18 for 102% of the debt covered)\n uint256 public liquidatorShareMantissa;\n\n /// @notice Thrown if trying to set liquidator's share lower than 100% of the debt covered\n error LiquidatorShareTooLow(uint256 liquidatorShareMantissa_);\n\n /// @notice Thrown if trying to set liquidator's share larger than this contract can receive from a liquidation\n error LiquidatorShareTooHigh(uint256 maxLiquidatorShareMantissa, uint256 liquidatorShareMantissa_);\n\n /// @notice Emitted when the liquidator's share is set\n event NewLiquidatorShare(uint256 oldLiquidatorShareMantissa, uint256 newLiquidatorShareMantissa);\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param comptroller_ The address of the Comptroller contract\n /// @param vBUSD_ The address of the VBNB\n /// @param treasury_ The address of Venus treasury\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address comptroller_, address vBUSD_, address treasury_) {\n ensureNonzeroAddress(vBUSD_);\n ensureNonzeroAddress(comptroller_);\n ensureNonzeroAddress(treasury_);\n vBUSD = IVBep20(vBUSD_);\n comptroller = IComptroller(comptroller_);\n treasury = treasury_;\n _disableInitializers();\n }\n\n /// @notice Initializer for the implementation contract.\n /// @param liquidatorShareMantissa_ Liquidator's share, scaled by 1e18 (e.g. 1.01 * 1e18 for 101%)\n /// @custom:error LiquidatorShareTooHigh is thrown if trying to set liquidator percent larger than the liquidation profit\n function initialize(uint256 liquidatorShareMantissa_) external virtual initializer {\n __Ownable2Step_init();\n __ReentrancyGuard_init();\n _validateLiquidatorShareMantissa(liquidatorShareMantissa_);\n liquidatorShareMantissa = liquidatorShareMantissa_;\n }\n\n /// @notice Liquidate the entire BUSD debt of a borrower, seizing vTokenCollateral\n /// @param borrower The borrower whose debt should be liquidated\n /// @param vTokenCollateral The collateral to seize from the borrower\n function liquidateEntireBorrow(address borrower, IVToken vTokenCollateral) external nonReentrant {\n uint256 repayAmount = vBUSD.borrowBalanceCurrent(borrower);\n _unpauseAndLiquidate(borrower, repayAmount, vTokenCollateral);\n }\n\n /// @notice Liquidate a BUSD borrow, repaying the repayAmount of BUSD\n /// @param borrower The borrower whose debt should be liquidated\n /// @param repayAmount The amount to repay\n /// @param vTokenCollateral The collateral to seize from the borrower\n function liquidateBorrow(address borrower, uint256 repayAmount, IVToken vTokenCollateral) external nonReentrant {\n _unpauseAndLiquidate(borrower, repayAmount, vTokenCollateral);\n }\n\n /// @notice Allows Governance to set the liquidator's share\n /// @param liquidatorShareMantissa_ Liquidator's share, scaled by 1e18 (e.g. 1.01 * 1e18 for 101%)\n /// @custom:access Only Governance\n function setLiquidatorShare(uint256 liquidatorShareMantissa_) external onlyOwner {\n _validateLiquidatorShareMantissa(liquidatorShareMantissa_);\n uint256 oldLiquidatorShareMantissa = liquidatorShareMantissa;\n liquidatorShareMantissa = liquidatorShareMantissa_;\n emit NewLiquidatorShare(oldLiquidatorShareMantissa, liquidatorShareMantissa_);\n }\n\n /// @notice Allows to recover token accidentally sent to this contract by sending the entire balance to Governance\n /// @param token The address of the token to recover\n /// @custom:access Only Governance\n function sweepToken(IERC20Upgradeable token) external onlyOwner {\n token.safeTransfer(msg.sender, token.balanceOf(address(this)));\n }\n\n /// @dev Unpauses the liquidation on the BUSD market, liquidates the borrower's debt,\n /// and pauses the liquidations back\n /// @param borrower The borrower whose debt should be liquidated\n /// @param repayAmount The amount to repay\n /// @param vTokenCollateral The collateral to seize from the borrower\n function _unpauseAndLiquidate(address borrower, uint256 repayAmount, IVToken vTokenCollateral) internal {\n address[] memory vTokens = new address[](1);\n vTokens[0] = address(vBUSD);\n IComptroller.Action[] memory actions = new IComptroller.Action[](1);\n actions[0] = IComptroller.Action.LIQUIDATE;\n\n comptroller._setActionsPaused(vTokens, actions, false);\n _liquidateBorrow(borrower, repayAmount, vTokenCollateral);\n comptroller._setActionsPaused(vTokens, actions, true);\n }\n\n /// @dev Performs the actual liquidation, transferring BUSD from the sender to this contract,\n /// repaying the debt, and transferring the seized collateral to the sender and the treasury\n /// @param borrower The borrower whose debt should be liquidated\n /// @param repayAmount The amount to repay\n /// @param vTokenCollateral The collateral to seize from the borrower\n function _liquidateBorrow(address borrower, uint256 repayAmount, IVToken vTokenCollateral) internal {\n ILiquidator liquidatorContract = ILiquidator(comptroller.liquidatorContract());\n IERC20Upgradeable busd = IERC20Upgradeable(vBUSD.underlying());\n\n uint256 actualRepayAmount = _transferIn(busd, msg.sender, repayAmount);\n approveOrRevert(busd, address(liquidatorContract), actualRepayAmount);\n uint256 balanceBefore = vTokenCollateral.balanceOf(address(this));\n liquidatorContract.liquidateBorrow(address(vBUSD), borrower, actualRepayAmount, vTokenCollateral);\n uint256 receivedAmount = vTokenCollateral.balanceOf(address(this)) - balanceBefore;\n approveOrRevert(busd, address(liquidatorContract), 0);\n\n (uint256 liquidatorAmount, uint256 treasuryAmount) = _computeShares(receivedAmount);\n vTokenCollateral.safeTransfer(msg.sender, liquidatorAmount);\n vTokenCollateral.safeTransfer(treasury, treasuryAmount);\n }\n\n /// @dev Transfers tokens to this contract and returns the actual transfer amount\n /// @param token The token to transfer\n /// @param from The account to transfer from\n /// @param amount The amount to transfer\n /// @return The actual amount transferred\n function _transferIn(IERC20Upgradeable token, address from, uint256 amount) internal returns (uint256) {\n uint256 prevBalance = token.balanceOf(address(this));\n token.safeTransferFrom(from, address(this), amount);\n return token.balanceOf(address(this)) - prevBalance;\n }\n\n /// @dev Computes the liquidator's and treasury's shares of the received amount\n /// @param receivedAmount The amount received from the liquidation\n /// @return liquidatorAmount The liquidator's share\n /// @return treasuryAmount The treasury's share\n function _computeShares(\n uint256 receivedAmount\n ) internal view returns (uint256 liquidatorAmount, uint256 treasuryAmount) {\n uint256 denominator = _getDenominator();\n liquidatorAmount = (receivedAmount * liquidatorShareMantissa) / denominator;\n treasuryAmount = receivedAmount - liquidatorAmount;\n }\n\n /// @dev Returns (liquidation incentive - treasury percent), the value used as the denominator\n /// when calculating the liquidator's share\n /// @return The denominator for the seized amount used when calculating the liquidator's share\n function _getDenominator() internal view returns (uint256) {\n uint256 totalPercentageToDistribute = comptroller.liquidationIncentiveMantissa();\n uint256 regularTreasuryPercent = ILiquidator(comptroller.liquidatorContract()).treasuryPercentMantissa();\n uint256 denominator = totalPercentageToDistribute - regularTreasuryPercent;\n return denominator;\n }\n\n /// @dev Checks if the liquidator's share is more than 100% of the debt covered and less\n /// than (liquidation incentive - treasury percent)\n /// @param liquidatorShareMantissa_ Liquidator's share, scaled by 1e18 (e.g. 1.01 * 1e18 for 101%)\n function _validateLiquidatorShareMantissa(uint256 liquidatorShareMantissa_) internal view {\n uint256 maxLiquidatorShareMantissa = _getDenominator();\n if (liquidatorShareMantissa_ < MANTISSA_ONE) {\n revert LiquidatorShareTooLow(liquidatorShareMantissa_);\n }\n\n if (liquidatorShareMantissa_ > maxLiquidatorShareMantissa) {\n revert LiquidatorShareTooHigh(maxLiquidatorShareMantissa, liquidatorShareMantissa_);\n }\n }\n}\n" + }, + "contracts/Liquidator/Liquidator.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport { Ownable2StepUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport \"./LiquidatorStorage.sol\";\nimport { IComptroller, IVToken, IVBep20, IVBNB, IVAIController, IProtocolShareReserve, IWBNB } from \"../InterfacesV8.sol\";\n\ncontract Liquidator is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable, LiquidatorStorage, AccessControlledV8 {\n /// @notice Address of vBNB contract.\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IVBNB public immutable vBnb;\n\n /// @notice Address of Venus Unitroller contract.\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IComptroller public immutable comptroller;\n\n /// @notice Address of VAIUnitroller contract.\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IVAIController public immutable vaiController;\n\n /// @notice Address of wBNB contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable wBNB;\n\n /// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\n uint256 internal constant MANTISSA_ONE = 1e18;\n\n /* Events */\n\n /// @notice Emitted when the percent of the seized amount that goes to treasury changes.\n event NewLiquidationTreasuryPercent(uint256 oldPercent, uint256 newPercent);\n\n /// @notice Emitted when a borrow is liquidated\n event LiquidateBorrowedTokens(\n address indexed liquidator,\n address indexed borrower,\n uint256 repayAmount,\n address vTokenBorrowed,\n address indexed vTokenCollateral,\n uint256 seizeTokensForTreasury,\n uint256 seizeTokensForLiquidator\n );\n\n /// @notice Emitted when the liquidation is restricted for a borrower\n event LiquidationRestricted(address indexed borrower);\n\n /// @notice Emitted when the liquidation restrictions are removed for a borrower\n event LiquidationRestrictionsDisabled(address indexed borrower);\n\n /// @notice Emitted when a liquidator is added to the allowedLiquidatorsByAccount mapping\n event AllowlistEntryAdded(address indexed borrower, address indexed liquidator);\n\n /// @notice Emitted when a liquidator is removed from the allowedLiquidatorsByAccount mapping\n event AllowlistEntryRemoved(address indexed borrower, address indexed liquidator);\n\n /// @notice Emitted when the amount of minLiquidatableVAI is updated\n event NewMinLiquidatableVAI(uint256 oldMinLiquidatableVAI, uint256 newMinLiquidatableVAI);\n\n /// @notice Emitted when the length of chunk gets updated\n event NewPendingRedeemChunkLength(uint256 oldPendingRedeemChunkLength, uint256 newPendingRedeemChunkLength);\n\n /// @notice Emitted when force liquidation is paused\n event ForceVAILiquidationPaused(address indexed sender);\n\n /// @notice Emitted when force liquidation is resumed\n event ForceVAILiquidationResumed(address indexed sender);\n\n /// @notice Emitted when new address of protocol share reserve is set\n event NewProtocolShareReserve(address indexed oldProtocolShareReserve, address indexed newProtocolShareReserves);\n\n /// @notice Emitted when reserves are reduced from liquidator contract to protocol share reserves\n event ProtocolLiquidationIncentiveTransferred(address indexed sender, address indexed token, uint256 reducedAmount);\n\n /* Errors */\n\n /// @notice Thrown if the liquidation is restricted and the liquidator is not in the allowedLiquidatorsByAccount mapping\n error LiquidationNotAllowed(address borrower, address liquidator);\n\n /// @notice Thrown if VToken transfer fails after the liquidation\n error VTokenTransferFailed(address from, address to, uint256 amount);\n\n /// @notice Thrown if the liquidation is not successful (the error code is from TokenErrorReporter)\n error LiquidationFailed(uint256 errorCode);\n\n /// @notice Thrown if trying to restrict liquidations for an already restricted borrower\n error AlreadyRestricted(address borrower);\n\n /// @notice Thrown if trying to unrestrict liquidations for a borrower that is not restricted\n error NoRestrictionsExist(address borrower);\n\n /// @notice Thrown if the liquidator is already in the allowedLiquidatorsByAccount mapping\n error AlreadyAllowed(address borrower, address liquidator);\n\n /// @notice Thrown if trying to remove a liquidator that is not in the allowedLiquidatorsByAccount mapping\n error AllowlistEntryNotFound(address borrower, address liquidator);\n\n /// @notice Thrown if BNB amount sent with the transaction doesn't correspond to the\n /// intended BNB repayment\n error WrongTransactionAmount(uint256 expected, uint256 actual);\n\n /// @notice Thrown if trying to set treasury percent larger than the liquidation profit\n error TreasuryPercentTooHigh(uint256 maxTreasuryPercentMantissa, uint256 treasuryPercentMantissa_);\n\n /// @notice Thrown if trying to liquidate any token when VAI debt is too high\n error VAIDebtTooHigh(uint256 vaiDebt, uint256 minLiquidatableVAI);\n\n /// @notice Thrown when vToken is not listed\n error MarketNotListed(address vToken);\n\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @param comptroller_ The address of the Comptroller contract\n /// @param vBnb_ The address of the VBNB\n /// @param wBNB_ The address of wBNB\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address comptroller_, address payable vBnb_, address wBNB_) {\n ensureNonzeroAddress(vBnb_);\n ensureNonzeroAddress(comptroller_);\n ensureNonzeroAddress(wBNB_);\n vBnb = IVBNB(vBnb_);\n wBNB = wBNB_;\n comptroller = IComptroller(comptroller_);\n vaiController = IVAIController(IComptroller(comptroller_).vaiController());\n _disableInitializers();\n }\n\n receive() external payable {}\n\n /// @notice Initializer for the implementation contract.\n /// @param treasuryPercentMantissa_ Treasury share, scaled by 1e18 (e.g. 0.2 * 1e18 for 20%)\n /// @param accessControlManager_ address of access control manager\n /// @param protocolShareReserve_ The address of the protocol share reserve contract\n function initialize(\n uint256 treasuryPercentMantissa_,\n address accessControlManager_,\n address protocolShareReserve_\n ) external virtual reinitializer(2) {\n __Liquidator_init(treasuryPercentMantissa_, accessControlManager_, protocolShareReserve_);\n }\n\n /// @dev Liquidator initializer for derived contracts.\n /// @param treasuryPercentMantissa_ Treasury share, scaled by 1e18 (e.g. 0.2 * 1e18 for 20%)\n /// @param accessControlManager_ address of access control manager\n /// @param protocolShareReserve_ The address of the protocol share reserve contract\n function __Liquidator_init(\n uint256 treasuryPercentMantissa_,\n address accessControlManager_,\n address protocolShareReserve_\n ) internal onlyInitializing {\n __Ownable2Step_init();\n __ReentrancyGuard_init();\n __Liquidator_init_unchained(treasuryPercentMantissa_, protocolShareReserve_);\n __AccessControlled_init_unchained(accessControlManager_);\n }\n\n /// @dev Liquidator initializer for derived contracts that doesn't call parent initializers.\n /// @param treasuryPercentMantissa_ Treasury share, scaled by 1e18 (e.g. 0.2 * 1e18 for 20%)\n /// @param protocolShareReserve_ The address of the protocol share reserve contract\n function __Liquidator_init_unchained(\n uint256 treasuryPercentMantissa_,\n address protocolShareReserve_\n ) internal onlyInitializing {\n validateTreasuryPercentMantissa(treasuryPercentMantissa_);\n treasuryPercentMantissa = treasuryPercentMantissa_;\n _setProtocolShareReserve(protocolShareReserve_);\n }\n\n /// @notice An admin function to restrict liquidations to allowed addresses only.\n /// @dev Use {addTo,removeFrom}AllowList to configure the allowed addresses.\n /// @param borrower The address of the borrower\n function restrictLiquidation(address borrower) external {\n _checkAccessAllowed(\"restrictLiquidation(address)\");\n if (liquidationRestricted[borrower]) {\n revert AlreadyRestricted(borrower);\n }\n liquidationRestricted[borrower] = true;\n emit LiquidationRestricted(borrower);\n }\n\n /// @notice An admin function to remove restrictions for liquidations.\n /// @dev Does not impact the allowedLiquidatorsByAccount mapping for the borrower, just turns off the check.\n /// @param borrower The address of the borrower\n function unrestrictLiquidation(address borrower) external {\n _checkAccessAllowed(\"unrestrictLiquidation(address)\");\n if (!liquidationRestricted[borrower]) {\n revert NoRestrictionsExist(borrower);\n }\n liquidationRestricted[borrower] = false;\n emit LiquidationRestrictionsDisabled(borrower);\n }\n\n /// @notice An admin function to add the liquidator to the allowedLiquidatorsByAccount mapping for a certain\n /// borrower. If the liquidations are restricted, only liquidators from the\n /// allowedLiquidatorsByAccount mapping can participate in liquidating the positions of this borrower.\n /// @param borrower The address of the borrower\n /// @param borrower The address of the liquidator\n function addToAllowlist(address borrower, address liquidator) external {\n _checkAccessAllowed(\"addToAllowlist(address,address)\");\n if (allowedLiquidatorsByAccount[borrower][liquidator]) {\n revert AlreadyAllowed(borrower, liquidator);\n }\n allowedLiquidatorsByAccount[borrower][liquidator] = true;\n emit AllowlistEntryAdded(borrower, liquidator);\n }\n\n /// @notice An admin function to remove the liquidator from the allowedLiquidatorsByAccount mapping of a certain\n /// borrower. If the liquidations are restricted, this liquidator will not be\n /// able to liquidate the positions of this borrower.\n /// @param borrower The address of the borrower\n /// @param borrower The address of the liquidator\n function removeFromAllowlist(address borrower, address liquidator) external {\n _checkAccessAllowed(\"removeFromAllowlist(address,address)\");\n if (!allowedLiquidatorsByAccount[borrower][liquidator]) {\n revert AllowlistEntryNotFound(borrower, liquidator);\n }\n allowedLiquidatorsByAccount[borrower][liquidator] = false;\n emit AllowlistEntryRemoved(borrower, liquidator);\n }\n\n /// @notice Liquidates a borrow and splits the seized amount between protocol share reserve and\n /// liquidator. The liquidators should use this interface instead of calling\n /// vToken.liquidateBorrow(...) directly.\n /// @notice Checks force VAI liquidation first; vToken should be address of vaiController if vaiDebt is greater than threshold\n /// @notice For BNB borrows msg.value should be equal to repayAmount; otherwise msg.value\n /// should be zero.\n /// @param vToken Borrowed vToken\n /// @param borrower The address of the borrower\n /// @param repayAmount The amount to repay on behalf of the borrower\n /// @param vTokenCollateral The collateral to seize\n function liquidateBorrow(\n address vToken,\n address borrower,\n uint256 repayAmount,\n IVToken vTokenCollateral\n ) external payable nonReentrant {\n ensureNonzeroAddress(borrower);\n checkRestrictions(borrower, msg.sender);\n (bool isListed, , ) = IComptroller(comptroller).markets(address(vTokenCollateral));\n if (!isListed) {\n revert MarketNotListed(address(vTokenCollateral));\n }\n\n _checkForceVAILiquidate(vToken, borrower);\n uint256 ourBalanceBefore = vTokenCollateral.balanceOf(address(this));\n if (vToken == address(vBnb)) {\n if (repayAmount != msg.value) {\n revert WrongTransactionAmount(repayAmount, msg.value);\n }\n vBnb.liquidateBorrow{ value: msg.value }(borrower, vTokenCollateral);\n } else {\n if (msg.value != 0) {\n revert WrongTransactionAmount(0, msg.value);\n }\n if (vToken == address(vaiController)) {\n _liquidateVAI(borrower, repayAmount, vTokenCollateral);\n } else {\n _liquidateBep20(IVBep20(vToken), borrower, repayAmount, vTokenCollateral);\n }\n }\n uint256 ourBalanceAfter = vTokenCollateral.balanceOf(address(this));\n uint256 seizedAmount = ourBalanceAfter - ourBalanceBefore;\n (uint256 ours, uint256 theirs) = _distributeLiquidationIncentive(vTokenCollateral, seizedAmount);\n _reduceReservesInternal();\n emit LiquidateBorrowedTokens(\n msg.sender,\n borrower,\n repayAmount,\n vToken,\n address(vTokenCollateral),\n ours,\n theirs\n );\n }\n\n /// @notice Sets the new percent of the seized amount that goes to treasury. Should\n /// be less than or equal to comptroller.liquidationIncentiveMantissa().sub(1e18).\n /// @param newTreasuryPercentMantissa New treasury percent (scaled by 10^18).\n function setTreasuryPercent(uint256 newTreasuryPercentMantissa) external {\n _checkAccessAllowed(\"setTreasuryPercent(uint256)\");\n validateTreasuryPercentMantissa(newTreasuryPercentMantissa);\n emit NewLiquidationTreasuryPercent(treasuryPercentMantissa, newTreasuryPercentMantissa);\n treasuryPercentMantissa = newTreasuryPercentMantissa;\n }\n\n /**\n * @notice Sets protocol share reserve contract address\n * @param protocolShareReserve_ The address of the protocol share reserve contract\n */\n function setProtocolShareReserve(address payable protocolShareReserve_) external onlyOwner {\n _setProtocolShareReserve(protocolShareReserve_);\n }\n\n /**\n * @notice Reduce the reserves of the pending accumulated reserves\n */\n function reduceReserves() external nonReentrant {\n _reduceReservesInternal();\n }\n\n function _reduceReservesInternal() internal {\n uint256 _pendingRedeemLength = pendingRedeem.length;\n uint256 range = _pendingRedeemLength >= pendingRedeemChunkLength\n ? pendingRedeemChunkLength\n : _pendingRedeemLength;\n for (uint256 index = range; index > 0; ) {\n address vToken = pendingRedeem[index - 1];\n uint256 vTokenBalance_ = IVToken(vToken).balanceOf(address(this));\n if (_redeemUnderlying(vToken, vTokenBalance_)) {\n if (vToken == address(vBnb)) {\n _reduceBnbReserves();\n } else {\n _reduceVTokenReserves(vToken);\n }\n pendingRedeem[index - 1] = pendingRedeem[pendingRedeem.length - 1];\n pendingRedeem.pop();\n }\n unchecked {\n index--;\n }\n }\n }\n\n /// @dev Transfers BEP20 tokens to self, then approves vToken to take these tokens.\n function _liquidateBep20(IVBep20 vToken, address borrower, uint256 repayAmount, IVToken vTokenCollateral) internal {\n (bool isListed, , ) = IComptroller(comptroller).markets(address(vToken));\n if (!isListed) {\n revert MarketNotListed(address(vToken));\n }\n\n IERC20Upgradeable borrowedToken = IERC20Upgradeable(vToken.underlying());\n uint256 actualRepayAmount = _transferBep20(borrowedToken, msg.sender, address(this), repayAmount);\n borrowedToken.safeApprove(address(vToken), 0);\n borrowedToken.safeApprove(address(vToken), actualRepayAmount);\n requireNoError(vToken.liquidateBorrow(borrower, actualRepayAmount, vTokenCollateral));\n }\n\n /// @dev Transfers BEP20 tokens to self, then approves VAI to take these tokens.\n function _liquidateVAI(address borrower, uint256 repayAmount, IVToken vTokenCollateral) internal {\n IERC20Upgradeable vai = IERC20Upgradeable(vaiController.getVAIAddress());\n vai.safeTransferFrom(msg.sender, address(this), repayAmount);\n vai.safeApprove(address(vaiController), 0);\n vai.safeApprove(address(vaiController), repayAmount);\n\n (uint256 err, ) = vaiController.liquidateVAI(borrower, repayAmount, vTokenCollateral);\n requireNoError(err);\n }\n\n /// @dev Distribute seized collateral between liquidator and protocol share reserve\n function _distributeLiquidationIncentive(\n IVToken vTokenCollateral,\n uint256 seizedAmount\n ) internal returns (uint256 ours, uint256 theirs) {\n (ours, theirs) = _splitLiquidationIncentive(seizedAmount);\n if (!vTokenCollateral.transfer(msg.sender, theirs)) {\n revert VTokenTransferFailed(address(this), msg.sender, theirs);\n }\n\n if (ours > 0 && !_redeemUnderlying(address(vTokenCollateral), ours)) {\n // Check if asset is already present in pendingRedeem array\n uint256 index;\n for (index; index < pendingRedeem.length; ) {\n if (pendingRedeem[index] == address(vTokenCollateral)) {\n break;\n }\n unchecked {\n index++;\n }\n }\n if (index == pendingRedeem.length) {\n pendingRedeem.push(address(vTokenCollateral));\n }\n } else {\n if (address(vTokenCollateral) == address(vBnb)) {\n _reduceBnbReserves();\n } else {\n _reduceVTokenReserves(address(vTokenCollateral));\n }\n }\n }\n\n /// @dev Wraps BNB to wBNB and sends to protocol share reserve\n function _reduceBnbReserves() private {\n uint256 bnbBalance = address(this).balance;\n IWBNB(wBNB).deposit{ value: bnbBalance }();\n IERC20Upgradeable(wBNB).safeTransfer(protocolShareReserve, bnbBalance);\n IProtocolShareReserve(protocolShareReserve).updateAssetsState(\n address(comptroller),\n wBNB,\n IProtocolShareReserve.IncomeType.LIQUIDATION\n );\n emit ProtocolLiquidationIncentiveTransferred(msg.sender, wBNB, bnbBalance);\n }\n\n /// @dev Redeem seized collateral to underlying assets\n function _redeemUnderlying(address vToken, uint256 amount) private returns (bool) {\n try IVToken(address(vToken)).redeem(amount) returns (uint256 response) {\n if (response == 0) {\n return true;\n } else {\n return false;\n }\n } catch {\n return false;\n }\n }\n\n /// @dev Transfers seized collateral other than BNB to protocol share reserve\n function _reduceVTokenReserves(address vToken) private {\n address underlying = IVBep20(vToken).underlying();\n uint256 underlyingBalance = IERC20Upgradeable(underlying).balanceOf(address(this));\n IERC20Upgradeable(underlying).safeTransfer(protocolShareReserve, underlyingBalance);\n IProtocolShareReserve(protocolShareReserve).updateAssetsState(\n address(comptroller),\n underlying,\n IProtocolShareReserve.IncomeType.LIQUIDATION\n );\n emit ProtocolLiquidationIncentiveTransferred(msg.sender, underlying, underlyingBalance);\n }\n\n /// @dev Transfers tokens and returns the actual transfer amount\n function _transferBep20(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 amount\n ) internal returns (uint256) {\n uint256 prevBalance = token.balanceOf(to);\n token.safeTransferFrom(from, to, amount);\n return token.balanceOf(to) - prevBalance;\n }\n\n /// @dev Computes the amounts that would go to treasury and to the liquidator.\n function _splitLiquidationIncentive(uint256 seizedAmount) internal view returns (uint256 ours, uint256 theirs) {\n uint256 totalIncentive = comptroller.liquidationIncentiveMantissa();\n ours = (seizedAmount * treasuryPercentMantissa) / totalIncentive;\n theirs = seizedAmount - ours;\n }\n\n function requireNoError(uint256 errCode) internal pure {\n if (errCode == uint256(0)) {\n return;\n }\n\n revert LiquidationFailed(errCode);\n }\n\n function checkRestrictions(address borrower, address liquidator) internal view {\n if (liquidationRestricted[borrower] && !allowedLiquidatorsByAccount[borrower][liquidator]) {\n revert LiquidationNotAllowed(borrower, liquidator);\n }\n }\n\n function validateTreasuryPercentMantissa(uint256 treasuryPercentMantissa_) internal view {\n uint256 maxTreasuryPercentMantissa = comptroller.liquidationIncentiveMantissa() - MANTISSA_ONE;\n if (treasuryPercentMantissa_ > maxTreasuryPercentMantissa) {\n revert TreasuryPercentTooHigh(maxTreasuryPercentMantissa, treasuryPercentMantissa_);\n }\n }\n\n /// @dev Checks liquidation action in comptroller and vaiDebt with minLiquidatableVAI threshold\n function _checkForceVAILiquidate(address vToken_, address borrower_) private view {\n uint256 _vaiDebt = vaiController.getVAIRepayAmount(borrower_);\n bool _isVAILiquidationPaused = comptroller.actionPaused(address(vaiController), IComptroller.Action.LIQUIDATE);\n bool _isForcedLiquidationEnabled = comptroller.isForcedLiquidationEnabled(vToken_);\n if (\n _isForcedLiquidationEnabled ||\n _isVAILiquidationPaused ||\n !forceVAILiquidate ||\n _vaiDebt < minLiquidatableVAI ||\n vToken_ == address(vaiController)\n ) return;\n revert VAIDebtTooHigh(_vaiDebt, minLiquidatableVAI);\n }\n\n function _setProtocolShareReserve(address protocolShareReserve_) internal {\n ensureNonzeroAddress(protocolShareReserve_);\n emit NewProtocolShareReserve(protocolShareReserve, protocolShareReserve_);\n protocolShareReserve = protocolShareReserve_;\n }\n\n /**\n * @notice Sets the threshold for minimum amount of vaiLiquidate\n * @param minLiquidatableVAI_ New address for the access control\n */\n function setMinLiquidatableVAI(uint256 minLiquidatableVAI_) external {\n _checkAccessAllowed(\"setMinLiquidatableVAI(uint256)\");\n emit NewMinLiquidatableVAI(minLiquidatableVAI, minLiquidatableVAI_);\n minLiquidatableVAI = minLiquidatableVAI_;\n }\n\n /**\n * @notice Length of the pendingRedeem array to be consider while redeeming in Liquidation transaction\n * @param newLength_ Length of the chunk\n */\n function setPendingRedeemChunkLength(uint256 newLength_) external {\n _checkAccessAllowed(\"setPendingRedeemChunkLength(uint256)\");\n require(newLength_ > 0, \"Invalid chunk size\");\n emit NewPendingRedeemChunkLength(pendingRedeemChunkLength, newLength_);\n pendingRedeemChunkLength = newLength_;\n }\n\n /**\n * @notice Pause Force Liquidation of VAI\n */\n function pauseForceVAILiquidate() external {\n _checkAccessAllowed(\"pauseForceVAILiquidate()\");\n require(forceVAILiquidate, \"Force Liquidation of VAI is already Paused\");\n forceVAILiquidate = false;\n emit ForceVAILiquidationPaused(msg.sender);\n }\n\n /**\n * @notice Resume Force Liquidation of VAI\n */\n function resumeForceVAILiquidate() external {\n _checkAccessAllowed(\"resumeForceVAILiquidate()\");\n require(!forceVAILiquidate, \"Force Liquidation of VAI is already resumed\");\n forceVAILiquidate = true;\n emit ForceVAILiquidationResumed(msg.sender);\n }\n\n function renounceOwnership() public override {}\n}\n" + }, + "contracts/Liquidator/LiquidatorStorage.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\ncontract LiquidatorStorage {\n /* State */\n\n /// @notice Percent of seized amount that goes to treasury.\n uint256 public treasuryPercentMantissa;\n\n /// @notice Mapping of addresses allowed to liquidate an account if liquidationRestricted[borrower] == true\n mapping(address => mapping(address => bool)) public allowedLiquidatorsByAccount;\n\n /// @notice Whether the liquidations are restricted to enabled allowedLiquidatorsByAccount addresses only\n mapping(address => bool) public liquidationRestricted;\n\n /// @notice minimum amount of VAI liquidation threshold\n uint256 public minLiquidatableVAI;\n\n /// @notice check for liquidation of VAI\n bool public forceVAILiquidate;\n\n /// @notice assests whose redeem is pending to reduce reserves\n address[] public pendingRedeem;\n\n /// @notice protocol share reserve contract address\n address public protocolShareReserve;\n\n /// @dev Size of chunk to consider when redeeming underlying at the time of liquidation\n uint256 internal pendingRedeemChunkLength;\n\n /// @notice gap to prevent collision in inheritance\n uint256[49] private __gap;\n}\n" + }, + "contracts/PegStability/IVAI.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface IVAI {\n function balanceOf(address usr) external returns (uint256);\n\n function transferFrom(address src, address dst, uint amount) external returns (bool);\n\n function mint(address usr, uint wad) external;\n\n function burn(address usr, uint wad) external;\n}\n" + }, + "contracts/PegStability/PegStability.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\nimport { IVAI } from \"./IVAI.sol\";\n\n/**\n * @title Peg Stability Contract.\n * @notice Contract for swapping stable token for VAI token and vice versa to maintain the peg stability between them.\n * @author Venus Protocol\n */\ncontract PegStability is AccessControlledV8, ReentrancyGuardUpgradeable {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n // Helper enum for calculation of the fee.\n enum FeeDirection {\n IN,\n OUT\n }\n\n /// @notice The divisor used to convert fees to basis points.\n uint256 public constant BASIS_POINTS_DIVISOR = 10000;\n\n /// @notice The mantissa value representing 1 (used for calculations).\n uint256 public constant MANTISSA_ONE = 1e18;\n\n /// @notice The value representing one dollar in the stable token.\n /// @dev Our oracle is returning amount depending on the number of decimals of the stable token. (36 - asset_decimals) E.g. 8 decimal asset = 1e28.\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n uint256 public immutable ONE_DOLLAR;\n\n /// @notice VAI token contract.\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IVAI public immutable VAI;\n\n /// @notice The address of the stable token contract.\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable STABLE_TOKEN_ADDRESS;\n\n /// @notice The address of ResilientOracle contract wrapped in its interface.\n ResilientOracleInterface public oracle;\n\n /// @notice The address of the Venus Treasury contract.\n address public venusTreasury;\n\n /// @notice The incoming stableCoin fee. (Fee for swapStableForVAI).\n uint256 public feeIn;\n\n /// @notice The outgoing stableCoin fee. (Fee for swapVAIForStable).\n uint256 public feeOut;\n\n /// @notice The maximum amount of VAI that can be minted through this contract.\n uint256 public vaiMintCap;\n\n /// @notice The total amount of VAI minted through this contract.\n uint256 public vaiMinted;\n\n /// @notice A flag indicating whether the contract is currently paused or not.\n bool public isPaused;\n\n /// @notice Event emitted when contract is paused.\n event PSMPaused(address indexed admin);\n\n /// @notice Event emitted when the contract is resumed after pause.\n event PSMResumed(address indexed admin);\n\n /// @notice Event emitted when feeIn state var is modified.\n event FeeInChanged(uint256 oldFeeIn, uint256 newFeeIn);\n\n /// @notice Event emitted when feeOut state var is modified.\n event FeeOutChanged(uint256 oldFeeOut, uint256 newFeeOut);\n\n /// @notice Event emitted when vaiMintCap state var is modified.\n event VAIMintCapChanged(uint256 oldCap, uint256 newCap);\n\n /// @notice Event emitted when venusTreasury state var is modified.\n event VenusTreasuryChanged(address indexed oldTreasury, address indexed newTreasury);\n\n /// @notice Event emitted when oracle state var is modified.\n event OracleChanged(address indexed oldOracle, address indexed newOracle);\n\n /// @notice Event emitted when stable token is swapped for VAI.\n event StableForVAISwapped(uint256 stableIn, uint256 vaiOut, uint256 fee);\n\n /// @notice Event emitted when stable token is swapped for VAI.\n event VAIForStableSwapped(uint256 vaiBurnt, uint256 stableOut, uint256 vaiFee);\n\n /// @notice thrown when contract is in paused state\n error Paused();\n\n /// @notice thrown when attempted to pause an already paused contract\n error AlreadyPaused();\n\n /// @notice thrown when attempted to resume the contract if it is already resumed\n error NotPaused();\n\n /// @notice thrown when stable token has more than 18 decimals\n error TooManyDecimals();\n\n /// @notice thrown when fee is >= 100%\n error InvalidFee();\n\n /// @notice thrown when a zero address is passed as a function parameter\n error ZeroAddress();\n\n /// @notice thrown when a zero amount is passed as stable token amount parameter\n error ZeroAmount();\n\n /// @notice thrown when the user doesn't have enough VAI balance to provide for the amount of stable tokens he wishes to get\n error NotEnoughVAI();\n\n /// @notice thrown when the amount of VAI to be burnt exceeds the vaiMinted amount\n error VAIMintedUnderflow();\n\n /// @notice thrown when the VAI transfer to treasury fails\n error VAITransferFail();\n\n /// @notice thrown when VAI to be minted will go beyond the mintCap threshold\n error VAIMintCapReached();\n /// @notice thrown when fee calculation will result in rounding down to 0 due to stable token amount being a too small number\n error AmountTooSmall();\n\n /**\n * @dev Prevents functions to execute when contract is paused.\n */\n modifier isActive() {\n if (isPaused) revert Paused();\n _;\n }\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address stableTokenAddress_, address vaiAddress_) {\n _ensureNonzeroAddress(stableTokenAddress_);\n _ensureNonzeroAddress(vaiAddress_);\n\n uint256 decimals_ = IERC20MetadataUpgradeable(stableTokenAddress_).decimals();\n\n if (decimals_ > 18) {\n revert TooManyDecimals();\n }\n\n ONE_DOLLAR = 10 ** (36 - decimals_); // 1$ scaled to the decimals returned by our Oracle\n STABLE_TOKEN_ADDRESS = stableTokenAddress_;\n VAI = IVAI(vaiAddress_);\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract via Proxy Contract with the required parameters.\n * @param accessControlManager_ The address of the AccessControlManager contract.\n * @param venusTreasury_ The address where fees will be sent.\n * @param oracleAddress_ The address of the ResilientOracle contract.\n * @param feeIn_ The percentage of fees to be applied to a stablecoin -> VAI swap.\n * @param feeOut_ The percentage of fees to be applied to a VAI -> stablecoin swap.\n * @param vaiMintCap_ The cap for the total amount of VAI that can be minted.\n */\n function initialize(\n address accessControlManager_,\n address venusTreasury_,\n address oracleAddress_,\n uint256 feeIn_,\n uint256 feeOut_,\n uint256 vaiMintCap_\n ) external initializer {\n _ensureNonzeroAddress(accessControlManager_);\n _ensureNonzeroAddress(venusTreasury_);\n _ensureNonzeroAddress(oracleAddress_);\n __AccessControlled_init(accessControlManager_);\n __ReentrancyGuard_init();\n\n if (feeIn_ >= BASIS_POINTS_DIVISOR || feeOut_ >= BASIS_POINTS_DIVISOR) {\n revert InvalidFee();\n }\n\n feeIn = feeIn_;\n feeOut = feeOut_;\n vaiMintCap = vaiMintCap_;\n venusTreasury = venusTreasury_;\n oracle = ResilientOracleInterface(oracleAddress_);\n }\n\n /*** Swap Functions ***/\n\n /**\n * @notice Swaps VAI for a stable token.\n * @param receiver The address where the stablecoin will be sent.\n * @param stableTknAmount The amount of stable tokens to receive.\n * @return The amount of VAI received and burnt from the sender.\n */\n // @custom:event Emits VAIForStableSwapped event.\n function swapVAIForStable(\n address receiver,\n uint256 stableTknAmount\n ) external isActive nonReentrant returns (uint256) {\n _ensureNonzeroAddress(receiver);\n _ensureNonzeroAmount(stableTknAmount);\n\n // update oracle price and calculate USD value of the stable token amount scaled in 18 decimals\n oracle.updateAssetPrice(STABLE_TOKEN_ADDRESS);\n uint256 stableTknAmountUSD = _previewTokenUSDAmount(stableTknAmount, FeeDirection.OUT);\n uint256 fee = _calculateFee(stableTknAmountUSD, FeeDirection.OUT);\n\n if (VAI.balanceOf(msg.sender) < stableTknAmountUSD + fee) {\n revert NotEnoughVAI();\n }\n if (vaiMinted < stableTknAmountUSD) {\n revert VAIMintedUnderflow();\n }\n\n unchecked {\n vaiMinted -= stableTknAmountUSD;\n }\n\n if (fee != 0) {\n bool success = VAI.transferFrom(msg.sender, venusTreasury, fee);\n if (!success) {\n revert VAITransferFail();\n }\n }\n\n VAI.burn(msg.sender, stableTknAmountUSD);\n IERC20Upgradeable(STABLE_TOKEN_ADDRESS).safeTransfer(receiver, stableTknAmount);\n emit VAIForStableSwapped(stableTknAmountUSD, stableTknAmount, fee);\n return stableTknAmountUSD;\n }\n\n /**\n * @notice Swaps stable tokens for VAI with fees.\n * @dev This function adds support to fee-on-transfer tokens. The actualTransferAmt is calculated, by recording token balance state before and after the transfer.\n * @param receiver The address that will receive the VAI tokens.\n * @param stableTknAmount The amount of stable tokens to be swapped.\n * @return Amount of VAI minted to the sender.\n */\n // @custom:event Emits StableForVAISwapped event.\n function swapStableForVAI(\n address receiver,\n uint256 stableTknAmount\n ) external isActive nonReentrant returns (uint256) {\n _ensureNonzeroAddress(receiver);\n _ensureNonzeroAmount(stableTknAmount);\n // transfer IN, supporting fee-on-transfer tokens\n uint256 balanceBefore = IERC20Upgradeable(STABLE_TOKEN_ADDRESS).balanceOf(address(this));\n IERC20Upgradeable(STABLE_TOKEN_ADDRESS).safeTransferFrom(msg.sender, address(this), stableTknAmount);\n uint256 balanceAfter = IERC20Upgradeable(STABLE_TOKEN_ADDRESS).balanceOf(address(this));\n\n //calculate actual transfered amount (in case of fee-on-transfer tokens)\n uint256 actualTransferAmt = balanceAfter - balanceBefore;\n\n // update oracle price and calculate USD value of the stable token amount scaled in 18 decimals\n oracle.updateAssetPrice(STABLE_TOKEN_ADDRESS);\n uint256 actualTransferAmtInUSD = _previewTokenUSDAmount(actualTransferAmt, FeeDirection.IN);\n\n //calculate feeIn\n uint256 fee = _calculateFee(actualTransferAmtInUSD, FeeDirection.IN);\n uint256 vaiToMint = actualTransferAmtInUSD - fee;\n\n if (vaiMinted + actualTransferAmtInUSD > vaiMintCap) {\n revert VAIMintCapReached();\n }\n unchecked {\n vaiMinted += actualTransferAmtInUSD;\n }\n\n // mint VAI to receiver\n VAI.mint(receiver, vaiToMint);\n\n // mint VAI fee to venus treasury\n if (fee != 0) {\n VAI.mint(venusTreasury, fee);\n }\n\n emit StableForVAISwapped(actualTransferAmt, vaiToMint, fee);\n return vaiToMint;\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Pause the PSM contract.\n * @dev Reverts if the contract is already paused.\n */\n // @custom:event Emits PSMPaused event.\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n if (isPaused) {\n revert AlreadyPaused();\n }\n isPaused = true;\n emit PSMPaused(msg.sender);\n }\n\n /**\n * @notice Resume the PSM contract.\n * @dev Reverts if the contract is not paused.\n */\n // @custom:event Emits PSMResumed event.\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n if (!isPaused) {\n revert NotPaused();\n }\n isPaused = false;\n emit PSMResumed(msg.sender);\n }\n\n /**\n * @notice Set the fee percentage for incoming swaps.\n * @dev Reverts if the new fee percentage is invalid (greater than or equal to BASIS_POINTS_DIVISOR).\n * @param feeIn_ The new fee percentage for incoming swaps.\n */\n // @custom:event Emits FeeInChanged event.\n function setFeeIn(uint256 feeIn_) external {\n _checkAccessAllowed(\"setFeeIn(uint256)\");\n // feeIn = 10000 = 100%\n if (feeIn_ >= BASIS_POINTS_DIVISOR) {\n revert InvalidFee();\n }\n uint256 oldFeeIn = feeIn;\n feeIn = feeIn_;\n emit FeeInChanged(oldFeeIn, feeIn_);\n }\n\n /**\n * @notice Set the fee percentage for outgoing swaps.\n * @dev Reverts if the new fee percentage is invalid (greater than or equal to BASIS_POINTS_DIVISOR).\n * @param feeOut_ The new fee percentage for outgoing swaps.\n */\n // @custom:event Emits FeeOutChanged event.\n function setFeeOut(uint256 feeOut_) external {\n _checkAccessAllowed(\"setFeeOut(uint256)\");\n // feeOut = 10000 = 100%\n if (feeOut_ >= BASIS_POINTS_DIVISOR) {\n revert InvalidFee();\n }\n uint256 oldFeeOut = feeOut;\n feeOut = feeOut_;\n emit FeeOutChanged(oldFeeOut, feeOut_);\n }\n\n /**\n * @dev Set the maximum amount of VAI that can be minted through this contract.\n * @param vaiMintCap_ The new maximum amount of VAI that can be minted.\n */\n // @custom:event Emits VAIMintCapChanged event.\n function setVAIMintCap(uint256 vaiMintCap_) external {\n _checkAccessAllowed(\"setVAIMintCap(uint256)\");\n uint256 oldVAIMintCap = vaiMintCap;\n vaiMintCap = vaiMintCap_;\n emit VAIMintCapChanged(oldVAIMintCap, vaiMintCap_);\n }\n\n /**\n * @notice Set the address of the Venus Treasury contract.\n * @dev Reverts if the new address is zero.\n * @param venusTreasury_ The new address of the Venus Treasury contract.\n */\n // @custom:event Emits VenusTreasuryChanged event.\n function setVenusTreasury(address venusTreasury_) external {\n _checkAccessAllowed(\"setVenusTreasury(address)\");\n _ensureNonzeroAddress(venusTreasury_);\n address oldTreasuryAddress = venusTreasury;\n venusTreasury = venusTreasury_;\n emit VenusTreasuryChanged(oldTreasuryAddress, venusTreasury_);\n }\n\n /**\n * @notice Set the address of the ResilientOracle contract.\n * @dev Reverts if the new address is zero.\n * @param oracleAddress_ The new address of the ResilientOracle contract.\n */\n // @custom:event Emits OracleChanged event.\n function setOracle(address oracleAddress_) external {\n _checkAccessAllowed(\"setOracle(address)\");\n _ensureNonzeroAddress(oracleAddress_);\n address oldOracleAddress = address(oracle);\n oracle = ResilientOracleInterface(oracleAddress_);\n emit OracleChanged(oldOracleAddress, oracleAddress_);\n }\n\n /**\n * @dev Disabling renounceOwnership function.\n */\n function renounceOwnership() public override {}\n\n /*** Helper Functions ***/\n\n /**\n * @notice Calculates the amount of VAI that would be burnt from the user.\n * @dev This calculation might be off with a bit, if the price of the oracle for this asset is not updated in the block this function is invoked.\n * @param stableTknAmount The amount of stable tokens to be received after the swap.\n * @return The amount of VAI that would be taken from the user.\n */\n function previewSwapVAIForStable(uint256 stableTknAmount) external view returns (uint256) {\n _ensureNonzeroAmount(stableTknAmount);\n uint256 stableTknAmountUSD = _previewTokenUSDAmount(stableTknAmount, FeeDirection.OUT);\n uint256 fee = _calculateFee(stableTknAmountUSD, FeeDirection.OUT);\n\n if (vaiMinted < stableTknAmountUSD) {\n revert VAIMintedUnderflow();\n }\n\n return stableTknAmountUSD + fee;\n }\n\n /**\n * @notice Calculates the amount of VAI that would be sent to the receiver.\n * @dev This calculation might be off with a bit, if the price of the oracle for this asset is not updated in the block this function is invoked.\n * @param stableTknAmount The amount of stable tokens provided for the swap.\n * @return The amount of VAI that would be sent to the receiver.\n */\n function previewSwapStableForVAI(uint256 stableTknAmount) external view returns (uint256) {\n _ensureNonzeroAmount(stableTknAmount);\n uint256 stableTknAmountUSD = _previewTokenUSDAmount(stableTknAmount, FeeDirection.IN);\n\n //calculate feeIn\n uint256 fee = _calculateFee(stableTknAmountUSD, FeeDirection.IN);\n uint256 vaiToMint = stableTknAmountUSD - fee;\n\n if (vaiMinted + stableTknAmountUSD > vaiMintCap) {\n revert VAIMintCapReached();\n }\n\n return vaiToMint;\n }\n\n /**\n * @dev Calculates the USD value of the given amount of stable tokens depending on the swap direction.\n * @param amount The amount of stable tokens.\n * @param direction The direction of the swap.\n * @return The USD value of the given amount of stable tokens scaled by 1e18 taking into account the direction of the swap\n */\n function _previewTokenUSDAmount(uint256 amount, FeeDirection direction) internal view returns (uint256) {\n return (amount * _getPriceInUSD(direction)) / MANTISSA_ONE;\n }\n\n /**\n * @notice Get the price of stable token in USD.\n * @dev This function returns either min(1$,oraclePrice) or max(1$,oraclePrice) with a decimal scale (36 - asset_decimals). E.g. for 8 decimal token 1$ will be 1e28.\n * @param direction The direction of the swap: FeeDirection.IN or FeeDirection.OUT.\n * @return The price in USD, adjusted based on the selected direction.\n */\n function _getPriceInUSD(FeeDirection direction) internal view returns (uint256) {\n // get price with a scale = (36 - asset_decimals)\n uint256 price = oracle.getPrice(STABLE_TOKEN_ADDRESS);\n\n if (direction == FeeDirection.IN) {\n // MIN(1, price)\n return price < ONE_DOLLAR ? price : ONE_DOLLAR;\n } else {\n // MAX(1, price)\n return price > ONE_DOLLAR ? price : ONE_DOLLAR;\n }\n }\n\n /**\n * @notice Calculate the fee amount based on the input amount and fee percentage.\n * @dev Reverts if the fee percentage calculation results in rounding down to 0.\n * @param amount The input amount to calculate the fee from.\n * @param direction The direction of the fee: FeeDirection.IN or FeeDirection.OUT.\n * @return The fee amount.\n */\n function _calculateFee(uint256 amount, FeeDirection direction) internal view returns (uint256) {\n uint256 feePercent;\n if (direction == FeeDirection.IN) {\n feePercent = feeIn;\n } else {\n feePercent = feeOut;\n }\n if (feePercent == 0) {\n return 0;\n } else {\n // checking if the percent calculation will result in rounding down to 0\n if (amount * feePercent < BASIS_POINTS_DIVISOR) {\n revert AmountTooSmall();\n }\n return (amount * feePercent) / BASIS_POINTS_DIVISOR;\n }\n }\n\n /**\n * @notice Checks that the address is not the zero address.\n * @param someone The address to check.\n */\n function _ensureNonzeroAddress(address someone) private pure {\n if (someone == address(0)) revert ZeroAddress();\n }\n\n /**\n * @notice Checks that the amount passed as stable tokens is bigger than zero\n * @param amount The amount to validate\n */\n function _ensureNonzeroAmount(uint256 amount) private pure {\n if (amount == 0) revert ZeroAmount();\n }\n}\n" + }, + "contracts/Swap/interfaces/CustomErrors.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\n// **************\n// *** ERRORS ***\n// **************\n\n///@notice Error indicating that suplying to a given market failed.\nerror SupplyError(address supplier, address vToken, uint256 errorCode);\n\n///@notice Error indicating that repaying to given market failed.\nerror RepayError(address repayer, address vToken, uint256 errorCode);\n\n///@notice Error indicating wBNB address passed is not the expected one.\nerror WrongAddress(address expectedAdddress, address passedAddress);\n\n///@notice Error thrown when deadline for swap has expired\nerror SwapDeadlineExpire(uint256 deadline, uint256 timestemp);\n\n///@notice Error thrown where the input amount parameter for a token is 0\nerror InsufficientInputAmount();\n\n///@notice Error thrown when the amount out passed is 0\nerror InsufficientOutputAmount();\n\n///@notice Error thrown when the amount received from a trade is below the minimum\nerror OutputAmountBelowMinimum(uint256 amountOut, uint256 amountOutMin);\n\n///@notice Error thrown when the amount In is above the amount in maximum\nerror InputAmountAboveMaximum(uint256 amountIn, uint256 amountIntMax);\n\n///@notice Error thrown when amount is above the msg.value(amountMax)\nerror ExcessiveInputAmount(uint256 amount, uint256 amountMax);\n\n///@notice Error thrown when the given reserves are equal to 0\nerror InsufficientLiquidity();\n\n///@notice Error thrown if a zero address is passed\nerror ZeroAddress();\n\n///@notice Error thrown if two token addresses are identical\nerror IdenticalAddresses();\n\n///@notice Error thrown when the trade path[] parameter consists of only 1 token (i.e. path.length<2)\nerror InvalidPath();\n\n///@notice Error thrown when invalid vToken address is passed to swap router\nerror VTokenNotListed(address vToken);\n\n///@notice Error thrown when invalid underlying is passed as per given vToken\nerror VTokenUnderlyingInvalid(address underlying);\n\n///@notice Error thrown when swapamount is less than the amountOutmin\nerror SwapAmountLessThanAmountOutMin(uint256 swapAmount, uint256 amountOutMin);\n\n///@notice Error thrown when swapRouter's balance is less than sweep amount\nerror InsufficientBalance(uint256 sweepAmount, uint256 balance);\n\n///@notice Error thrown when safeApprove failed\nerror SafeApproveFailed();\n\n///@notice Error thrown when safeTransfer failed\nerror SafeTransferFailed();\n\n///@notice Error thrown when transferFrom failed\nerror SafeTransferFromFailed();\n\n///@notice Error thrown when safeTransferBNB failed\nerror SafeTransferBNBFailed();\n\n///@notice Error thrown when reentrant check fails\nerror ReentrantCheck();\n" + }, + "contracts/Swap/interfaces/InterfaceComptroller.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\ninterface InterfaceComptroller {\n function markets(address) external view returns (bool);\n}\n" + }, + "contracts/Swap/interfaces/IPancakePair.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\ninterface IPancakePair {\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint);\n\n function balanceOf(address owner) external view returns (uint);\n\n function allowance(address owner, address spender) external view returns (uint);\n\n function approve(address spender, uint value) external returns (bool);\n\n function transfer(address to, uint value) external returns (bool);\n\n function transferFrom(address from, address to, uint value) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n\n function nonces(address owner) external view returns (uint);\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n event Mint(address indexed sender, uint amount0, uint amount1);\n event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint amount0In,\n uint amount1In,\n uint amount0Out,\n uint amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n\n function price0CumulativeLast() external view returns (uint);\n\n function price1CumulativeLast() external view returns (uint);\n\n function kLast() external view returns (uint);\n\n function mint(address to) external returns (uint liquidity);\n\n function burn(address to) external returns (uint amount0, uint amount1);\n\n function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n\n function skim(address to) external;\n\n function sync() external;\n\n function initialize(address, address) external;\n}\n" + }, + "contracts/Swap/interfaces/IPancakeSwapV2Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\ninterface IPancakeSwapV2Factory {\n event PairCreated(address indexed token0, address indexed token1, address pair, uint);\n\n function feeTo() external view returns (address);\n\n function feeToSetter() external view returns (address);\n\n function getPair(address tokenA, address tokenB) external view returns (address pair);\n\n function allPairs(uint) external view returns (address pair);\n\n function allPairsLength() external view returns (uint);\n\n function createPair(address tokenA, address tokenB) external returns (address pair);\n\n function setFeeTo(address) external;\n\n function setFeeToSetter(address) external;\n}\n" + }, + "contracts/Swap/interfaces/IPancakeSwapV2Router.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\ninterface IPancakeSwapV2Router {\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForTokensAtSupportingFee(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256 swapAmount);\n\n function swapExactBNBForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapExactBNBForTokensAtSupportingFee(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256 swapAmount);\n\n function swapExactTokensForBNB(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForBNBAtSupportingFee(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256 swapAmount);\n\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapBNBForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapTokensForExactBNB(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForTokensAndSupply(\n address vTokenAddress,\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapExactTokensForTokensAndSupplyAtSupportingFee(\n address vTokenAddress,\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapExactBNBForTokensAndSupply(\n address vTokenAddress,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external payable;\n\n function swapExactBNBForTokensAndSupplyAtSupportingFee(\n address vTokenAddress,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external payable;\n\n function swapTokensForExactTokensAndSupply(\n address vTokenAddress,\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapBNBForExactTokensAndSupply(\n address vTokenAddress,\n uint256 amountOut,\n address[] calldata path,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForBNBAndSupply(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapExactTokensForBNBAndSupplyAtSupportingFee(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapTokensForExactBNBAndSupply(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapBNBForFullTokenDebtAndRepay(\n address vTokenAddress,\n address[] calldata path,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForTokensAndRepay(\n address vTokenAddress,\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapExactTokensForTokensAndRepayAtSupportingFee(\n address vTokenAddress,\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapExactBNBForTokensAndRepay(\n address vTokenAddress,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external payable;\n\n function swapExactBNBForTokensAndRepayAtSupportingFee(\n address vTokenAddress,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external payable;\n\n function swapTokensForExactTokensAndRepay(\n address vTokenAddress,\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapTokensForFullTokenDebtAndRepay(\n address vTokenAddress,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapBNBForExactTokensAndRepay(\n address vTokenAddress,\n uint256 amountOut,\n address[] calldata path,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForBNBAndRepay(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapExactTokensForBNBAndRepayAtSupportingFee(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapTokensForExactBNBAndRepay(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external;\n\n function swapTokensForFullBNBDebtAndRepay(uint256 amountInMax, address[] calldata path, uint256 deadline) external;\n}\n" + }, + "contracts/Swap/interfaces/IVBNB.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\ninterface IVBNB {\n function repayBorrowBehalf(address borrower) external payable;\n\n function mint() external payable;\n\n function balanceOf(address owner) external view returns (uint256);\n}\n" + }, + "contracts/Swap/interfaces/IVtoken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\ninterface IVToken {\n function mintBehalf(address receiver, uint mintAmount) external returns (uint);\n\n function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);\n\n function borrowBalanceCurrent(address account) external returns (uint);\n\n function underlying() external returns (address);\n}\n" + }, + "contracts/Swap/interfaces/IWBNB.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface IWBNB {\n function deposit() external payable;\n\n function transfer(address to, uint value) external returns (bool);\n\n function withdraw(uint) external;\n\n function balanceOf(address owner) external view returns (uint256 balance);\n}\n" + }, + "contracts/Swap/IRouterHelper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\ninterface IRouterHelper {\n function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB);\n\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountOut);\n\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountIn);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);\n}\n" + }, + "contracts/Swap/lib/PancakeLibrary.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.25;\n\nimport \"../interfaces/IPancakePair.sol\";\nimport \"../interfaces/CustomErrors.sol\";\n\nlibrary PancakeLibrary {\n /**\n * @notice Used to handle return values from pairs sorted in this order\n * @param tokenA The address of token A\n * @param tokenB The address of token B\n * @return token0 token1 Sorted token addresses\n **/\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\n if (tokenA == tokenB) {\n revert IdenticalAddresses();\n }\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n if (token0 == address(0)) {\n revert ZeroAddress();\n }\n }\n\n /**\n * @notice Calculates the CREATE2 address for a pair without making any external calls\n * @param factory Address of the pancake swap factory\n * @param tokenA The address of token A\n * @param tokenB The address of token B\n * @return pair Address for a pair\n **/\n function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {\n (address token0, address token1) = sortTokens(tokenA, tokenB);\n pair = address(\n uint160(\n uint256(\n keccak256(\n abi.encodePacked(\n hex\"ff\",\n factory,\n keccak256(abi.encodePacked(token0, token1)),\n hex\"00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5\" // init code hash\n )\n )\n )\n )\n );\n }\n\n /**\n * @notice Fetches and sorts the reserves for a pair\n * @param factory Address of the pancake swap factory\n * @param tokenA The address of token A\n * @param tokenB The address of token B\n * @return reserveA reserveB Reserves for the token A and token B\n **/\n function getReserves(\n address factory,\n address tokenA,\n address tokenB\n ) internal view returns (uint256 reserveA, uint256 reserveB) {\n (address token0, ) = sortTokens(tokenA, tokenB);\n address pairAddress = pairFor(factory, tokenA, tokenB);\n (uint256 reserve0, uint256 reserve1, ) = IPancakePair(pairAddress).getReserves();\n (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\n }\n\n /**\n * @notice Given some amount of an asset and pair reserves, returns an equivalent amount of the other asset\n * @param amountA The amount of token A\n * @param reserveA The amount of reserves for token A before swap\n * @param reserveB The amount of reserves for token B before swap\n * @return amountB An equivalent amount of the token B\n **/\n function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) internal pure returns (uint256 amountB) {\n if (amountA == 0) {\n revert InsufficientInputAmount();\n } else if (reserveA == 0 || reserveB == 0) {\n revert InsufficientLiquidity();\n }\n amountB = (amountA * reserveB) / reserveA;\n }\n\n /**\n * @notice Given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset\n * @param amountIn The amount of token A need to swap\n * @param reserveIn The amount of reserves for token A before swap\n * @param reserveOut The amount of reserves for token B after swap\n * @return amountOut The maximum output amount of the token B\n **/\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) internal pure returns (uint256 amountOut) {\n if (amountIn == 0) {\n revert InsufficientInputAmount();\n } else if (reserveIn == 0 || reserveOut == 0) {\n revert InsufficientLiquidity();\n }\n uint256 amountInWithFee = amountIn * 9975;\n uint256 numerator = amountInWithFee * reserveOut;\n uint256 denominator = (reserveIn * 10000) + amountInWithFee;\n amountOut = numerator / denominator;\n }\n\n /**\n * @notice Given an output amount of an asset and pair reserves, returns a required input amount of the other asset\n * @param amountOut The amount of token B after swap\n * @param reserveIn The amount of reserves for token A before swap\n * @param reserveOut The amount of reserves for token B after swap\n * @return amountIn Required input amount of the token A\n **/\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) internal pure returns (uint256 amountIn) {\n if (amountOut == 0) {\n revert InsufficientOutputAmount();\n } else if (reserveIn == 0 || reserveOut == 0) {\n revert InsufficientLiquidity();\n }\n uint256 numerator = reserveIn * amountOut * 10000;\n uint256 denominator = (reserveOut - amountOut) * 9975;\n amountIn = (numerator / denominator) + 1;\n }\n\n /**\n * @notice Performs chained getAmountOut calculations on any number of pairs\n * @param factory Address of the pancake swap factory\n * @param amountIn The amount of tokens to swap.\n * @param path Array with addresses of the underlying assets to be swapped\n * @return amounts Array of amounts after performing swap for respective pairs in path\n **/\n function getAmountsOut(\n address factory,\n uint256 amountIn,\n address[] memory path\n ) internal view returns (uint256[] memory amounts) {\n if (path.length <= 1) {\n revert InvalidPath();\n }\n amounts = new uint256[](path.length);\n amounts[0] = amountIn;\n for (uint256 i; i < path.length - 1; ) {\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]);\n amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);\n unchecked {\n i += 1;\n }\n }\n }\n\n /**\n * @notice Performs chained getAmountIn calculations on any number of pairs\n * @param factory Address of the pancake swap factory\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param path Array with addresses of the underlying assets to be swapped\n * @return amounts Array of amounts after performing swap for respective pairs in path\n **/\n function getAmountsIn(\n address factory,\n uint256 amountOut,\n address[] memory path\n ) internal view returns (uint256[] memory amounts) {\n if (path.length <= 1) {\n revert InvalidPath();\n }\n amounts = new uint256[](path.length);\n amounts[amounts.length - 1] = amountOut;\n for (uint256 i = path.length - 1; i > 0; ) {\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i]);\n amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);\n unchecked {\n i -= 1;\n }\n }\n }\n}\n" + }, + "contracts/Swap/lib/TransferHelper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.25;\n\nimport \"../interfaces/CustomErrors.sol\";\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n /**\n * @dev `value` as the allowance of `spender` over the caller's tokens.\n * @param token Address of the token\n * @param to Address of the spender\n * @param value Amount as allowance\n */\n function safeApprove(address token, address to, uint256 value) internal {\n // bytes4(keccak256(bytes('approve(address,uint256)')));\n (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));\n if (!(success && (data.length == 0 || abi.decode(data, (bool))))) {\n revert SafeApproveFailed();\n }\n }\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n * @param token Address of the token\n * @param to Address of the receiver\n * @param value Amount need to transfer\n */\n function safeTransfer(address token, address to, uint256 value) internal {\n // bytes4(keccak256(bytes('transfer(address,uint256)')));\n (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));\n if (!(success && (data.length == 0 || abi.decode(data, (bool))))) {\n revert SafeTransferFailed();\n }\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n * @param token Address of the token\n * @param from Address of the asset'sowner\n * @param to Address of the receiver\n * @param value Amount need to transfer\n */\n function safeTransferFrom(address token, address from, address to, uint256 value) internal {\n // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));\n if (!(success && (data.length == 0 || abi.decode(data, (bool))))) {\n revert SafeTransferFromFailed();\n }\n }\n\n /**\n * @dev Transfer `value` amount of `BNB` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n * @param to Address of the receiver\n * @param value Amount need to transfer\n */\n function safeTransferBNB(address to, uint256 value) internal {\n (bool success, ) = to.call{ value: value }(new bytes(0));\n if (!success) {\n revert SafeTransferBNBFailed();\n }\n }\n}\n" + }, + "contracts/Swap/RouterHelper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"./lib/PancakeLibrary.sol\";\nimport \"./interfaces/IWBNB.sol\";\nimport \"./lib/TransferHelper.sol\";\n\nimport \"./interfaces/CustomErrors.sol\";\nimport \"./IRouterHelper.sol\";\n\nabstract contract RouterHelper is IRouterHelper {\n /// @notice Select the type of Token for which either a supporting fee would be deducted or not at the time of transfer.\n enum TypesOfTokens {\n NON_SUPPORTING_FEE,\n SUPPORTING_FEE\n }\n\n /// @notice Address of WBNB contract.\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice Address of pancake swap factory contract.\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable factory;\n\n // **************\n // *** EVENTS ***\n // **************\n /// @notice This event is emitted whenever a successful swap (tokenA -> tokenB) occurs\n event SwapTokensForTokens(address indexed swapper, address[] indexed path, uint256[] indexed amounts);\n\n /// @notice This event is emitted whenever a successful swap (tokenA -> tokenB) occurs\n event SwapTokensForTokensAtSupportingFee(address indexed swapper, address[] indexed path);\n\n /// @notice This event is emitted whenever a successful swap (BNB -> token) occurs\n event SwapBnbForTokens(address indexed swapper, address[] indexed path, uint256[] indexed amounts);\n\n /// @notice This event is emitted whenever a successful swap (BNB -> token) occurs\n event SwapBnbForTokensAtSupportingFee(address indexed swapper, address[] indexed path);\n\n /// @notice This event is emitted whenever a successful swap (token -> BNB) occurs\n event SwapTokensForBnb(address indexed swapper, address[] indexed path, uint256[] indexed amounts);\n\n /// @notice This event is emitted whenever a successful swap (token -> BNB) occurs\n event SwapTokensForBnbAtSupportingFee(address indexed swapper, address[] indexed path);\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address WBNB_, address factory_) {\n if (WBNB_ == address(0) || factory_ == address(0)) {\n revert ZeroAddress();\n }\n WBNB = WBNB_;\n factory = factory_;\n }\n\n /**\n * @notice Perform swap on the path(pairs)\n * @param amounts Araay of amounts of tokens after performing the swap\n * @param path Array with addresses of the underlying assets to be swapped\n * @param _to Recipient of the output tokens.\n */\n function _swap(uint256[] memory amounts, address[] memory path, address _to) internal virtual {\n for (uint256 i; i < path.length - 1; ) {\n (address input, address output) = (path[i], path[i + 1]);\n (address token0, ) = PancakeLibrary.sortTokens(input, output);\n uint256 amountOut = amounts[i + 1];\n (uint256 amount0Out, uint256 amount1Out) = input == token0\n ? (uint256(0), amountOut)\n : (amountOut, uint256(0));\n address to = i < path.length - 2 ? PancakeLibrary.pairFor(factory, output, path[i + 2]) : _to;\n IPancakePair(PancakeLibrary.pairFor(factory, input, output)).swap(amount0Out, amount1Out, to, new bytes(0));\n unchecked {\n i += 1;\n }\n }\n }\n\n // **** SWAP (supporting fee-on-transfer tokens) ****\n\n /**\n * @notice Perform swap on the path(pairs) for supporting fee\n * @dev requires the initial amount to have already been sent to the first pair\n * @param path Array with addresses of the underlying assets to be swapped\n * @param _to Recipient of the output tokens.\n */\n function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {\n for (uint256 i; i < path.length - 1; ) {\n (address input, address output) = (path[i], path[i + 1]);\n (address token0, ) = PancakeLibrary.sortTokens(input, output);\n IPancakePair pair = IPancakePair(PancakeLibrary.pairFor(factory, input, output));\n uint256 amountInput;\n uint256 amountOutput;\n {\n // scope to avoid stack too deep errors\n (uint256 reserve0, uint256 reserve1, ) = pair.getReserves();\n (uint256 reserveInput, uint256 reserveOutput) = input == token0\n ? (reserve0, reserve1)\n : (reserve1, reserve0);\n\n uint256 balance = IERC20(input).balanceOf(address(pair));\n amountInput = balance - reserveInput;\n amountOutput = PancakeLibrary.getAmountOut(amountInput, reserveInput, reserveOutput);\n }\n (uint256 amount0Out, uint256 amount1Out) = input == token0\n ? (uint256(0), amountOutput)\n : (amountOutput, uint256(0));\n address to = i < path.length - 2 ? PancakeLibrary.pairFor(factory, output, path[i + 2]) : _to;\n pair.swap(amount0Out, amount1Out, to, new bytes(0));\n unchecked {\n i += 1;\n }\n }\n }\n\n /**\n * @notice Swap token A for token B\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param swapFor TypesOfTokens, either supporing fee or non supporting fee\n * @return amounts Array of amounts after performing swap for respective pairs in path\n */\n function _swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n TypesOfTokens swapFor\n ) internal returns (uint256[] memory amounts) {\n address pairAddress = PancakeLibrary.pairFor(factory, path[0], path[1]);\n if (swapFor == TypesOfTokens.NON_SUPPORTING_FEE) {\n amounts = PancakeLibrary.getAmountsOut(factory, amountIn, path);\n if (amounts[amounts.length - 1] < amountOutMin) {\n revert OutputAmountBelowMinimum(amounts[amounts.length - 1], amountOutMin);\n }\n TransferHelper.safeTransferFrom(path[0], msg.sender, pairAddress, amounts[0]);\n _swap(amounts, path, to);\n emit SwapTokensForTokens(msg.sender, path, amounts);\n } else {\n TransferHelper.safeTransferFrom(path[0], msg.sender, pairAddress, amountIn);\n _swapSupportingFeeOnTransferTokens(path, to);\n emit SwapTokensForTokensAtSupportingFee(msg.sender, path);\n }\n }\n\n /**\n * @notice Swap exact BNB for token\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param swapFor TypesOfTokens, either supporing fee or non supporting fee\n * @return amounts Array of amounts after performing swap for respective pairs in path\n */\n function _swapExactBNBForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n TypesOfTokens swapFor\n ) internal returns (uint256[] memory amounts) {\n address wBNBAddress = WBNB;\n if (path[0] != wBNBAddress) {\n revert WrongAddress(wBNBAddress, path[0]);\n }\n IWBNB(wBNBAddress).deposit{ value: msg.value }();\n TransferHelper.safeTransfer(wBNBAddress, PancakeLibrary.pairFor(factory, path[0], path[1]), msg.value);\n if (swapFor == TypesOfTokens.NON_SUPPORTING_FEE) {\n amounts = PancakeLibrary.getAmountsOut(factory, msg.value, path);\n if (amounts[amounts.length - 1] < amountOutMin) {\n revert OutputAmountBelowMinimum(amounts[amounts.length - 1], amountOutMin);\n }\n _swap(amounts, path, to);\n emit SwapBnbForTokens(msg.sender, path, amounts);\n } else {\n _swapSupportingFeeOnTransferTokens(path, to);\n emit SwapBnbForTokensAtSupportingFee(msg.sender, path);\n }\n }\n\n /**\n * @notice Swap token A for BNB\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of BNB to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param swapFor TypesOfTokens, either supporing fee or non supporting fee\n * @return amounts Array of amounts after performing swap for respective pairs in path\n */\n function _swapExactTokensForBNB(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n TypesOfTokens swapFor\n ) internal returns (uint256[] memory amounts) {\n if (path[path.length - 1] != WBNB) {\n revert WrongAddress(WBNB, path[path.length - 1]);\n }\n uint256 WBNBAmount;\n if (swapFor == TypesOfTokens.NON_SUPPORTING_FEE) {\n amounts = PancakeLibrary.getAmountsOut(factory, amountIn, path);\n if (amounts[amounts.length - 1] < amountOutMin) {\n revert OutputAmountBelowMinimum(amounts[amounts.length - 1], amountOutMin);\n }\n TransferHelper.safeTransferFrom(\n path[0],\n msg.sender,\n PancakeLibrary.pairFor(factory, path[0], path[1]),\n amounts[0]\n );\n _swap(amounts, path, address(this));\n WBNBAmount = amounts[amounts.length - 1];\n } else {\n uint256 balanceBefore = IWBNB(WBNB).balanceOf(address(this));\n TransferHelper.safeTransferFrom(\n path[0],\n msg.sender,\n PancakeLibrary.pairFor(factory, path[0], path[1]),\n amountIn\n );\n _swapSupportingFeeOnTransferTokens(path, address(this));\n uint256 balanceAfter = IWBNB(WBNB).balanceOf(address(this));\n WBNBAmount = balanceAfter - balanceBefore;\n }\n IWBNB(WBNB).withdraw(WBNBAmount);\n if (to != address(this)) {\n TransferHelper.safeTransferBNB(to, WBNBAmount);\n }\n if (swapFor == TypesOfTokens.NON_SUPPORTING_FEE) {\n emit SwapTokensForBnb(msg.sender, path, amounts);\n } else {\n emit SwapTokensForBnbAtSupportingFee(msg.sender, path);\n }\n }\n\n /**\n * @notice Swap token A for exact amount of token B\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @return amounts Array of amounts after performing swap for respective pairs in path\n **/\n function _swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to\n ) internal returns (uint256[] memory amounts) {\n amounts = PancakeLibrary.getAmountsIn(factory, amountOut, path);\n if (amounts[0] > amountInMax) {\n revert InputAmountAboveMaximum(amounts[0], amountInMax);\n }\n TransferHelper.safeTransferFrom(\n path[0],\n msg.sender,\n PancakeLibrary.pairFor(factory, path[0], path[1]),\n amounts[0]\n );\n _swap(amounts, path, to);\n emit SwapTokensForTokens(msg.sender, path, amounts);\n }\n\n /**\n * @notice Swap BNB for exact amount of token B\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @return amounts Array of amounts after performing swap for respective pairs in path\n **/\n function _swapBNBForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to\n ) internal returns (uint256[] memory amounts) {\n if (path[0] != WBNB) {\n revert WrongAddress(WBNB, path[0]);\n }\n amounts = PancakeLibrary.getAmountsIn(factory, amountOut, path);\n if (amounts[0] > msg.value) {\n revert ExcessiveInputAmount(amounts[0], msg.value);\n }\n IWBNB(WBNB).deposit{ value: amounts[0] }();\n TransferHelper.safeTransfer(WBNB, PancakeLibrary.pairFor(factory, path[0], path[1]), amounts[0]);\n _swap(amounts, path, to);\n // refund dust BNB, if any\n if (msg.value > amounts[0]) TransferHelper.safeTransferBNB(msg.sender, msg.value - amounts[0]);\n emit SwapBnbForTokens(msg.sender, path, amounts);\n }\n\n /**\n * @notice Swap token A for exact BNB\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @return amounts Array of amounts after performing swap for respective pairs in path\n **/\n function _swapTokensForExactBNB(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to\n ) internal returns (uint256[] memory amounts) {\n if (path[path.length - 1] != WBNB) {\n revert WrongAddress(WBNB, path[path.length - 1]);\n }\n amounts = PancakeLibrary.getAmountsIn(factory, amountOut, path);\n if (amounts[0] > amountInMax) {\n revert InputAmountAboveMaximum(amounts[amounts.length - 1], amountInMax);\n }\n TransferHelper.safeTransferFrom(\n path[0],\n msg.sender,\n PancakeLibrary.pairFor(factory, path[0], path[1]),\n amounts[0]\n );\n _swap(amounts, path, address(this));\n IWBNB(WBNB).withdraw(amounts[amounts.length - 1]);\n if (to != address(this)) {\n TransferHelper.safeTransferBNB(to, amounts[amounts.length - 1]);\n }\n emit SwapTokensForBnb(msg.sender, path, amounts);\n }\n\n // **** LIBRARY FUNCTIONS ****\n\n /**\n * @notice Given some amount of an asset and pair reserves, returns an equivalent amount of the other asset\n * @param amountA The amount of token A\n * @param reserveA The amount of reserves for token A before swap\n * @param reserveB The amount of reserves for token B before swap\n * @return amountB An equivalent amount of the token B\n **/\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) external pure virtual override returns (uint256 amountB) {\n return PancakeLibrary.quote(amountA, reserveA, reserveB);\n }\n\n /**\n * @notice Given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset\n * @param amountIn The amount of token A need to swap\n * @param reserveIn The amount of reserves for token A before swap\n * @param reserveOut The amount of reserves for token B after swap\n * @return amountOut The maximum output amount of the token B\n **/\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure virtual override returns (uint256 amountOut) {\n return PancakeLibrary.getAmountOut(amountIn, reserveIn, reserveOut);\n }\n\n /**\n * @notice Given an output amount of an asset and pair reserves, returns a required input amount of the other asset\n * @param amountOut The amount of token B after swap\n * @param reserveIn The amount of reserves for token A before swap\n * @param reserveOut The amount of reserves for token B after swap\n * @return amountIn Required input amount of the token A\n **/\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure virtual override returns (uint256 amountIn) {\n return PancakeLibrary.getAmountIn(amountOut, reserveIn, reserveOut);\n }\n\n /**\n * @notice performs chained getAmountOut calculations on any number of pairs.\n * @param amountIn The amount of tokens to swap.\n * @param path Array with addresses of the underlying assets to be swapped.\n */\n function getAmountsOut(\n uint256 amountIn,\n address[] memory path\n ) external view virtual override returns (uint256[] memory amounts) {\n return PancakeLibrary.getAmountsOut(factory, amountIn, path);\n }\n\n /**\n * @notice performs chained getAmountIn calculations on any number of pairs.\n * @param amountOut amountOut The amount of the tokens needs to be as output token.\n * @param path Array with addresses of the underlying assets to be swapped.\n */\n function getAmountsIn(\n uint256 amountOut,\n address[] memory path\n ) external view virtual override returns (uint256[] memory amounts) {\n return PancakeLibrary.getAmountsIn(factory, amountOut, path);\n }\n}\n" + }, + "contracts/Swap/SwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.25;\n\nimport \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./interfaces/IPancakeSwapV2Router.sol\";\nimport \"./interfaces/IVtoken.sol\";\nimport \"./RouterHelper.sol\";\nimport \"./interfaces/IVBNB.sol\";\nimport \"./interfaces/IVtoken.sol\";\nimport \"./interfaces/InterfaceComptroller.sol\";\n\n/**\n * @title Venus's Pancake Swap Integration Contract\n * @notice This contracts allows users to swap a token for another one and supply/repay with the latter.\n * @dev For all functions that do not swap native BNB, user must approve this contract with the amount, prior the calling the swap function.\n * @author 0xlucian\n */\n\ncontract SwapRouter is Ownable2Step, RouterHelper, IPancakeSwapV2Router {\n using SafeERC20 for IERC20;\n\n address public immutable comptrollerAddress;\n\n uint256 private constant _NOT_ENTERED = 1;\n\n uint256 private constant _ENTERED = 2;\n\n address public vBNBAddress;\n\n /**\n * @dev Guard variable for re-entrancy checks\n */\n uint256 internal _status;\n\n // ***************\n // ** MODIFIERS **\n // ***************\n modifier ensure(uint256 deadline) {\n if (deadline < block.timestamp) {\n revert SwapDeadlineExpire(deadline, block.timestamp);\n }\n _;\n }\n\n modifier ensurePath(address[] calldata path) {\n if (path.length < 2) {\n revert InvalidPath();\n }\n _;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant() {\n if (_status == _ENTERED) {\n revert ReentrantCheck();\n }\n _status = _ENTERED;\n _;\n _status = _NOT_ENTERED;\n }\n\n /// @notice event emitted on sweep token success\n event SweepToken(address indexed token, address indexed to, uint256 sweepAmount);\n\n /// @notice event emitted on vBNBAddress update\n event VBNBAddressUpdated(address indexed oldAddress, address indexed newAddress);\n\n // *********************\n // **** CONSTRUCTOR ****\n // *********************\n\n /// @notice Constructor for the implementation contract. Sets immutable variables.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address WBNB_,\n address factory_,\n address _comptrollerAddress,\n address _vBNBAddress\n ) RouterHelper(WBNB_, factory_) {\n if (_comptrollerAddress == address(0) || _vBNBAddress == address(0)) {\n revert ZeroAddress();\n }\n comptrollerAddress = _comptrollerAddress;\n _status = _NOT_ENTERED;\n vBNBAddress = _vBNBAddress;\n }\n\n receive() external payable {\n assert(msg.sender == WBNB); // only accept BNB via fallback from the WBNB contract\n }\n\n // ****************************\n // **** EXTERNAL FUNCTIONS ****\n // ****************************\n\n /**\n * @notice Setter for the vBNB address.\n * @param _vBNBAddress Address of the BNB vToken to update.\n */\n function setVBNBAddress(address _vBNBAddress) external onlyOwner {\n if (_vBNBAddress == address(0)) {\n revert ZeroAddress();\n }\n\n _isVTokenListed(_vBNBAddress);\n\n address oldAddress = vBNBAddress;\n vBNBAddress = _vBNBAddress;\n\n emit VBNBAddressUpdated(oldAddress, vBNBAddress);\n }\n\n /**\n * @notice Swap token A for token B and supply to a Venus market\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n */\n function swapExactTokensForTokensAndSupply(\n address vTokenAddress,\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapExactTokensForTokens(amountIn, amountOutMin, path, address(this), TypesOfTokens.NON_SUPPORTING_FEE);\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _supply(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap deflationary (a small amount of fee is deducted at the time of transfer of token) token A for token B and supply to a Venus market.\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n */\n function swapExactTokensForTokensAndSupplyAtSupportingFee(\n address vTokenAddress,\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapExactTokensForTokens(amountIn, amountOutMin, path, address(this), TypesOfTokens.SUPPORTING_FEE);\n uint256 swapAmount = _checkForAmountOut(lastAsset, balanceBefore, amountOutMin, address(this));\n _supply(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap BNB for another token and supply to a Venus market\n * @dev The amount to be swapped is obtained from the msg.value, since we are swapping BNB\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapExactBNBForTokensAndSupply(\n address vTokenAddress,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external payable override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapExactBNBForTokens(amountOutMin, path, address(this), TypesOfTokens.NON_SUPPORTING_FEE);\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _supply(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap BNB for another deflationary token (a small amount of fee is deducted at the time of transfer of token) and supply to a Venus market\n * @dev The amount to be swapped is obtained from the msg.value, since we are swapping BNB\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapExactBNBForTokensAndSupplyAtSupportingFee(\n address vTokenAddress,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external payable override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapExactBNBForTokens(amountOutMin, path, address(this), TypesOfTokens.SUPPORTING_FEE);\n uint256 swapAmount = _checkForAmountOut(lastAsset, balanceBefore, amountOutMin, address(this));\n _supply(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap tokens for Exact tokens and supply to a Venus market\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapTokensForExactTokensAndSupply(\n address vTokenAddress,\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapTokensForExactTokens(amountOut, amountInMax, path, address(this));\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _supply(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap BNB for Exact tokens and supply to a Venus market\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapBNBForExactTokensAndSupply(\n address vTokenAddress,\n uint256 amountOut,\n address[] calldata path,\n uint256 deadline\n ) external payable override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapBNBForExactTokens(amountOut, path, address(this));\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _supply(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap Exact tokens for BNB and supply to a Venus market\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapExactTokensForBNBAndSupply(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n uint256 balanceBefore = address(this).balance;\n _swapExactTokensForBNB(amountIn, amountOutMin, path, address(this), TypesOfTokens.NON_SUPPORTING_FEE);\n uint256 balanceAfter = address(this).balance;\n uint256 swapAmount = balanceAfter - balanceBefore;\n _mintVBNBandTransfer(swapAmount);\n }\n\n /**\n * @notice Swap Exact deflationary tokens (a small amount of fee is deducted at the time of transfer of tokens) for BNB and supply to a Venus market\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapExactTokensForBNBAndSupplyAtSupportingFee(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n uint256 balanceBefore = address(this).balance;\n _swapExactTokensForBNB(amountIn, amountOutMin, path, address(this), TypesOfTokens.SUPPORTING_FEE);\n uint256 balanceAfter = address(this).balance;\n uint256 swapAmount = balanceAfter - balanceBefore;\n if (swapAmount < amountOutMin) {\n revert SwapAmountLessThanAmountOutMin(swapAmount, amountOutMin);\n }\n _mintVBNBandTransfer(swapAmount);\n }\n\n /**\n * @notice Swap tokens for Exact BNB and supply to a Venus market\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapTokensForExactBNBAndSupply(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n uint256 balanceBefore = address(this).balance;\n _swapTokensForExactBNB(amountOut, amountInMax, path, address(this));\n uint256 balanceAfter = address(this).balance;\n uint256 swapAmount = balanceAfter - balanceBefore;\n _mintVBNBandTransfer(swapAmount);\n }\n\n /**\n * @notice Swap token A for token B and repay a borrow from a Venus market\n * @param vTokenAddress The address of the vToken contract to repay.\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive (and repay)\n */\n function swapExactTokensForTokensAndRepay(\n address vTokenAddress,\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapExactTokensForTokens(amountIn, amountOutMin, path, address(this), TypesOfTokens.NON_SUPPORTING_FEE);\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _repay(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap deflationary token (a small amount of fee is deducted at the time of transfer of token) token A for token B and repay a borrow from a Venus market\n * @param vTokenAddress The address of the vToken contract to repay.\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive (and repay)\n */\n function swapExactTokensForTokensAndRepayAtSupportingFee(\n address vTokenAddress,\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapExactTokensForTokens(amountIn, amountOutMin, path, address(this), TypesOfTokens.SUPPORTING_FEE);\n uint256 swapAmount = _checkForAmountOut(lastAsset, balanceBefore, amountOutMin, address(this));\n _repay(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap BNB for another token and repay a borrow from a Venus market\n * @dev The amount to be swapped is obtained from the msg.value, since we are swapping BNB\n * @param vTokenAddress The address of the vToken contract to repay.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered so the swap path tokens are listed first and last asset is the token we receive\n */\n function swapExactBNBForTokensAndRepay(\n address vTokenAddress,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external payable override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapExactBNBForTokens(amountOutMin, path, address(this), TypesOfTokens.NON_SUPPORTING_FEE);\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _repay(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap BNB for another deflationary token (a small amount of fee is deducted at the time of transfer of token) and repay a borrow from a Venus market\n * @dev The amount to be swapped is obtained from the msg.value, since we are swapping BNB\n * @param vTokenAddress The address of the vToken contract to repay.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered so the swap path tokens are listed first and last asset is the token we receive\n */\n function swapExactBNBForTokensAndRepayAtSupportingFee(\n address vTokenAddress,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external payable override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapExactBNBForTokens(amountOutMin, path, address(this), TypesOfTokens.SUPPORTING_FEE);\n uint256 swapAmount = _checkForAmountOut(lastAsset, balanceBefore, amountOutMin, address(this));\n _repay(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap tokens for Exact tokens and repay to a Venus market\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapTokensForExactTokensAndRepay(\n address vTokenAddress,\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapTokensForExactTokens(amountOut, amountInMax, path, address(this));\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _repay(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap tokens for full tokens debt and repay to a Venus market\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapTokensForFullTokenDebtAndRepay(\n address vTokenAddress,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n uint256 amountOut = IVToken(vTokenAddress).borrowBalanceCurrent(msg.sender);\n _swapTokensForExactTokens(amountOut, amountInMax, path, address(this));\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _repay(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap BNB for Exact tokens and repay to a Venus market\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapBNBForExactTokensAndRepay(\n address vTokenAddress,\n uint256 amountOut,\n address[] calldata path,\n uint256 deadline\n ) external payable override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n _swapBNBForExactTokens(amountOut, path, address(this));\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _repay(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap BNB for Exact tokens and repay to a Venus market\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapBNBForFullTokenDebtAndRepay(\n address vTokenAddress,\n address[] calldata path,\n uint256 deadline\n ) external payable override nonReentrant ensure(deadline) ensurePath(path) {\n _ensureVTokenChecks(vTokenAddress, path[path.length - 1]);\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(address(this));\n uint256 amountOut = IVToken(vTokenAddress).borrowBalanceCurrent(msg.sender);\n _swapBNBForExactTokens(amountOut, path, address(this));\n uint256 swapAmount = _getSwapAmount(lastAsset, balanceBefore);\n _repay(lastAsset, vTokenAddress, swapAmount);\n }\n\n /**\n * @notice Swap Exact tokens for BNB and repay to a Venus market\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapExactTokensForBNBAndRepay(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n uint256 balanceBefore = address(this).balance;\n _swapExactTokensForBNB(amountIn, amountOutMin, path, address(this), TypesOfTokens.NON_SUPPORTING_FEE);\n uint256 balanceAfter = address(this).balance;\n uint256 swapAmount = balanceAfter - balanceBefore;\n IVBNB(vBNBAddress).repayBorrowBehalf{ value: swapAmount }(msg.sender);\n }\n\n /**\n * @notice Swap Exact deflationary tokens (a small amount of fee is deducted at the time of transfer of tokens) for BNB and repay to a Venus market\n * @param amountIn The amount of tokens to swap.\n * @param amountOutMin Minimum amount of tokens to receive.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapExactTokensForBNBAndRepayAtSupportingFee(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n uint256 balanceBefore = address(this).balance;\n _swapExactTokensForBNB(amountIn, amountOutMin, path, address(this), TypesOfTokens.SUPPORTING_FEE);\n uint256 balanceAfter = address(this).balance;\n uint256 swapAmount = balanceAfter - balanceBefore;\n if (swapAmount < amountOutMin) {\n revert SwapAmountLessThanAmountOutMin(swapAmount, amountOutMin);\n }\n IVBNB(vBNBAddress).repayBorrowBehalf{ value: swapAmount }(msg.sender);\n }\n\n /**\n * @notice Swap tokens for Exact BNB and repay to a Venus market\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapTokensForExactBNBAndRepay(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n uint256 balanceBefore = address(this).balance;\n _swapTokensForExactBNB(amountOut, amountInMax, path, address(this));\n uint256 balanceAfter = address(this).balance;\n uint256 swapAmount = balanceAfter - balanceBefore;\n IVBNB(vBNBAddress).repayBorrowBehalf{ value: swapAmount }(msg.sender);\n }\n\n /**\n * @notice Swap tokens for Exact BNB and repay to a Venus market\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param deadline Unix timestamp after which the transaction will revert.\n * @dev Addresses of underlying assets should be ordered that first asset is the token we are swapping and second asset is the token we receive\n * @dev In case of swapping native BNB the first asset in path array should be the wBNB address\n */\n function swapTokensForFullBNBDebtAndRepay(\n uint256 amountInMax,\n address[] calldata path,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) {\n uint256 balanceBefore = address(this).balance;\n uint256 amountOut = IVToken(vBNBAddress).borrowBalanceCurrent(msg.sender);\n _swapTokensForExactBNB(amountOut, amountInMax, path, address(this));\n uint256 balanceAfter = address(this).balance;\n uint256 swapAmount = balanceAfter - balanceBefore;\n IVBNB(vBNBAddress).repayBorrowBehalf{ value: swapAmount }(msg.sender);\n }\n\n /**\n * @notice Swaps an exact amount of input tokens for as many output tokens as possible,\n * along the route determined by the path. The first element of path is the input token,\n * the last is the output token, and any intermediate elements represent intermediate\n * pairs to trade through (if, for example, a direct pair does not exist).\n * @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n * @param amountIn The address of the vToken contract to repay.\n * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n */\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external virtual override nonReentrant ensure(deadline) ensurePath(path) returns (uint256[] memory amounts) {\n amounts = _swapExactTokensForTokens(amountIn, amountOutMin, path, to, TypesOfTokens.NON_SUPPORTING_FEE);\n }\n\n /**\n * @notice Swaps an exact amount of input tokens for as many output tokens as possible,\n * along the route determined by the path. The first element of path is the input token,\n * the last is the output token, and any intermediate elements represent intermediate\n * pairs to trade through (if, for example, a direct pair does not exist).\n * This method to swap deflationary tokens which would require supporting fee.\n * @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n * @param amountIn The address of the vToken contract to repay.\n * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n */\n function swapExactTokensForTokensAtSupportingFee(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external virtual override nonReentrant ensure(deadline) ensurePath(path) returns (uint256 swapAmount) {\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(to);\n _swapExactTokensForTokens(amountIn, amountOutMin, path, to, TypesOfTokens.SUPPORTING_FEE);\n swapAmount = _checkForAmountOut(lastAsset, balanceBefore, amountOutMin, to);\n }\n\n /**\n * @notice Swaps an exact amount of BNB for as many output tokens as possible,\n * along the route determined by the path. The first element of path must be WBNB,\n * the last is the output token, and any intermediate elements represent\n * intermediate pairs to trade through (if, for example, a direct pair does not exist).\n * @dev amountIn is passed through the msg.value of the transaction\n * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n */\n function swapExactBNBForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n ensure(deadline)\n ensurePath(path)\n returns (uint256[] memory amounts)\n {\n amounts = _swapExactBNBForTokens(amountOutMin, path, to, TypesOfTokens.NON_SUPPORTING_FEE);\n }\n\n /**\n * @notice Swaps an exact amount of ETH for as many output tokens as possible,\n * along the route determined by the path. The first element of path must be WBNB,\n * the last is the output token, and any intermediate elements represent\n * intermediate pairs to trade through (if, for example, a direct pair does not exist).\n * This method to swap deflationary tokens which would require supporting fee.\n * @dev amountIn is passed through the msg.value of the transaction\n * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n */\n function swapExactBNBForTokensAtSupportingFee(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable virtual override nonReentrant ensure(deadline) ensurePath(path) returns (uint256 swapAmount) {\n address lastAsset = path[path.length - 1];\n uint256 balanceBefore = IERC20(lastAsset).balanceOf(to);\n _swapExactBNBForTokens(amountOutMin, path, to, TypesOfTokens.SUPPORTING_FEE);\n swapAmount = _checkForAmountOut(lastAsset, balanceBefore, amountOutMin, to);\n }\n\n /**\n * @notice Swaps an exact amount of input tokens for as many output ETH as possible,\n * along the route determined by the path. The first element of path is the input token,\n * the last is the output ETH, and any intermediate elements represent intermediate\n * pairs to trade through (if, for example, a direct pair does not exist).\n * @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n * @param amountIn The address of the vToken contract to repay.\n * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n */\n function swapExactTokensForBNB(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) returns (uint256[] memory amounts) {\n amounts = _swapExactTokensForBNB(amountIn, amountOutMin, path, to, TypesOfTokens.NON_SUPPORTING_FEE);\n }\n\n /**\n * @notice Swaps an exact amount of input tokens for as many output ETH as possible,\n * along the route determined by the path. The first element of path is the input token,\n * the last is the output ETH, and any intermediate elements represent intermediate\n * pairs to trade through (if, for example, a direct pair does not exist).\n * This method to swap deflationary tokens which would require supporting fee.\n * @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n * @param amountIn The address of the vToken contract to repay.\n * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n */\n function swapExactTokensForBNBAtSupportingFee(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external override nonReentrant ensure(deadline) ensurePath(path) returns (uint256 swapAmount) {\n uint256 balanceBefore = to.balance;\n _swapExactTokensForBNB(amountIn, amountOutMin, path, to, TypesOfTokens.SUPPORTING_FEE);\n uint256 balanceAfter = to.balance;\n swapAmount = balanceAfter - balanceBefore;\n if (swapAmount < amountOutMin) {\n revert SwapAmountLessThanAmountOutMin(swapAmount, amountOutMin);\n }\n }\n\n /**\n * @notice Swaps an as many amount of input tokens for as exact amount of tokens as output,\n * along the route determined by the path. The first element of path is the input token,\n * the last is the output token, and any intermediate elements represent intermediate\n * pairs to trade through (if, for example, a direct pair does not exist).\n * @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n **/\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external virtual override nonReentrant ensure(deadline) ensurePath(path) returns (uint256[] memory amounts) {\n amounts = _swapTokensForExactTokens(amountOut, amountInMax, path, to);\n }\n\n /**\n * @notice Swaps an as ETH as input tokens for as exact amount of tokens as output,\n * along the route determined by the path. The first element of path is the input WBNB,\n * the last is the output as token, and any intermediate elements represent intermediate\n * pairs to trade through (if, for example, a direct pair does not exist).\n * @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n **/\n function swapBNBForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n ensure(deadline)\n ensurePath(path)\n returns (uint256[] memory amounts)\n {\n amounts = _swapBNBForExactTokens(amountOut, path, to);\n }\n\n /**\n * @notice Swaps an as many amount of input tokens for as exact amount of ETH as output,\n * along the route determined by the path. The first element of path is the input token,\n * the last is the output as ETH, and any intermediate elements represent intermediate\n * pairs to trade through (if, for example, a direct pair does not exist).\n * @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n * @param amountOut The amount of the tokens needs to be as output token.\n * @param amountInMax The maximum amount of input tokens that can be taken for the transaction not to revert.\n * @param path Array with addresses of the underlying assets to be swapped\n * @param to Recipient of the output tokens.\n * @param deadline Unix timestamp after which the transaction will revert.\n **/\n function swapTokensForExactBNB(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external virtual override nonReentrant ensure(deadline) ensurePath(path) returns (uint256[] memory amounts) {\n amounts = _swapTokensForExactBNB(amountOut, amountInMax, path, to);\n }\n\n /**\n * @notice A public function to sweep accidental BEP-20 transfers to this contract. Tokens are sent to the address `to`, provided in input\n * @param token The address of the ERC-20 token to sweep\n * @param to Recipient of the output tokens.\n * @param sweepAmount The ampunt of the tokens to sweep\n * @custom:access Only Governance\n */\n function sweepToken(IERC20 token, address to, uint256 sweepAmount) external onlyOwner nonReentrant {\n if (to == address(0)) {\n revert ZeroAddress();\n }\n uint256 balance = token.balanceOf(address(this));\n if (sweepAmount > balance) {\n revert InsufficientBalance(sweepAmount, balance);\n }\n token.safeTransfer(to, sweepAmount);\n\n emit SweepToken(address(token), to, sweepAmount);\n }\n\n /**\n * @notice Supply token to a Venus market\n * @param path The addresses of the underlying token\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param swapAmount The amount of tokens supply to Venus Market.\n */\n function _supply(address path, address vTokenAddress, uint256 swapAmount) internal {\n TransferHelper.safeApprove(path, vTokenAddress, 0);\n TransferHelper.safeApprove(path, vTokenAddress, swapAmount);\n uint256 response = IVToken(vTokenAddress).mintBehalf(msg.sender, swapAmount);\n if (response != 0) {\n revert SupplyError(msg.sender, vTokenAddress, response);\n }\n }\n\n /**\n * @notice Repay a borrow from Venus market\n * @param path The addresses of the underlying token\n * @param vTokenAddress The address of the vToken contract for supplying assets.\n * @param swapAmount The amount of tokens repay to Venus Market.\n */\n function _repay(address path, address vTokenAddress, uint256 swapAmount) internal {\n TransferHelper.safeApprove(path, vTokenAddress, 0);\n TransferHelper.safeApprove(path, vTokenAddress, swapAmount);\n uint256 response = IVToken(vTokenAddress).repayBorrowBehalf(msg.sender, swapAmount);\n if (response != 0) {\n revert RepayError(msg.sender, vTokenAddress, response);\n }\n }\n\n /**\n * @notice Check if the balance of to minus the balanceBefore is greater or equal to the amountOutMin.\n * @param asset The address of the underlying token\n * @param balanceBefore Balance before the swap.\n * @param amountOutMin Min amount out threshold.\n * @param to Recipient of the output tokens.\n */\n function _checkForAmountOut(\n address asset,\n uint256 balanceBefore,\n uint256 amountOutMin,\n address to\n ) internal view returns (uint256 swapAmount) {\n uint256 balanceAfter = IERC20(asset).balanceOf(to);\n swapAmount = balanceAfter - balanceBefore;\n if (swapAmount < amountOutMin) {\n revert SwapAmountLessThanAmountOutMin(swapAmount, amountOutMin);\n }\n }\n\n /**\n * @notice Returns the difference between the balance of this and the balanceBefore\n * @param asset The address of the underlying token\n * @param balanceBefore Balance before the swap.\n */\n function _getSwapAmount(address asset, uint256 balanceBefore) internal view returns (uint256 swapAmount) {\n uint256 balanceAfter = IERC20(asset).balanceOf(address(this));\n swapAmount = balanceAfter - balanceBefore;\n }\n\n /**\n * @notice Check isVTokenListed and last address in the path should be vToken underlying.\n * @param vTokenAddress Address of the vToken.\n * @param underlying Address of the underlying asset.\n */\n function _ensureVTokenChecks(address vTokenAddress, address underlying) internal {\n _isVTokenListed(vTokenAddress);\n if (IVToken(vTokenAddress).underlying() != underlying) {\n revert VTokenUnderlyingInvalid(underlying);\n }\n }\n\n /**\n * @notice Check is vToken listed in the pool.\n * @param vToken Address of the vToken.\n */\n function _isVTokenListed(address vToken) internal view {\n bool isListed = InterfaceComptroller(comptrollerAddress).markets(vToken);\n if (!isListed) {\n revert VTokenNotListed(vToken);\n }\n }\n\n /**\n * @notice Mint vBNB tokens to the market then transfer them to user\n * @param swapAmount Swapped BNB amount\n */\n function _mintVBNBandTransfer(uint256 swapAmount) internal {\n uint256 vBNBBalanceBefore = IVBNB(vBNBAddress).balanceOf(address(this));\n IVBNB(vBNBAddress).mint{ value: swapAmount }();\n uint256 vBNBBalanceAfter = IVBNB(vBNBAddress).balanceOf(address(this));\n IERC20(vBNBAddress).safeTransfer(msg.sender, (vBNBBalanceAfter - vBNBBalanceBefore));\n }\n}\n" + }, + "contracts/test/AccessControlManagerMock.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\ncontract AccessControlManagerMock {\n address public owner;\n\n constructor(address _owner) {\n owner = _owner;\n }\n\n function isAllowedToCall(address account, string calldata functionSig) public view returns (bool) {\n if (account == owner) {\n return true;\n }\n\n functionSig;\n\n return false;\n }\n}\n" + }, + "contracts/test/LiquidatorHarness.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"../Liquidator/Liquidator.sol\";\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\n\ncontract LiquidatorHarness is Liquidator {\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address comptroller_, address payable vBnb_, address wBnb_) Liquidator(comptroller_, vBnb_, wBnb_) {}\n\n function initialize(\n uint256 liquidationIncentiveMantissa_,\n address accessControlManager_,\n address protocolShareReserve_\n ) external override initializer {\n __Liquidator_init(liquidationIncentiveMantissa_, accessControlManager_, protocolShareReserve_);\n }\n\n event DistributeLiquidationIncentive(uint256 seizeTokensForTreasury, uint256 seizeTokensForLiquidator);\n\n /// @dev Splits the received vTokens between the liquidator and treasury.\n function distributeLiquidationIncentive(\n IVToken vTokenCollateral,\n uint256 siezedAmount\n ) public returns (uint256 ours, uint256 theirs) {\n (ours, theirs) = super._distributeLiquidationIncentive(vTokenCollateral, siezedAmount);\n emit DistributeLiquidationIncentive(ours, theirs);\n return (ours, theirs);\n }\n\n /// @dev Computes the amounts that would go to treasury and to the liquidator.\n function splitLiquidationIncentive(uint256 seizedAmount) public view returns (uint256 ours, uint256 theirs) {\n return super._splitLiquidationIncentive(seizedAmount);\n }\n}\n" + }, + "contracts/test/MockProtocolShareReserve.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { SafeERC20Upgradeable, IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { AccessControlledV8 } from \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\n\ninterface IIncomeDestination {\n function updateAssetsState(address comptroller, address asset) external;\n}\n\ninterface IVToken {\n function underlying() external view returns (address);\n}\n\ninterface IPrime is IIncomeDestination {\n function accrueInterest(address vToken) external;\n\n function vTokenForAsset(address asset) external view returns (address);\n\n function getAllMarkets() external view returns (address[] memory);\n}\n\ninterface IPoolRegistry {\n /// @notice Get VToken in the Pool for an Asset\n function getVTokenForAsset(address comptroller, address asset) external view returns (address);\n\n /// @notice Get the addresss of the Pools supported that include a market for the provided asset\n function getPoolsSupportedByAsset(address asset) external view returns (address[] memory);\n}\n\ninterface IMockProtocolShareReserve {\n /// @notice it represents the type of vToken income\n enum IncomeType {\n SPREAD,\n LIQUIDATION\n }\n\n function updateAssetsState(address comptroller, address asset, IncomeType incomeType) external;\n}\n\ninterface IComptroller {\n function isComptroller() external view returns (bool);\n\n function markets(address) external view returns (bool);\n\n function getAllMarkets() external view returns (address[] memory);\n}\n\nerror InvalidAddress();\nerror UnsupportedAsset();\nerror InvalidTotalPercentage();\nerror InvalidMaxLoopsLimit();\n\n/**\n * @title MaxLoopsLimitHelper\n * @author Venus\n * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.\n */\nabstract contract MaxLoopsLimitHelper {\n // Limit for the loops to avoid the DOS\n uint256 public maxLoopsLimit;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when max loops limit is set\n event MaxLoopsLimitUpdated(uint256 oldMaxLoopsLimit, uint256 newmaxLoopsLimit);\n\n /// @notice Thrown an error on maxLoopsLimit exceeds for any loop\n error MaxLoopsLimitExceeded(uint256 loopsLimit, uint256 requiredLoops);\n\n /**\n * @notice Set the limit for the loops can iterate to avoid the DOS\n * @param limit Limit for the max loops can execute at a time\n */\n function _setMaxLoopsLimit(uint256 limit) internal {\n require(limit > maxLoopsLimit, \"Comptroller: Invalid maxLoopsLimit\");\n\n uint256 oldMaxLoopsLimit = maxLoopsLimit;\n maxLoopsLimit = limit;\n\n emit MaxLoopsLimitUpdated(oldMaxLoopsLimit, limit);\n }\n\n /**\n * @notice Compare the maxLoopsLimit with number of the times loop iterate\n * @param len Length of the loops iterate\n * @custom:error MaxLoopsLimitExceeded error is thrown when loops length exceeds maxLoopsLimit\n */\n function _ensureMaxLoops(uint256 len) internal view {\n if (len > maxLoopsLimit) {\n revert MaxLoopsLimitExceeded(maxLoopsLimit, len);\n }\n }\n}\n\ncontract MockProtocolShareReserve is\n AccessControlledV8,\n ReentrancyGuardUpgradeable,\n MaxLoopsLimitHelper,\n IMockProtocolShareReserve\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /// @notice protocol income is categorized into two schemas.\n /// The first schema is the default one\n /// The second schema is for spread income from prime markets in core protocol\n enum Schema {\n DEFAULT,\n SPREAD_PRIME_CORE\n }\n\n struct DistributionConfig {\n Schema schema;\n /// @dev percenatge is represented without any scale\n uint256 percentage;\n address destination;\n }\n\n /// @notice address of core pool comptroller contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable CORE_POOL_COMPTROLLER;\n\n /// @notice address of WBNB contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WBNB;\n\n /// @notice address of vBNB contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable vBNB;\n\n /// @notice address of Prime contract\n address public prime;\n\n /// @notice address of pool registry contract\n address public poolRegistry;\n\n uint256 private constant MAX_PERCENT = 100;\n\n /// @notice comptroller => asset => schema => balance\n mapping(address => mapping(address => mapping(Schema => uint256))) public assetsReserves;\n\n /// @notice asset => balance\n mapping(address => uint256) public totalAssetReserve;\n\n /// @notice configuration for different income distribution targets\n DistributionConfig[] public distributionTargets;\n\n /// @notice Emitted when pool registry address is updated\n event PoolRegistryUpdated(address indexed oldPoolRegistry, address indexed newPoolRegistry);\n\n /// @notice Emitted when prime address is updated\n event PrimeUpdated(address indexed oldPrime, address indexed newPrime);\n\n /// @notice Event emitted after the updation of the assets reserves.\n event AssetsReservesUpdated(\n address indexed comptroller,\n address indexed asset,\n uint256 amount,\n IncomeType incomeType,\n Schema schema\n );\n\n /// @notice Event emitted when an asset is released to a target\n event AssetReleased(\n address indexed destination,\n address indexed asset,\n Schema schema,\n uint256 percent,\n uint256 amount\n );\n\n /// @notice Event emitted when asset reserves state is updated\n event ReservesUpdated(\n address indexed comptroller,\n address indexed asset,\n Schema schema,\n uint256 oldBalance,\n uint256 newBalance\n );\n\n /// @notice Event emitted when distribution configuration is updated\n event DistributionConfigUpdated(\n address indexed destination,\n uint256 oldPercentage,\n uint256 newPercentage,\n Schema schema\n );\n\n /// @notice Event emitted when distribution configuration is added\n event DistributionConfigAdded(address indexed destination, uint256 percentage, Schema schema);\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address _corePoolComptroller, address _wbnb, address _vbnb) {\n if (_corePoolComptroller == address(0)) revert InvalidAddress();\n if (_wbnb == address(0)) revert InvalidAddress();\n if (_vbnb == address(0)) revert InvalidAddress();\n\n CORE_POOL_COMPTROLLER = _corePoolComptroller;\n WBNB = _wbnb;\n vBNB = _vbnb;\n\n // Note that the contract is upgradeable. Use initialize() or reinitializers\n // to set the state variables.\n _disableInitializers();\n }\n\n /**\n * @dev Initializes the deployer to owner.\n * @param _accessControlManager The address of ACM contract\n * @param _loopsLimit Limit for the loops in the contract to avoid DOS\n */\n function initialize(address _accessControlManager, uint256 _loopsLimit) external initializer {\n __AccessControlled_init(_accessControlManager);\n __ReentrancyGuard_init();\n _setMaxLoopsLimit(_loopsLimit);\n }\n\n /**\n * @dev Pool registry setter.\n * @param _poolRegistry Address of the pool registry\n * @custom:error ZeroAddressNotAllowed is thrown when pool registry address is zero\n */\n function setPoolRegistry(address _poolRegistry) external onlyOwner {\n if (_poolRegistry == address(0)) revert InvalidAddress();\n emit PoolRegistryUpdated(poolRegistry, _poolRegistry);\n poolRegistry = _poolRegistry;\n }\n\n /**\n * @dev Prime contract address setter.\n * @param _prime Address of the prime contract\n */\n function setPrime(address _prime) external onlyOwner {\n if (_prime == address(0)) revert InvalidAddress();\n emit PrimeUpdated(prime, _prime);\n prime = _prime;\n }\n\n /**\n * @dev Add or update destination targets based on destination address\n * @param configs configurations of the destinations.\n */\n function addOrUpdateDistributionConfigs(DistributionConfig[] memory configs) external nonReentrant {\n _checkAccessAllowed(\"addOrUpdateDistributionConfigs(DistributionConfig[])\");\n\n //we need to accrue and release funds to prime before updating the distribution configuration\n //because prime relies on getUnreleasedFunds and its return value may change after config update\n _accrueAndReleaseFundsToPrime();\n for (uint256 i = 0; i < configs.length; ) {\n DistributionConfig memory _config = configs[i];\n require(_config.destination != address(0), \"ProtocolShareReserve: Destination address invalid\");\n\n bool updated = false;\n for (uint256 j = 0; j < distributionTargets.length; ) {\n DistributionConfig storage config = distributionTargets[j];\n\n if (_config.schema == config.schema && config.destination == _config.destination) {\n emit DistributionConfigUpdated(\n _config.destination,\n config.percentage,\n _config.percentage,\n _config.schema\n );\n config.percentage = _config.percentage;\n updated = true;\n break;\n }\n\n unchecked {\n ++j;\n }\n }\n\n if (!updated) {\n distributionTargets.push(_config);\n emit DistributionConfigAdded(_config.destination, _config.percentage, _config.schema);\n }\n\n unchecked {\n ++i;\n }\n }\n\n _ensurePercentages();\n _ensureMaxLoops(distributionTargets.length);\n }\n\n /**\n * @dev Release funds\n * @param comptroller the comptroller address of the pool\n * @param assets assets to be released to distribution targets\n */\n function releaseFunds(address comptroller, address[] memory assets) external nonReentrant {\n _accruePrimeInterest();\n\n for (uint256 i = 0; i < assets.length; ) {\n _releaseFund(comptroller, assets[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Used to find out the amount of funds that's going to be released when release funds is called.\n * @param comptroller the comptroller address of the pool\n * @param schema the schema of the distribution target\n * @param destination the destination address of the distribution target\n * @param asset the asset address which will be released\n */\n function getUnreleasedFunds(\n address comptroller,\n Schema schema,\n address destination,\n address asset\n ) external view returns (uint256) {\n for (uint256 i = 0; i < distributionTargets.length; ) {\n DistributionConfig storage _config = distributionTargets[i];\n if (_config.schema == schema && _config.destination == destination) {\n uint256 total = assetsReserves[comptroller][asset][schema];\n return (total * _config.percentage) / MAX_PERCENT;\n }\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Returns the total number of distribution targets\n */\n function totalDistributions() external view returns (uint256) {\n return distributionTargets.length;\n }\n\n /**\n * @dev Update the reserve of the asset for the specific pool after transferring to the protocol share reserve.\n * @param comptroller Comptroller address (pool)\n * @param asset Asset address.\n * @param incomeType type of income\n */\n function updateAssetsState(\n address comptroller,\n address asset,\n IncomeType incomeType\n ) public override(IMockProtocolShareReserve) nonReentrant {\n if (!IComptroller(comptroller).isComptroller()) revert InvalidAddress();\n if (asset == address(0)) revert InvalidAddress();\n if (\n comptroller != CORE_POOL_COMPTROLLER &&\n IPoolRegistry(poolRegistry).getVTokenForAsset(comptroller, asset) == address(0)\n ) revert InvalidAddress();\n\n Schema schema = getSchema(comptroller, asset, incomeType);\n uint256 currentBalance = IERC20Upgradeable(asset).balanceOf(address(this));\n uint256 assetReserve = totalAssetReserve[asset];\n\n if (currentBalance > assetReserve) {\n uint256 balanceDifference;\n unchecked {\n balanceDifference = currentBalance - assetReserve;\n }\n\n assetsReserves[comptroller][asset][schema] += balanceDifference;\n totalAssetReserve[asset] += balanceDifference;\n emit AssetsReservesUpdated(comptroller, asset, balanceDifference, incomeType, schema);\n }\n }\n\n /**\n * @dev Fetches the list of prime markets and then accrues interest and\n * releases the funds to prime for each market\n */\n function _accrueAndReleaseFundsToPrime() internal {\n address[] memory markets = IPrime(prime).getAllMarkets();\n for (uint256 i = 0; i < markets.length; ) {\n address market = markets[i];\n IPrime(prime).accrueInterest(market);\n _releaseFund(CORE_POOL_COMPTROLLER, _getUnderlying(market));\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev Fetches the list of prime markets and then accrues interest\n * to prime for each market\n */\n function _accruePrimeInterest() internal {\n // address[] memory markets = IPrime(prime).getAllMarkets();\n address[] memory markets = IPrime(prime).getAllMarkets();\n\n for (uint256 i = 0; i < markets.length; ) {\n address market = markets[i];\n IPrime(prime).accrueInterest(market);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev asset from a particular pool to be release to distribution targets\n * @param comptroller Comptroller address(pool)\n * @param asset Asset address.\n */\n function _releaseFund(address comptroller, address asset) internal {\n uint256 totalSchemas = uint256(type(Schema).max) + 1;\n uint256[] memory schemaBalances = new uint256[](totalSchemas);\n uint256 totalBalance;\n for (uint256 schemaValue; schemaValue < totalSchemas; ) {\n schemaBalances[schemaValue] = assetsReserves[comptroller][asset][Schema(schemaValue)];\n totalBalance += schemaBalances[schemaValue];\n\n unchecked {\n ++schemaValue;\n }\n }\n\n if (totalBalance == 0) {\n return;\n }\n\n uint256[] memory totalTransferAmounts = new uint256[](totalSchemas);\n for (uint256 i = 0; i < distributionTargets.length; ) {\n DistributionConfig memory _config = distributionTargets[i];\n\n uint256 transferAmount = (schemaBalances[uint256(_config.schema)] * _config.percentage) / MAX_PERCENT;\n totalTransferAmounts[uint256(_config.schema)] += transferAmount;\n\n IERC20Upgradeable(asset).safeTransfer(_config.destination, transferAmount);\n IIncomeDestination(_config.destination).updateAssetsState(comptroller, asset);\n\n emit AssetReleased(_config.destination, asset, _config.schema, _config.percentage, transferAmount);\n\n unchecked {\n ++i;\n }\n }\n\n uint256[] memory newSchemaBalances = new uint256[](totalSchemas);\n for (uint256 schemaValue = 0; schemaValue < totalSchemas; ) {\n newSchemaBalances[schemaValue] = schemaBalances[schemaValue] - totalTransferAmounts[schemaValue];\n assetsReserves[comptroller][asset][Schema(schemaValue)] = newSchemaBalances[schemaValue];\n totalAssetReserve[asset] = totalAssetReserve[asset] - totalTransferAmounts[schemaValue];\n\n emit ReservesUpdated(\n comptroller,\n asset,\n Schema(schemaValue),\n schemaBalances[schemaValue],\n newSchemaBalances[schemaValue]\n );\n\n unchecked {\n ++schemaValue;\n }\n }\n }\n\n /**\n * @dev Returns the schema based on comptroller, asset and income type\n * @param comptroller Comptroller address(pool)\n * @param asset Asset address.\n * @param incomeType type of income\n * @return schema schema for distribution\n */\n function getSchema(\n address comptroller,\n address asset,\n IncomeType incomeType\n ) internal view returns (Schema schema) {\n schema = Schema.DEFAULT;\n address vToken = IPrime(prime).vTokenForAsset(asset);\n if (vToken != address(0) && comptroller == CORE_POOL_COMPTROLLER && incomeType == IncomeType.SPREAD) {\n schema = Schema.SPREAD_PRIME_CORE;\n }\n }\n\n function _ensurePercentages() internal view {\n uint256 totalSchemas = uint256(type(Schema).max) + 1;\n uint256[] memory totalPercentages = new uint256[](totalSchemas);\n\n for (uint256 i = 0; i < distributionTargets.length; ) {\n DistributionConfig memory config = distributionTargets[i];\n totalPercentages[uint256(config.schema)] += config.percentage;\n\n unchecked {\n ++i;\n }\n }\n for (uint256 schemaValue = 0; schemaValue < totalSchemas; ) {\n if (totalPercentages[schemaValue] != MAX_PERCENT && totalPercentages[schemaValue] != 0)\n revert InvalidTotalPercentage();\n\n unchecked {\n ++schemaValue;\n }\n }\n }\n\n /**\n * @dev Returns the underlying asset address for the vToken\n * @param vToken vToken address\n * @return asset address of asset\n */\n function _getUnderlying(address vToken) internal view returns (address) {\n if (vToken == vBNB) {\n return WBNB;\n } else {\n return IVToken(vToken).underlying();\n }\n }\n}\n" + }, + "contracts/test/MockToken.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 { ERC20 } from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract MockToken is ERC20 {\n uint8 private immutable _decimals;\n\n constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) {\n _decimals = decimals_;\n }\n\n function faucet(uint256 amount) external {\n _mint(msg.sender, amount);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return _decimals;\n }\n}\n" + }, + "contracts/test/PrimeScenario.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"../Tokens/Prime/Prime.sol\";\n\ncontract PrimeScenario is Prime {\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address _wbnb,\n address _vbnb,\n uint256 _blocksPerYear,\n uint256 _stakingPeriod,\n uint256 _minimumStakedXVS,\n uint256 _maximumXVSCap,\n bool _timeBased\n ) Prime(_wbnb, _vbnb, _blocksPerYear, _stakingPeriod, _minimumStakedXVS, _maximumXVSCap, _timeBased) {}\n\n function calculateScore(uint256 xvs, uint256 capital) external view returns (uint256) {\n return Scores._calculateScore(xvs, capital, alphaNumerator, alphaDenominator);\n }\n\n function setPLP(address plp) external {\n primeLiquidityProvider = plp;\n }\n\n function mintForUser(address user) external {\n tokens[user] = Token(true, true);\n }\n\n function burnForUser(address user) external {\n tokens[user] = Token(false, false);\n }\n}\n" + }, + "contracts/Tokens/Prime/Interfaces/InterfaceComptroller.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.25;\n\ninterface InterfaceComptroller {\n function markets(address) external view returns (bool);\n}\n" + }, + "contracts/Tokens/Prime/Interfaces/IPoolRegistry.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\n/**\n * @title PoolRegistryInterface\n * @author Venus\n * @notice Interface implemented by `PoolRegistry`.\n */\ninterface PoolRegistryInterface {\n /**\n * @notice Struct for a Venus interest rate pool.\n */\n struct VenusPool {\n string name;\n address creator;\n address comptroller;\n uint256 blockPosted;\n uint256 timestampPosted;\n }\n\n /// @notice Get a pool by comptroller address\n function getPoolByComptroller(address comptroller) external view returns (VenusPool memory);\n}\n" + }, + "contracts/Tokens/Prime/Interfaces/IPrime.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport { PrimeStorageV1 } from \"../PrimeStorage.sol\";\n\n/**\n * @title IPrime\n * @author Venus\n * @notice Interface for Prime Token\n */\ninterface IPrime {\n struct APRInfo {\n // supply APR of the user in BPS\n uint256 supplyAPR;\n // borrow APR of the user in BPS\n uint256 borrowAPR;\n // total score of the market\n uint256 totalScore;\n // score of the user\n uint256 userScore;\n // capped XVS balance of the user\n uint256 xvsBalanceForScore;\n // capital of the user\n uint256 capital;\n // capped supply of the user\n uint256 cappedSupply;\n // capped borrow of the user\n uint256 cappedBorrow;\n // capped supply of user in USD\n uint256 supplyCapUSD;\n // capped borrow of user in USD\n uint256 borrowCapUSD;\n }\n\n struct Capital {\n // capital of the user\n uint256 capital;\n // capped supply of the user\n uint256 cappedSupply;\n // capped borrow of the user\n uint256 cappedBorrow;\n // capped supply of user in USD\n uint256 supplyCapUSD;\n // capped borrow of user in USD\n uint256 borrowCapUSD;\n }\n\n /**\n * @notice Returns boosted pending interest accrued for a user for all markets\n * @param user the account for which to get the accrued interests\n * @return pendingRewards the number of underlying tokens accrued by the user for all markets\n */\n function getPendingRewards(address user) external returns (PrimeStorageV1.PendingReward[] memory pendingRewards);\n\n /**\n * @notice Update total score of multiple users and market\n * @param users accounts for which we need to update score\n */\n function updateScores(address[] memory users) external;\n\n /**\n * @notice Update value of alpha\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\n */\n function updateAlpha(uint128 _alphaNumerator, uint128 _alphaDenominator) external;\n\n /**\n * @notice Update multipliers for a market\n * @param market address of the market vToken\n * @param supplyMultiplier new supply multiplier for the market, scaled by 1e18\n * @param borrowMultiplier new borrow multiplier for the market, scaled by 1e18\n */\n function updateMultipliers(address market, uint256 supplyMultiplier, uint256 borrowMultiplier) external;\n\n /**\n * @notice Add a market to prime program\n * @param comptroller address of the comptroller\n * @param market address of the market vToken\n * @param supplyMultiplier the multiplier for supply cap. It should be converted to 1e18\n * @param borrowMultiplier the multiplier for borrow cap. It should be converted to 1e18\n */\n function addMarket(\n address comptroller,\n address market,\n uint256 supplyMultiplier,\n uint256 borrowMultiplier\n ) external;\n\n /**\n * @notice Set limits for total tokens that can be minted\n * @param _irrevocableLimit total number of irrevocable tokens that can be minted\n * @param _revocableLimit total number of revocable tokens that can be minted\n */\n function setLimit(uint256 _irrevocableLimit, uint256 _revocableLimit) external;\n\n /**\n * @notice Directly issue prime tokens to users\n * @param isIrrevocable are the tokens being issued\n * @param users list of address to issue tokens to\n */\n function issue(bool isIrrevocable, address[] calldata users) external;\n\n /**\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\n * @param user the account address whose balance was updated\n */\n function xvsUpdated(address user) external;\n\n /**\n * @notice accrues interest and updates score for an user for a specific market\n * @param user the account address for which to accrue interest and update score\n * @param market the market for which to accrue interest and update score\n */\n function accrueInterestAndUpdateScore(address user, address market) external;\n\n /**\n * @notice For claiming prime token when staking period is completed\n */\n function claim() external;\n\n /**\n * @notice For burning any prime token\n * @param user the account address for which the prime token will be burned\n */\n function burn(address user) external;\n\n /**\n * @notice To pause or unpause claiming of interest\n */\n function togglePause() external;\n\n /**\n * @notice For user to claim boosted yield\n * @param vToken the market for which claim the accrued interest\n * @return amount the amount of tokens transferred to the user\n */\n function claimInterest(address vToken) external returns (uint256);\n\n /**\n * @notice For user to claim boosted yield\n * @param vToken the market for which claim the accrued interest\n * @param user the user for which to claim the accrued interest\n * @return amount the amount of tokens transferred to the user\n */\n function claimInterest(address vToken, address user) external returns (uint256);\n\n /**\n * @notice Distributes income from market since last distribution\n * @param vToken the market for which to distribute the income\n */\n function accrueInterest(address vToken) external;\n\n /**\n * @notice Returns boosted interest accrued for a user\n * @param vToken the market for which to fetch the accrued interest\n * @param user the account for which to get the accrued interest\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\n */\n function getInterestAccrued(address vToken, address user) external returns (uint256);\n\n /**\n * @notice Retrieves an array of all available markets\n * @return an array of addresses representing all available markets\n */\n function getAllMarkets() external view returns (address[] memory);\n\n /**\n * @notice fetch the numbers of seconds remaining for staking period to complete\n * @param user the account address for which we are checking the remaining time\n * @return timeRemaining the number of seconds the user needs to wait to claim prime token\n */\n function claimTimeRemaining(address user) external view returns (uint256);\n\n /**\n * @notice Returns supply and borrow APR for user for a given market\n * @param market the market for which to fetch the APR\n * @param user the account for which to get the APR\n * @return aprInfo APR information for the user for the given market\n */\n function calculateAPR(address market, address user) external view returns (APRInfo memory aprInfo);\n\n /**\n * @notice Returns supply and borrow APR for estimated supply, borrow and XVS staked\n * @param market the market for which to fetch the APR\n * @param user the account for which to get the APR\n * @param borrow hypothetical borrow amount\n * @param supply hypothetical supply amount\n * @param xvsStaked hypothetical staked XVS amount\n * @return aprInfo APR information for the user for the given market\n */\n function estimateAPR(\n address market,\n address user,\n uint256 borrow,\n uint256 supply,\n uint256 xvsStaked\n ) external view returns (APRInfo memory aprInfo);\n\n /**\n * @notice the total income that's going to be distributed in a year to prime token holders\n * @param vToken the market for which to fetch the total income that's going to distributed in a year\n * @return amount the total income\n */\n function incomeDistributionYearly(address vToken) external view returns (uint256 amount);\n\n /**\n * @notice Returns if user is a prime holder\n * @return isPrimeHolder true if user is a prime holder\n */\n function isUserPrimeHolder(address user) external view returns (bool);\n\n /**\n * @notice Set the limit for the loops can iterate to avoid the DOS\n * @param loopsLimit Number of loops limit\n */\n function setMaxLoopsLimit(uint256 loopsLimit) external;\n\n /**\n * @notice Update staked at timestamp for multiple users\n * @param users accounts for which we need to update staked at timestamp\n * @param timestamps new staked at timestamp for the users\n */\n function setStakedAt(address[] calldata users, uint256[] calldata timestamps) external;\n}\n" + }, + "contracts/Tokens/Prime/Interfaces/IPrimeLiquidityProvider.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\n/**\n * @title IPrimeLiquidityProvider\n * @author Venus\n * @notice Interface for PrimeLiquidityProvider\n */\ninterface IPrimeLiquidityProvider {\n /**\n * @notice Initialize the distribution of the token\n * @param tokens_ Array of addresses of the tokens to be intialized\n */\n function initializeTokens(address[] calldata tokens_) external;\n\n /**\n * @notice Pause fund transfer of tokens to Prime contract\n */\n function pauseFundsTransfer() external;\n\n /**\n * @notice Resume fund transfer of tokens to Prime contract\n */\n function resumeFundsTransfer() external;\n\n /**\n * @notice Set distribution speed (amount of token distribute per block or second)\n * @param tokens_ Array of addresses of the tokens\n * @param distributionSpeeds_ New distribution speeds for tokens\n */\n function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external;\n\n /**\n * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)\n * @param tokens_ Array of addresses of the tokens\n * @param maxDistributionSpeeds_ New distribution speeds for tokens\n */\n function setMaxTokensDistributionSpeed(\n address[] calldata tokens_,\n uint256[] calldata maxDistributionSpeeds_\n ) external;\n\n /**\n * @notice Set the prime token contract address\n * @param prime_ The new address of the prime token contract\n */\n function setPrimeToken(address prime_) external;\n\n /**\n * @notice Claim all the token accrued till last block or second\n * @param token_ The token to release to the Prime contract\n */\n function releaseFunds(address token_) external;\n\n /**\n * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\n * @param token_ The address of the ERC-20 token to sweep\n * @param to_ The address of the recipient\n * @param amount_ The amount of tokens needs to transfer\n */\n function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external;\n\n /**\n * @notice Accrue token by updating the distribution state\n * @param token_ Address of the token\n */\n function accrueTokens(address token_) external;\n\n /**\n * @notice Set the limit for the loops can iterate to avoid the DOS\n * @param loopsLimit Limit for the max loops can execute at a time\n */\n function setMaxLoopsLimit(uint256 loopsLimit) external;\n\n /**\n * @notice Get rewards per block or second for token\n * @param token_ Address of the token\n * @return speed returns the per block or second reward\n */\n function getEffectiveDistributionSpeed(address token_) external view returns (uint256);\n\n /**\n * @notice Get the amount of tokens accrued\n * @param token_ Address of the token\n * @return Amount of tokens that are accrued\n */\n function tokenAmountAccrued(address token_) external view returns (uint256);\n}\n" + }, + "contracts/Tokens/Prime/Interfaces/IVToken.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface IVToken {\n function borrowBalanceStored(address account) external view returns (uint256);\n\n function exchangeRateStored() external view returns (uint256);\n\n function balanceOf(address account) external view returns (uint256);\n\n function underlying() external view returns (address);\n\n function totalBorrows() external view returns (uint256);\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function decimals() external view returns (uint8);\n}\n" + }, + "contracts/Tokens/Prime/Interfaces/IXVSVault.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface IXVSVault {\n function getUserInfo(\n address _rewardToken,\n uint256 _pid,\n address _user\n ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals);\n\n function xvsAddress() external view returns (address);\n}\n" + }, + "contracts/Tokens/Prime/libs/FixedMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n// solhint-disable var-name-mixedcase\n\npragma solidity 0.8.25;\n\nimport { SafeCastUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\";\nimport { FixedMath0x } from \"./FixedMath0x.sol\";\n\nusing SafeCastUpgradeable for uint256;\n\nerror InvalidFixedPoint();\n\n/**\n * @title FixedMath\n * @author Venus\n * @notice FixedMath library is used for complex mathematical operations\n */\nlibrary FixedMath {\n error InvalidFraction(uint256 n, uint256 d);\n\n /**\n * @notice Convert some uint256 fraction `n` numerator / `d` denominator to a fixed-point number `f`.\n * @param n numerator\n * @param d denominator\n * @return fixed-point number\n */\n function _toFixed(uint256 n, uint256 d) internal pure returns (int256) {\n if (d.toInt256() < n.toInt256()) revert InvalidFraction(n, d);\n\n return (n.toInt256() * FixedMath0x.FIXED_1) / int256(d.toInt256());\n }\n\n /**\n * @notice Divide some unsigned int `u` by a fixed point number `f`\n * @param u unsigned dividend\n * @param f fixed point divisor, in FIXED_1 units\n * @return unsigned int quotient\n */\n function _uintDiv(uint256 u, int256 f) internal pure returns (uint256) {\n if (f < 0) revert InvalidFixedPoint();\n // multiply `u` by FIXED_1 to cancel out the built-in FIXED_1 in f\n return uint256((u.toInt256() * FixedMath0x.FIXED_1) / f);\n }\n\n /**\n * @notice Multiply some unsigned int `u` by a fixed point number `f`\n * @param u unsigned multiplicand\n * @param f fixed point multiplier, in FIXED_1 units\n * @return unsigned int product\n */\n function _uintMul(uint256 u, int256 f) internal pure returns (uint256) {\n if (f < 0) revert InvalidFixedPoint();\n // divide the product by FIXED_1 to cancel out the built-in FIXED_1 in f\n return uint256((u.toInt256() * f) / FixedMath0x.FIXED_1);\n }\n\n /// @notice see FixedMath0x\n function _ln(int256 x) internal pure returns (int256) {\n return FixedMath0x._ln(x);\n }\n\n /// @notice see FixedMath0x\n function _exp(int256 x) internal pure returns (int256) {\n return FixedMath0x._exp(x);\n }\n}\n" + }, + "contracts/Tokens/Prime/libs/FixedMath0x.sol": { + "content": "// SPDX-License-Identifier: MIT\n// solhint-disable max-line-length\n\npragma solidity 0.8.25;\n\n// Below is code from 0x's LibFixedMath.sol. Changes:\n// - addition of 0.8-style errors\n// - removal of unused functions\n// - added comments for clarity\n// https://github.com/0xProject/exchange-v3/blob/aae46bef841bfd1cc31028f41793db4fe7197084/contracts/staking/contracts/src/libs/LibFixedMath.sol\n\n/*\n\n Copyright 2017 Bprotocol Foundation, 2019 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n/// Thrown when the natural log function is given too large of an argument\nerror LnTooLarge(int256 x);\n/// Thrown when the natural log would have returned a number outside of ℝ\nerror LnNonRealResult(int256 x);\n/// Thrown when exp is given too large of an argument\nerror ExpTooLarge(int256 x);\n/// Thrown when an unsigned value is too large to be converted to a signed value\nerror UnsignedValueTooLarge(uint256 x);\n\n/**\n * @title FixedMath0x\n * @notice Signed, fixed-point, 127-bit precision math library\n */\nlibrary FixedMath0x {\n // Base for the fixed point numbers (this is our 1)\n int256 internal constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000);\n // Maximum ln argument (1)\n int256 private constant LN_MAX_VAL = FIXED_1;\n // Minimum ln argument. Notice this is related to EXP_MIN_VAL (e ^ -63.875)\n int256 private constant LN_MIN_VAL = int256(0x0000000000000000000000000000000000000000000000000000000733048c5a);\n // Maximum exp argument (0)\n int256 private constant EXP_MAX_VAL = 0;\n // Minimum exp argument. Notice this is related to LN_MIN_VAL (-63.875)\n int256 private constant EXP_MIN_VAL = -int256(0x0000000000000000000000000000001ff0000000000000000000000000000000);\n\n /// @dev Get the natural logarithm of a fixed-point number 0 < `x` <= LN_MAX_VAL\n function _ln(int256 x) internal pure returns (int256 r) {\n if (x > LN_MAX_VAL) {\n revert LnTooLarge(x);\n }\n if (x <= 0) {\n revert LnNonRealResult(x);\n }\n if (x == FIXED_1) {\n return 0;\n }\n if (x <= LN_MIN_VAL) {\n return EXP_MIN_VAL;\n }\n\n int256 y;\n int256 z;\n int256 w;\n\n // Rewrite the input as a quotient of negative natural exponents and a single residual q, such that 1 < q < 2\n // For example: log(0.3) = log(e^-1 * e^-0.25 * 1.0471028872385522)\n // = 1 - 0.25 - log(1 + 0.0471028872385522)\n // e ^ -32\n if (x <= int256(0x00000000000000000000000000000000000000000001c8464f76164760000000)) {\n r -= int256(0x0000000000000000000000000000001000000000000000000000000000000000); // - 32\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32\n }\n // e ^ -16\n if (x <= int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000)) {\n r -= int256(0x0000000000000000000000000000000800000000000000000000000000000000); // - 16\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000); // / e ^ -16\n }\n // e ^ -8\n if (x <= int256(0x00000000000000000000000000000000000afe10820813d78000000000000000)) {\n r -= int256(0x0000000000000000000000000000000400000000000000000000000000000000); // - 8\n x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000afe10820813d78000000000000000); // / e ^ -8\n }\n // e ^ -4\n if (x <= int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000)) {\n r -= int256(0x0000000000000000000000000000000200000000000000000000000000000000); // - 4\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000); // / e ^ -4\n }\n // e ^ -2\n if (x <= int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000)) {\n r -= int256(0x0000000000000000000000000000000100000000000000000000000000000000); // - 2\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000); // / e ^ -2\n }\n // e ^ -1\n if (x <= int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000)) {\n r -= int256(0x0000000000000000000000000000000080000000000000000000000000000000); // - 1\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000); // / e ^ -1\n }\n // e ^ -0.5\n if (x <= int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000)) {\n r -= int256(0x0000000000000000000000000000000040000000000000000000000000000000); // - 0.5\n x = (x * FIXED_1) / int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000); // / e ^ -0.5\n }\n // e ^ -0.25\n if (x <= int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000)) {\n r -= int256(0x0000000000000000000000000000000020000000000000000000000000000000); // - 0.25\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000); // / e ^ -0.25\n }\n // e ^ -0.125\n if (x <= int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) {\n r -= int256(0x0000000000000000000000000000000010000000000000000000000000000000); // - 0.125\n x = (x * FIXED_1) / int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d); // / e ^ -0.125\n }\n // `x` is now our residual in the range of 1 <= x <= 2 (or close enough).\n\n // Add the taylor series for log(1 + z), where z = x - 1\n z = y = x - FIXED_1;\n w = (y * y) / FIXED_1;\n r += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000;\n z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02\n r += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000;\n z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04\n r += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000;\n z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06\n r += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;\n z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08\n r += (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / 0x500000000000000000000000000000000;\n z = (z * w) / FIXED_1; // add y^09 / 09 - y^10 / 10\n r += (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / 0x600000000000000000000000000000000;\n z = (z * w) / FIXED_1; // add y^11 / 11 - y^12 / 12\n r += (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / 0x700000000000000000000000000000000;\n z = (z * w) / FIXED_1; // add y^13 / 13 - y^14 / 14\n r += (z * (0x088888888888888888888888888888888 - y)) / 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16\n }\n\n /// @dev Compute the natural exponent for a fixed-point number EXP_MIN_VAL <= `x` <= 1\n function _exp(int256 x) internal pure returns (int256 r) {\n if (x < EXP_MIN_VAL) {\n // Saturate to zero below EXP_MIN_VAL.\n return 0;\n }\n if (x == 0) {\n return FIXED_1;\n }\n if (x > EXP_MAX_VAL) {\n revert ExpTooLarge(x);\n }\n\n // Rewrite the input as a product of natural exponents and a\n // single residual q, where q is a number of small magnitude.\n // For example: e^-34.419 = e^(-32 - 2 - 0.25 - 0.125 - 0.044)\n // = e^-32 * e^-2 * e^-0.25 * e^-0.125 * e^-0.044\n // -> q = -0.044\n\n // Multiply with the taylor series for e^q\n int256 y;\n int256 z;\n // q = x % 0.125 (the residual)\n z = y = x % 0x0000000000000000000000000000000010000000000000000000000000000000;\n z = (z * y) / FIXED_1;\n r += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)\n z = (z * y) / FIXED_1;\n r += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)\n z = (z * y) / FIXED_1;\n r += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)\n z = (z * y) / FIXED_1;\n r += z * 0x004807432bc18000; // add y^05 * (20! / 05!)\n z = (z * y) / FIXED_1;\n r += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)\n z = (z * y) / FIXED_1;\n r += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)\n z = (z * y) / FIXED_1;\n r += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)\n z = (z * y) / FIXED_1;\n r += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)\n z = (z * y) / FIXED_1;\n r += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)\n z = (z * y) / FIXED_1;\n r += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)\n z = (z * y) / FIXED_1;\n r += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)\n z = (z * y) / FIXED_1;\n r += z * 0x0000000017499f00; // add y^13 * (20! / 13!)\n z = (z * y) / FIXED_1;\n r += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)\n z = (z * y) / FIXED_1;\n r += z * 0x00000000001c6380; // add y^15 * (20! / 15!)\n z = (z * y) / FIXED_1;\n r += z * 0x000000000001c638; // add y^16 * (20! / 16!)\n z = (z * y) / FIXED_1;\n r += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)\n z = (z * y) / FIXED_1;\n r += z * 0x000000000000017c; // add y^18 * (20! / 18!)\n z = (z * y) / FIXED_1;\n r += z * 0x0000000000000014; // add y^19 * (20! / 19!)\n z = (z * y) / FIXED_1;\n r += z * 0x0000000000000001; // add y^20 * (20! / 20!)\n r = r / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!\n\n // Multiply with the non-residual terms.\n x = -x;\n // e ^ -32\n if ((x & int256(0x0000000000000000000000000000001000000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x00000000000000000000000000000000000000f1aaddd7742e56d32fb9f99744)) /\n int256(0x0000000000000000000000000043cbaf42a000812488fc5c220ad7b97bf6e99e); // * e ^ -32\n }\n // e ^ -16\n if ((x & int256(0x0000000000000000000000000000000800000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x00000000000000000000000000000000000afe10820813d65dfe6a33c07f738f)) /\n int256(0x000000000000000000000000000005d27a9f51c31b7c2f8038212a0574779991); // * e ^ -16\n }\n // e ^ -8\n if ((x & int256(0x0000000000000000000000000000000400000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x0000000000000000000000000000000002582ab704279e8efd15e0265855c47a)) /\n int256(0x0000000000000000000000000000001b4c902e273a58678d6d3bfdb93db96d02); // * e ^ -8\n }\n // e ^ -4\n if ((x & int256(0x0000000000000000000000000000000200000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x000000000000000000000000000000001152aaa3bf81cb9fdb76eae12d029571)) /\n int256(0x00000000000000000000000000000003b1cc971a9bb5b9867477440d6d157750); // * e ^ -4\n }\n // e ^ -2\n if ((x & int256(0x0000000000000000000000000000000100000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x000000000000000000000000000000002f16ac6c59de6f8d5d6f63c1482a7c86)) /\n int256(0x000000000000000000000000000000015bf0a8b1457695355fb8ac404e7a79e3); // * e ^ -2\n }\n // e ^ -1\n if ((x & int256(0x0000000000000000000000000000000080000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x000000000000000000000000000000004da2cbf1be5827f9eb3ad1aa9866ebb3)) /\n int256(0x00000000000000000000000000000000d3094c70f034de4b96ff7d5b6f99fcd8); // * e ^ -1\n }\n // e ^ -0.5\n if ((x & int256(0x0000000000000000000000000000000040000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x0000000000000000000000000000000063afbe7ab2082ba1a0ae5e4eb1b479dc)) /\n int256(0x00000000000000000000000000000000a45af1e1f40c333b3de1db4dd55f29a7); // * e ^ -0.5\n }\n // e ^ -0.25\n if ((x & int256(0x0000000000000000000000000000000020000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) /\n int256(0x00000000000000000000000000000000910b022db7ae67ce76b441c27035c6a1); // * e ^ -0.25\n }\n // e ^ -0.125\n if ((x & int256(0x0000000000000000000000000000000010000000000000000000000000000000)) != 0) {\n r =\n (r * int256(0x00000000000000000000000000000000783eafef1c0a8f3978c7f81824d62ebf)) /\n int256(0x0000000000000000000000000000000088415abbe9a76bead8d00cf112e4d4a8); // * e ^ -0.125\n }\n }\n}\n" + }, + "contracts/Tokens/Prime/libs/Scores.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.25;\n\nimport { SafeCastUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\";\nimport { FixedMath } from \"./FixedMath.sol\";\n\nusing SafeCastUpgradeable for uint256;\n\n/**\n * @title Scores\n * @author Venus\n * @notice Scores library is used to calculate score of users\n */\nlibrary Scores {\n /**\n * @notice Calculate a membership score given some amount of `xvs` and `capital`, along\n * with some 𝝰 = `alphaNumerator` / `alphaDenominator`.\n * @param xvs amount of xvs (xvs, 1e18 decimal places)\n * @param capital amount of capital (1e18 decimal places)\n * @param alphaNumerator alpha param numerator\n * @param alphaDenominator alpha param denominator\n * @return membership score with 1e18 decimal places\n *\n * @dev 𝝰 must be in the range [0, 1]\n */\n function _calculateScore(\n uint256 xvs,\n uint256 capital,\n uint256 alphaNumerator,\n uint256 alphaDenominator\n ) internal pure returns (uint256) {\n // Score function is:\n // xvs^𝝰 * capital^(1-𝝰)\n // = capital * capital^(-𝝰) * xvs^𝝰\n // = capital * (xvs / capital)^𝝰\n // = capital * (e ^ (ln(xvs / capital))) ^ 𝝰\n // = capital * e ^ (𝝰 * ln(xvs / capital)) (1)\n // or\n // = capital / ( 1 / e ^ (𝝰 * ln(xvs / capital)))\n // = capital / (e ^ (𝝰 * ln(xvs / capital)) ^ -1)\n // = capital / e ^ (𝝰 * -1 * ln(xvs / capital))\n // = capital / e ^ (𝝰 * ln(capital / xvs)) (2)\n //\n // To avoid overflows, use (1) when xvs < capital and\n // use (2) when capital < xvs\n\n // If any side is 0, exit early\n if (xvs == 0 || capital == 0) return 0;\n\n // If both sides are equal, we have:\n // xvs^𝝰 * capital^(1-𝝰)\n // = xvs^𝝰 * xvs^(1-𝝰)\n // = xvs^(𝝰 + 1 - 𝝰) = xvs\n if (xvs == capital) return xvs;\n\n bool lessxvsThanCapital = xvs < capital;\n\n // (xvs / capital) or (capital / xvs), always in range (0, 1)\n int256 ratio = lessxvsThanCapital ? FixedMath._toFixed(xvs, capital) : FixedMath._toFixed(capital, xvs);\n\n // e ^ ( ln(ratio) * 𝝰 )\n int256 exponentiation = FixedMath._exp(\n (FixedMath._ln(ratio) * alphaNumerator.toInt256()) / alphaDenominator.toInt256()\n );\n\n if (lessxvsThanCapital) {\n // capital * e ^ (𝝰 * ln(xvs / capital))\n return FixedMath._uintMul(capital, exponentiation);\n }\n\n // capital / e ^ (𝝰 * ln(capital / xvs))\n return FixedMath._uintDiv(capital, exponentiation);\n }\n}\n" + }, + "contracts/Tokens/Prime/Prime.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { SafeERC20Upgradeable, IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { AccessControlledV8 } from \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\nimport { PausableUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport { MaxLoopsLimitHelper } from \"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\";\nimport { TimeManagerV8 } from \"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\";\n\nimport { IERC20MetadataUpgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\nimport { PrimeStorageV1 } from \"./PrimeStorage.sol\";\nimport { Scores } from \"./libs/Scores.sol\";\n\nimport { IPrimeLiquidityProvider } from \"./Interfaces/IPrimeLiquidityProvider.sol\";\nimport { IPrime } from \"./Interfaces/IPrime.sol\";\nimport { IXVSVault } from \"./Interfaces/IXVSVault.sol\";\nimport { IVToken } from \"./Interfaces/IVToken.sol\";\nimport { InterfaceComptroller } from \"./Interfaces/InterfaceComptroller.sol\";\nimport { PoolRegistryInterface } from \"./Interfaces/IPoolRegistry.sol\";\n\n/**\n * @title Prime\n * @author Venus\n * @notice Prime Token is used to provide extra rewards to the users who have staked a minimum of `MINIMUM_STAKED_XVS` XVS in the XVSVault for `STAKING_PERIOD` days\n * @custom:security-contact https://github.com/VenusProtocol/venus-protocol\n */\ncontract Prime is IPrime, AccessControlledV8, PausableUpgradeable, MaxLoopsLimitHelper, PrimeStorageV1, TimeManagerV8 {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /// @notice address of wrapped native token contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable WRAPPED_NATIVE_TOKEN;\n\n /// @notice address of native market contract\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable NATIVE_MARKET;\n\n /// @notice minimum amount of XVS user needs to stake to become a prime member\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n uint256 public immutable MINIMUM_STAKED_XVS;\n\n /// @notice maximum XVS taken in account when calculating user score\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n uint256 public immutable MAXIMUM_XVS_CAP;\n\n /// @notice number of days user need to stake to claim prime token\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n uint256 public immutable STAKING_PERIOD;\n\n /// @notice Emitted when prime token is minted\n event Mint(address indexed user, bool isIrrevocable);\n\n /// @notice Emitted when prime token is burned\n event Burn(address indexed user);\n\n /// @notice Emitted when a market is added to prime program\n event MarketAdded(\n address indexed comptroller,\n address indexed market,\n uint256 supplyMultiplier,\n uint256 borrowMultiplier\n );\n\n /// @notice Emitted when mint limits are updated\n event MintLimitsUpdated(\n uint256 indexed oldIrrevocableLimit,\n uint256 indexed oldRevocableLimit,\n uint256 indexed newIrrevocableLimit,\n uint256 newRevocableLimit\n );\n\n /// @notice Emitted when user score is updated\n event UserScoreUpdated(address indexed user);\n\n /// @notice Emitted when alpha is updated\n event AlphaUpdated(\n uint128 indexed oldNumerator,\n uint128 indexed oldDenominator,\n uint128 indexed newNumerator,\n uint128 newDenominator\n );\n\n /// @notice Emitted when multiplier is updated\n event MultiplierUpdated(\n address indexed market,\n uint256 indexed oldSupplyMultiplier,\n uint256 indexed oldBorrowMultiplier,\n uint256 newSupplyMultiplier,\n uint256 newBorrowMultiplier\n );\n\n /// @notice Emitted when interest is claimed\n event InterestClaimed(address indexed user, address indexed market, uint256 amount);\n\n /// @notice Emitted when revocable token is upgraded to irrevocable token\n event TokenUpgraded(address indexed user);\n\n /// @notice Emitted when stakedAt is updated\n event StakedAtUpdated(address indexed user, uint256 timestamp);\n\n /// @notice Error thrown when market is not supported\n error MarketNotSupported();\n\n /// @notice Error thrown when mint limit is reached\n error InvalidLimit();\n\n /// @notice Error thrown when user is not eligible to claim prime token\n error IneligibleToClaim();\n\n /// @notice Error thrown when user needs to wait more time to claim prime token\n error WaitMoreTime();\n\n /// @notice Error thrown when user has no prime token\n error UserHasNoPrimeToken();\n\n /// @notice Error thrown when no score updates are required\n error NoScoreUpdatesRequired();\n\n /// @notice Error thrown when market already exists\n error MarketAlreadyExists();\n\n /// @notice Error thrown when asset already exists\n error AssetAlreadyExists();\n\n /// @notice Error thrown when invalid address is passed\n error InvalidAddress();\n\n /// @notice Error thrown when invalid alpha arguments are passed\n error InvalidAlphaArguments();\n\n /// @notice Error thrown when invalid vToken is passed\n error InvalidVToken();\n\n /// @notice Error thrown when invalid length is passed\n error InvalidLength();\n\n /// @notice Error thrown when timestamp is invalid\n error InvalidTimestamp();\n\n /// @notice Error thrown when invalid comptroller is passed\n error InvalidComptroller();\n\n /**\n * @notice Prime constructor\n * @param _wrappedNativeToken Address of wrapped native token\n * @param _nativeMarket Address of native market\n * @param _blocksPerYear total blocks per year\n * @param _stakingPeriod total number of seconds for which user needs to stake to claim prime token\n * @param _minimumStakedXVS minimum amount of XVS user needs to stake to become a prime member (scaled by 1e18)\n * @param _maximumXVSCap maximum XVS taken in account when calculating user score (scaled by 1e18)\n * @param _timeBased A boolean indicating whether the contract is based on time or block.\n */\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address _wrappedNativeToken,\n address _nativeMarket,\n uint256 _blocksPerYear,\n uint256 _stakingPeriod,\n uint256 _minimumStakedXVS,\n uint256 _maximumXVSCap,\n bool _timeBased\n ) TimeManagerV8(_timeBased, _blocksPerYear) {\n WRAPPED_NATIVE_TOKEN = _wrappedNativeToken;\n NATIVE_MARKET = _nativeMarket;\n STAKING_PERIOD = _stakingPeriod;\n MINIMUM_STAKED_XVS = _minimumStakedXVS;\n MAXIMUM_XVS_CAP = _maximumXVSCap;\n\n // Note that the contract is upgradeable. Use initialize() or reinitializers\n // to set the state variables.\n _disableInitializers();\n }\n\n /**\n * @notice Prime initializer\n * @param xvsVault_ Address of XVSVault\n * @param xvsVaultRewardToken_ Address of XVSVault reward token\n * @param xvsVaultPoolId_ Pool id of XVSVault\n * @param alphaNumerator_ numerator of alpha. If alpha is 0.5 then numerator is 1.\n alphaDenominator_ must be greater than alphaNumerator_, alphaDenominator_ cannot be zero and alphaNumerator_ cannot be zero\n * @param alphaDenominator_ denominator of alpha. If alpha is 0.5 then denominator is 2.\n alpha is alphaNumerator_/alphaDenominator_. So, 0 < alpha < 1\n * @param accessControlManager_ Address of AccessControlManager\n * @param primeLiquidityProvider_ Address of PrimeLiquidityProvider\n * @param comptroller_ Address of core pool comptroller\n * @param oracle_ Address of Oracle\n * @param loopsLimit_ Maximum number of loops allowed in a single transaction\n * @custom:error Throw InvalidAddress if any of the address is invalid\n */\n function initialize(\n address xvsVault_,\n address xvsVaultRewardToken_,\n uint256 xvsVaultPoolId_,\n uint128 alphaNumerator_,\n uint128 alphaDenominator_,\n address accessControlManager_,\n address primeLiquidityProvider_,\n address comptroller_,\n address oracle_,\n uint256 loopsLimit_\n ) external initializer {\n if (xvsVault_ == address(0)) revert InvalidAddress();\n if (xvsVaultRewardToken_ == address(0)) revert InvalidAddress();\n if (oracle_ == address(0)) revert InvalidAddress();\n if (primeLiquidityProvider_ == address(0)) revert InvalidAddress();\n\n _checkAlphaArguments(alphaNumerator_, alphaDenominator_);\n\n alphaNumerator = alphaNumerator_;\n alphaDenominator = alphaDenominator_;\n xvsVaultRewardToken = xvsVaultRewardToken_;\n xvsVaultPoolId = xvsVaultPoolId_;\n xvsVault = xvsVault_;\n nextScoreUpdateRoundId = 0;\n primeLiquidityProvider = primeLiquidityProvider_;\n corePoolComptroller = comptroller_;\n oracle = ResilientOracleInterface(oracle_);\n\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n _setMaxLoopsLimit(loopsLimit_);\n\n _pause();\n }\n\n /**\n * @notice Prime initializer V2 for initializing pool registry\n * @param poolRegistry_ Address of IL pool registry\n */\n function initializeV2(address poolRegistry_) external reinitializer(2) {\n poolRegistry = poolRegistry_;\n }\n\n /**\n * @notice Returns boosted pending interest accrued for a user for all markets\n * @param user the account for which to get the accrued interests\n * @return pendingRewards the number of underlying tokens accrued by the user for all markets\n */\n function getPendingRewards(address user) external returns (PendingReward[] memory pendingRewards) {\n address[] storage allMarkets = _allMarkets;\n uint256 marketsLength = allMarkets.length;\n\n pendingRewards = new PendingReward[](marketsLength);\n for (uint256 i; i < marketsLength; ) {\n address market = allMarkets[i];\n uint256 interestAccrued = getInterestAccrued(market, user);\n uint256 accrued = interests[market][user].accrued;\n\n pendingRewards[i] = PendingReward({\n vToken: market,\n rewardToken: _getUnderlying(market),\n amount: interestAccrued + accrued\n });\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Update total score of multiple users and market\n * @param users accounts for which we need to update score\n * @custom:error Throw NoScoreUpdatesRequired if no score updates are required\n * @custom:error Throw UserHasNoPrimeToken if user has no prime token\n * @custom:event Emits UserScoreUpdated event\n */\n function updateScores(address[] calldata users) external {\n if (pendingScoreUpdates == 0) revert NoScoreUpdatesRequired();\n if (nextScoreUpdateRoundId == 0) revert NoScoreUpdatesRequired();\n\n for (uint256 i; i < users.length; ) {\n address user = users[i];\n\n if (!tokens[user].exists) revert UserHasNoPrimeToken();\n if (isScoreUpdated[nextScoreUpdateRoundId][user]) {\n unchecked {\n ++i;\n }\n continue;\n }\n\n address[] storage allMarkets = _allMarkets;\n uint256 marketsLength = allMarkets.length;\n\n for (uint256 j; j < marketsLength; ) {\n address market = allMarkets[j];\n _executeBoost(user, market);\n _updateScore(user, market);\n\n unchecked {\n ++j;\n }\n }\n\n --pendingScoreUpdates;\n isScoreUpdated[nextScoreUpdateRoundId][user] = true;\n\n unchecked {\n ++i;\n }\n\n emit UserScoreUpdated(user);\n }\n }\n\n /**\n * @notice Update value of alpha\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\n * @custom:event Emits AlphaUpdated event\n * @custom:access Controlled by ACM\n */\n function updateAlpha(uint128 _alphaNumerator, uint128 _alphaDenominator) external {\n _checkAccessAllowed(\"updateAlpha(uint128,uint128)\");\n _checkAlphaArguments(_alphaNumerator, _alphaDenominator);\n\n emit AlphaUpdated(alphaNumerator, alphaDenominator, _alphaNumerator, _alphaDenominator);\n\n alphaNumerator = _alphaNumerator;\n alphaDenominator = _alphaDenominator;\n\n uint256 marketslength = _allMarkets.length;\n\n for (uint256 i; i < marketslength; ) {\n accrueInterest(_allMarkets[i]);\n\n unchecked {\n ++i;\n }\n }\n\n _startScoreUpdateRound();\n }\n\n /**\n * @notice Update multipliers for a market\n * @param market address of the market vToken\n * @param supplyMultiplier new supply multiplier for the market, scaled by 1e18\n * @param borrowMultiplier new borrow multiplier for the market, scaled by 1e18\n * @custom:error Throw MarketNotSupported if market is not supported\n * @custom:event Emits MultiplierUpdated event\n * @custom:access Controlled by ACM\n */\n function updateMultipliers(address market, uint256 supplyMultiplier, uint256 borrowMultiplier) external {\n _checkAccessAllowed(\"updateMultipliers(address,uint256,uint256)\");\n\n Market storage _market = markets[market];\n if (!_market.exists) revert MarketNotSupported();\n\n accrueInterest(market);\n\n emit MultiplierUpdated(\n market,\n _market.supplyMultiplier,\n _market.borrowMultiplier,\n supplyMultiplier,\n borrowMultiplier\n );\n _market.supplyMultiplier = supplyMultiplier;\n _market.borrowMultiplier = borrowMultiplier;\n\n _startScoreUpdateRound();\n }\n\n /**\n * @notice Update staked at timestamp for multiple users\n * @param users accounts for which we need to update staked at timestamp\n * @param timestamps new staked at timestamp for the users\n * @custom:error Throw InvalidLength if users and timestamps length are not equal\n * @custom:event Emits StakedAtUpdated event for each user\n * @custom:access Controlled by ACM\n */\n function setStakedAt(address[] calldata users, uint256[] calldata timestamps) external {\n _checkAccessAllowed(\"setStakedAt(address[],uint256[])\");\n if (users.length != timestamps.length) revert InvalidLength();\n\n for (uint256 i; i < users.length; ) {\n if (timestamps[i] > block.timestamp) revert InvalidTimestamp();\n\n stakedAt[users[i]] = timestamps[i];\n emit StakedAtUpdated(users[i], timestamps[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Add a market to prime program\n * @param comptroller address of the comptroller\n * @param market address of the market vToken\n * @param supplyMultiplier the multiplier for supply cap. It should be converted to 1e18\n * @param borrowMultiplier the multiplier for borrow cap. It should be converted to 1e18\n * @custom:error Throw MarketAlreadyExists if market already exists\n * @custom:error Throw InvalidVToken if market is not valid\n * @custom:event Emits MarketAdded event\n * @custom:access Controlled by ACM\n */\n function addMarket(\n address comptroller,\n address market,\n uint256 supplyMultiplier,\n uint256 borrowMultiplier\n ) external {\n _checkAccessAllowed(\"addMarket(address,address,uint256,uint256)\");\n\n if (comptroller == address(0)) revert InvalidComptroller();\n\n if (\n comptroller != corePoolComptroller &&\n PoolRegistryInterface(poolRegistry).getPoolByComptroller(comptroller).comptroller != comptroller\n ) revert InvalidComptroller();\n\n Market storage _market = markets[market];\n if (_market.exists) revert MarketAlreadyExists();\n\n bool isMarketExist = InterfaceComptroller(comptroller).markets(market);\n if (!isMarketExist) revert InvalidVToken();\n\n delete _market.rewardIndex;\n _market.supplyMultiplier = supplyMultiplier;\n _market.borrowMultiplier = borrowMultiplier;\n delete _market.sumOfMembersScore;\n _market.exists = true;\n\n address underlying = _getUnderlying(market);\n\n if (vTokenForAsset[underlying] != address(0)) revert AssetAlreadyExists();\n vTokenForAsset[underlying] = market;\n\n _allMarkets.push(market);\n _startScoreUpdateRound();\n\n _ensureMaxLoops(_allMarkets.length);\n\n emit MarketAdded(comptroller, market, supplyMultiplier, borrowMultiplier);\n }\n\n /**\n * @notice Set limits for total tokens that can be minted\n * @param _irrevocableLimit total number of irrevocable tokens that can be minted\n * @param _revocableLimit total number of revocable tokens that can be minted\n * @custom:error Throw InvalidLimit if any of the limit is less than total tokens minted\n * @custom:event Emits MintLimitsUpdated event\n * @custom:access Controlled by ACM\n */\n function setLimit(uint256 _irrevocableLimit, uint256 _revocableLimit) external {\n _checkAccessAllowed(\"setLimit(uint256,uint256)\");\n if (_irrevocableLimit < totalIrrevocable || _revocableLimit < totalRevocable) revert InvalidLimit();\n\n emit MintLimitsUpdated(irrevocableLimit, revocableLimit, _irrevocableLimit, _revocableLimit);\n\n revocableLimit = _revocableLimit;\n irrevocableLimit = _irrevocableLimit;\n }\n\n /**\n * @notice Set the limit for the loops can iterate to avoid the DOS\n * @param loopsLimit Number of loops limit\n * @custom:event Emits MaxLoopsLimitUpdated event on success\n * @custom:access Controlled by ACM\n */\n function setMaxLoopsLimit(uint256 loopsLimit) external {\n _checkAccessAllowed(\"setMaxLoopsLimit(uint256)\");\n _setMaxLoopsLimit(loopsLimit);\n }\n\n /**\n * @notice Directly issue prime tokens to users\n * @param isIrrevocable are the tokens being issued\n * @param users list of address to issue tokens to\n * @custom:access Controlled by ACM\n */\n function issue(bool isIrrevocable, address[] calldata users) external {\n _checkAccessAllowed(\"issue(bool,address[])\");\n\n if (isIrrevocable) {\n for (uint256 i; i < users.length; ) {\n Token storage userToken = tokens[users[i]];\n if (userToken.exists && !userToken.isIrrevocable) {\n _upgrade(users[i]);\n } else {\n _mint(true, users[i]);\n _initializeMarkets(users[i]);\n }\n\n unchecked {\n ++i;\n }\n }\n } else {\n for (uint256 i; i < users.length; ) {\n _mint(false, users[i]);\n _initializeMarkets(users[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n }\n\n /**\n * @notice Executed by XVSVault whenever user's XVSVault balance changes\n * @param user the account address whose balance was updated\n */\n function xvsUpdated(address user) external {\n uint256 totalStaked = _xvsBalanceOfUser(user);\n bool isAccountEligible = _isEligible(totalStaked);\n\n uint256 userStakedAt = stakedAt[user];\n Token memory token = tokens[user];\n\n if (token.exists && !isAccountEligible) {\n delete stakedAt[user];\n emit StakedAtUpdated(user, 0);\n\n if (token.isIrrevocable) {\n _accrueInterestAndUpdateScore(user);\n } else {\n _burn(user);\n }\n } else if (!isAccountEligible && !token.exists && userStakedAt != 0) {\n delete stakedAt[user];\n emit StakedAtUpdated(user, 0);\n } else if (userStakedAt == 0 && isAccountEligible && !token.exists) {\n stakedAt[user] = block.timestamp;\n emit StakedAtUpdated(user, block.timestamp);\n } else if (token.exists && isAccountEligible) {\n _accrueInterestAndUpdateScore(user);\n\n if (stakedAt[user] == 0) {\n stakedAt[user] = block.timestamp;\n emit StakedAtUpdated(user, block.timestamp);\n }\n }\n }\n\n /**\n * @notice accrues interes and updates score for an user for a specific market\n * @param user the account address for which to accrue interest and update score\n * @param market the market for which to accrue interest and update score\n */\n function accrueInterestAndUpdateScore(address user, address market) external {\n _executeBoost(user, market);\n _updateScore(user, market);\n }\n\n /**\n * @notice For claiming prime token when staking period is completed\n */\n function claim() external {\n uint256 userStakedAt = stakedAt[msg.sender];\n if (userStakedAt == 0) revert IneligibleToClaim();\n if (block.timestamp - userStakedAt < STAKING_PERIOD) revert WaitMoreTime();\n\n _mint(false, msg.sender);\n _initializeMarkets(msg.sender);\n }\n\n /**\n * @notice For burning any prime token\n * @param user the account address for which the prime token will be burned\n * @custom:access Controlled by ACM\n */\n function burn(address user) external {\n _checkAccessAllowed(\"burn(address)\");\n _burn(user);\n }\n\n /**\n * @notice To pause or unpause claiming of interest\n * @custom:access Controlled by ACM\n */\n function togglePause() external {\n _checkAccessAllowed(\"togglePause()\");\n if (paused()) {\n _unpause();\n } else {\n _pause();\n }\n }\n\n /**\n * @notice For user to claim boosted yield\n * @param vToken the market for which claim the accrued interest\n * @return amount the amount of tokens transferred to the msg.sender\n */\n function claimInterest(address vToken) external whenNotPaused returns (uint256) {\n return _claimInterest(vToken, msg.sender);\n }\n\n /**\n * @notice For user to claim boosted yield\n * @param vToken the market for which claim the accrued interest\n * @param user the user for which to claim the accrued interest\n * @return amount the amount of tokens transferred to the user\n */\n function claimInterest(address vToken, address user) external whenNotPaused returns (uint256) {\n return _claimInterest(vToken, user);\n }\n\n /**\n * @notice Retrieves an array of all available markets\n * @return an array of addresses representing all available markets\n */\n function getAllMarkets() external view returns (address[] memory) {\n return _allMarkets;\n }\n\n /**\n * @notice Retrieves the core pool comptroller address\n * @return the core pool comptroller address\n */\n function comptroller() external view returns (address) {\n return corePoolComptroller;\n }\n\n /**\n * @notice fetch the numbers of seconds remaining for staking period to complete\n * @param user the account address for which we are checking the remaining time\n * @return timeRemaining the number of seconds the user needs to wait to claim prime token\n */\n function claimTimeRemaining(address user) external view returns (uint256) {\n uint256 userStakedAt = stakedAt[user];\n if (userStakedAt == 0) return STAKING_PERIOD;\n\n uint256 totalTimeStaked;\n unchecked {\n totalTimeStaked = block.timestamp - userStakedAt;\n }\n\n if (totalTimeStaked < STAKING_PERIOD) {\n unchecked {\n return STAKING_PERIOD - totalTimeStaked;\n }\n }\n return 0;\n }\n\n /**\n * @notice Returns if user is a prime holder\n * @return isPrimeHolder true if user is a prime holder\n */\n function isUserPrimeHolder(address user) external view returns (bool) {\n return tokens[user].exists;\n }\n\n /**\n * @notice Returns supply and borrow APR for user for a given market\n * @param market the market for which to fetch the APR\n * @param user the account for which to get the APR\n * @return aprInfo APR information for the user for the given market\n */\n function calculateAPR(address market, address user) external view returns (APRInfo memory aprInfo) {\n IVToken vToken = IVToken(market);\n uint256 borrow = vToken.borrowBalanceStored(user);\n uint256 exchangeRate = vToken.exchangeRateStored();\n uint256 balanceOfAccount = vToken.balanceOf(user);\n uint256 supply = (exchangeRate * balanceOfAccount) / EXP_SCALE;\n\n aprInfo.userScore = interests[market][user].score;\n aprInfo.totalScore = markets[market].sumOfMembersScore;\n\n aprInfo.xvsBalanceForScore = _xvsBalanceForScore(_xvsBalanceOfUser(user));\n Capital memory capital = _capitalForScore(aprInfo.xvsBalanceForScore, borrow, supply, address(vToken));\n\n aprInfo.capital = capital.capital;\n aprInfo.cappedSupply = capital.cappedSupply;\n aprInfo.cappedBorrow = capital.cappedBorrow;\n aprInfo.supplyCapUSD = capital.supplyCapUSD;\n aprInfo.borrowCapUSD = capital.borrowCapUSD;\n\n (aprInfo.supplyAPR, aprInfo.borrowAPR) = _calculateUserAPR(\n market,\n supply,\n borrow,\n aprInfo.cappedSupply,\n aprInfo.cappedBorrow,\n aprInfo.userScore,\n aprInfo.totalScore\n );\n }\n\n /**\n * @notice Returns supply and borrow APR for estimated supply, borrow and XVS staked\n * @param market the market for which to fetch the APR\n * @param user the account for which to get the APR\n * @return aprInfo APR information for the user for the given market\n */\n function estimateAPR(\n address market,\n address user,\n uint256 borrow,\n uint256 supply,\n uint256 xvsStaked\n ) external view returns (APRInfo memory aprInfo) {\n aprInfo.totalScore = markets[market].sumOfMembersScore - interests[market][user].score;\n\n aprInfo.xvsBalanceForScore = _xvsBalanceForScore(xvsStaked);\n Capital memory capital = _capitalForScore(aprInfo.xvsBalanceForScore, borrow, supply, market);\n\n aprInfo.capital = capital.capital;\n aprInfo.cappedSupply = capital.cappedSupply;\n aprInfo.cappedBorrow = capital.cappedBorrow;\n aprInfo.supplyCapUSD = capital.supplyCapUSD;\n aprInfo.borrowCapUSD = capital.borrowCapUSD;\n\n uint256 decimals = IERC20MetadataUpgradeable(_getUnderlying(market)).decimals();\n aprInfo.capital = aprInfo.capital * (10 ** (18 - decimals));\n\n aprInfo.userScore = Scores._calculateScore(\n aprInfo.xvsBalanceForScore,\n aprInfo.capital,\n alphaNumerator,\n alphaDenominator\n );\n\n aprInfo.totalScore = aprInfo.totalScore + aprInfo.userScore;\n\n (aprInfo.supplyAPR, aprInfo.borrowAPR) = _calculateUserAPR(\n market,\n supply,\n borrow,\n aprInfo.cappedSupply,\n aprInfo.cappedBorrow,\n aprInfo.userScore,\n aprInfo.totalScore\n );\n }\n\n /**\n * @notice Distributes income from market since last distribution\n * @param vToken the market for which to distribute the income\n * @custom:error Throw MarketNotSupported if market is not supported\n */\n function accrueInterest(address vToken) public {\n Market storage market = markets[vToken];\n\n if (!market.exists) revert MarketNotSupported();\n\n address underlying = _getUnderlying(vToken);\n\n IPrimeLiquidityProvider _primeLiquidityProvider = IPrimeLiquidityProvider(primeLiquidityProvider);\n _primeLiquidityProvider.accrueTokens(underlying);\n uint256 totalAccruedInPLP = _primeLiquidityProvider.tokenAmountAccrued(underlying);\n uint256 unreleasedPLPAccruedInterest = totalAccruedInPLP - unreleasedPLPIncome[underlying];\n uint256 distributionIncome = unreleasedPLPAccruedInterest;\n\n if (distributionIncome == 0) {\n return;\n }\n\n unreleasedPLPIncome[underlying] = totalAccruedInPLP;\n\n uint256 delta;\n if (market.sumOfMembersScore != 0) {\n delta = ((distributionIncome * EXP_SCALE) / market.sumOfMembersScore);\n }\n\n market.rewardIndex += delta;\n }\n\n /**\n * @notice Returns boosted interest accrued for a user\n * @param vToken the market for which to fetch the accrued interest\n * @param user the account for which to get the accrued interest\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\n */\n function getInterestAccrued(address vToken, address user) public returns (uint256) {\n accrueInterest(vToken);\n\n return _interestAccrued(vToken, user);\n }\n\n /**\n * @notice accrues interest and updates score of all markets for an user\n * @param user the account address for which to accrue interest and update score\n */\n function _accrueInterestAndUpdateScore(address user) internal {\n address[] storage allMarkets = _allMarkets;\n uint256 marketsLength = allMarkets.length;\n\n for (uint256 i; i < marketsLength; ) {\n address market = allMarkets[i];\n _executeBoost(user, market);\n _updateScore(user, market);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Initializes all the markets for the user when a prime token is minted\n * @param account the account address for which markets needs to be initialized\n */\n function _initializeMarkets(address account) internal {\n address[] storage allMarkets = _allMarkets;\n uint256 marketsLength = allMarkets.length;\n\n for (uint256 i; i < marketsLength; ) {\n address market = allMarkets[i];\n accrueInterest(market);\n\n interests[market][account].rewardIndex = markets[market].rewardIndex;\n\n uint256 score = _calculateScore(market, account);\n interests[market][account].score = score;\n markets[market].sumOfMembersScore = markets[market].sumOfMembersScore + score;\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice calculate the current score of user\n * @param market the market for which to calculate the score\n * @param user the account for which to calculate the score\n * @return score the score of the user\n */\n function _calculateScore(address market, address user) internal returns (uint256) {\n uint256 xvsBalanceForScore = _xvsBalanceForScore(_xvsBalanceOfUser(user));\n\n IVToken vToken = IVToken(market);\n uint256 borrow = vToken.borrowBalanceStored(user);\n uint256 exchangeRate = vToken.exchangeRateStored();\n uint256 balanceOfAccount = vToken.balanceOf(user);\n uint256 supply = (exchangeRate * balanceOfAccount) / EXP_SCALE;\n\n address xvsToken = IXVSVault(xvsVault).xvsAddress();\n oracle.updateAssetPrice(xvsToken);\n oracle.updatePrice(market);\n\n Capital memory capital = _capitalForScore(xvsBalanceForScore, borrow, supply, market);\n\n uint256 decimals = IERC20MetadataUpgradeable(_getUnderlying(market)).decimals();\n\n capital.capital = capital.capital * (10 ** (18 - decimals));\n\n return Scores._calculateScore(xvsBalanceForScore, capital.capital, alphaNumerator, alphaDenominator);\n }\n\n /**\n * @notice To transfer the accrued interest to user\n * @param vToken the market for which to claim\n * @param user the account for which to get the accrued interest\n * @return amount the amount of tokens transferred to the user\n * @custom:event Emits InterestClaimed event\n */\n function _claimInterest(address vToken, address user) internal returns (uint256) {\n uint256 amount = getInterestAccrued(vToken, user);\n amount += interests[vToken][user].accrued;\n\n interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;\n delete interests[vToken][user].accrued;\n\n address underlying = _getUnderlying(vToken);\n IERC20Upgradeable asset = IERC20Upgradeable(underlying);\n\n if (amount > asset.balanceOf(address(this))) {\n delete unreleasedPLPIncome[underlying];\n IPrimeLiquidityProvider(primeLiquidityProvider).releaseFunds(address(asset));\n }\n\n asset.safeTransfer(user, amount);\n\n emit InterestClaimed(user, vToken, amount);\n\n return amount;\n }\n\n /**\n * @notice Used to mint a new prime token\n * @param isIrrevocable is the tokens being issued is irrevocable\n * @param user token owner\n * @custom:error Throw IneligibleToClaim if user is not eligible to claim prime token\n * @custom:event Emits Mint event\n */\n function _mint(bool isIrrevocable, address user) internal {\n Token storage token = tokens[user];\n if (token.exists) revert IneligibleToClaim();\n\n token.exists = true;\n token.isIrrevocable = isIrrevocable;\n\n if (isIrrevocable) {\n ++totalIrrevocable;\n } else {\n ++totalRevocable;\n }\n\n if (totalIrrevocable > irrevocableLimit || totalRevocable > revocableLimit) revert InvalidLimit();\n _updateRoundAfterTokenMinted(user);\n\n emit Mint(user, isIrrevocable);\n }\n\n /**\n * @notice Used to burn a new prime token\n * @param user owner whose prime token to burn\n * @custom:error Throw UserHasNoPrimeToken if user has no prime token\n * @custom:event Emits Burn event\n */\n function _burn(address user) internal {\n Token memory token = tokens[user];\n if (!token.exists) revert UserHasNoPrimeToken();\n\n address[] storage allMarkets = _allMarkets;\n uint256 marketsLength = allMarkets.length;\n\n for (uint256 i; i < marketsLength; ) {\n address market = allMarkets[i];\n _executeBoost(user, market);\n markets[market].sumOfMembersScore = markets[market].sumOfMembersScore - interests[market][user].score;\n\n delete interests[market][user].score;\n delete interests[market][user].rewardIndex;\n\n unchecked {\n ++i;\n }\n }\n\n if (token.isIrrevocable) {\n --totalIrrevocable;\n } else {\n --totalRevocable;\n }\n\n delete tokens[user].exists;\n delete tokens[user].isIrrevocable;\n\n _updateRoundAfterTokenBurned(user);\n\n emit Burn(user);\n }\n\n /**\n * @notice Used to upgrade an token\n * @param user owner whose prime token to upgrade\n * @custom:error Throw InvalidLimit if total irrevocable tokens exceeds the limit\n * @custom:event Emits TokenUpgraded event\n */\n function _upgrade(address user) internal {\n Token storage userToken = tokens[user];\n\n userToken.isIrrevocable = true;\n ++totalIrrevocable;\n --totalRevocable;\n\n if (totalIrrevocable > irrevocableLimit) revert InvalidLimit();\n\n emit TokenUpgraded(user);\n }\n\n /**\n * @notice Accrue rewards for the user. Must be called before updating score\n * @param user account for which we need to accrue rewards\n * @param vToken the market for which we need to accrue rewards\n */\n function _executeBoost(address user, address vToken) internal {\n if (!markets[vToken].exists || !tokens[user].exists) {\n return;\n }\n\n accrueInterest(vToken);\n interests[vToken][user].accrued += _interestAccrued(vToken, user);\n interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;\n }\n\n /**\n * @notice Update total score of user and market. Must be called after changing account's borrow or supply balance.\n * @param user account for which we need to update score\n * @param market the market for which we need to score\n */\n function _updateScore(address user, address market) internal {\n Market storage _market = markets[market];\n if (!_market.exists || !tokens[user].exists) {\n return;\n }\n\n uint256 score = _calculateScore(market, user);\n _market.sumOfMembersScore = _market.sumOfMembersScore - interests[market][user].score + score;\n\n interests[market][user].score = score;\n }\n\n /**\n * @notice Verify new alpha arguments\n * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1\n * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2\n * @custom:error Throw InvalidAlphaArguments if alpha is invalid\n */\n function _checkAlphaArguments(uint128 _alphaNumerator, uint128 _alphaDenominator) internal pure {\n if (_alphaNumerator >= _alphaDenominator || _alphaNumerator == 0) {\n revert InvalidAlphaArguments();\n }\n }\n\n /**\n * @notice starts round to update scores of a particular or all markets\n */\n function _startScoreUpdateRound() internal {\n nextScoreUpdateRoundId++;\n totalScoreUpdatesRequired = totalIrrevocable + totalRevocable;\n pendingScoreUpdates = totalScoreUpdatesRequired;\n }\n\n /**\n * @notice update the required score updates when token is burned before round is completed\n */\n function _updateRoundAfterTokenBurned(address user) internal {\n if (totalScoreUpdatesRequired != 0) --totalScoreUpdatesRequired;\n\n if (pendingScoreUpdates != 0 && !isScoreUpdated[nextScoreUpdateRoundId][user]) {\n --pendingScoreUpdates;\n }\n }\n\n /**\n * @notice update the required score updates when token is minted before round is completed\n */\n function _updateRoundAfterTokenMinted(address user) internal {\n if (totalScoreUpdatesRequired != 0) isScoreUpdated[nextScoreUpdateRoundId][user] = true;\n }\n\n /**\n * @notice fetch the current XVS balance of user in the XVSVault\n * @param user the account address\n * @return xvsBalance the XVS balance of user\n */\n function _xvsBalanceOfUser(address user) internal view returns (uint256) {\n (uint256 xvs, , uint256 pendingWithdrawals) = IXVSVault(xvsVault).getUserInfo(\n xvsVaultRewardToken,\n xvsVaultPoolId,\n user\n );\n return (xvs - pendingWithdrawals);\n }\n\n /**\n * @notice calculate the current XVS balance that will be used in calculation of score\n * @param xvs the actual XVS balance of user\n * @return xvsBalanceForScore the XVS balance to use in score\n */\n function _xvsBalanceForScore(uint256 xvs) internal view returns (uint256) {\n if (xvs > MAXIMUM_XVS_CAP) {\n return MAXIMUM_XVS_CAP;\n }\n return xvs;\n }\n\n /**\n * @notice calculate the capital for calculation of score\n * @param xvs the actual XVS balance of user\n * @param borrow the borrow balance of user\n * @param supply the supply balance of user\n * @param market the market vToken address\n * @return capital the capital to use in calculation of score\n */\n function _capitalForScore(\n uint256 xvs,\n uint256 borrow,\n uint256 supply,\n address market\n ) internal view returns (Capital memory capital) {\n address xvsToken = IXVSVault(xvsVault).xvsAddress();\n\n uint256 xvsPrice = oracle.getPrice(xvsToken);\n capital.borrowCapUSD = (xvsPrice * ((xvs * markets[market].borrowMultiplier) / EXP_SCALE)) / EXP_SCALE;\n capital.supplyCapUSD = (xvsPrice * ((xvs * markets[market].supplyMultiplier) / EXP_SCALE)) / EXP_SCALE;\n\n uint256 tokenPrice = oracle.getUnderlyingPrice(market);\n uint256 supplyUSD = (tokenPrice * supply) / EXP_SCALE;\n uint256 borrowUSD = (tokenPrice * borrow) / EXP_SCALE;\n\n if (supplyUSD >= capital.supplyCapUSD) {\n supply = supplyUSD != 0 ? (supply * capital.supplyCapUSD) / supplyUSD : 0;\n }\n\n if (borrowUSD >= capital.borrowCapUSD) {\n borrow = borrowUSD != 0 ? (borrow * capital.borrowCapUSD) / borrowUSD : 0;\n }\n\n capital.capital = supply + borrow;\n capital.cappedSupply = supply;\n capital.cappedBorrow = borrow;\n }\n\n /**\n * @notice Used to get if the XVS balance is eligible for prime token\n * @param amount amount of XVS\n * @return isEligible true if the staked XVS amount is enough to consider the associated user eligible for a Prime token, false otherwise\n */\n function _isEligible(uint256 amount) internal view returns (bool) {\n if (amount >= MINIMUM_STAKED_XVS) {\n return true;\n }\n\n return false;\n }\n\n /**\n * @notice Calculate the interests accrued by the user in the market, since the last accrual\n * @param vToken the market for which to calculate the accrued interest\n * @param user the user for which to calculate the accrued interest\n * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual\n */\n function _interestAccrued(address vToken, address user) internal view returns (uint256) {\n Interest memory interest = interests[vToken][user];\n uint256 index = markets[vToken].rewardIndex - interest.rewardIndex;\n\n uint256 score = interest.score;\n\n return (index * score) / EXP_SCALE;\n }\n\n /**\n * @notice Returns the underlying token associated with the VToken, or wrapped native token if the market is native market\n * @param vToken the market whose underlying token will be returned\n * @return underlying The address of the underlying token associated with the VToken, or the address of the WRAPPED_NATIVE_TOKEN token if the market is NATIVE_MARKET\n */\n function _getUnderlying(address vToken) internal view returns (address) {\n if (vToken == NATIVE_MARKET) {\n return WRAPPED_NATIVE_TOKEN;\n }\n return IVToken(vToken).underlying();\n }\n\n //////////////////////////////////////////////////\n //////////////// APR Calculation ////////////////\n ////////////////////////////////////////////////\n\n /**\n * @notice the total income that's going to be distributed in a year to prime token holders\n * @param vToken the market for which to fetch the total income that's going to distributed in a year\n * @return amount the total income\n */\n function incomeDistributionYearly(address vToken) public view returns (uint256 amount) {\n uint256 totalIncomePerBlockOrSecondFromPLP = IPrimeLiquidityProvider(primeLiquidityProvider)\n .getEffectiveDistributionSpeed(_getUnderlying(vToken));\n amount = blocksOrSecondsPerYear * totalIncomePerBlockOrSecondFromPLP;\n }\n\n /**\n * @notice used to calculate the supply and borrow APR of the user\n * @param vToken the market for which to fetch the APR\n * @param totalSupply the total token supply of the user\n * @param totalBorrow the total tokens borrowed by the user\n * @param totalCappedSupply the total token capped supply of the user\n * @param totalCappedBorrow the total capped tokens borrowed by the user\n * @param userScore the score of the user\n * @param totalScore the total market score\n * @return supplyAPR the supply APR of the user\n * @return borrowAPR the borrow APR of the user\n */\n function _calculateUserAPR(\n address vToken,\n uint256 totalSupply,\n uint256 totalBorrow,\n uint256 totalCappedSupply,\n uint256 totalCappedBorrow,\n uint256 userScore,\n uint256 totalScore\n ) internal view returns (uint256 supplyAPR, uint256 borrowAPR) {\n if (totalScore == 0) return (0, 0);\n\n uint256 userYearlyIncome = (userScore * incomeDistributionYearly(vToken)) / totalScore;\n\n uint256 totalCappedValue = totalCappedSupply + totalCappedBorrow;\n\n if (totalCappedValue == 0) return (0, 0);\n\n uint256 maximumBps = MAXIMUM_BPS;\n uint256 userSupplyIncomeYearly;\n uint256 userBorrowIncomeYearly;\n userSupplyIncomeYearly = (userYearlyIncome * totalCappedSupply) / totalCappedValue;\n userBorrowIncomeYearly = (userYearlyIncome * totalCappedBorrow) / totalCappedValue;\n supplyAPR = totalSupply == 0 ? 0 : ((userSupplyIncomeYearly * maximumBps) / totalSupply);\n borrowAPR = totalBorrow == 0 ? 0 : ((userBorrowIncomeYearly * maximumBps) / totalBorrow);\n }\n}\n" + }, + "contracts/Tokens/Prime/PrimeLiquidityProvider.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { PrimeLiquidityProviderStorageV1 } from \"./PrimeLiquidityProviderStorage.sol\";\nimport { SafeERC20Upgradeable, IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { AccessControlledV8 } from \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport { PausableUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport { IPrimeLiquidityProvider } from \"./Interfaces/IPrimeLiquidityProvider.sol\";\nimport { MaxLoopsLimitHelper } from \"@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol\";\nimport { TimeManagerV8 } from \"@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol\";\n\n/**\n * @title PrimeLiquidityProvider\n * @author Venus\n * @notice PrimeLiquidityProvider is used to fund Prime\n */\ncontract PrimeLiquidityProvider is\n IPrimeLiquidityProvider,\n AccessControlledV8,\n PausableUpgradeable,\n MaxLoopsLimitHelper,\n PrimeLiquidityProviderStorageV1,\n TimeManagerV8\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /// @notice The default max token distribution speed\n uint256 public constant DEFAULT_MAX_DISTRIBUTION_SPEED = 1e18;\n\n /// @notice Emitted when a token distribution is initialized\n event TokenDistributionInitialized(address indexed token);\n\n /// @notice Emitted when a new token distribution speed is set\n event TokenDistributionSpeedUpdated(address indexed token, uint256 oldSpeed, uint256 newSpeed);\n\n /// @notice Emitted when a new max distribution speed for token is set\n event MaxTokenDistributionSpeedUpdated(address indexed token, uint256 oldSpeed, uint256 newSpeed);\n\n /// @notice Emitted when prime token contract address is changed\n event PrimeTokenUpdated(address indexed oldPrimeToken, address indexed newPrimeToken);\n\n /// @notice Emitted when distribution state(Index and block or second) is updated\n event TokensAccrued(address indexed token, uint256 amount);\n\n /// @notice Emitted when token is transferred to the prime contract\n event TokenTransferredToPrime(address indexed token, uint256 amount);\n\n /// @notice Emitted on sweep token success\n event SweepToken(address indexed token, address indexed to, uint256 sweepAmount);\n\n /// @notice Thrown when arguments are passed are invalid\n error InvalidArguments();\n\n /// @notice Thrown when distribution speed is greater than maxTokenDistributionSpeeds[tokenAddress]\n error InvalidDistributionSpeed(uint256 speed, uint256 maxSpeed);\n\n /// @notice Thrown when caller is not the desired caller\n error InvalidCaller();\n\n /// @notice Thrown when token is initialized\n error TokenAlreadyInitialized(address token);\n\n ///@notice Error thrown when PrimeLiquidityProvider's balance is less than sweep amount\n error InsufficientBalance(uint256 sweepAmount, uint256 balance);\n\n /// @notice Error thrown when funds transfer is paused\n error FundsTransferIsPaused();\n\n /// @notice Error thrown when accrueTokens is called for an uninitialized token\n error TokenNotInitialized(address token_);\n\n /// @notice Error thrown when argument value in setter is same as previous value\n error AddressesMustDiffer();\n\n /**\n * @notice Compares two addresses to ensure they are different\n * @param oldAddress The original address to compare\n * @param newAddress The new address to compare\n */\n modifier compareAddress(address oldAddress, address newAddress) {\n if (newAddress == oldAddress) {\n revert AddressesMustDiffer();\n }\n _;\n }\n\n /**\n * @notice Prime Liquidity Provider constructor\n * @param _timeBased A boolean indicating whether the contract is based on time or block.\n * @param _blocksPerYear total blocks per year\n */\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(bool _timeBased, uint256 _blocksPerYear) TimeManagerV8(_timeBased, _blocksPerYear) {\n _disableInitializers();\n }\n\n /**\n * @notice PrimeLiquidityProvider initializer\n * @dev Initializes the deployer to owner\n * @param accessControlManager_ AccessControlManager contract address\n * @param tokens_ Array of addresses of the tokens\n * @param distributionSpeeds_ New distribution speeds for tokens\n * @param loopsLimit_ Maximum number of loops allowed in a single transaction\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\n */\n function initialize(\n address accessControlManager_,\n address[] calldata tokens_,\n uint256[] calldata distributionSpeeds_,\n uint256[] calldata maxDistributionSpeeds_,\n uint256 loopsLimit_\n ) external initializer {\n _ensureZeroAddress(accessControlManager_);\n\n __AccessControlled_init(accessControlManager_);\n __Pausable_init();\n _setMaxLoopsLimit(loopsLimit_);\n\n uint256 numTokens = tokens_.length;\n _ensureMaxLoops(numTokens);\n\n if ((numTokens != distributionSpeeds_.length) || (numTokens != maxDistributionSpeeds_.length)) {\n revert InvalidArguments();\n }\n\n for (uint256 i; i < numTokens; ) {\n _initializeToken(tokens_[i]);\n _setMaxTokenDistributionSpeed(tokens_[i], maxDistributionSpeeds_[i]);\n _setTokenDistributionSpeed(tokens_[i], distributionSpeeds_[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Initialize the distribution of the token\n * @param tokens_ Array of addresses of the tokens to be intialized\n * @custom:access Only Governance\n */\n function initializeTokens(address[] calldata tokens_) external onlyOwner {\n uint256 tokensLength = tokens_.length;\n _ensureMaxLoops(tokensLength);\n\n for (uint256 i; i < tokensLength; ) {\n _initializeToken(tokens_[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Pause fund transfer of tokens to Prime contract\n * @custom:access Controlled by ACM\n */\n function pauseFundsTransfer() external {\n _checkAccessAllowed(\"pauseFundsTransfer()\");\n _pause();\n }\n\n /**\n * @notice Resume fund transfer of tokens to Prime contract\n * @custom:access Controlled by ACM\n */\n function resumeFundsTransfer() external {\n _checkAccessAllowed(\"resumeFundsTransfer()\");\n _unpause();\n }\n\n /**\n * @notice Set distribution speed (amount of token distribute per block or second)\n * @param tokens_ Array of addresses of the tokens\n * @param distributionSpeeds_ New distribution speeds for tokens\n * @custom:access Controlled by ACM\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\n */\n function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external {\n _checkAccessAllowed(\"setTokensDistributionSpeed(address[],uint256[])\");\n uint256 numTokens = tokens_.length;\n _ensureMaxLoops(numTokens);\n\n if (numTokens != distributionSpeeds_.length) {\n revert InvalidArguments();\n }\n\n for (uint256 i; i < numTokens; ) {\n _ensureTokenInitialized(tokens_[i]);\n _setTokenDistributionSpeed(tokens_[i], distributionSpeeds_[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)\n * @param tokens_ Array of addresses of the tokens\n * @param maxDistributionSpeeds_ New distribution speeds for tokens\n * @custom:access Controlled by ACM\n * @custom:error Throw InvalidArguments on different length of tokens and speeds array\n */\n function setMaxTokensDistributionSpeed(\n address[] calldata tokens_,\n uint256[] calldata maxDistributionSpeeds_\n ) external {\n _checkAccessAllowed(\"setMaxTokensDistributionSpeed(address[],uint256[])\");\n uint256 numTokens = tokens_.length;\n _ensureMaxLoops(numTokens);\n\n if (numTokens != maxDistributionSpeeds_.length) {\n revert InvalidArguments();\n }\n\n for (uint256 i; i < numTokens; ) {\n _setMaxTokenDistributionSpeed(tokens_[i], maxDistributionSpeeds_[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @notice Set the prime token contract address\n * @param prime_ The new address of the prime token contract\n * @custom:event Emits PrimeTokenUpdated event\n * @custom:access Only owner\n */\n function setPrimeToken(address prime_) external onlyOwner compareAddress(prime, prime_) {\n _ensureZeroAddress(prime_);\n\n emit PrimeTokenUpdated(prime, prime_);\n prime = prime_;\n }\n\n /**\n * @notice Set the limit for the loops can iterate to avoid the DOS\n * @param loopsLimit Limit for the max loops can execute at a time\n * @custom:event Emits MaxLoopsLimitUpdated event on success\n * @custom:access Controlled by ACM\n */\n function setMaxLoopsLimit(uint256 loopsLimit) external {\n _checkAccessAllowed(\"setMaxLoopsLimit(uint256)\");\n _setMaxLoopsLimit(loopsLimit);\n }\n\n /**\n * @notice Claim all the token accrued till last block or second\n * @param token_ The token to release to the Prime contract\n * @custom:event Emits TokenTransferredToPrime event\n * @custom:error Throw InvalidArguments on Zero address(token)\n * @custom:error Throw FundsTransferIsPaused is paused\n * @custom:error Throw InvalidCaller if the sender is not the Prime contract\n */\n function releaseFunds(address token_) external {\n address _prime = prime;\n if (msg.sender != _prime) revert InvalidCaller();\n if (paused()) {\n revert FundsTransferIsPaused();\n }\n\n accrueTokens(token_);\n uint256 accruedAmount = _tokenAmountAccrued[token_];\n delete _tokenAmountAccrued[token_];\n\n emit TokenTransferredToPrime(token_, accruedAmount);\n\n IERC20Upgradeable(token_).safeTransfer(_prime, accruedAmount);\n }\n\n /**\n * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user\n * @param token_ The address of the ERC-20 token to sweep\n * @param to_ The address of the recipient\n * @param amount_ The amount of tokens needs to transfer\n * @custom:event Emits SweepToken event\n * @custom:error Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract\n * @custom:access Only Governance\n */\n function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external onlyOwner {\n uint256 balance = token_.balanceOf(address(this));\n if (amount_ > balance) {\n revert InsufficientBalance(amount_, balance);\n }\n\n emit SweepToken(address(token_), to_, amount_);\n\n token_.safeTransfer(to_, amount_);\n }\n\n /**\n * @notice Get rewards per block or second for token\n * @param token_ Address of the token\n * @return speed returns the per block or second reward\n */\n function getEffectiveDistributionSpeed(address token_) external view returns (uint256) {\n uint256 distributionSpeed = tokenDistributionSpeeds[token_];\n uint256 balance = IERC20Upgradeable(token_).balanceOf(address(this));\n uint256 accrued = _tokenAmountAccrued[token_];\n\n if (balance > accrued) {\n return distributionSpeed;\n }\n\n return 0;\n }\n\n /**\n * @notice Accrue token by updating the distribution state\n * @param token_ Address of the token\n * @custom:event Emits TokensAccrued event\n */\n function accrueTokens(address token_) public {\n _ensureZeroAddress(token_);\n\n _ensureTokenInitialized(token_);\n\n uint256 blockNumberOrSecond = getBlockNumberOrTimestamp();\n uint256 deltaBlocksOrSeconds;\n unchecked {\n deltaBlocksOrSeconds = blockNumberOrSecond - lastAccruedBlockOrSecond[token_];\n }\n\n if (deltaBlocksOrSeconds != 0) {\n uint256 distributionSpeed = tokenDistributionSpeeds[token_];\n uint256 balance = IERC20Upgradeable(token_).balanceOf(address(this));\n\n uint256 balanceDiff = balance - _tokenAmountAccrued[token_];\n if (distributionSpeed != 0 && balanceDiff != 0) {\n uint256 accruedSinceUpdate = deltaBlocksOrSeconds * distributionSpeed;\n uint256 tokenAccrued = (balanceDiff <= accruedSinceUpdate ? balanceDiff : accruedSinceUpdate);\n\n _tokenAmountAccrued[token_] += tokenAccrued;\n emit TokensAccrued(token_, tokenAccrued);\n }\n\n lastAccruedBlockOrSecond[token_] = blockNumberOrSecond;\n }\n }\n\n /**\n * @notice Get the last accrued block or second for token\n * @param token_ Address of the token\n * @return blockNumberOrSecond returns the last accrued block or second\n */\n function lastAccruedBlock(address token_) external view returns (uint256) {\n return lastAccruedBlockOrSecond[token_];\n }\n\n /**\n * @notice Get the tokens accrued\n * @param token_ Address of the token\n * @return returns the amount of accrued tokens for the token provided\n */\n function tokenAmountAccrued(address token_) external view returns (uint256) {\n return _tokenAmountAccrued[token_];\n }\n\n /**\n * @notice Initialize the distribution of the token\n * @param token_ Address of the token to be intialized\n * @custom:event Emits TokenDistributionInitialized event\n * @custom:error Throw TokenAlreadyInitialized if token is already initialized\n */\n function _initializeToken(address token_) internal {\n _ensureZeroAddress(token_);\n uint256 blockNumberOrSecond = getBlockNumberOrTimestamp();\n uint256 initializedBlockOrSecond = lastAccruedBlockOrSecond[token_];\n\n if (initializedBlockOrSecond != 0) {\n revert TokenAlreadyInitialized(token_);\n }\n\n /*\n * Update token state block number or second\n */\n lastAccruedBlockOrSecond[token_] = blockNumberOrSecond;\n\n emit TokenDistributionInitialized(token_);\n }\n\n /**\n * @notice Set distribution speed (amount of token distribute per block or second)\n * @param token_ Address of the token\n * @param distributionSpeed_ New distribution speed for token\n * @custom:event Emits TokenDistributionSpeedUpdated event\n * @custom:error Throw InvalidDistributionSpeed if speed is greater than max speed\n */\n function _setTokenDistributionSpeed(address token_, uint256 distributionSpeed_) internal {\n uint256 maxDistributionSpeed = maxTokenDistributionSpeeds[token_];\n if (maxDistributionSpeed == 0) {\n maxTokenDistributionSpeeds[token_] = maxDistributionSpeed = DEFAULT_MAX_DISTRIBUTION_SPEED;\n }\n\n if (distributionSpeed_ > maxDistributionSpeed) {\n revert InvalidDistributionSpeed(distributionSpeed_, maxDistributionSpeed);\n }\n\n uint256 oldDistributionSpeed = tokenDistributionSpeeds[token_];\n if (oldDistributionSpeed != distributionSpeed_) {\n // Distribution speed updated so let's update distribution state to ensure that\n // 1. Token accrued properly for the old speed, and\n // 2. Token accrued at the new speed starts after this block or second.\n accrueTokens(token_);\n\n // Update speed\n tokenDistributionSpeeds[token_] = distributionSpeed_;\n\n emit TokenDistributionSpeedUpdated(token_, oldDistributionSpeed, distributionSpeed_);\n }\n }\n\n /**\n * @notice Set max distribution speed (amount of maximum token distribute per block or second)\n * @param token_ Address of the token\n * @param maxDistributionSpeed_ New max distribution speed for token\n * @custom:event Emits MaxTokenDistributionSpeedUpdated event\n */\n function _setMaxTokenDistributionSpeed(address token_, uint256 maxDistributionSpeed_) internal {\n emit MaxTokenDistributionSpeedUpdated(token_, tokenDistributionSpeeds[token_], maxDistributionSpeed_);\n maxTokenDistributionSpeeds[token_] = maxDistributionSpeed_;\n }\n\n /**\n * @notice Revert on non initialized token\n * @param token_ Token Address to be verified for\n */\n function _ensureTokenInitialized(address token_) internal view {\n uint256 lastBlockOrSecondAccrued = lastAccruedBlockOrSecond[token_];\n\n if (lastBlockOrSecondAccrued == 0) {\n revert TokenNotInitialized(token_);\n }\n }\n\n /**\n * @notice Revert on zero address\n * @param address_ Address to be verified\n */\n function _ensureZeroAddress(address address_) internal pure {\n if (address_ == address(0)) {\n revert InvalidArguments();\n }\n }\n}\n" + }, + "contracts/Tokens/Prime/PrimeLiquidityProviderStorage.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/**\n * @title PrimeLiquidityProviderStorageV1\n * @author Venus\n * @notice Storage for Prime Liquidity Provider\n */\ncontract PrimeLiquidityProviderStorageV1 {\n /// @notice Address of the Prime contract\n address public prime;\n\n /// @notice The rate at which token is distributed (per block or second)\n mapping(address => uint256) public tokenDistributionSpeeds;\n\n /// @notice The max token distribution speed for token\n mapping(address => uint256) public maxTokenDistributionSpeeds;\n\n /// @notice The block or second till which rewards are distributed for an asset\n mapping(address => uint256) public lastAccruedBlockOrSecond;\n\n /// @notice The token accrued but not yet transferred to prime contract\n mapping(address => uint256) internal _tokenAmountAccrued;\n\n /// @dev This empty reserved space is put in place to allow future versions to add new\n /// variables without shifting down storage in the inheritance chain.\n uint256[45] private __gap;\n}\n" + }, + "contracts/Tokens/Prime/PrimeStorage.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { ResilientOracleInterface } from \"@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol\";\n\n/**\n * @title PrimeStorageV1\n * @author Venus\n * @notice Storage for Prime Token\n */\ncontract PrimeStorageV1 {\n struct Token {\n bool exists;\n bool isIrrevocable;\n }\n\n struct Market {\n uint256 supplyMultiplier;\n uint256 borrowMultiplier;\n uint256 rewardIndex;\n uint256 sumOfMembersScore;\n bool exists;\n }\n\n struct Interest {\n uint256 accrued;\n uint256 score;\n uint256 rewardIndex;\n }\n\n struct PendingReward {\n address vToken;\n address rewardToken;\n uint256 amount;\n }\n\n /// @notice Base unit for computations, usually used in scaling (multiplications, divisions)\n uint256 internal constant EXP_SCALE = 1e18;\n\n /// @notice maximum BPS = 100%\n uint256 internal constant MAXIMUM_BPS = 1e4;\n\n /// @notice Mapping to get prime token's metadata\n mapping(address => Token) public tokens;\n\n /// @notice Tracks total irrevocable tokens minted\n uint256 public totalIrrevocable;\n\n /// @notice Tracks total revocable tokens minted\n uint256 public totalRevocable;\n\n /// @notice Indicates maximum revocable tokens that can be minted\n uint256 public revocableLimit;\n\n /// @notice Indicates maximum irrevocable tokens that can be minted\n uint256 public irrevocableLimit;\n\n /// @notice Tracks when prime token eligible users started staking for claiming prime token\n mapping(address => uint256) public stakedAt;\n\n /// @notice vToken to market configuration\n mapping(address => Market) public markets;\n\n /// @notice vToken to user to user index\n mapping(address => mapping(address => Interest)) public interests;\n\n /// @notice A list of boosted markets\n address[] internal _allMarkets;\n\n /// @notice numerator of alpha. Ex: if alpha is 0.5 then this will be 1\n uint128 public alphaNumerator;\n\n /// @notice denominator of alpha. Ex: if alpha is 0.5 then this will be 2\n uint128 public alphaDenominator;\n\n /// @notice address of XVS vault\n address public xvsVault;\n\n /// @notice address of XVS vault reward token\n address public xvsVaultRewardToken;\n\n /// @notice address of XVS vault pool id\n uint256 public xvsVaultPoolId;\n\n /// @notice mapping to check if a account's score was updated in the round\n mapping(uint256 => mapping(address => bool)) public isScoreUpdated;\n\n /// @notice unique id for next round\n uint256 public nextScoreUpdateRoundId;\n\n /// @notice total number of accounts whose score needs to be updated\n uint256 public totalScoreUpdatesRequired;\n\n /// @notice total number of accounts whose score is yet to be updated\n uint256 public pendingScoreUpdates;\n\n /// @notice mapping used to find if an asset is part of prime markets\n mapping(address => address) public vTokenForAsset;\n\n /// @notice Address of core pool comptroller contract\n address internal corePoolComptroller;\n\n /// @notice unreleased income from PLP that's already distributed to prime holders\n /// @dev mapping of asset address => amount\n mapping(address => uint256) public unreleasedPLPIncome;\n\n /// @notice The address of PLP contract\n address public primeLiquidityProvider;\n\n /// @notice The address of ResilientOracle contract\n ResilientOracleInterface public oracle;\n\n /// @notice The address of PoolRegistry contract\n address public poolRegistry;\n\n /// @dev This empty reserved space is put in place to allow future versions to add new\n /// variables without shifting down storage in the inheritance chain.\n uint256[26] private __gap;\n}\n" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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 (address initialOwner) {\n _transferOwnership(initialOwner);\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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 virtual 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(Address.isContract(IBeacon(newBeacon).implementation()), \"ERC1967: beacon implementation is not a contract\");\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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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 overriden 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 internall 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 overriden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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 constructor (address initialOwner) Ownable(initialOwner) {}\n\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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/openzeppelin/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" + }, + "hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../openzeppelin/proxy/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 OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\n address internal immutable _ADMIN;\n\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 _ADMIN = admin_;\n\n // still store it to work with EIP-1967\n bytes32 slot = _ADMIN_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, admin_)\n }\n emit AdminChanged(address(0), 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 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 function _getAdmin() internal view virtual override returns (address) {\n return _ADMIN;\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "storageLayout", + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} diff --git a/deployments/opsepolia_addresses.json b/deployments/opsepolia_addresses.json index 7f2635eba..86e09e60f 100644 --- a/deployments/opsepolia_addresses.json +++ b/deployments/opsepolia_addresses.json @@ -2,6 +2,16 @@ "name": "opsepolia", "chainId": "11155420", "addresses": { - "VTreasuryV8": "0x5A1a12F47FA7007C9e23cf5e025F3f5d3aC7d755" + "DefaultProxyAdmin": "0xa9aaf2A1cCf2C3a87997942abaA740887cC89241", + "Prime": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "PrimeLiquidityProvider": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "PrimeLiquidityProvider_Implementation": "0x66aaabFb90852D16e419aB739a64bFa3b5B0a16f", + "PrimeLiquidityProvider_Proxy": "0xE3EC955b94D197a8e4081844F3f25F81047A9AF5", + "Prime_Implementation": "0x84cca3c7719d1F9c35b5cfF14BE05801B8fD69d7", + "Prime_Proxy": "0x54dEb59698c628be5EEd5AD41Fd825Eb3Be89704", + "VTreasuryV8": "0x5A1a12F47FA7007C9e23cf5e025F3f5d3aC7d755", + "XVSStore": "0xE888FA54b32BfaD3cE0e3C7D566EFe809a6A0143", + "XVSVaultProxy": "0x4d344e48F02234E82D7D1dB84d0A4A18Aa43Dacc", + "XVSVaultProxy_Implementation": "0x7A02458c1c1504Abf37160401A5020ED003ba347" } } diff --git a/deployments/xlayermainnet.json b/deployments/xlayermainnet.json deleted file mode 100644 index 89390d028..000000000 --- a/deployments/xlayermainnet.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "xlayermainnet", - "chainId": "196", - "contracts": {} -} diff --git a/deployments/xlayermainnet_addresses.json b/deployments/xlayermainnet_addresses.json deleted file mode 100644 index fd900a922..000000000 --- a/deployments/xlayermainnet_addresses.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "xlayermainnet", - "chainId": "196", - "addresses": {} -} diff --git a/deployments/xlayertestnet.json b/deployments/xlayertestnet.json deleted file mode 100644 index 60f0254a7..000000000 --- a/deployments/xlayertestnet.json +++ /dev/null @@ -1,200 +0,0 @@ -{ - "name": "xlayertestnet", - "chainId": "195", - "contracts": { - "VTreasuryV8": { - "address": "0x740aF73D4AB6300dc4c8D707a424EFC5f1bd04DA", - "abi": [ - { - "inputs": [], - "name": "ZeroAddressNotAllowed", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferStarted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "withdrawAddress", - "type": "address" - } - ], - "name": "WithdrawTreasuryNative", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "tokenAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "withdrawAddress", - "type": "address" - } - ], - "name": "WithdrawTreasuryToken", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "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": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - }, - { - "internalType": "address payable", - "name": "withdrawAddress", - "type": "address" - } - ], - "name": "withdrawTreasuryNative", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "withdrawAddress", - "type": "address" - } - ], - "name": "withdrawTreasuryToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ] - } - } -} diff --git a/deployments/xlayertestnet/.chainId b/deployments/xlayertestnet/.chainId deleted file mode 100644 index a0b994e37..000000000 --- a/deployments/xlayertestnet/.chainId +++ /dev/null @@ -1 +0,0 @@ -195 \ No newline at end of file diff --git a/deployments/xlayertestnet_addresses.json b/deployments/xlayertestnet_addresses.json deleted file mode 100644 index f70c40d73..000000000 --- a/deployments/xlayertestnet_addresses.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "xlayertestnet", - "chainId": "195", - "addresses": { - "VTreasuryV8": "0x740aF73D4AB6300dc4c8D707a424EFC5f1bd04DA" - } -} diff --git a/hardhat.config.ts b/hardhat.config.ts index a0d6ff6ed..6f11c3775 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -61,6 +61,11 @@ extendConfig((config: HardhatConfig) => { "node_modules/@venusprotocol/oracle/deployments/arbitrumone", "node_modules/@venusprotocol/token-bridge/deployments/arbitrumone", ], + opsepolia: [ + "node_modules/@venusprotocol/governance-contracts/deployments/opsepolia", + "node_modules/@venusprotocol/oracle/deployments/opsepolia", + "node_modules/@venusprotocol/token-bridge/deployments/opsepolia", + ], }, }; } @@ -190,18 +195,6 @@ const config: HardhatUserConfig = { live: true, accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [], }, - xlayertestnet: { - url: process.env.ARCHIVE_NODE_xlayertestnet || "https://testrpc.xlayer.tech/", - chainId: 195, - live: true, - accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [], - }, - xlayermainnet: { - url: process.env.ARCHIVE_NODE_xlayermainnet || "https://rpc.xlayer.tech/", - chainId: 196, - live: true, - accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [], - }, opsepolia: { url: process.env.ARCHIVE_NODE_opsepolia || "https://sepolia.optimism.io", chainId: 11155420, @@ -225,8 +218,6 @@ const config: HardhatUserConfig = { opbnbmainnet: process.env.ETHERSCAN_API_KEY || "ETHERSCAN_API_KEY", arbitrumsepolia: process.env.ETHERSCAN_API_KEY || "ETHERSCAN_API_KEY", arbitrumone: process.env.ETHERSCAN_API_KEY || "ETHERSCAN_API_KEY", - xlayertestnet: process.env.ETHERSCAN_API_KEY || "ETHERSCAN_API_KEY", - xlayermainnet: process.env.ETHERSCAN_API_KEY || "ETHERSCAN_API_KEY", opsepolia: process.env.ETHERSCAN_API_KEY || "ETHERSCAN_API_KEY", opmainnet: process.env.ETHERSCAN_API_KEY || "ETHERSCAN_API_KEY", }, @@ -295,22 +286,6 @@ const config: HardhatUserConfig = { browserURL: "https://arbiscan.io/", }, }, - { - network: "xlayertestnet", - chainId: 195, - urls: { - apiURL: "https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/XLAYER_TESTNET", - browserURL: "https://www.oklink.com/xlayer-test", - }, - }, - { - network: "xlayermainnet", - chainId: 196, - urls: { - apiURL: "https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/XLAYER", - browserURL: "https://www.oklink.com/xlayer", - }, - }, { network: "opsepolia", chainId: 11155420, diff --git a/package.json b/package.json index 6a828c346..504c95728 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@venusprotocol/venus-protocol", - "version": "9.2.0", + "version": "9.3.0-dev.6", "description": "The Venus Money Market", "repository": "git@github.com:VenusProtocol/venus-protocol.git", "author": "Venus", @@ -34,10 +34,10 @@ "@nomicfoundation/hardhat-ethers": "^3.0.0", "@openzeppelin/contracts": "4.9.3", "@openzeppelin/contracts-upgradeable": "^4.8.0", - "@venusprotocol/governance-contracts": "^2.3.0", - "@venusprotocol/protocol-reserve": "^2.3.0", + "@venusprotocol/governance-contracts": "^2.4.0", + "@venusprotocol/protocol-reserve": "^2.4.0", "@venusprotocol/solidity-utilities": "^2.0.3", - "@venusprotocol/token-bridge": "^2.2.0", + "@venusprotocol/token-bridge": "^2.3.0", "bignumber.js": "^9.1.2", "dotenv": "^16.0.1", "module-alias": "^2.2.2" diff --git a/yarn.lock b/yarn.lock index 2ac414e81..d3a92846e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3540,36 +3540,25 @@ __metadata: languageName: node linkType: hard -"@venusprotocol/governance-contracts@npm:^1.4.0": - version: 1.4.0 - resolution: "@venusprotocol/governance-contracts@npm:1.4.0" - dependencies: - "@venusprotocol/solidity-utilities": ^1.1.0 - hardhat-deploy-ethers: ^0.3.0-beta.13 - module-alias: ^2.2.2 - checksum: 85c6b6a815edb0befa4c38e3652a58464827d390620210b99575c16960ee6505e95e7c2192ebc972da7ed758d3c62e150d32fbdd1f01acab1731f29b11d1884e - languageName: node - linkType: hard - -"@venusprotocol/governance-contracts@npm:^2.1.0": - version: 2.2.0 - resolution: "@venusprotocol/governance-contracts@npm:2.2.0" +"@venusprotocol/governance-contracts@npm:^2.3.0": + version: 2.3.0 + resolution: "@venusprotocol/governance-contracts@npm:2.3.0" dependencies: "@venusprotocol/solidity-utilities": 2.0.0 hardhat-deploy-ethers: ^0.3.0-beta.13 module-alias: ^2.2.2 - checksum: 8e6ba9b824a47cc03b296e4cfa2f9781e30e412710dd71f1e52d7b0d41d8cd6efb0b877239edadbf4eb382bda57436d96a4ee5cac6d0fae29b555ccdb68fc8c0 + checksum: b7c6054d36f435e6360acbe5ef31816901377bffb119147a519c7aa93f8ad4205dfbb85deb706a5fbc37ab144dfdb42284f18c8e95bc729a780303c828221891 languageName: node linkType: hard -"@venusprotocol/governance-contracts@npm:^2.3.0": - version: 2.3.0 - resolution: "@venusprotocol/governance-contracts@npm:2.3.0" +"@venusprotocol/governance-contracts@npm:^2.4.0": + version: 2.4.0 + resolution: "@venusprotocol/governance-contracts@npm:2.4.0" dependencies: "@venusprotocol/solidity-utilities": 2.0.0 hardhat-deploy-ethers: ^0.3.0-beta.13 module-alias: ^2.2.2 - checksum: b7c6054d36f435e6360acbe5ef31816901377bffb119147a519c7aa93f8ad4205dfbb85deb706a5fbc37ab144dfdb42284f18c8e95bc729a780303c828221891 + checksum: 2a754a05a655bc7b24c33685f86c9bd616a6e7cba4b048315b11eca67a8c1e37c033f04e1b4394e7326251b6af49ab257275cef72727c8976ae16c7f2c2ff0e7 languageName: node linkType: hard @@ -3594,44 +3583,27 @@ __metadata: languageName: node linkType: hard -"@venusprotocol/protocol-reserve@npm:^1.4.0": - version: 1.5.0 - resolution: "@venusprotocol/protocol-reserve@npm:1.5.0" - dependencies: - "@nomiclabs/hardhat-ethers": ^2.2.3 - "@openzeppelin/contracts": ^4.8.3 - "@openzeppelin/contracts-upgradeable": ^4.8.3 - "@openzeppelin/hardhat-upgrades": ^1.21.0 - "@solidity-parser/parser": ^0.13.2 - "@venusprotocol/solidity-utilities": ^1.3.0 - ethers: ^5.7.0 - hardhat-deploy: ^0.11.14 - module-alias: ^2.2.2 - checksum: 813bc162103ab756e84bbb0e65fd416ed105cb4a06f9fe55d4a2a066af5bd63b11ca9f2c791376148114ce2b469970c8fe29c85ee1d47f9da9841f2eac8b01e0 - languageName: node - linkType: hard - -"@venusprotocol/protocol-reserve@npm:^2.0.0": - version: 2.2.0 - resolution: "@venusprotocol/protocol-reserve@npm:2.2.0" +"@venusprotocol/protocol-reserve@npm:^2.3.0": + version: 2.3.0 + resolution: "@venusprotocol/protocol-reserve@npm:2.3.0" dependencies: "@nomiclabs/hardhat-ethers": ^2.2.3 "@openzeppelin/contracts": ^4.8.3 "@openzeppelin/contracts-upgradeable": ^4.8.3 "@openzeppelin/hardhat-upgrades": ^1.21.0 "@solidity-parser/parser": ^0.13.2 - "@venusprotocol/solidity-utilities": ^2.0.0 - "@venusprotocol/venus-protocol": ^7.5.0 + "@venusprotocol/solidity-utilities": ^2.0.3 + "@venusprotocol/venus-protocol": ^9.1.0 ethers: ^5.7.0 hardhat-deploy: ^0.11.14 module-alias: ^2.2.2 - checksum: ae875b95c1adabcc73ca52f74bf3f875c15e8a29cc6cbdf08038542692e5c397d986424194f1e1819659b0bc17d53770e75e7f74304ecbee24e9e84dd4ef79ed + checksum: b9e12702281d0790c0136f922400b5f90ff88d04d2af97580620a2677190c1957a4fdb38ff6600ff5e4f71e4d521c8bb013d7775814a2f68e3883544f38caa95 languageName: node linkType: hard -"@venusprotocol/protocol-reserve@npm:^2.3.0": - version: 2.3.0 - resolution: "@venusprotocol/protocol-reserve@npm:2.3.0" +"@venusprotocol/protocol-reserve@npm:^2.4.0": + version: 2.4.0 + resolution: "@venusprotocol/protocol-reserve@npm:2.4.0" dependencies: "@nomiclabs/hardhat-ethers": ^2.2.3 "@openzeppelin/contracts": ^4.8.3 @@ -3643,7 +3615,7 @@ __metadata: ethers: ^5.7.0 hardhat-deploy: ^0.11.14 module-alias: ^2.2.2 - checksum: b9e12702281d0790c0136f922400b5f90ff88d04d2af97580620a2677190c1957a4fdb38ff6600ff5e4f71e4d521c8bb013d7775814a2f68e3883544f38caa95 + checksum: 6e5ffa1c458cff073f9b920ab6385d9db0c86ac11d0950fe421a853e709ee12ec0013c6d3e9cb4e50e94f749dcd33e7a515d57828c5aa6f925dee8324e896ee5 languageName: node linkType: hard @@ -3654,13 +3626,6 @@ __metadata: languageName: node linkType: hard -"@venusprotocol/solidity-utilities@npm:^1.1.0, @venusprotocol/solidity-utilities@npm:^1.2.0, @venusprotocol/solidity-utilities@npm:^1.3.0": - version: 1.3.0 - resolution: "@venusprotocol/solidity-utilities@npm:1.3.0" - checksum: d1109365a5e01959c47b25fb129373db93792e60bf1bc0ed324b63c2a64f6e4a7878ebf016cfade94bc41a2c1245d3e861fdc6b8c5844ac210ed1d73e7307e72 - languageName: node - linkType: hard - "@venusprotocol/solidity-utilities@npm:^2.0.0, @venusprotocol/solidity-utilities@npm:^2.0.3": version: 2.0.3 resolution: "@venusprotocol/solidity-utilities@npm:2.0.3" @@ -3668,24 +3633,9 @@ __metadata: languageName: node linkType: hard -"@venusprotocol/token-bridge@npm:^1.1.0": - version: 1.1.0 - resolution: "@venusprotocol/token-bridge@npm:1.1.0" - dependencies: - "@layerzerolabs/solidity-examples": ^1.0.0 - "@openzeppelin/contracts": ^4.8.3 - "@openzeppelin/contracts-upgradeable": ^4.8.3 - "@openzeppelin/hardhat-upgrades": ^1.21.0 - "@solidity-parser/parser": ^0.13.2 - ethers: ^5.7.0 - module-alias: ^2.2.2 - checksum: 86c0e758491b63ce7da57aacf764a4d040a54fdc89994c92a79363e4cbb33b84cd1db38630e76cbcc26f6f7a5a676b3ac96871ad98486701982ea4699bdc15f1 - languageName: node - linkType: hard - -"@venusprotocol/token-bridge@npm:^2.0.0": - version: 2.1.0 - resolution: "@venusprotocol/token-bridge@npm:2.1.0" +"@venusprotocol/token-bridge@npm:^2.2.0": + version: 2.2.0 + resolution: "@venusprotocol/token-bridge@npm:2.2.0" dependencies: "@layerzerolabs/solidity-examples": ^1.0.0 "@openzeppelin/contracts": ^4.8.3 @@ -3694,13 +3644,13 @@ __metadata: "@solidity-parser/parser": ^0.13.2 ethers: ^5.7.0 module-alias: ^2.2.2 - checksum: 022163873126822b7cd84bd470b2f7bdb439cad1ac78136a5956418803bdc873360de28ab8d1e50f28ab80add900d56660c8273ac132ba47bbd3c3890b67b046 + checksum: 86bdefc8853cd334bedbb9d63b4a8d266271dcaa28705fdb6368a66fbc22838e0d1c00cf4b9eb2083c925a6a3e47bbfebd234d660b0660a9b437a52a5f0d7a90 languageName: node linkType: hard -"@venusprotocol/token-bridge@npm:^2.2.0": - version: 2.2.0 - resolution: "@venusprotocol/token-bridge@npm:2.2.0" +"@venusprotocol/token-bridge@npm:^2.3.0": + version: 2.3.0 + resolution: "@venusprotocol/token-bridge@npm:2.3.0" dependencies: "@layerzerolabs/solidity-examples": ^1.0.0 "@openzeppelin/contracts": ^4.8.3 @@ -3709,43 +3659,25 @@ __metadata: "@solidity-parser/parser": ^0.13.2 ethers: ^5.7.0 module-alias: ^2.2.2 - checksum: 86bdefc8853cd334bedbb9d63b4a8d266271dcaa28705fdb6368a66fbc22838e0d1c00cf4b9eb2083c925a6a3e47bbfebd234d660b0660a9b437a52a5f0d7a90 - languageName: node - linkType: hard - -"@venusprotocol/venus-protocol@npm:^7.5.0": - version: 7.5.0 - resolution: "@venusprotocol/venus-protocol@npm:7.5.0" - dependencies: - "@nomicfoundation/hardhat-ethers": ^3.0.0 - "@openzeppelin/contracts": 4.9.3 - "@openzeppelin/contracts-upgradeable": ^4.8.0 - "@venusprotocol/governance-contracts": ^1.4.0 - "@venusprotocol/protocol-reserve": ^1.4.0 - "@venusprotocol/solidity-utilities": ^1.2.0 - "@venusprotocol/token-bridge": ^1.1.0 - bignumber.js: ^9.1.2 - dotenv: ^16.0.1 - module-alias: ^2.2.2 - checksum: 0a39304b6f2e0db05a20dacf6d678f3245be878a121e7d1ddeb503c28974dea9cbec0228be3d03f77abb97d1adb8e6e8ad8708cb730a5833e62c4e6735fb6eea + checksum: c9f3dcf9eb014592404de14998f817c230e51ec640074ad0811c4ab21e141478b91daefe949b51fc80d6437f3b1f1bb9f606f2c50c2720b01a2e673008208917 languageName: node linkType: hard "@venusprotocol/venus-protocol@npm:^9.1.0": - version: 9.1.0 - resolution: "@venusprotocol/venus-protocol@npm:9.1.0" + version: 9.2.0 + resolution: "@venusprotocol/venus-protocol@npm:9.2.0" dependencies: "@nomicfoundation/hardhat-ethers": ^3.0.0 "@openzeppelin/contracts": 4.9.3 "@openzeppelin/contracts-upgradeable": ^4.8.0 - "@venusprotocol/governance-contracts": ^2.1.0 - "@venusprotocol/protocol-reserve": ^2.0.0 + "@venusprotocol/governance-contracts": ^2.3.0 + "@venusprotocol/protocol-reserve": ^2.3.0 "@venusprotocol/solidity-utilities": ^2.0.3 - "@venusprotocol/token-bridge": ^2.0.0 + "@venusprotocol/token-bridge": ^2.2.0 bignumber.js: ^9.1.2 dotenv: ^16.0.1 module-alias: ^2.2.2 - checksum: 7c1063d7a584fc95787022dad0de62583ee8965a061d024ae4fbd86c7aee4dda04c8f562b2b7293a672fe38a57580105af9e28b9293590b13e17459863812135 + checksum: 5d0b6a7355c9cd44463fdd982a43828d9129cce5a16430593fbda8dc366226367cc559e87dd10a74605a16cf8919c49b9210d833461582eb32b17e5397b1ebaa languageName: node linkType: hard @@ -3786,11 +3718,11 @@ __metadata: "@types/node": ^18.7.1 "@typescript-eslint/eslint-plugin": ^5.40.0 "@typescript-eslint/parser": ^5.40.0 - "@venusprotocol/governance-contracts": ^2.3.0 + "@venusprotocol/governance-contracts": ^2.4.0 "@venusprotocol/oracle": 2.5.0 - "@venusprotocol/protocol-reserve": ^2.3.0 + "@venusprotocol/protocol-reserve": ^2.4.0 "@venusprotocol/solidity-utilities": ^2.0.3 - "@venusprotocol/token-bridge": ^2.2.0 + "@venusprotocol/token-bridge": ^2.3.0 bignumber.js: ^9.1.2 chai: ^4.3.6 dotenv: ^16.0.1