From a965c72944dcdbc9a227cdadc441fb256e4dbf67 Mon Sep 17 00:00:00 2001 From: Debugger022 Date: Fri, 29 Sep 2023 13:33:49 +0530 Subject: [PATCH 1/4] feat: added vip and simulations for adding cut param for both mainnet and testnet --- .../abi/Comptroller.json | 2782 +++++++++++++++++ .../abi/IERC20UpgradableAbi.json | 295 ++ .../abi/VBep20DelegateAbi.json | 1539 +++++++++ .../abi/priceOracleAbi.json | 154 + .../simulations.ts | 436 +++ .../utils/cut-params.json | 3 + .../simulations.ts | 432 +++ .../utils/cut-params.json | 3 + .../vip-param-add-mainnet.ts | 31 + .../vip-param-add-testnet.ts | 31 + 10 files changed, 5706 insertions(+) create mode 100644 simulations/vip-diamond-cut-param-add/abi/Comptroller.json create mode 100644 simulations/vip-diamond-cut-param-add/abi/IERC20UpgradableAbi.json create mode 100644 simulations/vip-diamond-cut-param-add/abi/VBep20DelegateAbi.json create mode 100644 simulations/vip-diamond-cut-param-add/abi/priceOracleAbi.json create mode 100644 simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts create mode 100644 simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/utils/cut-params.json create mode 100644 simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts create mode 100644 simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/utils/cut-params.json create mode 100644 vips/vip-diamond-cut-param-add/vip-param-add-mainnet.ts create mode 100644 vips/vip-diamond-cut-param-add/vip-param-add-testnet.ts diff --git a/simulations/vip-diamond-cut-param-add/abi/Comptroller.json b/simulations/vip-diamond-cut-param-add/abi/Comptroller.json new file mode 100644 index 000000000..fb2b4582e --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/abi/Comptroller.json @@ -0,0 +1,2782 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "enum ComptrollerV9Storage.Action", + "name": "action", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bool", + "name": "pauseState", + "type": "bool" + } + ], + "name": "ActionPausedMarket", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "ActionProtocolPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "allowDelegatedBorrows", + "type": "bool" + } + ], + "name": "DelegateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "venusDelta", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "venusBorrowIndex", + "type": "uint256" + } + ], + "name": "DistributedBorrowerVenus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "supplier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "venusDelta", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "venusSupplyIndex", + "type": "uint256" + } + ], + "name": "DistributedSupplierVenus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "DistributedVAIVaultVenus", + "type": "event" + }, + { + "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": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "MarketEntered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "MarketExited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + } + ], + "name": "MarketListed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlAddress", + "type": "address" + } + ], + "name": "NewAccessControl", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowCap", + "type": "uint256" + } + ], + "name": "NewBorrowCap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldCloseFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCloseFactorMantissa", + "type": "uint256" + } + ], + "name": "NewCloseFactor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldCollateralFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCollateralFactorMantissa", + "type": "uint256" + } + ], + "name": "NewCollateralFactor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldComptrollerLens", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newComptrollerLens", + "type": "address" + } + ], + "name": "NewComptrollerLens", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldLiquidationIncentiveMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newLiquidationIncentiveMantissa", + "type": "uint256" + } + ], + "name": "NewLiquidationIncentive", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldLiquidatorContract", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newLiquidatorContract", + "type": "address" + } + ], + "name": "NewLiquidatorContract", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPauseGuardian", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPauseGuardian", + "type": "address" + } + ], + "name": "NewPauseGuardian", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract PriceOracle", + "name": "oldPriceOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract PriceOracle", + "name": "newPriceOracle", + "type": "address" + } + ], + "name": "NewPriceOracle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyCap", + "type": "uint256" + } + ], + "name": "NewSupplyCap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldTreasuryAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newTreasuryAddress", + "type": "address" + } + ], + "name": "NewTreasuryAddress", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldTreasuryGuardian", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newTreasuryGuardian", + "type": "address" + } + ], + "name": "NewTreasuryGuardian", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldTreasuryPercent", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTreasuryPercent", + "type": "uint256" + } + ], + "name": "NewTreasuryPercent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract VAIControllerInterface", + "name": "oldVAIController", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract VAIControllerInterface", + "name": "newVAIController", + "type": "address" + } + ], + "name": "NewVAIController", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldVAIMintRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newVAIMintRate", + "type": "uint256" + } + ], + "name": "NewVAIMintRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "vault_", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "releaseStartBlock_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "releaseInterval_", + "type": "uint256" + } + ], + "name": "NewVAIVaultInfo", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldVenusVAIVaultRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newVenusVAIVaultRate", + "type": "uint256" + } + ], + "name": "NewVenusVAIVaultRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "VenusBorrowSpeedUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "VenusGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSpeed", + "type": "uint256" + } + ], + "name": "VenusSupplySpeedUpdated", + "type": "event" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract Unitroller", + "name": "unitroller", + "type": "address" + } + ], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "_grantXVS", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newAccessControlAddress", + "type": "address" + } + ], + "name": "_setAccessControl", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "enum ComptrollerV9Storage.Action[]", + "name": "actions", + "type": "uint8[]" + }, + { + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "_setActionsPaused", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "newCloseFactorMantissa", + "type": "uint256" + } + ], + "name": "_setCloseFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newCollateralFactorMantissa", + "type": "uint256" + } + ], + "name": "_setCollateralFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract ComptrollerLensInterface", + "name": "comptrollerLens_", + "type": "address" + } + ], + "name": "_setComptrollerLens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "newLiquidationIncentiveMantissa", + "type": "uint256" + } + ], + "name": "_setLiquidationIncentive", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newLiquidatorContract_", + "type": "address" + } + ], + "name": "_setLiquidatorContract", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "newBorrowCaps", + "type": "uint256[]" + } + ], + "name": "_setMarketBorrowCaps", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "newSupplyCaps", + "type": "uint256[]" + } + ], + "name": "_setMarketSupplyCaps", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newPauseGuardian", + "type": "address" + } + ], + "name": "_setPauseGuardian", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract PriceOracle", + "name": "newOracle", + "type": "address" + } + ], + "name": "_setPriceOracle", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setProtocolPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newTreasuryGuardian", + "type": "address" + }, + { + "internalType": "address", + "name": "newTreasuryAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newTreasuryPercent", + "type": "uint256" + } + ], + "name": "_setTreasuryData", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VAIControllerInterface", + "name": "vaiController_", + "type": "address" + } + ], + "name": "_setVAIController", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "newVAIMintRate", + "type": "uint256" + } + ], + "name": "_setVAIMintRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vault_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "releaseStartBlock_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minReleaseAmount_", + "type": "uint256" + } + ], + "name": "_setVAIVaultInfo", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "supplySpeeds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "borrowSpeeds", + "type": "uint256[]" + } + ], + "name": "_setVenusSpeeds", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "venusVAIVaultRate_", + "type": "uint256" + } + ], + "name": "_setVenusVAIVaultRate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + } + ], + "name": "_supportMarket", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "accountAssets", + "outputs": [ + { + "internalType": "contract VToken", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "market", + "type": "address" + }, + { + "internalType": "enum ComptrollerV9Storage.Action", + "name": "action", + "type": "uint8" + } + ], + "name": "actionPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allMarkets", + "outputs": [ + { + "internalType": "contract VToken", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "approvedDelegates", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "borrowCapGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrowVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + } + ], + "name": "checkMembership", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address[]", + "name": "holders", + "type": "address[]" + }, + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + }, + { + "internalType": "bool", + "name": "borrowers", + "type": "bool" + }, + { + "internalType": "bool", + "name": "suppliers", + "type": "bool" + }, + { + "internalType": "bool", + "name": "collateral", + "type": "bool" + } + ], + "name": "claimVenus", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + }, + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + } + ], + "name": "claimVenus", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + } + ], + "name": "claimVenus", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address[]", + "name": "holders", + "type": "address[]" + }, + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + }, + { + "internalType": "bool", + "name": "borrowers", + "type": "bool" + }, + { + "internalType": "bool", + "name": "suppliers", + "type": "bool" + } + ], + "name": "claimVenus", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + } + ], + "name": "claimVenusAsCollateral", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "closeFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "comptrollerImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "comptrollerLens", + "outputs": [ + { + "internalType": "contract ComptrollerLensInterface", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address[]", + "name": "vTokens", + "type": "address[]" + } + ], + "name": "enterMarkets", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vTokenAddress", + "type": "address" + } + ], + "name": "exitMarket", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "contract VToken[]", + "name": "", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAssetsIn", + "outputs": [ + { + "internalType": "contract VToken[]", + "name": "", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "vTokenModify", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "getHypotheticalAccountLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getXVSAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getXVSVTokenAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isComptroller", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "vTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "liquidateBorrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "vTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualRepayAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "liquidateBorrowVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "vTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "vTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualRepayAmount", + "type": "uint256" + } + ], + "name": "liquidateCalculateSeizeTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "vTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualRepayAmount", + "type": "uint256" + } + ], + "name": "liquidateVAICalculateSeizeTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "liquidationIncentiveMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "liquidatorContract", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isVenus", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "maxAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "minReleaseAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mintAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "mintVAIGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualMintAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "mintVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "mintedVAIs", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract PriceOracle", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pauseGuardian", + "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": "pendingComptrollerImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "protocolPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeemAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeemVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "releaseStartBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "releaseToVault", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualRepayAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowerIndex", + "type": "uint256" + } + ], + "name": "repayBorrowVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "repayVAIGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "vTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seizeAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "vTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seizeVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "setMintedVAIOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "supplyCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transferTokens", + "type": "uint256" + } + ], + "name": "transferAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transferTokens", + "type": "uint256" + } + ], + "name": "transferVerify", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryPercent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowBorrows", + "type": "bool" + } + ], + "name": "updateDelegate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaiController", + "outputs": [ + { + "internalType": "contract VAIControllerInterface", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaiMintRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaiVaultAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "venusAccrued", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "venusBorrowSpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "venusBorrowState", + "outputs": [ + { + "internalType": "uint224", + "name": "index", + "type": "uint224" + }, + { + "internalType": "uint32", + "name": "block", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "venusBorrowerIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "venusInitialIndex", + "outputs": [ + { + "internalType": "uint224", + "name": "", + "type": "uint224" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "venusRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "venusSpeeds", + "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": "venusSupplierIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "venusSupplySpeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "venusSupplyState", + "outputs": [ + { + "internalType": "uint224", + "name": "index", + "type": "uint224" + }, + { + "internalType": "uint32", + "name": "block", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "venusVAIVaultRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-diamond-cut-param-add/abi/IERC20UpgradableAbi.json b/simulations/vip-diamond-cut-param-add/abi/IERC20UpgradableAbi.json new file mode 100644 index 000000000..374b04c75 --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/abi/IERC20UpgradableAbi.json @@ -0,0 +1,295 @@ +[ + { + "inputs": [ + { "internalType": "string", "name": "name_", "type": "string" }, + { "internalType": "string", "name": "symbol_", "type": "string" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "userAddress", "type": "address" }, + { "indexed": false, "internalType": "address payable", "name": "relayerAddress", "type": "address" }, + { "indexed": false, "internalType": "bytes", "name": "functionSignature", "type": "bytes" } + ], + "name": "MetaTransactionExecuted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, + { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERC712_VERSION", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PREDICATE_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "userAddress", "type": "address" }, + { "internalType": "bytes", "name": "functionSignature", "type": "bytes" }, + { "internalType": "bytes32", "name": "sigR", "type": "bytes32" }, + { "internalType": "bytes32", "name": "sigS", "type": "bytes32" }, + { "internalType": "uint8", "name": "sigV", "type": "uint8" } + ], + "name": "executeMetaTransaction", + "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "getChainId", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getDomainSeperator", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], + "name": "getNonce", + "outputs": [{ "internalType": "uint256", "name": "nonce", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], + "name": "getRoleAdmin", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "uint256", "name": "index", "type": "uint256" } + ], + "name": "getRoleMember", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], + "name": "getRoleMemberCount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "hasRole", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "addedValue", "type": "uint256" } + ], + "name": "increaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/simulations/vip-diamond-cut-param-add/abi/VBep20DelegateAbi.json b/simulations/vip-diamond-cut-param-add/abi/VBep20DelegateAbi.json new file mode 100644 index 000000000..0f6421ac5 --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/abi/VBep20DelegateAbi.json @@ -0,0 +1,1539 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "cashPrior", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "interestAccumulated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "AccrueInterest", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "Borrow", + "type": "event" + }, + { + "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": "liquidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "vTokenCollateral", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "LiquidateBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "MintBehalf", + "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": "contract ComptrollerInterface", + "name": "oldComptroller", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract ComptrollerInterface", + "name": "newComptroller", + "type": "address" + } + ], + "name": "NewComptroller", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "oldInterestRateModel", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "NewMarketInterestRateModel", + "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": "uint256", + "name": "oldReserveFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "NewReserveFactor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "Redeem", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "RedeemFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "RepayBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "benefactor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "addAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reduceAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesReduced", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": false, + "inputs": [], + "name": "_acceptAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "addAmount", + "type": "uint256" + } + ], + "name": "_addReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "_becomeImplementation", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "reduceAmount", + "type": "uint256" + } + ], + "name": "_reduceReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "_resignImplementation", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract ComptrollerInterface", + "name": "newComptroller", + "type": "address" + } + ], + "name": "_setComptroller", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "_setInterestRateModel", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address payable", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "_setPendingAdmin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "_setReserveFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "accrualBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "accrueInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOfUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "borrowBalanceCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "borrowBalanceStored", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrowBehalf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "borrowIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "borrowRatePerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "contract ComptrollerInterface", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "exchangeRateCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "exchangeRateStored", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountSnapshot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getCash", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "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": "address", + "name": "underlying_", + "type": "address" + }, + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "contract InterestRateModel", + "name": "interestRateModel_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialExchangeRateMantissa_", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name_", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol_", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals_", + "type": "uint8" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller_", + "type": "address" + }, + { + "internalType": "contract InterestRateModel", + "name": "interestRateModel_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialExchangeRateMantissa_", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name_", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol_", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals_", + "type": "uint8" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "interestRateModel", + "outputs": [ + { + "internalType": "contract InterestRateModel", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isVToken", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract VTokenInterface", + "name": "vTokenCollateral", + "type": "address" + } + ], + "name": "liquidateBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mintBehalf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + } + ], + "name": "redeemUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrowBehalf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "reserveFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "supplyRatePerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "totalBorrowsCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "underlying", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-diamond-cut-param-add/abi/priceOracleAbi.json b/simulations/vip-diamond-cut-param-add/abi/priceOracleAbi.json new file mode 100644 index 000000000..2eb50681a --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/abi/priceOracleAbi.json @@ -0,0 +1,154 @@ +[ + { + "inputs": [{ "internalType": "uint256", "name": "maxStalePeriod_", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "feed", "type": "address" }, + { "indexed": false, "internalType": "string", "name": "symbol", "type": "string" } + ], + "name": "FeedSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldMaxStalePeriod", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newMaxStalePeriod", "type": "uint256" } + ], + "name": "MaxStalePeriodUpdated", + "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": "asset", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "previousPriceMantissa", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "requestedPriceMantissa", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newPriceMantissa", "type": "uint256" } + ], + "name": "PricePosted", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "asset", "type": "address" }], + "name": "assetPrices", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "string", "name": "symbol", "type": "string" }], + "name": "getFeed", + "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "contract VToken", "name": "vToken", "type": "address" }], + "name": "getUnderlyingPrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isPriceOracle", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "maxStalePeriod", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "newAdmin", "type": "address" }], + "name": "setAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "uint256", "name": "price", "type": "uint256" } + ], + "name": "setDirectPrice", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "string", "name": "symbol", "type": "string" }, + { "internalType": "address", "name": "feed", "type": "address" } + ], + "name": "setFeed", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "newMaxStalePeriod", "type": "uint256" }], + "name": "setMaxStalePeriod", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "contract VToken", "name": "vToken", "type": "address" }, + { "internalType": "uint256", "name": "underlyingPriceMantissa", "type": "uint256" } + ], + "name": "setUnderlyingPrice", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts new file mode 100644 index 000000000..2210b6627 --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts @@ -0,0 +1,436 @@ +import { impersonateAccount } from "@nomicfoundation/hardhat-network-helpers"; +import { expect } from "chai"; +import { BigNumberish, Contract, Signer } from "ethers"; +import { parseUnits } from "ethers/lib/utils"; +import { ethers } from "hardhat"; + +import { initMainnetUser } from "../../../src/utils"; +import { forking, pretendExecutingVip, testVip } from "../../../src/vip-framework"; +import { vipCutParamAdd } from "../../../vips/vip-diamond-cut-param-add/vip-param-add-mainnet"; +import Comptroller from "../abi/Comptroller.json"; +import IERC20Upgradeable from "../abi/IERC20UpgradableAbi.json"; +import VBEP20_DELEGATE_ABI from "../abi/VBep20DelegateAbi.json"; + +const UNITROLLER = "0xfD36E2c2a6789Db23113685031d7F16329158384"; +const Owner = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; +const VBUSD = "0x95c78222B3D6e262426483D42CfA53685A67Ab9D"; +const VUSDT = "0xfD5840Cd36d94D7229439859C0112a4185BC0255"; + +// Added function signature for venusInitialIndex to market facet as cut param to diamond proxy +// This fork block contains tests for venusInitialIndex only. +forking(32159070, async () => { + let diamondUnitroller: ethers.Contract; + + before(async () => { + diamondUnitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + }); + + describe("Before execution of VIP", async () => { + it("Fetching of VenusInitialIndex should revert", async () => { + await expect(diamondUnitroller.venusInitialIndex()).to.be.reverted; + }); + }); + + testVip("VIP-Diamond cut param add", vipCutParamAdd()); + + describe("After execution of vip", async () => { + it("Fetching of VenusInitialIndex should return value", async () => { + expect(await diamondUnitroller.venusInitialIndex()).to.be.equal(parseUnits("1", 36)); + }); + }); +}); + +// As this vip is updating diamond proxy for the first time after it's implementation, +// therefore adding additional tests to verify all storage values before and after executing this vip, +// setter functions and core functionalities are working properly +forking(32159070, async () => { + let owner: Signer, + unitroller: Contract, + // layout variables + oracle: Contract, + maxAssets: BigNumberish, + closeFactorMantissa: BigNumberish, + liquidationIncentiveMantissa: BigNumberish, + allMarkets: Array, + venusSupplyState: any, + venusBorrowState: any, + venusAccrued: BigNumberish, + vaiMintRate: BigNumberish, + vaiController: Contract, + mintedVAIs: BigNumberish, + mintVAIGuardianPaused: boolean, + repayVAIGuardianPaused: boolean, + protocolPaused: boolean, + venusVAIVaultRate: BigNumberish, + vaiVaultAddress: string, + releaseStartBlock: BigNumberish, + minReleaseAmount: BigNumberish, + treasuryGuardian: boolean, + treasuryAddress: string, + treasuryPercent: BigNumberish, + liquidatorContract: Contract, + comptrollerLens: Contract; + + const borrowSpeeds: any = {}; + const supplySpeeds: any = {}; + const userBorrowIndexes: any = {}; + const userSupplyIndexes: any = {}; + const markets: any = {}; + + let BUSD: Contract; + let busdHolder: Signer; + let vBUSD: Contract; + let vUSDT: Contract; + let diamondUnitroller: Contract; + + before(async () => { + unitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + + diamondUnitroller = new ethers.Contract(unitroller.address, Comptroller, ethers.provider); + + await impersonateAccount(Owner); + owner = await ethers.getSigner(Owner); + const [signer] = await ethers.getSigners(); + await signer.sendTransaction({ + to: await owner.getAddress(), + value: ethers.BigNumber.from("10000000000000000000"), + data: undefined, + }); + + busdHolder = await initMainnetUser("0x8894E0a0c962CB723c1976a4421c95949bE2D4E3", parseUnits("1000", 18)); + + [vBUSD, vUSDT] = await Promise.all( + [VBUSD, VUSDT].map((address: string) => { + return new ethers.Contract(address, VBEP20_DELEGATE_ABI, ethers.provider); + }), + ); + + [BUSD] = await Promise.all( + [vBUSD].map(async (vToken: Contract) => { + const underlying = await vToken.underlying(); + return new ethers.Contract(underlying, IERC20Upgradeable, ethers.provider); + }), + ); + }); + + describe("Verify Storage slots before vip execution", async () => { + // These tests checks the storage collision of comptroller while updating it via diamond. + describe("Verify storage layout before vip execution", async () => { + it("verify all the state before and after upgrade", async () => { + oracle = await unitroller.oracle(); + + maxAssets = await unitroller.maxAssets(); + + closeFactorMantissa = await unitroller.closeFactorMantissa(); + + liquidationIncentiveMantissa = await unitroller.liquidationIncentiveMantissa(); + + venusSupplyState = await unitroller.venusSupplyState(BUSD.address); + + venusBorrowState = await unitroller.venusBorrowState(BUSD.address); + + venusAccrued = await unitroller.venusAccrued(BUSD.address); + + vaiMintRate = await unitroller.vaiMintRate(); + + vaiController = await unitroller.vaiController(); + + mintedVAIs = await unitroller.mintedVAIs(await busdHolder.getAddress()); + + mintVAIGuardianPaused = await unitroller.mintVAIGuardianPaused(); + + repayVAIGuardianPaused = await unitroller.repayVAIGuardianPaused(); + + protocolPaused = await unitroller.protocolPaused(); + + venusVAIVaultRate = await unitroller.venusVAIVaultRate(); + + vaiVaultAddress = await unitroller.vaiVaultAddress(); + + releaseStartBlock = await unitroller.releaseStartBlock(); + + minReleaseAmount = await unitroller.minReleaseAmount(); + + treasuryGuardian = await unitroller.treasuryGuardian(); + + treasuryAddress = await unitroller.treasuryAddress(); + + treasuryPercent = await unitroller.treasuryPercent(); + + liquidatorContract = await unitroller.liquidatorContract(); + + comptrollerLens = await unitroller.comptrollerLens(); + + // checking all public mappings + allMarkets = await unitroller.getAllMarkets(); + + for (const marketIndex in allMarkets) { + const marketAddress = allMarkets[marketIndex].toString(); + + borrowSpeeds[marketAddress] = await unitroller.venusBorrowSpeeds(marketAddress); + supplySpeeds[marketAddress] = await unitroller.venusSupplySpeeds(marketAddress); + markets[marketAddress] = await unitroller.markets(marketAddress); + + userBorrowIndexes[marketAddress] = await unitroller.venusBorrowerIndex( + marketAddress, + await busdHolder.getAddress(), + ); + userSupplyIndexes[marketAddress] = await unitroller.venusSupplierIndex( + marketAddress, + await busdHolder.getAddress(), + ); + } + }); + }); + }); + + testVip("VIP-Diamond Contract Migration", vipCutParamAdd()); + + describe("Verify Storage slots after VIP execution", async () => { + // These tests checks the storage collision of comptroller while updating it via diamond. + describe("Verify storage layout after VIP execution", async () => { + it("verify all the state before and after upgrade", async () => { + const oracelUpgrade = await diamondUnitroller.oracle(); + expect(oracle).to.equal(oracelUpgrade); + + const maxAssetsAfterUpgrade = await diamondUnitroller.maxAssets(); + expect(maxAssets).to.equal(maxAssetsAfterUpgrade); + + const closeFactorMantissaAfterUpgrade = await diamondUnitroller.closeFactorMantissa(); + expect(closeFactorMantissa).to.equal(closeFactorMantissaAfterUpgrade); + + const liquidationIncentiveMantissaAfterUpgrade = await diamondUnitroller.liquidationIncentiveMantissa(); + expect(liquidationIncentiveMantissa).to.equal(liquidationIncentiveMantissaAfterUpgrade); + + const venusSupplyStateAfterUpgrade = await diamondUnitroller.venusSupplyState(BUSD.address); + expect(venusSupplyState.index.toString()).to.equal(venusSupplyStateAfterUpgrade.index.toString()); + + const venusBorrowStateAfterUpgrade = await diamondUnitroller.venusBorrowState(BUSD.address); + expect(venusBorrowState.index.toString()).to.equal(venusBorrowStateAfterUpgrade.index.toString()); + + const venusAccruedAfterUpgrade = await diamondUnitroller.venusAccrued(BUSD.address); + expect(venusAccrued).to.equal(venusAccruedAfterUpgrade); + + const vaiMintRateAfterUpgrade = await diamondUnitroller.vaiMintRate(); + expect(vaiMintRate).to.equal(vaiMintRateAfterUpgrade); + + const vaiControllerUpgrade = await diamondUnitroller.vaiController(); + expect(vaiControllerUpgrade).to.equal(vaiController); + + const mintedVAIsUpgrade = await diamondUnitroller.mintedVAIs(await busdHolder.getAddress()); + expect(mintedVAIsUpgrade).to.equal(mintedVAIs); + + const mintVAIGuardianPausedUpgrade = await diamondUnitroller.mintVAIGuardianPaused(); + expect(mintVAIGuardianPausedUpgrade).to.equal(mintVAIGuardianPaused); + + const repayVAIGuardianPausedUpgrade = await diamondUnitroller.repayVAIGuardianPaused(); + expect(repayVAIGuardianPausedUpgrade).to.equal(repayVAIGuardianPaused); + + const protocolPausedUpgrade = await diamondUnitroller.protocolPaused(); + expect(protocolPausedUpgrade).to.equal(protocolPaused); + + const venusVAIVaultRateUpgrade = await diamondUnitroller.venusVAIVaultRate(); + expect(venusVAIVaultRateUpgrade).to.equal(venusVAIVaultRate); + + const vaiVaultAddressUpgrade = await diamondUnitroller.vaiVaultAddress(); + expect(vaiVaultAddressUpgrade).to.equal(vaiVaultAddress); + + const releaseStartBlockUpgrade = await diamondUnitroller.releaseStartBlock(); + expect(releaseStartBlockUpgrade).to.equal(releaseStartBlock); + + const minReleaseAmountUpgrade = await diamondUnitroller.minReleaseAmount(); + expect(minReleaseAmountUpgrade).to.equal(minReleaseAmount); + + const treasuryGuardianUpgrade = await diamondUnitroller.treasuryGuardian(); + expect(treasuryGuardian).to.equal(treasuryGuardianUpgrade); + + const treasuryAddressUpgrade = await diamondUnitroller.treasuryAddress(); + expect(treasuryAddress).to.equal(treasuryAddressUpgrade); + + const treasuryPercentUpgrade = await diamondUnitroller.treasuryPercent(); + expect(treasuryPercent).to.equal(treasuryPercentUpgrade); + + const liquidatorContractUpgrade = await diamondUnitroller.liquidatorContract(); + expect(liquidatorContract).to.equal(liquidatorContractUpgrade); + + const comptrollerLensUpgrade = await diamondUnitroller.comptrollerLens(); + expect(comptrollerLens).to.equal(comptrollerLensUpgrade); + + // checking all public mappings + for (const marketIndex in allMarkets) { + const marketAddress = allMarkets[marketIndex].toString(); + + const marketUpgrade = await diamondUnitroller.markets(marketAddress); + expect(markets[marketAddress].collateralFactorMantissa).to.equal(marketUpgrade.collateralFactorMantissa); + expect(markets[marketAddress].isListed).to.equal(marketUpgrade.isListed); + expect(markets[marketAddress].isVenus).to.equal(marketUpgrade.isVenus); + + const venusBorrowSpeed = await diamondUnitroller.venusBorrowSpeeds(marketAddress); + const venusSupplySpeed = await diamondUnitroller.venusSupplySpeeds(marketAddress); + expect(borrowSpeeds[marketAddress]).to.equal(venusBorrowSpeed); + expect(supplySpeeds[marketAddress]).to.equal(venusSupplySpeed); + + const userBorrowIndex = await diamondUnitroller.venusBorrowerIndex( + marketAddress, + await busdHolder.getAddress(), + ); + const userSupplyIndex = await diamondUnitroller.venusSupplierIndex( + marketAddress, + await busdHolder.getAddress(), + ); + expect(userBorrowIndexes[marketAddress]).to.equal(userBorrowIndex); + expect(userSupplyIndexes[marketAddress]).to.equal(userSupplyIndex); + } + }); + }); + }); + + describe("Verify states of diamond Contract", () => { + describe("Diamond setters", () => { + it("setting market supply cap", async () => { + const currentSupplyCap = (await diamondUnitroller.supplyCaps(vBUSD.address)).toString(); + await diamondUnitroller.connect(owner)._setMarketSupplyCaps([vBUSD.address], [parseUnits("100000", 18)]); + expect(await diamondUnitroller.supplyCaps(vBUSD.address)).to.equals(parseUnits("100000", 18)); + await diamondUnitroller.connect(owner)._setMarketSupplyCaps([vBUSD.address], [parseUnits(currentSupplyCap, 0)]); + expect(await diamondUnitroller.supplyCaps(vBUSD.address)).to.equals(parseUnits(currentSupplyCap, 0)); + }); + + it("setting close factor", async () => { + const currentCloseFactor = (await diamondUnitroller.closeFactorMantissa()).toString(); + await diamondUnitroller.connect(owner)._setCloseFactor(parseUnits("1", 17)); + expect(await diamondUnitroller.closeFactorMantissa()).to.equals(parseUnits("1", 17)); + await diamondUnitroller.connect(owner)._setCloseFactor(parseUnits(currentCloseFactor, 0)); + expect(await diamondUnitroller.closeFactorMantissa()).to.equals(parseUnits(currentCloseFactor, 0)); + }); + + it("setting Liquidation Incentive", async () => { + await diamondUnitroller.connect(owner)._setLiquidationIncentive(parseUnits("13", 17)); + expect(await diamondUnitroller.liquidationIncentiveMantissa()).to.equal(parseUnits("13", 17)); + + await diamondUnitroller.connect(owner)._setLiquidationIncentive(parseUnits("11", 17)); + expect(await diamondUnitroller.liquidationIncentiveMantissa()).to.equal(parseUnits("11", 17)); + }); + + it("setting Pause Guardian", async () => { + const currentPauseGuardia = (await diamondUnitroller.pauseGuardian()).toString(); + + await diamondUnitroller.connect(owner)._setPauseGuardian(await owner.getAddress()); + expect(await diamondUnitroller.pauseGuardian()).to.equal(await owner.getAddress()); + + await diamondUnitroller.connect(owner)._setPauseGuardian(currentPauseGuardia); + expect(await diamondUnitroller.pauseGuardian()).to.equal(currentPauseGuardia); + }); + + it("setting market borrow cap", async () => { + const currentBorrowCap = (await diamondUnitroller.borrowCaps(vUSDT.address)).toString(); + await diamondUnitroller.connect(owner)._setMarketBorrowCaps([vUSDT.address], [parseUnits("10000", 18)]); + expect(await diamondUnitroller.borrowCaps(vUSDT.address)).to.equal(parseUnits("10000", 18)); + + await diamondUnitroller.connect(owner)._setMarketBorrowCaps([vUSDT.address], [currentBorrowCap]); + expect(await diamondUnitroller.borrowCaps(vUSDT.address)).to.equal(currentBorrowCap); + }); + + it("pausing mint action in vBUSD", async () => { + const isActionPaused = await diamondUnitroller.actionPaused(VBUSD, 0); + + await diamondUnitroller.connect(owner)._setActionsPaused([VBUSD], [0], !isActionPaused); + + await expect(await diamondUnitroller.actionPaused(VBUSD, 0)).to.be.equal(!isActionPaused); + + if (!isActionPaused) { + await diamondUnitroller.connect(owner)._setActionsPaused([VBUSD], [0], false); + } + }); + }); + }); +}); + +forking(32159070, async () => { + let owner, unitroller; + let USDT: Contract; + let usdtHolder: Signer; + let vUSDT: Contract; + let diamondUnitroller: Contract; + + before(async () => { + await pretendExecutingVip(vipCutParamAdd()); + unitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + + diamondUnitroller = new ethers.Contract(unitroller.address, Comptroller, ethers.provider); + + await impersonateAccount(Owner); + owner = await ethers.getSigner(Owner); + const [signer] = await ethers.getSigners(); + await signer.sendTransaction({ + to: owner.address, + value: ethers.BigNumber.from("10000000000000000000"), + data: undefined, + }); + + usdtHolder = await initMainnetUser("0x8894E0a0c962CB723c1976a4421c95949bE2D4E3", parseUnits("1000", 18)); + + [vUSDT] = await Promise.all( + [VUSDT].map((address: string) => { + return new ethers.Contract(address, VBEP20_DELEGATE_ABI, ethers.provider); + }), + ); + [USDT] = await Promise.all( + [vUSDT].map(async (vToken: Contract) => { + const underlying = await vToken.underlying(); + return new ethers.Contract(underlying, IERC20Upgradeable, ethers.provider); + }), + ); + await diamondUnitroller.connect(owner)._setActionsPaused([VBUSD], [0], false); + }); + + describe("Diamond Hooks", () => { + it("mint vToken vUSDT", async () => { + const vUSDTBalance = await USDT.balanceOf(vUSDT.address); + const usdtHolderBalance = await USDT.balanceOf(await usdtHolder.getAddress()); + await USDT.connect(usdtHolder).approve(vUSDT.address, parseUnits("1", 18)); + await vUSDT.connect(usdtHolder).mint(parseUnits("1", 18)); + const newvUSDTBalance = await USDT.balanceOf(vUSDT.address); + const newUsdtHolderBalance = await USDT.balanceOf(await usdtHolder.getAddress()); + + expect(newvUSDTBalance).greaterThan(vUSDTBalance); + expect(newUsdtHolderBalance).lessThan(usdtHolderBalance); + }); + + it("redeem vToken", async () => { + await USDT.connect(usdtHolder).approve(vUSDT.address, parseUnits("1", 18)); + await expect(vUSDT.connect(usdtHolder).mint(parseUnits("1", 18))).to.emit(vUSDT, "Mint"); + + const vUSDTUserBal = await vUSDT.connect(usdtHolder).balanceOf(await usdtHolder.getAddress()); + await expect(vUSDT.connect(usdtHolder).redeem(parseUnits("1", 8))).to.emit(vUSDT, "Redeem"); + const newVUSDTUserBal = await vUSDT.connect(usdtHolder).balanceOf(await usdtHolder.getAddress()); + + expect(newVUSDTUserBal).to.equal(vUSDTUserBal.sub(parseUnits("1", 8))); + }); + + it("borrow vToken", async () => { + const usdtUserBal = await USDT.balanceOf(await usdtHolder.getAddress()); + + await expect(vUSDT.connect(usdtHolder).borrow(parseUnits("1", 18))).to.emit(vUSDT, "Borrow"); + + expect((await USDT.balanceOf(await usdtHolder.getAddress())).toString()).to.equal( + usdtUserBal.add(parseUnits("1", 18)), + ); + }); + + it("Repay vToken", async () => { + await USDT.connect(usdtHolder).approve(vUSDT.address, parseUnits("1", 18)); + await expect(vUSDT.connect(usdtHolder).mint(parseUnits("1", 18))).to.emit(vUSDT, "Mint"); + + const usdtUserBal = await USDT.balanceOf(await usdtHolder.getAddress()); + await vUSDT.connect(usdtHolder).borrow(parseUnits("0.5", 18)); + + expect((await USDT.balanceOf(await usdtHolder.getAddress())).toString()).to.greaterThan(usdtUserBal); + + await USDT.connect(usdtHolder).approve(vUSDT.address, parseUnits("0.5", 18)); + await vUSDT.connect(usdtHolder).repayBorrow(parseUnits("0.5", 18)); + + const balanceAfterRepay = await USDT.balanceOf(await usdtHolder.getAddress()); + expect(balanceAfterRepay).to.equal(usdtUserBal); + }); + }); +}); diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/utils/cut-params.json b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/utils/cut-params.json new file mode 100644 index 000000000..89085b9f8 --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/utils/cut-params.json @@ -0,0 +1,3 @@ +{ + "cutParams": [["0x40A30E1B01e0CF3eE3F22f769b0E437160550eEa", 0, ["0xc5b4db55"]]] +} diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts new file mode 100644 index 000000000..f01e89916 --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts @@ -0,0 +1,432 @@ +import { impersonateAccount } from "@nomicfoundation/hardhat-network-helpers"; +import { expect } from "chai"; +import { BigNumberish, Contract, Signer } from "ethers"; +import { parseUnits } from "ethers/lib/utils"; +import { ethers } from "hardhat"; + +import { initMainnetUser } from "../../../src/utils"; +import { forking, pretendExecutingVip, testVip } from "../../../src/vip-framework"; +import { vipCutParamAdd } from "../../../vips/vip-diamond-cut-param-add/vip-param-add-testnet"; +import Comptroller from "../abi/Comptroller.json"; +import IERC20Upgradeable from "../abi/IERC20UpgradableAbi.json"; +import VBEP20_DELEGATE_ABI from "../abi/VBep20DelegateAbi.json"; + +const UNITROLLER = "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D"; +const Owner = "0xce10739590001705F7FF231611ba4A48B2820327"; +const VBUSD = "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4"; +const VUSDT = "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A"; + +// Added function signature for venusInitialIndex to market facet as cut param to diamond proxy +// This fork block contains tests for venusInitialIndex only. +forking(33757000, async () => { + let diamondUnitroller: ethers.Contract; + + before(async () => { + diamondUnitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + }); + + describe("Before execution of VIP", async () => { + it("Fetching of VenusInitialIndex should revert", async () => { + await expect(diamondUnitroller.venusInitialIndex()).to.be.reverted; + }); + }); + + testVip("VIP-Diamond cut param add", vipCutParamAdd()); + + describe("After execution of vip", async () => { + it("Fetching of VenusInitialIndex should return value", async () => { + expect(await diamondUnitroller.venusInitialIndex()).to.be.equal(parseUnits("1", 36)); + }); + }); +}); + +// As this vip is updating diamond proxy for the first time after it's implementation, +// therefore adding additional tests to verify all storage values before and after executing this vip, +// setter functions and core functionalities are working properly +forking(33757000, async () => { + let owner: Signer, + unitroller: Contract, + // layout variables + oracle: Contract, + maxAssets: BigNumberish, + closeFactorMantissa: BigNumberish, + liquidationIncentiveMantissa: BigNumberish, + allMarkets: Array, + venusSupplyState: any, + venusBorrowState: any, + venusAccrued: BigNumberish, + vaiMintRate: BigNumberish, + vaiController: Contract, + mintedVAIs: BigNumberish, + mintVAIGuardianPaused: boolean, + repayVAIGuardianPaused: boolean, + protocolPaused: boolean, + venusVAIVaultRate: BigNumberish, + vaiVaultAddress: string, + releaseStartBlock: BigNumberish, + minReleaseAmount: BigNumberish, + treasuryGuardian: boolean, + treasuryAddress: string, + treasuryPercent: BigNumberish, + liquidatorContract: Contract, + comptrollerLens: Contract; + + const borrowSpeeds: any = {}; + const supplySpeeds: any = {}; + const userBorrowIndexes: any = {}; + const userSupplyIndexes: any = {}; + const markets: any = {}; + + let BUSD: Contract; + let busdHolder: Signer; + let vBUSD: Contract; + let vUSDT: Contract; + let diamondUnitroller: Contract; + + before(async () => { + unitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + + diamondUnitroller = new ethers.Contract(unitroller.address, Comptroller, ethers.provider); + + await impersonateAccount(Owner); + owner = await ethers.getSigner(Owner); + const [signer] = await ethers.getSigners(); + await signer.sendTransaction({ + to: await owner.getAddress(), + value: ethers.BigNumber.from("10000000000000000000"), + data: undefined, + }); + + busdHolder = await initMainnetUser("0xC825AD791A6046991e3706b6342970f6d87e4888", parseUnits("1000", 18)); + + [vBUSD, vUSDT] = await Promise.all( + [VBUSD, VUSDT].map((address: string) => { + return new ethers.Contract(address, VBEP20_DELEGATE_ABI, ethers.provider); + }), + ); + + [BUSD] = await Promise.all( + [vBUSD].map(async (vToken: Contract) => { + const underlying = await vToken.underlying(); + return new ethers.Contract(underlying, IERC20Upgradeable, ethers.provider); + }), + ); + }); + + describe("Verify Storage slots before vip execution", async () => { + // These tests checks the storage collision of comptroller while updating it via diamond. + describe("Verify storage layout before vip execution", async () => { + it("verify all the state before and after upgrade", async () => { + oracle = await unitroller.oracle(); + + maxAssets = await unitroller.maxAssets(); + + closeFactorMantissa = await unitroller.closeFactorMantissa(); + + liquidationIncentiveMantissa = await unitroller.liquidationIncentiveMantissa(); + + venusSupplyState = await unitroller.venusSupplyState(BUSD.address); + + venusBorrowState = await unitroller.venusBorrowState(BUSD.address); + + venusAccrued = await unitroller.venusAccrued(BUSD.address); + + vaiMintRate = await unitroller.vaiMintRate(); + + vaiController = await unitroller.vaiController(); + + mintedVAIs = await unitroller.mintedVAIs(await busdHolder.getAddress()); + + mintVAIGuardianPaused = await unitroller.mintVAIGuardianPaused(); + + repayVAIGuardianPaused = await unitroller.repayVAIGuardianPaused(); + + protocolPaused = await unitroller.protocolPaused(); + + venusVAIVaultRate = await unitroller.venusVAIVaultRate(); + + vaiVaultAddress = await unitroller.vaiVaultAddress(); + + releaseStartBlock = await unitroller.releaseStartBlock(); + + minReleaseAmount = await unitroller.minReleaseAmount(); + + treasuryGuardian = await unitroller.treasuryGuardian(); + + treasuryAddress = await unitroller.treasuryAddress(); + + treasuryPercent = await unitroller.treasuryPercent(); + + liquidatorContract = await unitroller.liquidatorContract(); + + comptrollerLens = await unitroller.comptrollerLens(); + + // checking all public mappings + allMarkets = await unitroller.getAllMarkets(); + + for (const marketIndex in allMarkets) { + const marketAddress = allMarkets[marketIndex].toString(); + + borrowSpeeds[marketAddress] = await unitroller.venusBorrowSpeeds(marketAddress); + supplySpeeds[marketAddress] = await unitroller.venusSupplySpeeds(marketAddress); + markets[marketAddress] = await unitroller.markets(marketAddress); + + userBorrowIndexes[marketAddress] = await unitroller.venusBorrowerIndex( + marketAddress, + await busdHolder.getAddress(), + ); + userSupplyIndexes[marketAddress] = await unitroller.venusSupplierIndex( + marketAddress, + await busdHolder.getAddress(), + ); + } + }); + }); + }); + + testVip("VIP-Diamond cut param add", vipCutParamAdd()); + + describe("Verify Storage slots after VIP execution", async () => { + // These tests checks the storage collision of comptroller while updating it via diamond. + describe("Verify storage layout after VIP execution", async () => { + it("verify all the state before and after upgrade", async () => { + const oracelUpgrade = await diamondUnitroller.oracle(); + expect(oracle).to.equal(oracelUpgrade); + + const maxAssetsAfterUpgrade = await diamondUnitroller.maxAssets(); + expect(maxAssets).to.equal(maxAssetsAfterUpgrade); + + const closeFactorMantissaAfterUpgrade = await diamondUnitroller.closeFactorMantissa(); + expect(closeFactorMantissa).to.equal(closeFactorMantissaAfterUpgrade); + + const liquidationIncentiveMantissaAfterUpgrade = await diamondUnitroller.liquidationIncentiveMantissa(); + expect(liquidationIncentiveMantissa).to.equal(liquidationIncentiveMantissaAfterUpgrade); + + const venusSupplyStateAfterUpgrade = await diamondUnitroller.venusSupplyState(BUSD.address); + expect(venusSupplyState.index.toString()).to.equal(venusSupplyStateAfterUpgrade.index.toString()); + + const venusBorrowStateAfterUpgrade = await diamondUnitroller.venusBorrowState(BUSD.address); + expect(venusBorrowState.index.toString()).to.equal(venusBorrowStateAfterUpgrade.index.toString()); + + const venusAccruedAfterUpgrade = await diamondUnitroller.venusAccrued(BUSD.address); + expect(venusAccrued).to.equal(venusAccruedAfterUpgrade); + + const vaiMintRateAfterUpgrade = await diamondUnitroller.vaiMintRate(); + expect(vaiMintRate).to.equal(vaiMintRateAfterUpgrade); + + const vaiControllerUpgrade = await diamondUnitroller.vaiController(); + expect(vaiControllerUpgrade).to.equal(vaiController); + + const mintedVAIsUpgrade = await diamondUnitroller.mintedVAIs(await busdHolder.getAddress()); + expect(mintedVAIsUpgrade).to.equal(mintedVAIs); + + const mintVAIGuardianPausedUpgrade = await diamondUnitroller.mintVAIGuardianPaused(); + expect(mintVAIGuardianPausedUpgrade).to.equal(mintVAIGuardianPaused); + + const repayVAIGuardianPausedUpgrade = await diamondUnitroller.repayVAIGuardianPaused(); + expect(repayVAIGuardianPausedUpgrade).to.equal(repayVAIGuardianPaused); + + const protocolPausedUpgrade = await diamondUnitroller.protocolPaused(); + expect(protocolPausedUpgrade).to.equal(protocolPaused); + + const venusVAIVaultRateUpgrade = await diamondUnitroller.venusVAIVaultRate(); + expect(venusVAIVaultRateUpgrade).to.equal(venusVAIVaultRate); + + const vaiVaultAddressUpgrade = await diamondUnitroller.vaiVaultAddress(); + expect(vaiVaultAddressUpgrade).to.equal(vaiVaultAddress); + + const releaseStartBlockUpgrade = await diamondUnitroller.releaseStartBlock(); + expect(releaseStartBlockUpgrade).to.equal(releaseStartBlock); + + const minReleaseAmountUpgrade = await diamondUnitroller.minReleaseAmount(); + expect(minReleaseAmountUpgrade).to.equal(minReleaseAmount); + + const treasuryGuardianUpgrade = await diamondUnitroller.treasuryGuardian(); + expect(treasuryGuardian).to.equal(treasuryGuardianUpgrade); + + const treasuryAddressUpgrade = await diamondUnitroller.treasuryAddress(); + expect(treasuryAddress).to.equal(treasuryAddressUpgrade); + + const treasuryPercentUpgrade = await diamondUnitroller.treasuryPercent(); + expect(treasuryPercent).to.equal(treasuryPercentUpgrade); + + const liquidatorContractUpgrade = await diamondUnitroller.liquidatorContract(); + expect(liquidatorContract).to.equal(liquidatorContractUpgrade); + + const comptrollerLensUpgrade = await diamondUnitroller.comptrollerLens(); + expect(comptrollerLens).to.equal(comptrollerLensUpgrade); + + // checking all public mappings + for (const marketIndex in allMarkets) { + const marketAddress = allMarkets[marketIndex].toString(); + + const marketUpgrade = await diamondUnitroller.markets(marketAddress); + expect(markets[marketAddress].collateralFactorMantissa).to.equal(marketUpgrade.collateralFactorMantissa); + expect(markets[marketAddress].isListed).to.equal(marketUpgrade.isListed); + expect(markets[marketAddress].isVenus).to.equal(marketUpgrade.isVenus); + + const venusBorrowSpeed = await diamondUnitroller.venusBorrowSpeeds(marketAddress); + const venusSupplySpeed = await diamondUnitroller.venusSupplySpeeds(marketAddress); + expect(borrowSpeeds[marketAddress]).to.equal(venusBorrowSpeed); + expect(supplySpeeds[marketAddress]).to.equal(venusSupplySpeed); + + const userBorrowIndex = await diamondUnitroller.venusBorrowerIndex( + marketAddress, + await busdHolder.getAddress(), + ); + const userSupplyIndex = await diamondUnitroller.venusSupplierIndex( + marketAddress, + await busdHolder.getAddress(), + ); + expect(userBorrowIndexes[marketAddress]).to.equal(userBorrowIndex); + expect(userSupplyIndexes[marketAddress]).to.equal(userSupplyIndex); + } + }); + }); + }); + + describe("Verify states of diamond Contract", () => { + describe("Diamond setters", () => { + it("setting market supply cap", async () => { + const currentSupplyCap = (await diamondUnitroller.supplyCaps(vBUSD.address)).toString(); + await diamondUnitroller.connect(owner)._setMarketSupplyCaps([vBUSD.address], [parseUnits("100000", 18)]); + expect(await diamondUnitroller.supplyCaps(vBUSD.address)).to.equals(parseUnits("100000", 18)); + await diamondUnitroller.connect(owner)._setMarketSupplyCaps([vBUSD.address], [parseUnits(currentSupplyCap, 0)]); + expect(await diamondUnitroller.supplyCaps(vBUSD.address)).to.equals(parseUnits(currentSupplyCap, 0)); + }); + + it("setting close factor", async () => { + const currentCloseFactor = (await diamondUnitroller.closeFactorMantissa()).toString(); + await diamondUnitroller.connect(owner)._setCloseFactor(parseUnits("1", 17)); + expect(await diamondUnitroller.closeFactorMantissa()).to.equals(parseUnits("1", 17)); + await diamondUnitroller.connect(owner)._setCloseFactor(parseUnits(currentCloseFactor, 0)); + expect(await diamondUnitroller.closeFactorMantissa()).to.equals(parseUnits(currentCloseFactor, 0)); + }); + + it("setting Liquidation Incentive", async () => { + await diamondUnitroller.connect(owner)._setLiquidationIncentive(parseUnits("13", 17)); + expect(await diamondUnitroller.liquidationIncentiveMantissa()).to.equal(parseUnits("13", 17)); + + await diamondUnitroller.connect(owner)._setLiquidationIncentive(parseUnits("11", 17)); + expect(await diamondUnitroller.liquidationIncentiveMantissa()).to.equal(parseUnits("11", 17)); + }); + + it("setting Pause Guardian", async () => { + const currentPauseGuardia = (await diamondUnitroller.pauseGuardian()).toString(); + + await diamondUnitroller.connect(owner)._setPauseGuardian(await owner.getAddress()); + expect(await diamondUnitroller.pauseGuardian()).to.equal(await owner.getAddress()); + + await diamondUnitroller.connect(owner)._setPauseGuardian(currentPauseGuardia); + expect(await diamondUnitroller.pauseGuardian()).to.equal(currentPauseGuardia); + }); + + it("setting market borrow cap", async () => { + const currentBorrowCap = (await diamondUnitroller.borrowCaps(vUSDT.address)).toString(); + await diamondUnitroller.connect(owner)._setMarketBorrowCaps([vUSDT.address], [parseUnits("10000", 18)]); + expect(await diamondUnitroller.borrowCaps(vUSDT.address)).to.equal(parseUnits("10000", 18)); + + await diamondUnitroller.connect(owner)._setMarketBorrowCaps([vUSDT.address], [currentBorrowCap]); + expect(await diamondUnitroller.borrowCaps(vUSDT.address)).to.equal(currentBorrowCap); + }); + + it("pausing mint action in vBUSD", async () => { + const isActionPaused = await diamondUnitroller.actionPaused(VBUSD, 0); + + await diamondUnitroller.connect(owner)._setActionsPaused([VBUSD], [0], !isActionPaused); + + await expect(await diamondUnitroller.actionPaused(VBUSD, 0)).to.be.equal(!isActionPaused); + + if (!isActionPaused) { + await diamondUnitroller.connect(owner)._setActionsPaused([VBUSD], [0], false); + } + }); + }); + }); +}); + +forking(33757000, async () => { + let owner, unitroller; + let USDT: Contract; + let usdtHolder: Signer; + let vUSDT: Contract; + let diamondUnitroller: Contract; + + before(async () => { + await pretendExecutingVip(vipCutParamAdd()); + unitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + + diamondUnitroller = new ethers.Contract(unitroller.address, Comptroller, ethers.provider); + + await impersonateAccount(Owner); + owner = await ethers.getSigner(Owner); + const [signer] = await ethers.getSigners(); + await signer.sendTransaction({ + to: owner.address, + value: ethers.BigNumber.from("10000000000000000000"), + data: undefined, + }); + + usdtHolder = await initMainnetUser("0xa0747a72C329377C2CE4F0F3165197B3a5359EfE", parseUnits("1000", 18)); + + [vUSDT] = await Promise.all( + [VUSDT].map((address: string) => { + return new ethers.Contract(address, VBEP20_DELEGATE_ABI, ethers.provider); + }), + ); + [USDT] = await Promise.all( + [vUSDT].map(async (vToken: Contract) => { + const underlying = await vToken.underlying(); + return new ethers.Contract(underlying, IERC20Upgradeable, ethers.provider); + }), + ); + await diamondUnitroller.connect(owner)._setActionsPaused([VBUSD], [0], false); + }); + + describe("Diamond Hooks", () => { + it("mint vToken vUSDT", async () => { + const vUSDTBalance = await USDT.balanceOf(vUSDT.address); + const usdtHolderBalance = await USDT.balanceOf(await usdtHolder.getAddress()); + await USDT.connect(usdtHolder).approve(vUSDT.address, 2000); + await vUSDT.connect(usdtHolder).mint(2000); + const newvUSDTBalance = await USDT.balanceOf(vUSDT.address); + const newUsdtHolderBalance = await USDT.balanceOf(await usdtHolder.getAddress()); + + expect(newvUSDTBalance).greaterThan(vUSDTBalance); + expect(newUsdtHolderBalance).lessThan(usdtHolderBalance); + }); + + it("redeem vToken", async () => { + await USDT.connect(usdtHolder).approve(vUSDT.address, 2000); + await expect(vUSDT.connect(usdtHolder).mint(2000)).to.emit(vUSDT, "Mint"); + + const vUSDTUserBal = await vUSDT.connect(usdtHolder).balanceOf(await usdtHolder.getAddress()); + await expect(vUSDT.connect(usdtHolder).redeem(2000)).to.emit(vUSDT, "Redeem"); + const newVUSDTUserBal = await vUSDT.connect(usdtHolder).balanceOf(await usdtHolder.getAddress()); + + expect(newVUSDTUserBal).to.equal(vUSDTUserBal.sub(2000)); + }); + + it("borrow vToken", async () => { + const usdtUserBal = await USDT.balanceOf(await usdtHolder.getAddress()); + + await expect(vUSDT.connect(usdtHolder).borrow(1000)).to.emit(vUSDT, "Borrow"); + + expect((await USDT.balanceOf(await usdtHolder.getAddress())).toString()).to.equal(usdtUserBal.add(1000)); + }); + + it("Repay vToken", async () => { + await USDT.connect(usdtHolder).approve(vUSDT.address, 2000); + + const usdtUserBal = await USDT.balanceOf(await usdtHolder.getAddress()); + await vUSDT.connect(usdtHolder).borrow(1000); + + expect((await USDT.balanceOf(await usdtHolder.getAddress())).toString()).to.greaterThan(usdtUserBal); + + await vUSDT.connect(usdtHolder).repayBorrow(1000); + + const balanceAfterRepay = await USDT.balanceOf(await usdtHolder.getAddress()); + expect(balanceAfterRepay).to.equal(usdtUserBal); + }); + }); +}); diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/utils/cut-params.json b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/utils/cut-params.json new file mode 100644 index 000000000..0e010a8d7 --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/utils/cut-params.json @@ -0,0 +1,3 @@ +{ + "cutParams": [["0x1B9806d9d2925e8Cd318E268e562eeb7e02C6E00", 0, ["0xc5b4db55"]]] +} diff --git a/vips/vip-diamond-cut-param-add/vip-param-add-mainnet.ts b/vips/vip-diamond-cut-param-add/vip-param-add-mainnet.ts new file mode 100644 index 000000000..50d346324 --- /dev/null +++ b/vips/vip-diamond-cut-param-add/vip-param-add-mainnet.ts @@ -0,0 +1,31 @@ +import { cutParams as params } from "../../simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/utils/cut-params.json"; +import { ProposalType } from "../../src/types"; +import { makeProposal } from "../../src/utils"; + +const UNITROLLER = "0xfD36E2c2a6789Db23113685031d7F16329158384"; +const cutParams = params; + +export const vipCutParamAdd = () => { + const meta = { + version: "v2", + title: "VIP-Diamond-Cut-Param-Add", + description: `In Diamond Proxy implementation of comptroller, Adding function signature for venusInitialIndex + as cut param to the Market Facet`, + + forDescription: "Execute this proposal", + againstDescription: "Do not execute this proposal", + abstainDescription: "Indifferent to execution", + }; + + return makeProposal( + [ + { + target: UNITROLLER, + signature: "diamondCut((address,uint8,bytes4[])[])", + params: [cutParams], + }, + ], + meta, + ProposalType.REGULAR, + ); +}; diff --git a/vips/vip-diamond-cut-param-add/vip-param-add-testnet.ts b/vips/vip-diamond-cut-param-add/vip-param-add-testnet.ts new file mode 100644 index 000000000..2bf97d304 --- /dev/null +++ b/vips/vip-diamond-cut-param-add/vip-param-add-testnet.ts @@ -0,0 +1,31 @@ +import { cutParams as params } from "../../simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/utils/cut-params.json"; +import { ProposalType } from "../../src/types"; +import { makeProposal } from "../../src/utils"; + +const UNITROLLER = "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D"; +const cutParams = params; + +export const vipCutParamAdd = () => { + const meta = { + version: "v2", + title: "VIP-Diamond-Cut-Param-Add", + description: `In Diamond Proxy implementation of comptroller, Adding function signature for venusInitialIndex + as cut param to the Market Facet`, + + forDescription: "Execute this proposal", + againstDescription: "Do not execute this proposal", + abstainDescription: "Indifferent to execution", + }; + + return makeProposal( + [ + { + target: UNITROLLER, + signature: "diamondCut((address,uint8,bytes4[])[])", + params: [cutParams], + }, + ], + meta, + ProposalType.REGULAR, + ); +}; From 76a2a8990a485bf8619943f73f8a83742814e105 Mon Sep 17 00:00:00 2001 From: Debugger022 Date: Fri, 29 Sep 2023 17:36:22 +0530 Subject: [PATCH 2/4] tests: add tests for calculating pendingRewards --- .../abi/VenusLens.json | 839 ++++++++++++++++++ .../simulations.ts | 15 + .../simulations.ts | 21 +- 3 files changed, 872 insertions(+), 3 deletions(-) create mode 100644 simulations/vip-diamond-cut-param-add/abi/VenusLens.json diff --git a/simulations/vip-diamond-cut-param-add/abi/VenusLens.json b/simulations/vip-diamond-cut-param-add/abi/VenusLens.json new file mode 100644 index 000000000..a7fff9593 --- /dev/null +++ b/simulations/vip-diamond-cut-param-add/abi/VenusLens.json @@ -0,0 +1,839 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BLOCKS_PER_DAY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLimits", + "outputs": [ + { + "components": [ + { + "internalType": "contract VToken[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "shortfall", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.AccountLimits", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address payable", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "comptrollerAddress", + "type": "address" + } + ], + "name": "getDailyXVS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovProposals", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "proposer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "eta", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "uint256", + "name": "startBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "forVotes", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "againstVotes", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "executed", + "type": "bool" + } + ], + "internalType": "struct VenusLens.GovProposal[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract GovernorAlpha", + "name": "governor", + "type": "address" + }, + { + "internalType": "address", + "name": "voter", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "proposalIds", + "type": "uint256[]" + } + ], + "name": "getGovReceipts", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "hasVoted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "support", + "type": "bool" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct VenusLens.GovReceipt[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract XVS", + "name": "xvs", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32[]", + "name": "blockNumbers", + "type": "uint32[]" + } + ], + "name": "getVenusVotes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VenusVotes[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract XVS", + "name": "xvs", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getXVSBalanceMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + } + ], + "internalType": "struct VenusLens.XVSBalanceMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract XVS", + "name": "xvs", + "type": "address" + }, + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getXVSBalanceMetadataExt", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votes", + "type": "uint256" + }, + { + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allocated", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.XVSBalanceMetadataExt", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + }, + { + "internalType": "contract ComptrollerInterface", + "name": "comptroller", + "type": "address" + } + ], + "name": "pendingRewards", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "distributorAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardTokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "totalRewards", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "vTokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.PendingReward[]", + "name": "pendingRewards", + "type": "tuple[]" + } + ], + "internalType": "struct VenusLens.RewardSummary", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "vTokenBalances", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenBalances", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + }, + { + "internalType": "address payable", + "name": "account", + "type": "address" + } + ], + "name": "vTokenBalancesAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balanceOf", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalanceCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceOfUnderlying", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAllowance", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenBalances[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + } + ], + "name": "vTokenMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "vTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "venusSupplySpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "venusBorrowSpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dailySupplyXvs", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dailyBorrowXvs", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenMetadata", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + } + ], + "name": "vTokenMetadataAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exchangeRateCurrent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalReserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalCash", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + }, + { + "internalType": "address", + "name": "underlyingAssetAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "vTokenDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "venusSupplySpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "venusBorrowSpeed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dailySupplyXvs", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dailyBorrowXvs", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenMetadata[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract VToken", + "name": "vToken", + "type": "address" + } + ], + "name": "vTokenUnderlyingPrice", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenUnderlyingPrice", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "contract VToken[]", + "name": "vTokens", + "type": "address[]" + } + ], + "name": "vTokenUnderlyingPriceAll", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + } + ], + "internalType": "struct VenusLens.VTokenUnderlyingPrice[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts index 2210b6627..f1d698764 100644 --- a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts +++ b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts @@ -10,25 +10,34 @@ import { vipCutParamAdd } from "../../../vips/vip-diamond-cut-param-add/vip-para import Comptroller from "../abi/Comptroller.json"; import IERC20Upgradeable from "../abi/IERC20UpgradableAbi.json"; import VBEP20_DELEGATE_ABI from "../abi/VBep20DelegateAbi.json"; +import VENUS_LENS_ABI from "../abi/VenusLens.json"; const UNITROLLER = "0xfD36E2c2a6789Db23113685031d7F16329158384"; +const VENUS_LENS = "0xfB0f09dB330dC842a6637BfB959209424BbFE8C7"; const Owner = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; const VBUSD = "0x95c78222B3D6e262426483D42CfA53685A67Ab9D"; const VUSDT = "0xfD5840Cd36d94D7229439859C0112a4185BC0255"; +const USER = "0x8894E0a0c962CB723c1976a4421c95949bE2D4E3"; // Added function signature for venusInitialIndex to market facet as cut param to diamond proxy // This fork block contains tests for venusInitialIndex only. forking(32159070, async () => { let diamondUnitroller: ethers.Contract; + let venusLens: ethers.Contract; before(async () => { diamondUnitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + venusLens = new ethers.Contract(VENUS_LENS, VENUS_LENS_ABI, ethers.provider); }); describe("Before execution of VIP", async () => { it("Fetching of VenusInitialIndex should revert", async () => { await expect(diamondUnitroller.venusInitialIndex()).to.be.reverted; }); + + it("Calculation of pending rewards should revert", async () => { + await expect(venusLens.pendingRewards(USER, UNITROLLER)).to.be.reverted; + }); }); testVip("VIP-Diamond cut param add", vipCutParamAdd()); @@ -37,6 +46,12 @@ forking(32159070, async () => { it("Fetching of VenusInitialIndex should return value", async () => { expect(await diamondUnitroller.venusInitialIndex()).to.be.equal(parseUnits("1", 36)); }); + + it("Calculation of pending rewards should return value", async () => { + const rewards = await venusLens.pendingRewards(USER, UNITROLLER); + expect(rewards.length).to.be.greaterThan(0); + expect(rewards[3][0].amount).to.be.equal(0); + }); }); }); diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts index f01e89916..19b0eb89a 100644 --- a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts +++ b/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts @@ -10,25 +10,34 @@ import { vipCutParamAdd } from "../../../vips/vip-diamond-cut-param-add/vip-para import Comptroller from "../abi/Comptroller.json"; import IERC20Upgradeable from "../abi/IERC20UpgradableAbi.json"; import VBEP20_DELEGATE_ABI from "../abi/VBep20DelegateAbi.json"; +import VENUS_LENS_ABI from "../abi/VenusLens.json"; const UNITROLLER = "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D"; +const VENUS_LENS = "0x36B434654bD5fb010f8A68e190428dc4789E1b24"; const Owner = "0xce10739590001705F7FF231611ba4A48B2820327"; const VBUSD = "0x08e0A5575De71037aE36AbfAfb516595fE68e5e4"; const VUSDT = "0xb7526572FFE56AB9D7489838Bf2E18e3323b441A"; +const USER = "0xC825AD791A6046991e3706b6342970f6d87e4888"; // Added function signature for venusInitialIndex to market facet as cut param to diamond proxy // This fork block contains tests for venusInitialIndex only. -forking(33757000, async () => { +forking(33763885, async () => { let diamondUnitroller: ethers.Contract; + let venusLens: ethers.Contract; before(async () => { diamondUnitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); + venusLens = new ethers.Contract(VENUS_LENS, VENUS_LENS_ABI, ethers.provider); }); describe("Before execution of VIP", async () => { it("Fetching of VenusInitialIndex should revert", async () => { await expect(diamondUnitroller.venusInitialIndex()).to.be.reverted; }); + + it("Calculation of pending rewards should revert", async () => { + await expect(venusLens.pendingRewards(USER, UNITROLLER)).to.be.reverted; + }); }); testVip("VIP-Diamond cut param add", vipCutParamAdd()); @@ -37,13 +46,19 @@ forking(33757000, async () => { it("Fetching of VenusInitialIndex should return value", async () => { expect(await diamondUnitroller.venusInitialIndex()).to.be.equal(parseUnits("1", 36)); }); + + it("Calculation of pending rewards should return value", async () => { + const rewards = await venusLens.pendingRewards(USER, UNITROLLER); + expect(rewards.length).to.be.greaterThan(0); + expect(rewards[3][0].amount).to.be.equal(0); + }); }); }); // As this vip is updating diamond proxy for the first time after it's implementation, // therefore adding additional tests to verify all storage values before and after executing this vip, // setter functions and core functionalities are working properly -forking(33757000, async () => { +forking(33763885, async () => { let owner: Signer, unitroller: Contract, // layout variables @@ -345,7 +360,7 @@ forking(33757000, async () => { }); }); -forking(33757000, async () => { +forking(33763885, async () => { let owner, unitroller; let USDT: Contract; let usdtHolder: Signer; From a89456042cb6b043fc6c5d94d0e0f10b54a4021e Mon Sep 17 00:00:00 2001 From: Debugger022 Date: Thu, 5 Oct 2023 17:37:02 +0530 Subject: [PATCH 3/4] refactor: Added vip number 181 to add cut param to diamond proxy --- .../abi/Comptroller.json | 0 .../abi/IERC20UpgradableAbi.json | 0 .../abi/VBep20DelegateAbi.json | 0 .../abi/VenusLens.json | 0 .../abi/priceOracleAbi.json | 0 .../vip-181-testnet}/simulations.ts | 8 ++++---- .../vip-181-testnet}/utils/cut-params.json | 0 .../vip-181}/simulations.ts | 8 ++++---- .../vip-181}/utils/cut-params.json | 0 .../vip-181-testnet.ts} | 6 +++--- .../vip-param-add-mainnet.ts => vip-181/vip-181.ts} | 6 +++--- 11 files changed, 14 insertions(+), 14 deletions(-) rename simulations/{vip-diamond-cut-param-add => vip-181}/abi/Comptroller.json (100%) rename simulations/{vip-diamond-cut-param-add => vip-181}/abi/IERC20UpgradableAbi.json (100%) rename simulations/{vip-diamond-cut-param-add => vip-181}/abi/VBep20DelegateAbi.json (100%) rename simulations/{vip-diamond-cut-param-add => vip-181}/abi/VenusLens.json (100%) rename simulations/{vip-diamond-cut-param-add => vip-181}/abi/priceOracleAbi.json (100%) rename simulations/{vip-diamond-cut-param-add/vip-diamond-cut-param-testnet => vip-181/vip-181-testnet}/simulations.ts (98%) rename simulations/{vip-diamond-cut-param-add/vip-diamond-cut-param-testnet => vip-181/vip-181-testnet}/utils/cut-params.json (100%) rename simulations/{vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet => vip-181/vip-181}/simulations.ts (98%) rename simulations/{vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet => vip-181/vip-181}/utils/cut-params.json (100%) rename vips/{vip-diamond-cut-param-add/vip-param-add-testnet.ts => vip-181/vip-181-testnet.ts} (78%) rename vips/{vip-diamond-cut-param-add/vip-param-add-mainnet.ts => vip-181/vip-181.ts} (78%) diff --git a/simulations/vip-diamond-cut-param-add/abi/Comptroller.json b/simulations/vip-181/abi/Comptroller.json similarity index 100% rename from simulations/vip-diamond-cut-param-add/abi/Comptroller.json rename to simulations/vip-181/abi/Comptroller.json diff --git a/simulations/vip-diamond-cut-param-add/abi/IERC20UpgradableAbi.json b/simulations/vip-181/abi/IERC20UpgradableAbi.json similarity index 100% rename from simulations/vip-diamond-cut-param-add/abi/IERC20UpgradableAbi.json rename to simulations/vip-181/abi/IERC20UpgradableAbi.json diff --git a/simulations/vip-diamond-cut-param-add/abi/VBep20DelegateAbi.json b/simulations/vip-181/abi/VBep20DelegateAbi.json similarity index 100% rename from simulations/vip-diamond-cut-param-add/abi/VBep20DelegateAbi.json rename to simulations/vip-181/abi/VBep20DelegateAbi.json diff --git a/simulations/vip-diamond-cut-param-add/abi/VenusLens.json b/simulations/vip-181/abi/VenusLens.json similarity index 100% rename from simulations/vip-diamond-cut-param-add/abi/VenusLens.json rename to simulations/vip-181/abi/VenusLens.json diff --git a/simulations/vip-diamond-cut-param-add/abi/priceOracleAbi.json b/simulations/vip-181/abi/priceOracleAbi.json similarity index 100% rename from simulations/vip-diamond-cut-param-add/abi/priceOracleAbi.json rename to simulations/vip-181/abi/priceOracleAbi.json diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts b/simulations/vip-181/vip-181-testnet/simulations.ts similarity index 98% rename from simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts rename to simulations/vip-181/vip-181-testnet/simulations.ts index 19b0eb89a..8cd50599f 100644 --- a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/simulations.ts +++ b/simulations/vip-181/vip-181-testnet/simulations.ts @@ -6,7 +6,7 @@ import { ethers } from "hardhat"; import { initMainnetUser } from "../../../src/utils"; import { forking, pretendExecutingVip, testVip } from "../../../src/vip-framework"; -import { vipCutParamAdd } from "../../../vips/vip-diamond-cut-param-add/vip-param-add-testnet"; +import { vip181Testnet } from "../../../vips/vip-181/vip-181-testnet"; import Comptroller from "../abi/Comptroller.json"; import IERC20Upgradeable from "../abi/IERC20UpgradableAbi.json"; import VBEP20_DELEGATE_ABI from "../abi/VBep20DelegateAbi.json"; @@ -40,7 +40,7 @@ forking(33763885, async () => { }); }); - testVip("VIP-Diamond cut param add", vipCutParamAdd()); + testVip("VIP-Diamond cut param add", vip181Testnet()); describe("After execution of vip", async () => { it("Fetching of VenusInitialIndex should return value", async () => { @@ -199,7 +199,7 @@ forking(33763885, async () => { }); }); - testVip("VIP-Diamond cut param add", vipCutParamAdd()); + testVip("VIP-Diamond cut param add", vip181Testnet()); describe("Verify Storage slots after VIP execution", async () => { // These tests checks the storage collision of comptroller while updating it via diamond. @@ -368,7 +368,7 @@ forking(33763885, async () => { let diamondUnitroller: Contract; before(async () => { - await pretendExecutingVip(vipCutParamAdd()); + await pretendExecutingVip(vip181Testnet()); unitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); diamondUnitroller = new ethers.Contract(unitroller.address, Comptroller, ethers.provider); diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/utils/cut-params.json b/simulations/vip-181/vip-181-testnet/utils/cut-params.json similarity index 100% rename from simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/utils/cut-params.json rename to simulations/vip-181/vip-181-testnet/utils/cut-params.json diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts b/simulations/vip-181/vip-181/simulations.ts similarity index 98% rename from simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts rename to simulations/vip-181/vip-181/simulations.ts index f1d698764..27e261725 100644 --- a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/simulations.ts +++ b/simulations/vip-181/vip-181/simulations.ts @@ -6,7 +6,7 @@ import { ethers } from "hardhat"; import { initMainnetUser } from "../../../src/utils"; import { forking, pretendExecutingVip, testVip } from "../../../src/vip-framework"; -import { vipCutParamAdd } from "../../../vips/vip-diamond-cut-param-add/vip-param-add-mainnet"; +import { vip181 } from "../../../vips/vip-181/vip-181"; import Comptroller from "../abi/Comptroller.json"; import IERC20Upgradeable from "../abi/IERC20UpgradableAbi.json"; import VBEP20_DELEGATE_ABI from "../abi/VBep20DelegateAbi.json"; @@ -40,7 +40,7 @@ forking(32159070, async () => { }); }); - testVip("VIP-Diamond cut param add", vipCutParamAdd()); + testVip("VIP-Diamond cut param add", vip181()); describe("After execution of vip", async () => { it("Fetching of VenusInitialIndex should return value", async () => { @@ -199,7 +199,7 @@ forking(32159070, async () => { }); }); - testVip("VIP-Diamond Contract Migration", vipCutParamAdd()); + testVip("VIP-Diamond Contract Migration", vip181()); describe("Verify Storage slots after VIP execution", async () => { // These tests checks the storage collision of comptroller while updating it via diamond. @@ -368,7 +368,7 @@ forking(32159070, async () => { let diamondUnitroller: Contract; before(async () => { - await pretendExecutingVip(vipCutParamAdd()); + await pretendExecutingVip(vip181()); unitroller = new ethers.Contract(UNITROLLER, Comptroller, ethers.provider); diamondUnitroller = new ethers.Contract(unitroller.address, Comptroller, ethers.provider); diff --git a/simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/utils/cut-params.json b/simulations/vip-181/vip-181/utils/cut-params.json similarity index 100% rename from simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/utils/cut-params.json rename to simulations/vip-181/vip-181/utils/cut-params.json diff --git a/vips/vip-diamond-cut-param-add/vip-param-add-testnet.ts b/vips/vip-181/vip-181-testnet.ts similarity index 78% rename from vips/vip-diamond-cut-param-add/vip-param-add-testnet.ts rename to vips/vip-181/vip-181-testnet.ts index 2bf97d304..513f3ccca 100644 --- a/vips/vip-diamond-cut-param-add/vip-param-add-testnet.ts +++ b/vips/vip-181/vip-181-testnet.ts @@ -1,14 +1,14 @@ -import { cutParams as params } from "../../simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-testnet/utils/cut-params.json"; +import { cutParams as params } from "../../simulations/vip-181/vip-181-testnet/utils/cut-params.json"; import { ProposalType } from "../../src/types"; import { makeProposal } from "../../src/utils"; const UNITROLLER = "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D"; const cutParams = params; -export const vipCutParamAdd = () => { +export const vip181Testnet = () => { const meta = { version: "v2", - title: "VIP-Diamond-Cut-Param-Add", + title: "VIP-181 Add cut param to Diamond Comptroller", description: `In Diamond Proxy implementation of comptroller, Adding function signature for venusInitialIndex as cut param to the Market Facet`, diff --git a/vips/vip-diamond-cut-param-add/vip-param-add-mainnet.ts b/vips/vip-181/vip-181.ts similarity index 78% rename from vips/vip-diamond-cut-param-add/vip-param-add-mainnet.ts rename to vips/vip-181/vip-181.ts index 50d346324..d625e219a 100644 --- a/vips/vip-diamond-cut-param-add/vip-param-add-mainnet.ts +++ b/vips/vip-181/vip-181.ts @@ -1,14 +1,14 @@ -import { cutParams as params } from "../../simulations/vip-diamond-cut-param-add/vip-diamond-cut-param-mainnet/utils/cut-params.json"; +import { cutParams as params } from "../../simulations/vip-181/vip-181/utils/cut-params.json"; import { ProposalType } from "../../src/types"; import { makeProposal } from "../../src/utils"; const UNITROLLER = "0xfD36E2c2a6789Db23113685031d7F16329158384"; const cutParams = params; -export const vipCutParamAdd = () => { +export const vip181 = () => { const meta = { version: "v2", - title: "VIP-Diamond-Cut-Param-Add", + title: "VIP-181 Add cut param to Diamond Comptroller", description: `In Diamond Proxy implementation of comptroller, Adding function signature for venusInitialIndex as cut param to the Market Facet`, From fb29c8f073d29b42124eef19b064224bc3ab6ae9 Mon Sep 17 00:00:00 2001 From: Jesus Lanchas Date: Thu, 5 Oct 2023 15:51:03 +0200 Subject: [PATCH 4/4] feat: add final description for VIP 181 --- vips/vip-181/vip-181.ts | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/vips/vip-181/vip-181.ts b/vips/vip-181/vip-181.ts index d625e219a..3e733a6eb 100644 --- a/vips/vip-181/vip-181.ts +++ b/vips/vip-181/vip-181.ts @@ -8,9 +8,38 @@ const cutParams = params; export const vip181 = () => { const meta = { version: "v2", - title: "VIP-181 Add cut param to Diamond Comptroller", - description: `In Diamond Proxy implementation of comptroller, Adding function signature for venusInitialIndex - as cut param to the Market Facet`, + title: "VIP-181 Fix on the Diamond Comptroller configuration", + description: `#### Summary + +If passed this VIP will apply a fix in the configuration of the Diamond Comptroller deployed at [VIP-174](https://app.venus.io/#/governance/proposal/174). It doesn’t involve any code change or contract upgrade. + +#### Description + +[VIP-174](https://app.venus.io/#/governance/proposal/174) didn't include the config in the Diamond Comptroller to route the function "venusInitialIndex()" to a specific facet. So, when the Diamond Comptroller receives the call to invoke that function (from the [VenusLens](https://bscscan.com/address/0xfB0f09dB330dC842a6637BfB959209424BbFE8C7) contract, for example) it throws the error "Diamond: Function does not exist". + +The solution, proposed in this VIP, is to add a route in the Diamond Comptroller for the missing function. It could be routed to any facet, because the public constant "venusInitialIndex" is defined in the parent contract [FacetBase](https://github.com/VenusProtocol/venus-protocol/blob/main/contracts/Comptroller/Diamond/facets/FacetBase.sol#L26), extended by every facet. This VIP proposes to route it to the [MarketFacet](https://bscscan.com/address/0x40A30E1B01e0CF3eE3F22f769b0E437160550eEa), where the "venusInitialIndex" constant is already used. + +- Sighash of "venusInitialIndex()": 0xc5b4db55 (used to identify the invoked function) +- Market facet in mainnet: [0x40A30E1B01e0CF3eE3F22f769b0E437160550eEa](https://bscscan.com/address/0x40A30E1B01e0CF3eE3F22f769b0E437160550eEa) + +**Security and additional considerations** + +This VIP doesn’t involve any code change or contract upgrade. We applied the following security procedures for this configuration change: + +- **Comptroller contract behavior post upgrade**: in a simulation environment, validating Comptroller works as expected after the configuration update, specifically the access to the function "venusInitialIndex()" +- **Comptroller storage layout**: in a simulation environment, validating the storage variables are accessible and correct after the upgrade +- **Deployment on testnet**: the same configuration change has been applied to the Diamond Comptroller [deployed to testnet](https://testnet.bscscan.com/tx/0x67a8d1be46858a40a38d6512489e746936a242c0ae756a5e52a4aeb78ba4ebf8), and used in the Venus Protocol testnet deployment + +**Deployed contracts on main net** + +- [Comptroller proxy (Unitroller)](https://bscscan.com/address/0xfd36e2c2a6789db23113685031d7f16329158384) +- [Comptroller implementation (Diamond)](https://bscscan.com/address/0xAd69AA3811fE0EE7dBd4e25C4bae40e6422c76C8) + +**References** + +- [Simulation pre and post upgrade](https://github.com/VenusProtocol/vips/pull/80) +- [Documentation](https://docs-v4.venus.io/technical-reference/reference-technical-articles/diamond-comptroller) +`, forDescription: "Execute this proposal", againstDescription: "Do not execute this proposal",