@venusprotocol/protocol-reserve 1.0.0-converters.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +215 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +183 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json +297 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.json +194 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.json +233 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +10 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +115 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.json +76 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.json +24 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.json +63 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.json +24 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.json +194 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.json +86 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.json +10 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.json +10 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.json +24 -0
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.dbg.json +4 -0
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.json +181 -0
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.dbg.json +4 -0
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.json +282 -0
- package/artifacts/@venusprotocol/isolated-pools/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.dbg.json +4 -0
- package/artifacts/@venusprotocol/isolated-pools/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.json +59 -0
- package/artifacts/@venusprotocol/oracle/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +4 -0
- package/artifacts/@venusprotocol/oracle/contracts/ResilientOracle.sol/ResilientOracle.json +649 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +4 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.json +40 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +4 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.json +30 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +4 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.json +75 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +4 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.json +49 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/VBep20Interface.sol/VBep20Interface.dbg.json +4 -0
- package/artifacts/@venusprotocol/oracle/contracts/interfaces/VBep20Interface.sol/VBep20Interface.json +246 -0
- package/artifacts/@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.dbg.json +4 -0
- package/artifacts/@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.json +59 -0
- package/artifacts/build-info/09a7fbe40ee8fdfd62afe79292e77863.json +1 -0
- package/artifacts/contracts/Interfaces/IComptroller.sol/IComptroller.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IComptroller.sol/IComptroller.json +56 -0
- package/artifacts/contracts/Interfaces/IConverterNetwork.sol/IConverterNetwork.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IConverterNetwork.sol/IConverterNetwork.json +127 -0
- package/artifacts/contracts/Interfaces/IIncomeDestination.sol/IIncomeDestination.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IIncomeDestination.sol/IIncomeDestination.json +29 -0
- package/artifacts/contracts/Interfaces/IPoolRegistry.sol/IPoolRegistry.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IPoolRegistry.sol/IPoolRegistry.json +54 -0
- package/artifacts/contracts/Interfaces/IPrime.sol/IPrime.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IPrime.sol/IPrime.json +74 -0
- package/artifacts/contracts/Interfaces/IProtocolShareReserve.sol/IProtocolShareReserve.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IProtocolShareReserve.sol/IProtocolShareReserve.json +34 -0
- package/artifacts/contracts/Interfaces/IRiskFund.sol/IRiskFund.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IRiskFund.sol/IRiskFund.json +77 -0
- package/artifacts/contracts/Interfaces/IRiskFund.sol/IRiskFundGetters.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IRiskFund.sol/IRiskFundGetters.json +24 -0
- package/artifacts/contracts/Interfaces/IRiskFundConverter.sol/IRiskFundConverter.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IRiskFundConverter.sol/IRiskFundConverter.json +48 -0
- package/artifacts/contracts/Interfaces/IShortfall.sol/IShortfall.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IShortfall.sol/IShortfall.json +24 -0
- package/artifacts/contracts/Interfaces/IVToken.sol/IVToken.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IVToken.sol/IVToken.json +24 -0
- package/artifacts/contracts/Interfaces/IXVSVault.sol/IXVSVault.dbg.json +4 -0
- package/artifacts/contracts/Interfaces/IXVSVault.sol/IXVSVault.json +24 -0
- package/artifacts/contracts/ProtocolReserve/ProtocolShareReserve.sol/ProtocolShareReserve.dbg.json +4 -0
- package/artifacts/contracts/ProtocolReserve/ProtocolShareReserve.sol/ProtocolShareReserve.json +892 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/MaxLoopsLimitHelpersStorage.dbg.json +4 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/MaxLoopsLimitHelpersStorage.json +24 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/ReserveHelpersStorage.dbg.json +4 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/ReserveHelpersStorage.json +139 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/RiskFundV1Storage.dbg.json +4 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/RiskFundV1Storage.json +178 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/RiskFundV2Storage.dbg.json +4 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/RiskFundV2Storage.json +191 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundV2.sol/RiskFundV2.dbg.json +4 -0
- package/artifacts/contracts/ProtocolReserve/RiskFundV2.sol/RiskFundV2.json +582 -0
- package/artifacts/contracts/ProtocolReserve/XVSVaultTreasury.sol/XVSVaultTreasury.dbg.json +4 -0
- package/artifacts/contracts/ProtocolReserve/XVSVaultTreasury.sol/XVSVaultTreasury.json +315 -0
- package/artifacts/contracts/Test/Mocks/MockACM.sol/MockACM.dbg.json +4 -0
- package/artifacts/contracts/Test/Mocks/MockACM.sol/MockACM.json +369 -0
- package/artifacts/contracts/Test/Mocks/MockArraySorter.sol/MockArraySorter.dbg.json +4 -0
- package/artifacts/contracts/Test/Mocks/MockArraySorter.sol/MockArraySorter.json +40 -0
- package/artifacts/contracts/Test/Mocks/MockConverter.sol/MockConverter.dbg.json +4 -0
- package/artifacts/contracts/Test/Mocks/MockConverter.sol/MockConverter.json +1199 -0
- package/artifacts/contracts/Test/Mocks/MockDeflationaryToken.sol/MockDeflatingToken.dbg.json +4 -0
- package/artifacts/contracts/Test/Mocks/MockDeflationaryToken.sol/MockDeflatingToken.json +332 -0
- package/artifacts/contracts/Test/Mocks/MockRiskFundConverter.sol/MockRiskFundConverter.dbg.json +4 -0
- package/artifacts/contracts/Test/Mocks/MockRiskFundConverter.sol/MockRiskFundConverter.json +1559 -0
- package/artifacts/contracts/Test/Mocks/MockToken.sol/MockToken.dbg.json +4 -0
- package/artifacts/contracts/Test/Mocks/MockToken.sol/MockToken.json +333 -0
- package/artifacts/contracts/TokenConverter/AbstractTokenConverter.sol/AbstractTokenConverter.dbg.json +4 -0
- package/artifacts/contracts/TokenConverter/AbstractTokenConverter.sol/AbstractTokenConverter.json +1085 -0
- package/artifacts/contracts/TokenConverter/ConverterNetwork.sol/ConverterNetwork.dbg.json +4 -0
- package/artifacts/contracts/TokenConverter/ConverterNetwork.sol/ConverterNetwork.json +457 -0
- package/artifacts/contracts/TokenConverter/IAbstractTokenConverter.sol/IAbstractTokenConverter.dbg.json +4 -0
- package/artifacts/contracts/TokenConverter/IAbstractTokenConverter.sol/IAbstractTokenConverter.json +344 -0
- package/artifacts/contracts/TokenConverter/RiskFundConverter.sol/RiskFundConverter.dbg.json +4 -0
- package/artifacts/contracts/TokenConverter/RiskFundConverter.sol/RiskFundConverter.json +1429 -0
- package/artifacts/contracts/TokenConverter/SingleTokenConverter.sol/SingleTokenConverter.dbg.json +4 -0
- package/artifacts/contracts/TokenConverter/SingleTokenConverter.sol/SingleTokenConverter.json +1145 -0
- package/contracts/Interfaces/IComptroller.sol +10 -0
- package/contracts/Interfaces/IConverterNetwork.sol +46 -0
- package/contracts/Interfaces/IIncomeDestination.sol +6 -0
- package/contracts/Interfaces/IPoolRegistry.sol +10 -0
- package/contracts/Interfaces/IPrime.sol +12 -0
- package/contracts/Interfaces/IProtocolShareReserve.sol +16 -0
- package/contracts/Interfaces/IRiskFund.sol +28 -0
- package/contracts/Interfaces/IRiskFundConverter.sol +8 -0
- package/contracts/Interfaces/IShortfall.sol +11 -0
- package/contracts/Interfaces/IVToken.sol +6 -0
- package/contracts/Interfaces/IXVSVault.sol +9 -0
- package/contracts/ProtocolReserve/ProtocolShareReserve.sol +547 -0
- package/contracts/ProtocolReserve/RiskFundStorage.sol +67 -0
- package/contracts/ProtocolReserve/RiskFundV2.sol +220 -0
- package/contracts/ProtocolReserve/XVSVaultTreasury.sol +95 -0
- package/contracts/Test/Mocks/MockACM.sol +93 -0
- package/contracts/Test/Mocks/MockArraySorter.sol +14 -0
- package/contracts/Test/Mocks/MockConverter.sol +69 -0
- package/contracts/Test/Mocks/MockDeflationaryToken.sol +113 -0
- package/contracts/Test/Mocks/MockRiskFundConverter.sol +45 -0
- package/contracts/Test/Mocks/MockToken.sol +30 -0
- package/contracts/TokenConverter/AbstractTokenConverter.sol +1022 -0
- package/contracts/TokenConverter/ConverterNetwork.sol +242 -0
- package/contracts/TokenConverter/IAbstractTokenConverter.sol +132 -0
- package/contracts/TokenConverter/RiskFundConverter.sol +436 -0
- package/contracts/TokenConverter/SingleTokenConverter.sol +77 -0
- package/contracts/Utils/ArrayHelpers.sol +41 -0
- package/contracts/Utils/Constants.sol +11 -0
- package/contracts/Utils/Validators.sol +26 -0
- package/deploy/001-risk-fund-converter.ts +124 -0
- package/deploy/1-deploy.ts +64 -0
- package/deployments/bscmainnet/.chainId +1 -0
- package/deployments/bscmainnet/DefaultProxyAdmin.json +257 -0
- package/deployments/bscmainnet/ProtocolShareReserve.json +1126 -0
- package/deployments/bscmainnet/ProtocolShareReserve_Implementation.json +1400 -0
- package/deployments/bscmainnet/ProtocolShareReserve_Proxy.json +261 -0
- package/deployments/bscmainnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json +78 -0
- package/deployments/bscmainnet/solcInputs/aee5f1db1180ece295e59c8f036fe600.json +90 -0
- package/deployments/bsctestnet/.chainId +1 -0
- package/deployments/bsctestnet/DefaultProxyAdmin.json +257 -0
- package/deployments/bsctestnet/ProtocolShareReserve.json +1126 -0
- package/deployments/bsctestnet/ProtocolShareReserve_Implementation.json +1400 -0
- package/deployments/bsctestnet/ProtocolShareReserve_Proxy.json +261 -0
- package/deployments/bsctestnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json +78 -0
- package/deployments/bsctestnet/solcInputs/aee5f1db1180ece295e59c8f036fe600.json +90 -0
- package/package.json +119 -0
- package/typechain/AbstractTokenConverter.d.ts +1516 -0
- package/typechain/AccessControl.d.ts +388 -0
- package/typechain/AccessControlledV8.d.ts +341 -0
- package/typechain/BoundValidatorInterface.d.ts +126 -0
- package/typechain/ContextUpgradeable.d.ts +92 -0
- package/typechain/ConverterNetwork.d.ts +721 -0
- package/typechain/ERC165.d.ts +116 -0
- package/typechain/ERC20.d.ts +441 -0
- package/typechain/IAbstractTokenConverter.d.ts +606 -0
- package/typechain/IAccessControl.d.ts +333 -0
- package/typechain/IAccessControlManagerV8.d.ts +504 -0
- package/typechain/IComptroller.d.ts +136 -0
- package/typechain/IConverterNetwork.d.ts +292 -0
- package/typechain/IERC165.d.ts +116 -0
- package/typechain/IERC20.d.ts +324 -0
- package/typechain/IERC20Metadata.d.ts +363 -0
- package/typechain/IERC20PermitUpgradeable.d.ts +187 -0
- package/typechain/IERC20Upgradeable.d.ts +324 -0
- package/typechain/IIncomeDestination.d.ts +122 -0
- package/typechain/IPoolRegistry.d.ts +155 -0
- package/typechain/IPrime.d.ts +197 -0
- package/typechain/IProtocolShareReserve.d.ts +127 -0
- package/typechain/IRiskFund.d.ts +200 -0
- package/typechain/IRiskFundConverter.d.ts +138 -0
- package/typechain/IRiskFundGetters.d.ts +103 -0
- package/typechain/IShortfall.d.ts +110 -0
- package/typechain/IVToken.d.ts +98 -0
- package/typechain/IXVSVault.d.ts +95 -0
- package/typechain/Initializable.d.ts +92 -0
- package/typechain/MaxLoopsLimitHelper.d.ts +128 -0
- package/typechain/MaxLoopsLimitHelpersStorage.d.ts +101 -0
- package/typechain/MockACM.d.ts +615 -0
- package/typechain/MockArraySorter.d.ts +118 -0
- package/typechain/MockConverter.d.ts +1705 -0
- package/typechain/MockDeflatingToken.d.ts +486 -0
- package/typechain/MockRiskFundConverter.d.ts +2193 -0
- package/typechain/MockToken.d.ts +505 -0
- package/typechain/OracleInterface.d.ts +98 -0
- package/typechain/Ownable2StepUpgradeable.d.ts +261 -0
- package/typechain/OwnableUpgradeable.d.ts +193 -0
- package/typechain/PausableUpgradeable.d.ts +129 -0
- package/typechain/ProtocolShareReserve.d.ts +1332 -0
- package/typechain/ReentrancyGuardUpgradeable.d.ts +92 -0
- package/typechain/ReserveHelpersStorage.d.ts +300 -0
- package/typechain/ResilientOracle.d.ts +1022 -0
- package/typechain/ResilientOracleInterface.d.ts +192 -0
- package/typechain/RiskFundConverter.d.ts +1949 -0
- package/typechain/RiskFundV1Storage.d.ts +353 -0
- package/typechain/RiskFundV2.d.ts +893 -0
- package/typechain/RiskFundV2Storage.d.ts +372 -0
- package/typechain/SingleTokenConverter.d.ts +1598 -0
- package/typechain/TwapInterface.d.ts +124 -0
- package/typechain/VBep20Interface.d.ts +379 -0
- package/typechain/XVSVaultTreasury.d.ts +515 -0
- package/typechain/common.d.ts +35 -0
- package/typechain/factories/AbstractTokenConverter__factory.ts +1105 -0
- package/typechain/factories/AccessControl__factory.ts +227 -0
- package/typechain/factories/AccessControlledV8__factory.ts +196 -0
- package/typechain/factories/BoundValidatorInterface__factory.ts +59 -0
- package/typechain/factories/ContextUpgradeable__factory.ts +39 -0
- package/typechain/factories/ConverterNetwork__factory.ts +502 -0
- package/typechain/factories/ERC165__factory.ts +39 -0
- package/typechain/factories/ERC20__factory.ts +340 -0
- package/typechain/factories/IAbstractTokenConverter__factory.ts +364 -0
- package/typechain/factories/IAccessControlManagerV8__factory.ts +301 -0
- package/typechain/factories/IAccessControl__factory.ts +198 -0
- package/typechain/factories/IComptroller__factory.ts +68 -0
- package/typechain/factories/IConverterNetwork__factory.ts +142 -0
- package/typechain/factories/IERC165__factory.ts +42 -0
- package/typechain/factories/IERC20Metadata__factory.ts +248 -0
- package/typechain/factories/IERC20PermitUpgradeable__factory.ts +105 -0
- package/typechain/factories/IERC20Upgradeable__factory.ts +209 -0
- package/typechain/factories/IERC20__factory.ts +203 -0
- package/typechain/factories/IIncomeDestination__factory.ts +44 -0
- package/typechain/factories/IPoolRegistry__factory.ts +66 -0
- package/typechain/factories/IPrime__factory.ts +83 -0
- package/typechain/factories/IProtocolShareReserve__factory.ts +53 -0
- package/typechain/factories/IRiskFundConverter__factory.ts +63 -0
- package/typechain/factories/IRiskFundGetters__factory.ts +39 -0
- package/typechain/factories/IRiskFund__factory.ts +89 -0
- package/typechain/factories/IShortfall__factory.ts +36 -0
- package/typechain/factories/IVToken__factory.ts +36 -0
- package/typechain/factories/IXVSVault__factory.ts +36 -0
- package/typechain/factories/Initializable__factory.ts +36 -0
- package/typechain/factories/MaxLoopsLimitHelper__factory.ts +74 -0
- package/typechain/factories/MaxLoopsLimitHelpersStorage__factory.ts +75 -0
- package/typechain/factories/MockACM__factory.ts +411 -0
- package/typechain/factories/MockArraySorter__factory.ts +85 -0
- package/typechain/factories/MockConverter__factory.ts +1242 -0
- package/typechain/factories/MockDeflatingToken__factory.ts +389 -0
- package/typechain/factories/MockRiskFundConverter__factory.ts +1625 -0
- package/typechain/factories/MockToken__factory.ts +398 -0
- package/typechain/factories/OracleInterface__factory.ts +45 -0
- package/typechain/factories/Ownable2StepUpgradeable__factory.ts +134 -0
- package/typechain/factories/OwnableUpgradeable__factory.ts +91 -0
- package/typechain/factories/PausableUpgradeable__factory.ts +78 -0
- package/typechain/factories/ProtocolShareReserve__factory.ts +957 -0
- package/typechain/factories/ReentrancyGuardUpgradeable__factory.ts +43 -0
- package/typechain/factories/ReserveHelpersStorage__factory.ts +188 -0
- package/typechain/factories/ResilientOracleInterface__factory.ts +94 -0
- package/typechain/factories/ResilientOracle__factory.ts +710 -0
- package/typechain/factories/RiskFundConverter__factory.ts +1491 -0
- package/typechain/factories/RiskFundV1Storage__factory.ts +223 -0
- package/typechain/factories/RiskFundV2Storage__factory.ts +236 -0
- package/typechain/factories/RiskFundV2__factory.ts +624 -0
- package/typechain/factories/SingleTokenConverter__factory.ts +1200 -0
- package/typechain/factories/TwapInterface__factory.ts +61 -0
- package/typechain/factories/VBep20Interface__factory.ts +261 -0
- package/typechain/factories/XVSVaultTreasury__factory.ts +365 -0
- package/typechain/index.ts +112 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
pragma solidity 0.8.13;
|
|
3
|
+
|
|
4
|
+
import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
|
|
5
|
+
import { AccessControlledV8 } from "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol";
|
|
6
|
+
import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
|
|
7
|
+
|
|
8
|
+
import { IRiskFund } from "../Interfaces/IRiskFund.sol";
|
|
9
|
+
import { IRiskFundConverter } from "../Interfaces/IRiskFundConverter.sol";
|
|
10
|
+
|
|
11
|
+
import { ensureNonzeroAddress, ensureNonzeroValue } from "../Utils/Validators.sol";
|
|
12
|
+
import { EXP_SCALE } from "../Utils/Constants.sol";
|
|
13
|
+
|
|
14
|
+
import { RiskFundV2Storage } from "./RiskFundStorage.sol";
|
|
15
|
+
|
|
16
|
+
/// @title RiskFundV2
|
|
17
|
+
/// @author Venus
|
|
18
|
+
/// @notice Contract with basic features to hold base asset for different Comptrollers
|
|
19
|
+
/// @dev This contract does not support BNB
|
|
20
|
+
/// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion
|
|
21
|
+
contract RiskFundV2 is AccessControlledV8, RiskFundV2Storage, IRiskFund {
|
|
22
|
+
using SafeERC20Upgradeable for IERC20Upgradeable;
|
|
23
|
+
|
|
24
|
+
/// @notice Emitted when convertible base asset address is updated
|
|
25
|
+
event ConvertibleBaseAssetUpdated(address indexed oldConvertibleBaseAsset, address indexed newConvertibleBaseAsset);
|
|
26
|
+
|
|
27
|
+
/// @notice Emitted when risk fund converter address is updated
|
|
28
|
+
event RiskFundConverterUpdated(address indexed oldRiskFundConverter, address indexed newRiskFundConverter);
|
|
29
|
+
|
|
30
|
+
/// @notice Emitted when shortfall contract address is updated
|
|
31
|
+
event ShortfallContractUpdated(address indexed oldShortfallContract, address indexed newShortfallContract);
|
|
32
|
+
|
|
33
|
+
/// @notice Emitted when reserves are transferred for auction
|
|
34
|
+
event TransferredReserveForAuction(address indexed comptroller, uint256 amount);
|
|
35
|
+
|
|
36
|
+
/// @notice Emitted when pool asset states is updated with amount transferred to this contract
|
|
37
|
+
event PoolAssetsIncreased(address indexed comptroller, address indexed asset, uint256 amount);
|
|
38
|
+
|
|
39
|
+
/// @notice Emitted when pool asset states is updated with amount transferred from this contract on sweeping tokens
|
|
40
|
+
event PoolAssetsDecreased(address indexed comptroller, address indexed asset, uint256 amount);
|
|
41
|
+
|
|
42
|
+
/// @notice Event emitted when tokens are swept
|
|
43
|
+
event SweepToken(address indexed token, address indexed to, uint256 amount);
|
|
44
|
+
|
|
45
|
+
/// @notice Error is thrown when updatePoolState is not called by riskFundConverter
|
|
46
|
+
error InvalidRiskFundConverter();
|
|
47
|
+
|
|
48
|
+
/// @notice Error is thrown when transferReserveForAuction is called by non shortfall address
|
|
49
|
+
error InvalidShortfallAddress();
|
|
50
|
+
|
|
51
|
+
/// @notice thrown when amount entered is greater than balance
|
|
52
|
+
error InsufficientBalance();
|
|
53
|
+
|
|
54
|
+
/// @notice Error is thrown when pool reserve is less than the amount needed
|
|
55
|
+
error InsufficientPoolReserve(address comptroller, uint256 amount, uint256 poolReserve);
|
|
56
|
+
|
|
57
|
+
/// @dev Convertible base asset setter
|
|
58
|
+
/// @param convertibleBaseAsset_ Address of the convertible base asset
|
|
59
|
+
/// @custom:event ConvertibleBaseAssetUpdated emit on success
|
|
60
|
+
/// @custom:error ZeroAddressNotAllowed is thrown when convertible base asset address is zero
|
|
61
|
+
/// @custom:access Only Governance
|
|
62
|
+
function setConvertibleBaseAsset(address convertibleBaseAsset_) external onlyOwner {
|
|
63
|
+
ensureNonzeroAddress(convertibleBaseAsset_);
|
|
64
|
+
emit ConvertibleBaseAssetUpdated(convertibleBaseAsset, convertibleBaseAsset_);
|
|
65
|
+
convertibleBaseAsset = convertibleBaseAsset_;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// @dev Risk fund converter setter
|
|
69
|
+
/// @param riskFundConverter_ Address of the risk fund converter
|
|
70
|
+
/// @custom:event RiskFundConverterUpdated emit on success
|
|
71
|
+
/// @custom:error ZeroAddressNotAllowed is thrown when risk fund converter address is zero
|
|
72
|
+
/// @custom:access Only Governance
|
|
73
|
+
function setRiskFundConverter(address riskFundConverter_) external onlyOwner {
|
|
74
|
+
ensureNonzeroAddress(riskFundConverter_);
|
|
75
|
+
emit RiskFundConverterUpdated(riskFundConverter, riskFundConverter_);
|
|
76
|
+
riskFundConverter = riskFundConverter_;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// @dev Shortfall contract address setter
|
|
80
|
+
/// @param shortfallContractAddress_ Address of the auction contract
|
|
81
|
+
/// @custom:event ShortfallContractUpdated emit on success
|
|
82
|
+
/// @custom:error ZeroAddressNotAllowed is thrown when shortfall contract address is zero
|
|
83
|
+
/// @custom:access Only Governance
|
|
84
|
+
function setShortfallContractAddress(address shortfallContractAddress_) external onlyOwner {
|
|
85
|
+
ensureNonzeroAddress(shortfallContractAddress_);
|
|
86
|
+
emit ShortfallContractUpdated(shortfall, shortfallContractAddress_);
|
|
87
|
+
shortfall = shortfallContractAddress_;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// @dev Transfer tokens for auction to shortfall contract
|
|
91
|
+
/// @param comptroller Comptroller of the pool
|
|
92
|
+
/// @param amount Amount to be transferred to the shortfall
|
|
93
|
+
/// @return Amount of tokens transferred to the shortfall
|
|
94
|
+
/// @custom:event TransferredReserveForAuction emit on success
|
|
95
|
+
/// @custom:error InvalidShortfallAddress is thrown when caller is not shortfall contract
|
|
96
|
+
/// @custom:error InsufficientPoolReserve is thrown when pool reserve is less than the amount needed
|
|
97
|
+
/// @custom:access Only Shortfall contract
|
|
98
|
+
function transferReserveForAuction(address comptroller, uint256 amount)
|
|
99
|
+
external
|
|
100
|
+
override
|
|
101
|
+
nonReentrant
|
|
102
|
+
returns (uint256)
|
|
103
|
+
{
|
|
104
|
+
uint256 poolReserve = poolAssetsFunds[comptroller][convertibleBaseAsset];
|
|
105
|
+
|
|
106
|
+
if (msg.sender != shortfall) {
|
|
107
|
+
revert InvalidShortfallAddress();
|
|
108
|
+
}
|
|
109
|
+
if (amount > poolReserve) {
|
|
110
|
+
revert InsufficientPoolReserve(comptroller, amount, poolReserve);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
unchecked {
|
|
114
|
+
poolAssetsFunds[comptroller][convertibleBaseAsset] = poolReserve - amount;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
IERC20Upgradeable(convertibleBaseAsset).safeTransfer(shortfall, amount);
|
|
118
|
+
emit TransferredReserveForAuction(comptroller, amount);
|
|
119
|
+
|
|
120
|
+
return amount;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// @notice Function to sweep baseAsset for pool, Tokens are sent to address(to)
|
|
124
|
+
/// @param tokenAddress Address of the asset(token)
|
|
125
|
+
/// @param to Address to which assets will be transferred
|
|
126
|
+
/// @param amount Amount need to sweep for the pool
|
|
127
|
+
/// @custom:event Emits SweepToken event on success
|
|
128
|
+
/// @custom:error ZeroAddressNotAllowed is thrown when tokenAddress/to address is zero
|
|
129
|
+
/// @custom:access Only Governance
|
|
130
|
+
function sweepToken(
|
|
131
|
+
address tokenAddress,
|
|
132
|
+
address to,
|
|
133
|
+
uint256 amount
|
|
134
|
+
) external onlyOwner nonReentrant {
|
|
135
|
+
ensureNonzeroAddress(tokenAddress);
|
|
136
|
+
ensureNonzeroAddress(to);
|
|
137
|
+
ensureNonzeroValue(amount);
|
|
138
|
+
|
|
139
|
+
IERC20Upgradeable token = IERC20Upgradeable(tokenAddress);
|
|
140
|
+
preSweepToken(tokenAddress, amount);
|
|
141
|
+
token.safeTransfer(to, amount);
|
|
142
|
+
|
|
143
|
+
emit SweepToken(tokenAddress, to, amount);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @notice Get the Amount of the Base asset in the risk fund for the specific pool.
|
|
148
|
+
* @param comptroller Comptroller address(pool).
|
|
149
|
+
* @return Base Asset's reserve in risk fund.
|
|
150
|
+
*/
|
|
151
|
+
function getPoolsBaseAssetReserves(address comptroller) external view returns (uint256) {
|
|
152
|
+
return poolAssetsFunds[comptroller][convertibleBaseAsset];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// @dev Update the reserve of the asset for the specific pool after transferring to risk fund
|
|
156
|
+
/// @param comptroller Comptroller address (pool)
|
|
157
|
+
/// @param asset Address of the asset(token)
|
|
158
|
+
/// @param amount Amount transferred for the pool
|
|
159
|
+
/// @custom:event PoolAssetsIncreased emits on success
|
|
160
|
+
/// @custom:error InvalidRiskFundConverter is thrown if caller is not riskFundConverter contract
|
|
161
|
+
/// @custom:access Only RiskFundConverter contract
|
|
162
|
+
function updatePoolState(
|
|
163
|
+
address comptroller,
|
|
164
|
+
address asset,
|
|
165
|
+
uint256 amount
|
|
166
|
+
) public {
|
|
167
|
+
if (msg.sender != riskFundConverter) {
|
|
168
|
+
revert InvalidRiskFundConverter();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
poolAssetsFunds[comptroller][asset] += amount;
|
|
172
|
+
emit PoolAssetsIncreased(comptroller, asset, amount);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/// @notice Operations to perform before sweeping tokens
|
|
176
|
+
/// @param tokenAddress Address of the token
|
|
177
|
+
/// @param amount Amount transferred to address(to)
|
|
178
|
+
/// @custom:error InsufficientBalance is thrown when amount entered is greater than balance
|
|
179
|
+
function preSweepToken(address tokenAddress, uint256 amount) internal {
|
|
180
|
+
uint256 balance = IERC20Upgradeable(tokenAddress).balanceOf(address(this));
|
|
181
|
+
if (amount > balance) revert InsufficientBalance();
|
|
182
|
+
|
|
183
|
+
address[] memory pools = IRiskFundConverter(riskFundConverter).getPools(tokenAddress);
|
|
184
|
+
|
|
185
|
+
uint256 assetReserves;
|
|
186
|
+
uint256 poolsLength = pools.length;
|
|
187
|
+
for (uint256 i; i < poolsLength; ) {
|
|
188
|
+
assetReserves += poolAssetsFunds[pools[i]][tokenAddress];
|
|
189
|
+
unchecked {
|
|
190
|
+
++i;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
uint256 balanceDiff = balance - assetReserves;
|
|
195
|
+
|
|
196
|
+
if (balanceDiff < amount) {
|
|
197
|
+
uint256 amountDiff;
|
|
198
|
+
unchecked {
|
|
199
|
+
amountDiff = amount - balanceDiff;
|
|
200
|
+
}
|
|
201
|
+
uint256 distributedShare;
|
|
202
|
+
for (uint256 i; i < poolsLength; ) {
|
|
203
|
+
if (poolAssetsFunds[pools[i]][tokenAddress] != 0) {
|
|
204
|
+
uint256 poolAmountShare;
|
|
205
|
+
if (i < (poolsLength - 1)) {
|
|
206
|
+
poolAmountShare = (poolAssetsFunds[pools[i]][tokenAddress] * amount) / assetReserves;
|
|
207
|
+
distributedShare += poolAmountShare;
|
|
208
|
+
} else {
|
|
209
|
+
poolAmountShare = amountDiff - distributedShare;
|
|
210
|
+
}
|
|
211
|
+
poolAssetsFunds[pools[i]][tokenAddress] -= poolAmountShare;
|
|
212
|
+
emit PoolAssetsDecreased(pools[i], tokenAddress, poolAmountShare);
|
|
213
|
+
}
|
|
214
|
+
unchecked {
|
|
215
|
+
++i;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
pragma solidity 0.8.13;
|
|
3
|
+
|
|
4
|
+
import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
|
|
5
|
+
import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
|
|
6
|
+
import { AccessControlledV8 } from "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol";
|
|
7
|
+
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
|
|
8
|
+
|
|
9
|
+
import { ensureNonzeroAddress, ensureNonzeroValue } from "../Utils/Validators.sol";
|
|
10
|
+
import { IXVSVault } from "../Interfaces/IXVSVault.sol";
|
|
11
|
+
|
|
12
|
+
/// @title XVSVaultTreasury
|
|
13
|
+
/// @author Venus
|
|
14
|
+
/// @notice XVSVaultTreasury stores the tokens sent by SingleTokenConverter(XVS) and funds XVSVault
|
|
15
|
+
/// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion
|
|
16
|
+
contract XVSVaultTreasury is AccessControlledV8, ReentrancyGuardUpgradeable {
|
|
17
|
+
using SafeERC20Upgradeable for IERC20Upgradeable;
|
|
18
|
+
|
|
19
|
+
/// @notice The xvs token address
|
|
20
|
+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
21
|
+
address public immutable XVS_ADDRESS;
|
|
22
|
+
|
|
23
|
+
/// @notice The xvsvault address
|
|
24
|
+
address public xvsVault;
|
|
25
|
+
|
|
26
|
+
/// @notice Emitted when XVS vault address is updated
|
|
27
|
+
event XVSVaultUpdated(address indexed oldXVSVault, address indexed newXVSVault);
|
|
28
|
+
|
|
29
|
+
/// @notice Emitted when funds transferred to XVSStore address
|
|
30
|
+
event FundsTransferredToXVSStore(address indexed xvsStore, uint256 amountMantissa);
|
|
31
|
+
|
|
32
|
+
/// @notice Thrown when given input amount is zero
|
|
33
|
+
error InsufficientBalance();
|
|
34
|
+
|
|
35
|
+
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
36
|
+
/// @param xvsAddress_ XVS token address
|
|
37
|
+
constructor(address xvsAddress_) {
|
|
38
|
+
ensureNonzeroAddress(xvsAddress_);
|
|
39
|
+
XVS_ADDRESS = xvsAddress_;
|
|
40
|
+
|
|
41
|
+
// Note that the contract is upgradeable. Use initialize() or reinitializers
|
|
42
|
+
// to set the state variables.
|
|
43
|
+
_disableInitializers();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// @param accessControlManager_ Access control manager contract address
|
|
47
|
+
/// @param xvsVault_ XVSVault address
|
|
48
|
+
/// @custom:event XVSVaultUpdated emits on success
|
|
49
|
+
/// @custom:error ZeroAddressNotAllowed is thrown when XVS vault address is zero
|
|
50
|
+
function initialize(address accessControlManager_, address xvsVault_) public initializer {
|
|
51
|
+
__AccessControlled_init(accessControlManager_);
|
|
52
|
+
__ReentrancyGuard_init();
|
|
53
|
+
_setXVSVault(xvsVault_);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// @dev XVS vault setter
|
|
57
|
+
/// @param xvsVault_ Address of the XVS vault
|
|
58
|
+
/// @custom:event XVSVaultUpdated emits on success
|
|
59
|
+
/// @custom:error ZeroAddressNotAllowed is thrown when XVS vault address is zero
|
|
60
|
+
function setXVSVault(address xvsVault_) external onlyOwner {
|
|
61
|
+
_setXVSVault(xvsVault_);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// @notice This function transfers funds to the XVS vault
|
|
65
|
+
/// @param amountMantissa Amount to be sent to XVS vault
|
|
66
|
+
/// @custom:event FundsTransferredToXVSStore emits on success
|
|
67
|
+
/// @custom:error InsufficientBalance is thrown when amount entered is greater than balance
|
|
68
|
+
/// @custom:access Restricted by ACM
|
|
69
|
+
function fundXVSVault(uint256 amountMantissa) external nonReentrant {
|
|
70
|
+
_checkAccessAllowed("fundXVSVault(uint256)");
|
|
71
|
+
ensureNonzeroValue(amountMantissa);
|
|
72
|
+
|
|
73
|
+
uint256 balance = IERC20Upgradeable(XVS_ADDRESS).balanceOf(address(this));
|
|
74
|
+
|
|
75
|
+
if (balance < amountMantissa) {
|
|
76
|
+
revert InsufficientBalance();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
address xvsStore = IXVSVault(xvsVault).xvsStore();
|
|
80
|
+
ensureNonzeroAddress(xvsStore);
|
|
81
|
+
IERC20Upgradeable(XVS_ADDRESS).safeTransfer(xvsStore, amountMantissa);
|
|
82
|
+
|
|
83
|
+
emit FundsTransferredToXVSStore(xvsStore, amountMantissa);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/// @dev XVS vault setter
|
|
87
|
+
/// @param xvsVault_ Address of the XVS vault
|
|
88
|
+
/// @custom:event XVSVaultUpdated emits on success
|
|
89
|
+
/// @custom:error ZeroAddressNotAllowed is thrown when XVS vault address is zero
|
|
90
|
+
function _setXVSVault(address xvsVault_) internal {
|
|
91
|
+
ensureNonzeroAddress(xvsVault_);
|
|
92
|
+
emit XVSVaultUpdated(xvsVault, xvsVault_);
|
|
93
|
+
xvsVault = xvsVault_;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
pragma solidity 0.8.13;
|
|
2
|
+
|
|
3
|
+
import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
|
|
4
|
+
|
|
5
|
+
contract MockACM is AccessControl {
|
|
6
|
+
/// @notice Emitted when an account is given a permission to a certain contract function
|
|
7
|
+
/// @dev If contract address is 0x000..0 this means that the account is a default admin of this function and
|
|
8
|
+
/// can call any contract function with this signature
|
|
9
|
+
event PermissionGranted(address account, address contractAddress, string functionSig);
|
|
10
|
+
|
|
11
|
+
/// @notice Emitted when an account is revoked a permission to a certain contract function
|
|
12
|
+
event PermissionRevoked(address account, address contractAddress, string functionSig);
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
// Grant the contract deployer the default admin role: it will be able
|
|
16
|
+
// to grant and revoke any roles
|
|
17
|
+
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @notice Gives a function call permission to one single account
|
|
22
|
+
* @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE
|
|
23
|
+
* @param contractAddress address of contract for which call permissions will be granted
|
|
24
|
+
* @dev if contractAddress is zero address, the account can access the specified function
|
|
25
|
+
* on **any** contract managed by this ACL
|
|
26
|
+
* @param functionSig signature e.g. "functionName(uint256,bool)"
|
|
27
|
+
* @param accountToPermit account that will be given access to the contract function
|
|
28
|
+
* @custom:event Emits a {RoleGranted} and {PermissionGranted} events.
|
|
29
|
+
*/
|
|
30
|
+
function giveCallPermission(
|
|
31
|
+
address contractAddress,
|
|
32
|
+
string memory functionSig,
|
|
33
|
+
address accountToPermit
|
|
34
|
+
) public {
|
|
35
|
+
bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));
|
|
36
|
+
grantRole(role, accountToPermit);
|
|
37
|
+
emit PermissionGranted(accountToPermit, contractAddress, functionSig);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @notice Revokes an account's permission to a particular function call
|
|
42
|
+
* @dev this function can be called only from Role Admin or DEFAULT_ADMIN_ROLE
|
|
43
|
+
* May emit a {RoleRevoked} event.
|
|
44
|
+
* @param contractAddress address of contract for which call permissions will be revoked
|
|
45
|
+
* @param functionSig signature e.g. "functionName(uint256,bool)"
|
|
46
|
+
* @custom:event Emits {RoleRevoked} and {PermissionRevoked} events.
|
|
47
|
+
*/
|
|
48
|
+
function revokeCallPermission(
|
|
49
|
+
address contractAddress,
|
|
50
|
+
string memory functionSig,
|
|
51
|
+
address accountToRevoke
|
|
52
|
+
) public {
|
|
53
|
+
bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));
|
|
54
|
+
revokeRole(role, accountToRevoke);
|
|
55
|
+
emit PermissionRevoked(accountToRevoke, contractAddress, functionSig);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @notice Verifies if the given account can call a contract's guarded function
|
|
60
|
+
* @dev Since restricted contracts using this function as a permission hook, we can get contracts address with msg.sender
|
|
61
|
+
* @param account for which call permissions will be checked
|
|
62
|
+
* @param functionSig restricted function signature e.g. "functionName(uint256,bool)"
|
|
63
|
+
* @return false if the user account cannot call the particular contract function
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
function isAllowedToCall(address account, string memory functionSig) public view returns (bool) {
|
|
67
|
+
bytes32 role = keccak256(abi.encodePacked(msg.sender, functionSig));
|
|
68
|
+
|
|
69
|
+
if (hasRole(role, account)) {
|
|
70
|
+
return true;
|
|
71
|
+
} else {
|
|
72
|
+
role = keccak256(abi.encodePacked(address(0), functionSig));
|
|
73
|
+
return hasRole(role, account);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @notice Verifies if the given account can call a contract's guarded function
|
|
79
|
+
* @dev This function is used as a view function to check permissions rather than contract hook for access restriction check.
|
|
80
|
+
* @param account for which call permissions will be checked against
|
|
81
|
+
* @param contractAddress address of the restricted contract
|
|
82
|
+
* @param functionSig signature of the restricted function e.g. "functionName(uint256,bool)"
|
|
83
|
+
* @return false if the user account cannot call the particular contract function
|
|
84
|
+
*/
|
|
85
|
+
function hasPermission(
|
|
86
|
+
address account,
|
|
87
|
+
address contractAddress,
|
|
88
|
+
string memory functionSig
|
|
89
|
+
) public view returns (bool) {
|
|
90
|
+
bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));
|
|
91
|
+
return hasRole(role, account);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
pragma solidity ^0.8.10;
|
|
3
|
+
import { sort } from "../../Utils/ArrayHelpers.sol";
|
|
4
|
+
|
|
5
|
+
contract MockArraySorter {
|
|
6
|
+
function sortArray(uint256[] memory balances, address[] memory addrs)
|
|
7
|
+
external
|
|
8
|
+
view
|
|
9
|
+
returns (address[] memory, uint256[] memory)
|
|
10
|
+
{
|
|
11
|
+
sort(balances, addrs);
|
|
12
|
+
return (addrs, balances);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
pragma solidity ^0.8.10;
|
|
3
|
+
|
|
4
|
+
import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
|
|
5
|
+
import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
|
|
6
|
+
import { ResilientOracle } from "@venusprotocol/oracle/contracts/ResilientOracle.sol";
|
|
7
|
+
|
|
8
|
+
import { AbstractTokenConverter } from "../../TokenConverter/AbstractTokenConverter.sol";
|
|
9
|
+
import { IRiskFundGetters } from "../../Interfaces/IRiskFund.sol";
|
|
10
|
+
|
|
11
|
+
contract MockConverter is AbstractTokenConverter {
|
|
12
|
+
using SafeERC20Upgradeable for IERC20Upgradeable;
|
|
13
|
+
|
|
14
|
+
/// @notice Store the previous state for the asset transferred to ProtocolShareReserve combined(for all pools)
|
|
15
|
+
mapping(address => uint256) public assetsReserves;
|
|
16
|
+
|
|
17
|
+
/// @notice Store the asset's reserve per pool in the ProtocolShareReserve
|
|
18
|
+
/// @dev Comptroller(pool) -> Asset -> amount
|
|
19
|
+
mapping(address => mapping(address => uint256)) public poolsAssetsReserves;
|
|
20
|
+
|
|
21
|
+
/// @notice Emitted after updating of the assets reserves
|
|
22
|
+
/// amount -> reserve increased by amount
|
|
23
|
+
event AssetsReservesUpdated(address indexed comptroller, address indexed asset, uint256 amount);
|
|
24
|
+
|
|
25
|
+
function mockPrivateConversion(
|
|
26
|
+
address comptroller,
|
|
27
|
+
address tokenAddressOut,
|
|
28
|
+
uint256 balanceDiff
|
|
29
|
+
) external {
|
|
30
|
+
_privateConversion(comptroller, tokenAddressOut, balanceDiff);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function AbstractTokenConverter_init(
|
|
34
|
+
address accessControlManager_,
|
|
35
|
+
ResilientOracle priceOracle_,
|
|
36
|
+
address destinationAddress_
|
|
37
|
+
) public initializer {
|
|
38
|
+
__AbstractTokenConverter_init(accessControlManager_, priceOracle_, destinationAddress_);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function balanceOf(address tokenAddress) public view override returns (uint256 tokenBalance) {
|
|
42
|
+
IERC20Upgradeable token = IERC20Upgradeable(tokenAddress);
|
|
43
|
+
tokenBalance = token.balanceOf(address(this));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function _postPrivateConversionHook(
|
|
47
|
+
address comptroller,
|
|
48
|
+
address tokenAddressIn,
|
|
49
|
+
uint256 convertedTokenInBalance,
|
|
50
|
+
address tokenAddressOut,
|
|
51
|
+
uint256 convertedTokenOutBalance
|
|
52
|
+
) internal override {
|
|
53
|
+
if (convertedTokenInBalance > 0) {
|
|
54
|
+
assetsReserves[tokenAddressIn] += convertedTokenInBalance;
|
|
55
|
+
poolsAssetsReserves[comptroller][tokenAddressIn] += convertedTokenInBalance;
|
|
56
|
+
emit AssetsReservesUpdated(comptroller, tokenAddressIn, convertedTokenInBalance);
|
|
57
|
+
}
|
|
58
|
+
if (convertedTokenOutBalance > 0) {
|
|
59
|
+
assetsReserves[tokenAddressOut] += convertedTokenOutBalance;
|
|
60
|
+
poolsAssetsReserves[comptroller][tokenAddressOut] += convertedTokenOutBalance;
|
|
61
|
+
emit AssetsReservesUpdated(comptroller, tokenAddressOut, convertedTokenOutBalance);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// @notice Get base asset address
|
|
66
|
+
function _getDestinationBaseAsset() internal view override returns (address) {
|
|
67
|
+
return IRiskFundGetters(destinationAddress).convertibleBaseAsset();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
pragma solidity 0.8.13;
|
|
2
|
+
|
|
3
|
+
contract MockDeflatingToken {
|
|
4
|
+
string public constant NAME = "Deflating Test Token";
|
|
5
|
+
string public constant SYMBOL = "DTT";
|
|
6
|
+
uint8 public constant DECIMALS = 18;
|
|
7
|
+
uint256 public totalSupply;
|
|
8
|
+
mapping(address => uint256) public balanceOf;
|
|
9
|
+
mapping(address => mapping(address => uint256)) public allowance;
|
|
10
|
+
|
|
11
|
+
bytes32 public immutable DOMAIN_SEPARATOR;
|
|
12
|
+
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
|
|
13
|
+
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
|
|
14
|
+
mapping(address => uint256) public nonces;
|
|
15
|
+
|
|
16
|
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
|
17
|
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
|
18
|
+
|
|
19
|
+
constructor(uint256 _totalSupply) {
|
|
20
|
+
uint256 chainId;
|
|
21
|
+
assembly {
|
|
22
|
+
chainId := chainid()
|
|
23
|
+
}
|
|
24
|
+
DOMAIN_SEPARATOR = keccak256(
|
|
25
|
+
abi.encode(
|
|
26
|
+
keccak256("EIP712Domain(string NAME,string version,uint256 chainId,address verifyingContract)"),
|
|
27
|
+
keccak256(bytes(NAME)),
|
|
28
|
+
keccak256(bytes("1")),
|
|
29
|
+
chainId,
|
|
30
|
+
address(this)
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
_mint(msg.sender, _totalSupply);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function approve(address spender, uint256 value) external returns (bool) {
|
|
37
|
+
_approve(msg.sender, spender, value);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function transfer(address to, uint256 value) external returns (bool) {
|
|
42
|
+
_transfer(msg.sender, to, value);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function transferFrom(
|
|
47
|
+
address from,
|
|
48
|
+
address to,
|
|
49
|
+
uint256 value
|
|
50
|
+
) external returns (bool) {
|
|
51
|
+
if (allowance[from][msg.sender] != type(uint256).max) {
|
|
52
|
+
allowance[from][msg.sender] = allowance[from][msg.sender] - value;
|
|
53
|
+
}
|
|
54
|
+
_transfer(from, to, value);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function permit(
|
|
59
|
+
address owner,
|
|
60
|
+
address spender,
|
|
61
|
+
uint256 value,
|
|
62
|
+
uint256 deadline,
|
|
63
|
+
uint8 v,
|
|
64
|
+
bytes32 r,
|
|
65
|
+
bytes32 s
|
|
66
|
+
) external {
|
|
67
|
+
require(deadline >= block.timestamp, "EXPIRED");
|
|
68
|
+
bytes32 digest = keccak256(
|
|
69
|
+
abi.encodePacked(
|
|
70
|
+
"\x19\x01",
|
|
71
|
+
DOMAIN_SEPARATOR,
|
|
72
|
+
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
address recoveredAddress = ecrecover(digest, v, r, s);
|
|
76
|
+
require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNATURE");
|
|
77
|
+
_approve(owner, spender, value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function _mint(address to, uint256 value) internal {
|
|
81
|
+
totalSupply = totalSupply + value;
|
|
82
|
+
balanceOf[to] = balanceOf[to] + value;
|
|
83
|
+
emit Transfer(address(0), to, value);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function _burn(address from, uint256 value) internal {
|
|
87
|
+
balanceOf[from] = balanceOf[from] - value;
|
|
88
|
+
totalSupply = totalSupply - value;
|
|
89
|
+
emit Transfer(from, address(0), value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function _approve(
|
|
93
|
+
address owner,
|
|
94
|
+
address spender,
|
|
95
|
+
uint256 value
|
|
96
|
+
) private {
|
|
97
|
+
allowance[owner][spender] = value;
|
|
98
|
+
emit Approval(owner, spender, value);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function _transfer(
|
|
102
|
+
address from,
|
|
103
|
+
address to,
|
|
104
|
+
uint256 value
|
|
105
|
+
) private {
|
|
106
|
+
uint256 burnAmount = value / 100;
|
|
107
|
+
_burn(from, burnAmount);
|
|
108
|
+
uint256 transferAmount = value - burnAmount;
|
|
109
|
+
balanceOf[from] = balanceOf[from] - transferAmount;
|
|
110
|
+
balanceOf[to] = balanceOf[to] + transferAmount;
|
|
111
|
+
emit Transfer(from, to, transferAmount);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
pragma solidity 0.8.13;
|
|
3
|
+
|
|
4
|
+
import { RiskFundConverter } from "../../TokenConverter/RiskFundConverter.sol";
|
|
5
|
+
|
|
6
|
+
contract MockRiskFundConverter is RiskFundConverter {
|
|
7
|
+
constructor(
|
|
8
|
+
address corePoolComptroller_,
|
|
9
|
+
address vBNB_,
|
|
10
|
+
address nativeWrapped_
|
|
11
|
+
) RiskFundConverter(corePoolComptroller_, vBNB_, nativeWrapped_) {}
|
|
12
|
+
|
|
13
|
+
function postConversionHookMock(
|
|
14
|
+
address tokenInAddress,
|
|
15
|
+
address tokenOutAddress,
|
|
16
|
+
uint256 amountIn,
|
|
17
|
+
uint256 amountOut
|
|
18
|
+
) external {
|
|
19
|
+
super._postConversionHook(tokenInAddress, tokenOutAddress, amountIn, amountOut);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function preTransferHookMock(address tokenOutAddress, uint256 amountOut) external {
|
|
23
|
+
super._preTransferHook(tokenOutAddress, amountOut);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function setAssetsReserves(address asset, uint256 amount) external {
|
|
27
|
+
assetsReserves[asset] = amount;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function setPoolsAssetsReserves(
|
|
31
|
+
address comptroller,
|
|
32
|
+
address asset,
|
|
33
|
+
uint256 amount
|
|
34
|
+
) external {
|
|
35
|
+
poolsAssetsReserves[comptroller][asset] = amount;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getPoolsAssetsReserves(address comptroller, address asset) external view returns (uint256) {
|
|
39
|
+
return poolsAssetsReserves[comptroller][asset];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getAssetsReserves(address asset) external view returns (uint256) {
|
|
43
|
+
return assetsReserves[asset];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.0;
|
|
5
|
+
|
|
6
|
+
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
7
|
+
|
|
8
|
+
contract MockToken is ERC20 {
|
|
9
|
+
uint8 private immutable _decimals;
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
string memory name_,
|
|
13
|
+
string memory symbol_,
|
|
14
|
+
uint8 decimals_
|
|
15
|
+
) ERC20(name_, symbol_) {
|
|
16
|
+
_decimals = decimals_;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function faucet(uint256 amount) external {
|
|
20
|
+
_mint(msg.sender, amount);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function allocateTo(address owner, uint256 amount) external {
|
|
24
|
+
_mint(owner, amount);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function decimals() public view virtual override returns (uint8) {
|
|
28
|
+
return _decimals;
|
|
29
|
+
}
|
|
30
|
+
}
|