@venusprotocol/isolated-pools 1.0.0-dev.1 → 1.0.0-dev.11

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.
Files changed (265) hide show
  1. package/README.md +1 -11
  2. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
  3. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +215 -0
  4. package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
  5. package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +183 -0
  6. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +4 -0
  7. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.json +63 -0
  8. package/artifacts/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.dbg.json +4 -0
  9. package/artifacts/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.json +56 -0
  10. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.dbg.json +4 -0
  11. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.json +24 -0
  12. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol/ERC1967Upgrade.dbg.json +4 -0
  13. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol/ERC1967Upgrade.json +56 -0
  14. package/artifacts/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.dbg.json +4 -0
  15. package/artifacts/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.json +19 -0
  16. package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.dbg.json +4 -0
  17. package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.json +80 -0
  18. package/artifacts/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.dbg.json +4 -0
  19. package/artifacts/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.json +24 -0
  20. package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.dbg.json +4 -0
  21. package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.json +113 -0
  22. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +4 -0
  23. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json +297 -0
  24. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +4 -0
  25. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.json +194 -0
  26. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +4 -0
  27. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.json +233 -0
  28. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +4 -0
  29. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.json +10 -0
  30. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
  31. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
  32. package/artifacts/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.dbg.json +4 -0
  33. package/artifacts/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.json +10 -0
  34. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
  35. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +10 -0
  36. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
  37. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
  38. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
  39. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
  40. package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
  41. package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
  42. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +4 -0
  43. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +10 -0
  44. package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.dbg.json +4 -0
  45. package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +115 -0
  46. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +4 -0
  47. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.json +76 -0
  48. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +4 -0
  49. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.json +24 -0
  50. package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.dbg.json +4 -0
  51. package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.json +24 -0
  52. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json +4 -0
  53. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.json +194 -0
  54. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.dbg.json +4 -0
  55. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.json +86 -0
  56. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.dbg.json +4 -0
  57. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.json +10 -0
  58. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +4 -0
  59. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.json +10 -0
  60. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +4 -0
  61. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.json +24 -0
  62. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol/AccessControlManager.dbg.json +4 -0
  63. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol/AccessControlManager.json +369 -0
  64. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.dbg.json +4 -0
  65. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.json +181 -0
  66. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.dbg.json +4 -0
  67. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.json +282 -0
  68. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +4 -0
  69. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.json +40 -0
  70. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +4 -0
  71. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.json +30 -0
  72. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +4 -0
  73. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.json +43 -0
  74. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +4 -0
  75. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.json +49 -0
  76. package/artifacts/build-info/5d0b3e7c7d317c28bfc8eca20c31f64e.json +1 -0
  77. package/artifacts/build-info/f19d689bc99e63a20dd2a17a14e2b84a.json +1 -0
  78. package/artifacts/contracts/BaseJumpRateModelV2.sol/BaseJumpRateModelV2.dbg.json +4 -0
  79. package/artifacts/contracts/BaseJumpRateModelV2.sol/BaseJumpRateModelV2.json +276 -0
  80. package/artifacts/contracts/Comptroller.sol/Comptroller.dbg.json +4 -0
  81. package/artifacts/contracts/Comptroller.sol/Comptroller.json +1667 -0
  82. package/artifacts/contracts/ComptrollerInterface.sol/ComptrollerInterface.dbg.json +4 -0
  83. package/artifacts/contracts/ComptrollerInterface.sol/ComptrollerInterface.json +285 -0
  84. package/artifacts/contracts/ComptrollerInterface.sol/ComptrollerViewInterface.dbg.json +4 -0
  85. package/artifacts/contracts/ComptrollerInterface.sol/ComptrollerViewInterface.json +170 -0
  86. package/artifacts/contracts/ComptrollerStorage.sol/ComptrollerStorage.dbg.json +4 -0
  87. package/artifacts/contracts/ComptrollerStorage.sol/ComptrollerStorage.json +173 -0
  88. package/artifacts/contracts/ErrorReporter.sol/TokenErrorReporter.dbg.json +4 -0
  89. package/artifacts/contracts/ErrorReporter.sol/TokenErrorReporter.json +156 -0
  90. package/artifacts/contracts/ExponentialNoError.sol/ExponentialNoError.dbg.json +4 -0
  91. package/artifacts/contracts/ExponentialNoError.sol/ExponentialNoError.json +10 -0
  92. package/artifacts/contracts/IPancakeswapV2Router.sol/IPancakeswapV2Router.dbg.json +4 -0
  93. package/artifacts/contracts/IPancakeswapV2Router.sol/IPancakeswapV2Router.json +50 -0
  94. package/artifacts/contracts/InterestRateModel.sol/InterestRateModel.dbg.json +4 -0
  95. package/artifacts/contracts/InterestRateModel.sol/InterestRateModel.json +97 -0
  96. package/artifacts/contracts/JumpRateModelV2.sol/JumpRateModelV2.dbg.json +4 -0
  97. package/artifacts/contracts/JumpRateModelV2.sol/JumpRateModelV2.json +307 -0
  98. package/artifacts/contracts/Lens/PoolLens.sol/PoolLens.dbg.json +4 -0
  99. package/artifacts/contracts/Lens/PoolLens.sol/PoolLens.json +1087 -0
  100. package/artifacts/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.dbg.json +4 -0
  101. package/artifacts/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.json +59 -0
  102. package/artifacts/contracts/Pool/PoolRegistry.sol/PoolRegistry.dbg.json +4 -0
  103. package/artifacts/contracts/Pool/PoolRegistry.sol/PoolRegistry.json +689 -0
  104. package/artifacts/contracts/Pool/PoolRegistryInterface.sol/PoolRegistryInterface.dbg.json +4 -0
  105. package/artifacts/contracts/Pool/PoolRegistryInterface.sol/PoolRegistryInterface.json +176 -0
  106. package/artifacts/contracts/Rewards/RewardsDistributor.sol/RewardsDistributor.dbg.json +4 -0
  107. package/artifacts/contracts/Rewards/RewardsDistributor.sol/RewardsDistributor.json +928 -0
  108. package/artifacts/contracts/RiskFund/IProtocolShareReserve.sol/IProtocolShareReserve.dbg.json +4 -0
  109. package/artifacts/contracts/RiskFund/IProtocolShareReserve.sol/IProtocolShareReserve.json +29 -0
  110. package/artifacts/contracts/RiskFund/IRiskFund.sol/IRiskFund.dbg.json +4 -0
  111. package/artifacts/contracts/RiskFund/IRiskFund.sol/IRiskFund.json +101 -0
  112. package/artifacts/contracts/RiskFund/ProtocolShareReserve.sol/ProtocolShareReserve.dbg.json +4 -0
  113. package/artifacts/contracts/RiskFund/ProtocolShareReserve.sol/ProtocolShareReserve.json +296 -0
  114. package/artifacts/contracts/RiskFund/ReserveHelpers.sol/ReserveHelpers.dbg.json +4 -0
  115. package/artifacts/contracts/RiskFund/ReserveHelpers.sol/ReserveHelpers.json +83 -0
  116. package/artifacts/contracts/RiskFund/RiskFund.sol/RiskFund.dbg.json +4 -0
  117. package/artifacts/contracts/RiskFund/RiskFund.sol/RiskFund.json +596 -0
  118. package/artifacts/contracts/Shortfall/IShortfall.sol/IShortfall.dbg.json +4 -0
  119. package/artifacts/contracts/Shortfall/IShortfall.sol/IShortfall.json +24 -0
  120. package/artifacts/contracts/Shortfall/Shortfall.sol/Shortfall.dbg.json +4 -0
  121. package/artifacts/contracts/Shortfall/Shortfall.sol/Shortfall.json +761 -0
  122. package/artifacts/contracts/VToken.sol/VToken.dbg.json +4 -0
  123. package/artifacts/contracts/VToken.sol/VToken.json +1850 -0
  124. package/artifacts/contracts/VTokenInterfaces.sol/VTokenInterface.dbg.json +4 -0
  125. package/artifacts/contracts/VTokenInterfaces.sol/VTokenInterface.json +1398 -0
  126. package/artifacts/contracts/VTokenInterfaces.sol/VTokenStorage.dbg.json +4 -0
  127. package/artifacts/contracts/VTokenInterfaces.sol/VTokenStorage.json +219 -0
  128. package/artifacts/contracts/WhitePaperInterestRateModel.sol/WhitePaperInterestRateModel.dbg.json +4 -0
  129. package/artifacts/contracts/WhitePaperInterestRateModel.sol/WhitePaperInterestRateModel.json +192 -0
  130. package/artifacts/contracts/test/ComptrollerHarness.sol/ComptrollerHarness.dbg.json +4 -0
  131. package/artifacts/contracts/test/ComptrollerHarness.sol/ComptrollerHarness.json +1712 -0
  132. package/artifacts/contracts/test/ComptrollerHarness.sol/EchoTypesComptroller.dbg.json +4 -0
  133. package/artifacts/contracts/test/ComptrollerHarness.sol/EchoTypesComptroller.json +94 -0
  134. package/artifacts/contracts/test/ComptrollerScenario.sol/ComptrollerScenario.dbg.json +4 -0
  135. package/artifacts/contracts/test/ComptrollerScenario.sol/ComptrollerScenario.json +1744 -0
  136. package/artifacts/contracts/test/ERC20.sol/ERC20.dbg.json +4 -0
  137. package/artifacts/contracts/test/ERC20.sol/ERC20.json +194 -0
  138. package/artifacts/contracts/test/ERC20.sol/ERC20Base.dbg.json +4 -0
  139. package/artifacts/contracts/test/ERC20.sol/ERC20Base.json +141 -0
  140. package/artifacts/contracts/test/ERC20.sol/ERC20Harness.dbg.json +4 -0
  141. package/artifacts/contracts/test/ERC20.sol/ERC20Harness.json +351 -0
  142. package/artifacts/contracts/test/ERC20.sol/ERC20NS.dbg.json +4 -0
  143. package/artifacts/contracts/test/ERC20.sol/ERC20NS.json +182 -0
  144. package/artifacts/contracts/test/ERC20.sol/NonStandardToken.dbg.json +4 -0
  145. package/artifacts/contracts/test/ERC20.sol/NonStandardToken.json +247 -0
  146. package/artifacts/contracts/test/ERC20.sol/StandardToken.dbg.json +4 -0
  147. package/artifacts/contracts/test/ERC20.sol/StandardToken.json +259 -0
  148. package/artifacts/contracts/test/EvilToken.sol/EvilToken.dbg.json +4 -0
  149. package/artifacts/contracts/test/EvilToken.sol/EvilToken.json +303 -0
  150. package/artifacts/contracts/test/FaucetToken.sol/FaucetNonStandardToken.dbg.json +4 -0
  151. package/artifacts/contracts/test/FaucetToken.sol/FaucetNonStandardToken.json +265 -0
  152. package/artifacts/contracts/test/FaucetToken.sol/FaucetToken.dbg.json +4 -0
  153. package/artifacts/contracts/test/FaucetToken.sol/FaucetToken.json +277 -0
  154. package/artifacts/contracts/test/FaucetToken.sol/FaucetTokenReEntrantHarness.dbg.json +4 -0
  155. package/artifacts/contracts/test/FaucetToken.sol/FaucetTokenReEntrantHarness.json +313 -0
  156. package/artifacts/contracts/test/FeeToken.sol/FeeToken.dbg.json +4 -0
  157. package/artifacts/contracts/test/FeeToken.sol/FeeToken.json +313 -0
  158. package/artifacts/contracts/test/HarnessMaxLoopsLimitHelper.sol/HarnessMaxLoopsLimitHelper.dbg.json +4 -0
  159. package/artifacts/contracts/test/HarnessMaxLoopsLimitHelper.sol/HarnessMaxLoopsLimitHelper.json +85 -0
  160. package/artifacts/contracts/test/MockDeflationaryToken.sol/MockDeflatingToken.dbg.json +4 -0
  161. package/artifacts/contracts/test/MockDeflationaryToken.sol/MockDeflatingToken.json +332 -0
  162. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IERC20.dbg.json +4 -0
  163. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IERC20.json +233 -0
  164. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeFactory.dbg.json +4 -0
  165. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeFactory.json +187 -0
  166. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakePair.dbg.json +4 -0
  167. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakePair.json +668 -0
  168. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeRouter01.dbg.json +4 -0
  169. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeRouter01.json +760 -0
  170. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeRouter02.dbg.json +4 -0
  171. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeRouter02.json +962 -0
  172. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IWETH.dbg.json +4 -0
  173. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IWETH.json +55 -0
  174. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/PancakeLibrary.dbg.json +4 -0
  175. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/PancakeLibrary.json +10 -0
  176. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/PancakeRouter.dbg.json +4 -0
  177. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/PancakeRouter.json +982 -0
  178. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/SafeMath.dbg.json +4 -0
  179. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/SafeMath.json +10 -0
  180. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/TransferHelper.dbg.json +4 -0
  181. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/TransferHelper.json +10 -0
  182. package/artifacts/contracts/test/Mocks/MockPriceOracle.sol/MockPriceOracle.dbg.json +4 -0
  183. package/artifacts/contracts/test/Mocks/MockPriceOracle.sol/MockPriceOracle.json +85 -0
  184. package/artifacts/contracts/test/Mocks/MockToken.sol/MockToken.dbg.json +4 -0
  185. package/artifacts/contracts/test/Mocks/MockToken.sol/MockToken.json +315 -0
  186. package/artifacts/contracts/test/SafeMath.sol/SafeMath.dbg.json +4 -0
  187. package/artifacts/contracts/test/SafeMath.sol/SafeMath.json +10 -0
  188. package/artifacts/contracts/test/UpgradedVToken.sol/UpgradedVToken.dbg.json +4 -0
  189. package/artifacts/contracts/test/UpgradedVToken.sol/UpgradedVToken.json +1946 -0
  190. package/artifacts/contracts/test/VTokenHarness.sol/VTokenHarness.dbg.json +4 -0
  191. package/artifacts/contracts/test/VTokenHarness.sol/VTokenHarness.json +2306 -0
  192. package/contracts/BaseJumpRateModelV2.sol +4 -3
  193. package/contracts/Comptroller.sol +40 -15
  194. package/contracts/ComptrollerInterface.sol +10 -0
  195. package/contracts/ComptrollerStorage.sol +5 -0
  196. package/contracts/ErrorReporter.sol +5 -0
  197. package/contracts/ExponentialNoError.sol +0 -7
  198. package/contracts/Lens/PoolLens.sol +13 -0
  199. package/contracts/MaxLoopsLimitHelper.sol +5 -0
  200. package/contracts/Pool/PoolRegistry.sol +58 -206
  201. package/contracts/Pool/PoolRegistryInterface.sol +12 -7
  202. package/contracts/Rewards/RewardsDistributor.sol +15 -0
  203. package/contracts/RiskFund/IProtocolShareReserve.sol +5 -0
  204. package/contracts/RiskFund/IRiskFund.sol +5 -0
  205. package/contracts/RiskFund/ProtocolShareReserve.sol +5 -0
  206. package/contracts/RiskFund/ReserveHelpers.sol +5 -0
  207. package/contracts/RiskFund/RiskFund.sol +5 -5
  208. package/contracts/Shortfall/IShortfall.sol +5 -0
  209. package/contracts/Shortfall/Shortfall.sol +33 -22
  210. package/contracts/VToken.sol +31 -9
  211. package/contracts/VTokenInterfaces.sol +10 -0
  212. package/contracts/WhitePaperInterestRateModel.sol +1 -1
  213. package/contracts/lib/imports.sol +11 -0
  214. package/contracts/test/MockDeflationaryToken.sol +113 -0
  215. package/dist/deploy/001-deploy-mock-tokens.d.ts +3 -0
  216. package/dist/deploy/001-deploy-mock-tokens.js +23 -0
  217. package/dist/deploy/002-price-oracle.d.ts +2 -0
  218. package/dist/deploy/002-price-oracle.js +9 -0
  219. package/dist/deploy/003-price-oracle-configure-feeds.d.ts +2 -0
  220. package/dist/deploy/003-price-oracle-configure-feeds.js +9 -0
  221. package/{deploy/004-swap-router.ts → dist/deploy/004-swap-router.d.ts} +0 -3
  222. package/dist/deploy/004-swap-router.js +8 -0
  223. package/dist/deploy/005-access-control.d.ts +3 -0
  224. package/dist/deploy/005-access-control.js +16 -0
  225. package/dist/deploy/006-deploy-factories.d.ts +3 -0
  226. package/dist/deploy/006-deploy-factories.js +37 -0
  227. package/dist/deploy/007-access-control-configure.d.ts +3 -0
  228. package/dist/deploy/007-access-control-configure.js +69 -0
  229. package/dist/deploy/008-deploy-pool-lens.d.ts +3 -0
  230. package/dist/deploy/008-deploy-pool-lens.js +15 -0
  231. package/dist/deploy/009-deploy-pools.d.ts +3 -0
  232. package/dist/deploy/009-deploy-pools.js +186 -0
  233. package/dist/deploy/010-rewards.d.ts +3 -0
  234. package/dist/deploy/010-rewards.js +76 -0
  235. package/dist/deploy/011-transfer-pools-ownership.d.ts +3 -0
  236. package/dist/deploy/011-transfer-pools-ownership.js +75 -0
  237. package/dist/deploy/012-riskfund-protocolshare.d.ts +3 -0
  238. package/dist/deploy/012-riskfund-protocolshare.js +139 -0
  239. package/dist/deploy/013-transfer-funds-ownership.d.ts +3 -0
  240. package/dist/deploy/013-transfer-funds-ownership.js +46 -0
  241. package/dist/hardhat.config.d.ts +14 -0
  242. package/dist/hardhat.config.js +237 -0
  243. package/dist/helpers/deploymentConfig.d.ts +59 -0
  244. package/dist/helpers/deploymentConfig.js +836 -0
  245. package/dist/helpers/utils.d.ts +3 -0
  246. package/dist/helpers/utils.js +28 -0
  247. package/package.json +3 -11
  248. package/contracts/Factories/JumpRateModelFactory.sol +0 -26
  249. package/contracts/Factories/VTokenProxyFactory.sol +0 -53
  250. package/contracts/Factories/WhitePaperInterestRateModelFactory.sol +0 -12
  251. package/contracts/Proxy/UpgradeableBeacon.sol +0 -10
  252. package/deploy/001-deploy-mock-tokens.ts +0 -29
  253. package/deploy/002-price-oracle.ts +0 -7
  254. package/deploy/003-price-oracle-configure-feeds.ts +0 -7
  255. package/deploy/005-access-control.ts +0 -20
  256. package/deploy/006-deploy-factories.ts +0 -82
  257. package/deploy/007-access-control-configure.ts +0 -142
  258. package/deploy/008-deploy-pool-lens.ts +0 -19
  259. package/deploy/009-deploy-pools.ts +0 -171
  260. package/deploy/010-rewards.ts +0 -84
  261. package/deploy/011-transfer-pools-ownership.ts +0 -93
  262. package/deploy/012-riskfund-protocolshare.ts +0 -140
  263. package/deploy/013-transfer-funds-ownership.ts +0 -63
  264. package/helpers/deploymentConfig.ts +0 -897
  265. package/helpers/utils.ts +0 -24
@@ -1,9 +1,14 @@
1
1
  // SPDX-License-Identifier: BSD-3-Clause
2
2
  pragma solidity 0.8.13;
3
3
 
4
+ /**
5
+ * @title PoolRegistryInterface
6
+ * @author Venus
7
+ * @notice Interface implemented by `PoolRegistry`.
8
+ */
4
9
  interface PoolRegistryInterface {
5
10
  /**
6
- * @dev Struct for a Venus interest rate pool.
11
+ * @notice Struct for a Venus interest rate pool.
7
12
  */
8
13
  struct VenusPool {
9
14
  string name;
@@ -14,7 +19,7 @@ interface PoolRegistryInterface {
14
19
  }
15
20
 
16
21
  /**
17
- * @dev Struct for a Venus interest rate pool metadata.
22
+ * @notice Struct for a Venus interest rate pool metadata.
18
23
  */
19
24
  struct VenusPoolMetaData {
20
25
  string category;
@@ -22,18 +27,18 @@ interface PoolRegistryInterface {
22
27
  string description;
23
28
  }
24
29
 
25
- /*** get All Pools in PoolRegistry ***/
30
+ /// @notice Get all pools in PoolRegistry
26
31
  function getAllPools() external view returns (VenusPool[] memory);
27
32
 
28
- /*** get a Pool by comptrollerAddress ***/
33
+ /// @notice Get a pool by comptroller address
29
34
  function getPoolByComptroller(address comptroller) external view returns (VenusPool memory);
30
35
 
31
- /*** get VToken in the Pool for an Asset ***/
36
+ /// @notice Get the address of the VToken contract in the Pool where the underlying token is the provided asset
32
37
  function getVTokenForAsset(address comptroller, address asset) external view returns (address);
33
38
 
34
- /*** get Pools supported by Asset ***/
39
+ /// @notice Get the addresss of the Pools supported that include a market for the provided asset
35
40
  function getPoolsSupportedByAsset(address asset) external view returns (address[] memory);
36
41
 
37
- /*** get metadata of a Pool by comptroller ***/
42
+ /// @notice Get the metadata of a Pool by comptroller address
38
43
  function getVenusPoolMetadata(address comptroller) external view returns (VenusPoolMetaData memory);
39
44
  }
@@ -11,6 +11,21 @@ import { VToken } from "../VToken.sol";
11
11
  import { Comptroller } from "../Comptroller.sol";
12
12
  import { MaxLoopsLimitHelper } from "../MaxLoopsLimitHelper.sol";
13
13
 
14
+ /**
15
+ * @title `RewardsDistributor`
16
+ * @author Venus
17
+ * @notice Contract used to configure, track and distribute rewards to users based on their actions (borrows and supplies) in the protocol.
18
+ * Users can receive additional rewards through a `RewardsDistributor`. Each `RewardsDistributor` proxy is initialized with a specific reward
19
+ * token and `Comptroller`, which can then distribute the reward token to users that supply or borrow in the associated pool.
20
+ * Authorized users can set the reward token borrow and supply speeds for each market in the pool. This sets a fixed amount of reward
21
+ * token to be released each block for borrowers and suppliers, which is distributed based on a user’s percentage of the borrows or supplies
22
+ * respectively. The owner can also set up reward distributions to contributor addresses (distinct from suppliers and borrowers) by setting
23
+ * their contributor reward token speed, which similarly allocates a fixed amount of reward token per block.
24
+ *
25
+ * The owner has the ability to transfer any amount of reward tokens held by the contract to any other address. Rewards are not distributed
26
+ * automatically and must be claimed by a user calling `claimRewardToken()`. Users should be aware that it is up to the owner and other centralized
27
+ * entities to ensure that the `RewardsDistributor` holds enough tokens to distribute the accumulated rewards of users and contributors.
28
+ */
14
29
  contract RewardsDistributor is ExponentialNoError, Ownable2StepUpgradeable, AccessControlledV8, MaxLoopsLimitHelper {
15
30
  using SafeERC20Upgradeable for IERC20Upgradeable;
16
31
 
@@ -1,6 +1,11 @@
1
1
  // SPDX-License-Identifier: BSD-3-Clause
2
2
  pragma solidity 0.8.13;
3
3
 
4
+ /**
5
+ * @title IProtocolShareReserve
6
+ * @author Venus
7
+ * @notice Interface implemented by `ProtocolShareReserve`.
8
+ */
4
9
  interface IProtocolShareReserve {
5
10
  function updateAssetsState(address comptroller, address asset) external;
6
11
  }
@@ -1,6 +1,11 @@
1
1
  // SPDX-License-Identifier: BSD-3-Clause
2
2
  pragma solidity 0.8.13;
3
3
 
4
+ /**
5
+ * @title IRiskFund
6
+ * @author Venus
7
+ * @notice Interface implemented by `RiskFund`.
8
+ */
4
9
  interface IRiskFund {
5
10
  function swapPoolsAssets(
6
11
  address[] calldata markets,
@@ -11,6 +11,11 @@ import { ReserveHelpers } from "./ReserveHelpers.sol";
11
11
  import { IRiskFund } from "./IRiskFund.sol";
12
12
  import { ensureNonzeroAddress } from "../lib/validators.sol";
13
13
 
14
+ /**
15
+ * @title ProtocolShareReserve
16
+ * @author Venus
17
+ * @notice Contract used to store and distribute the reserves generated in the markets.
18
+ */
14
19
  contract ProtocolShareReserve is Ownable2StepUpgradeable, ExponentialNoError, ReserveHelpers, IProtocolShareReserve {
15
20
  using SafeERC20Upgradeable for IERC20Upgradeable;
16
21
 
@@ -8,6 +8,11 @@ import { ensureNonzeroAddress } from "../lib/validators.sol";
8
8
  import { ComptrollerInterface } from "../ComptrollerInterface.sol";
9
9
  import { PoolRegistryInterface } from "../Pool/PoolRegistryInterface.sol";
10
10
 
11
+ /**
12
+ * @title ReserveHelpers
13
+ * @author Venus
14
+ * @notice Contract with basic features to track/hold different assets for different Comptrollers.
15
+ */
11
16
  contract ReserveHelpers {
12
17
  using SafeERC20Upgradeable for IERC20Upgradeable;
13
18
 
@@ -19,6 +19,9 @@ import { MaxLoopsLimitHelper } from "../MaxLoopsLimitHelper.sol";
19
19
  import { ensureNonzeroAddress } from "../lib/validators.sol";
20
20
 
21
21
  /**
22
+ * @title ReserveHelpers
23
+ * @author Venus
24
+ * @notice Contract with basic features to track/hold different assets for different Comptrollers.
22
25
  * @dev This contract does not support BNB.
23
26
  */
24
27
  contract RiskFund is
@@ -48,9 +51,6 @@ contract RiskFund is
48
51
  /// @notice Emitted when PancakeSwap router contract address is updated
49
52
  event PancakeSwapRouterUpdated(address indexed oldPancakeSwapRouter, address indexed newPancakeSwapRouter);
50
53
 
51
- /// @notice Emitted when min amount out for PancakeSwap is updated
52
- event AmountOutMinUpdated(uint256 oldAmountOutMin, uint256 newAmountOutMin);
53
-
54
54
  /// @notice Emitted when minimum amount to convert is updated
55
55
  event MinAmountToConvertUpdated(uint256 oldMinAmountToConvert, uint256 newMinAmountToConvert);
56
56
 
@@ -156,7 +156,7 @@ contract RiskFund is
156
156
  * @notice Swap array of pool assets into base asset's tokens of at least a minimum amount
157
157
  * @param markets Array of vTokens whose assets to swap for base asset
158
158
  * @param amountsOutMin Minimum amount to receive for swap
159
- * @param paths A path conststing of PCS token pairs for each swap
159
+ * @param paths A path consisting of PCS token pairs for each swap
160
160
  * @return Number of swapped tokens
161
161
  * @custom:error ZeroAddressNotAllowed is thrown if PoolRegistry contract address is not configured
162
162
  */
@@ -236,7 +236,7 @@ contract RiskFund is
236
236
  * @param vToken VToken
237
237
  * @param comptroller Comptroller address
238
238
  * @param amountOutMin Minimum amount to receive for swap
239
- * @param path A path for the swap conststing of PCS token pairs
239
+ * @param path A path for the swap consisting of PCS token pairs
240
240
  * @return Number of swapped tokens.
241
241
  */
242
242
  function _swapAsset(
@@ -1,6 +1,11 @@
1
1
  // SPDX-License-Identifier: BSD-3-Clause
2
2
  pragma solidity 0.8.13;
3
3
 
4
+ /**
5
+ * @title IShortfall
6
+ * @author Venus
7
+ * @notice Interface implemented by `Shortfall`.
8
+ */
4
9
  interface IShortfall {
5
10
  function convertibleBaseAsset() external returns (address);
6
11
  }
@@ -17,6 +17,16 @@ import { PoolRegistryInterface } from "../Pool/PoolRegistryInterface.sol";
17
17
  import { ensureNonzeroAddress } from "../lib/validators.sol";
18
18
  import { EXP_SCALE } from "../lib/constants.sol";
19
19
 
20
+ /**
21
+ * @title Shortfall
22
+ * @author Venus
23
+ * @notice Shortfall is an auction contract designed to auction off the `convertibleBaseAsset` accumulated in `RiskFund`. The `convertibleBaseAsset`
24
+ * is auctioned in exchange for users paying off the pool's bad debt. An auction can be started by anyone once a pool's bad debt has reached a minimum value.
25
+ * This value is set and can be changed by the authorized accounts. If the pool’s bad debt exceeds the risk fund plus a 10% incentive, then the auction winner
26
+ * is determined by who will pay off the largest percentage of the pool's bad debt. The auction winner then exchanges for the entire risk fund. Otherwise,
27
+ * if the risk fund covers the pool's bad debt plus the 10% incentive, then the auction winner is determined by who will take the smallest percentage of the
28
+ * risk fund in exchange for paying off all the pool's bad debt.
29
+ */
20
30
  contract Shortfall is Ownable2StepUpgradeable, AccessControlledV8, ReentrancyGuardUpgradeable, IShortfall {
21
31
  using SafeERC20Upgradeable for IERC20Upgradeable;
22
32
 
@@ -45,12 +55,13 @@ contract Shortfall is Ownable2StepUpgradeable, AccessControlledV8, ReentrancyGua
45
55
  uint256 highestBidBlock;
46
56
  uint256 startBidBps;
47
57
  mapping(VToken => uint256) marketDebt;
58
+ mapping(VToken => uint256) bidAmount;
48
59
  }
49
60
 
50
61
  /// @dev Max basis points i.e., 100%
51
62
  uint256 private constant MAX_BPS = 10000;
52
63
 
53
- uint256 private constant DEFAULT_NEXT_BIDDER_BLOCK_LIMIT = 10;
64
+ uint256 private constant DEFAULT_NEXT_BIDDER_BLOCK_LIMIT = 100;
54
65
 
55
66
  uint256 private constant DEFAULT_WAIT_FOR_FIRST_BIDDER = 100;
56
67
 
@@ -174,13 +185,20 @@ contract Shortfall is Ownable2StepUpgradeable, AccessControlledV8, ReentrancyGua
174
185
  * @notice Place a bid greater than the previous in an ongoing auction
175
186
  * @param comptroller Comptroller address of the pool
176
187
  * @param bidBps The bid percent of the risk fund or bad debt depending on auction type
188
+ * @param auctionStartBlock The block number when auction started
177
189
  * @custom:event Emits BidPlaced event on success
178
190
  */
179
- function placeBid(address comptroller, uint256 bidBps) external nonReentrant {
191
+ function placeBid(
192
+ address comptroller,
193
+ uint256 bidBps,
194
+ uint256 auctionStartBlock
195
+ ) external nonReentrant {
180
196
  Auction storage auction = auctions[comptroller];
181
197
 
198
+ require(auction.startBlock == auctionStartBlock, "auction has been restarted");
182
199
  require(_isStarted(auction), "no on-going auction");
183
200
  require(!_isStale(auction), "auction is stale, restart it");
201
+ require(bidBps > 0, "basis points cannot be zero");
184
202
  require(bidBps <= MAX_BPS, "basis points cannot be more than 10000");
185
203
  require(
186
204
  (auction.auctionType == AuctionType.LARGE_POOL_DEBT &&
@@ -197,22 +215,20 @@ contract Shortfall is Ownable2StepUpgradeable, AccessControlledV8, ReentrancyGua
197
215
  VToken vToken = VToken(address(auction.markets[i]));
198
216
  IERC20Upgradeable erc20 = IERC20Upgradeable(address(vToken.underlying()));
199
217
 
200
- if (auction.auctionType == AuctionType.LARGE_POOL_DEBT) {
201
- if (auction.highestBidder != address(0)) {
202
- uint256 previousBidAmount = ((auction.marketDebt[auction.markets[i]] * auction.highestBidBps) /
203
- MAX_BPS);
204
- erc20.safeTransfer(auction.highestBidder, previousBidAmount);
205
- }
218
+ if (auction.highestBidder != address(0)) {
219
+ erc20.safeTransfer(auction.highestBidder, auction.bidAmount[auction.markets[i]]);
220
+ }
221
+ uint256 balanceBefore = erc20.balanceOf(address(this));
206
222
 
223
+ if (auction.auctionType == AuctionType.LARGE_POOL_DEBT) {
207
224
  uint256 currentBidAmount = ((auction.marketDebt[auction.markets[i]] * bidBps) / MAX_BPS);
208
225
  erc20.safeTransferFrom(msg.sender, address(this), currentBidAmount);
209
226
  } else {
210
- if (auction.highestBidder != address(0)) {
211
- erc20.safeTransfer(auction.highestBidder, auction.marketDebt[auction.markets[i]]);
212
- }
213
-
214
227
  erc20.safeTransferFrom(msg.sender, address(this), auction.marketDebt[auction.markets[i]]);
215
228
  }
229
+
230
+ uint256 balanceAfter = erc20.balanceOf(address(this));
231
+ auction.bidAmount[auction.markets[i]] = balanceAfter - balanceBefore;
216
232
  }
217
233
 
218
234
  auction.highestBidder = msg.sender;
@@ -226,7 +242,6 @@ contract Shortfall is Ownable2StepUpgradeable, AccessControlledV8, ReentrancyGua
226
242
  * @notice Close an auction
227
243
  * @param comptroller Comptroller address of the pool
228
244
  * @custom:event Emits AuctionClosed event on successful close
229
- * @custom:event Errors if auctions are paused
230
245
  */
231
246
  function closeAuction(address comptroller) external nonReentrant {
232
247
  Auction storage auction = auctions[comptroller];
@@ -246,14 +261,10 @@ contract Shortfall is Ownable2StepUpgradeable, AccessControlledV8, ReentrancyGua
246
261
  VToken vToken = VToken(address(auction.markets[i]));
247
262
  IERC20Upgradeable erc20 = IERC20Upgradeable(address(vToken.underlying()));
248
263
 
249
- if (auction.auctionType == AuctionType.LARGE_POOL_DEBT) {
250
- uint256 bidAmount = ((auction.marketDebt[auction.markets[i]] * auction.highestBidBps) / MAX_BPS);
251
- erc20.safeTransfer(address(auction.markets[i]), bidAmount);
252
- marketsDebt[i] = bidAmount;
253
- } else {
254
- erc20.safeTransfer(address(auction.markets[i]), auction.marketDebt[auction.markets[i]]);
255
- marketsDebt[i] = auction.marketDebt[auction.markets[i]];
256
- }
264
+ uint256 balanceBefore = erc20.balanceOf(address(auction.markets[i]));
265
+ erc20.safeTransfer(address(auction.markets[i]), auction.bidAmount[auction.markets[i]]);
266
+ uint256 balanceAfter = erc20.balanceOf(address(auction.markets[i]));
267
+ marketsDebt[i] = balanceAfter - balanceBefore;
257
268
 
258
269
  auction.markets[i].badDebtRecovered(marketsDebt[i]);
259
270
  }
@@ -295,11 +306,11 @@ contract Shortfall is Ownable2StepUpgradeable, AccessControlledV8, ReentrancyGua
295
306
  * @notice Restart an auction
296
307
  * @param comptroller Address of the pool
297
308
  * @custom:event Emits AuctionRestarted event on successful restart
298
- * @custom:event Errors if auctions are paused
299
309
  */
300
310
  function restartAuction(address comptroller) external {
301
311
  Auction storage auction = auctions[comptroller];
302
312
 
313
+ require(!auctionsPaused, "auctions are paused");
303
314
  require(_isStarted(auction), "no on-going auction");
304
315
  require(_isStale(auction), "you need to wait for more time for first bidder");
305
316
 
@@ -15,8 +15,30 @@ import { IProtocolShareReserve } from "./RiskFund/IProtocolShareReserve.sol";
15
15
  import { ensureNonzeroAddress } from "./lib/validators.sol";
16
16
 
17
17
  /**
18
- * @title Venus VToken Contract
19
- * @author Venus Dev Team
18
+ * @title VToken
19
+ * @author Venus
20
+ * @notice Each asset that is supported by a pool is integrated through an instance of the `VToken` contract. As outlined in the protocol overview,
21
+ * each isolated pool creates its own `vToken` corresponding to an asset. Within a given pool, each included `vToken` is referred to as a market of
22
+ * the pool. The main actions a user regularly interacts with in a market are:
23
+
24
+ - mint/redeem of vTokens;
25
+ - transfer of vTokens;
26
+ - borrow/repay a loan on an underlying asset;
27
+ - liquidate a borrow or liquidate/heal an account.
28
+
29
+ * A user supplies the underlying asset to a pool by minting `vTokens`, where the corresponding `vToken` amount is determined by the `exchangeRate`.
30
+ * The `exchangeRate` will change over time, dependent on a number of factors, some of which accrue interest. Additionally, once users have minted
31
+ * `vToken` in a pool, they can borrow any asset in the isolated pool by using their `vToken` as collateral. In order to borrow an asset or use a `vToken`
32
+ * as collateral, the user must be entered into each corresponding market (else, the `vToken` will not be considered collateral for a borrow). Note that
33
+ * a user may borrow up to a portion of their collateral determined by the market’s collateral factor. However, if their borrowed amount exceeds an amount
34
+ * calculated using the market’s corresponding liquidation threshold, the borrow is eligible for liquidation. When a user repays a borrow, they must also
35
+ * pay off interest accrued on the borrow.
36
+ *
37
+ * The Venus protocol includes unique mechanisms for healing an account and liquidating an account. These actions are performed in the `Comptroller`
38
+ * and consider all borrows and collateral for which a given account is entered within a market. These functions may only be called on an account with a
39
+ * total collateral amount that is no larger than a universal `minLiquidatableCollateral` value, which is used for all markets within a `Comptroller`.
40
+ * Both functions settle all of an account’s borrows, but `healAccount()` may add `badDebt` to a vToken. For more detail, see the description of
41
+ * `healAccount()` and `liquidateAccount()` in the `Comptroller` summary section below.
20
42
  */
21
43
  contract VToken is
22
44
  Ownable2StepUpgradeable,
@@ -846,31 +868,31 @@ contract VToken is
846
868
 
847
869
  uint256 redeemTokens;
848
870
  uint256 redeemAmount;
871
+
849
872
  /* If redeemTokensIn > 0: */
850
873
  if (redeemTokensIn > 0) {
851
874
  /*
852
875
  * We calculate the exchange rate and the amount of underlying to be redeemed:
853
876
  * redeemTokens = redeemTokensIn
854
- * redeemAmount = redeemTokensIn x exchangeRateCurrent
855
877
  */
856
878
  redeemTokens = redeemTokensIn;
857
- redeemAmount = mul_ScalarTruncate(exchangeRate, redeemTokensIn);
858
879
  } else {
859
880
  /*
860
881
  * We get the current exchange rate and calculate the amount to be redeemed:
861
882
  * redeemTokens = redeemAmountIn / exchangeRate
862
- * redeemAmount = redeemAmountIn
863
883
  */
864
884
  redeemTokens = div_(redeemAmountIn, exchangeRate);
865
885
 
866
886
  uint256 _redeemAmount = mul_(redeemTokens, exchangeRate);
867
887
  if (_redeemAmount != 0 && _redeemAmount != redeemAmountIn) redeemTokens++; // round up
868
- redeemAmount = redeemAmountIn;
869
888
  }
870
889
 
871
- // Revert if tokens is zero and amount is nonzero or token is nonzero and amount is zero
872
- if ((redeemTokens == 0 && redeemAmount > 0) || (redeemTokens != 0 && redeemAmount == 0)) {
873
- revert("redeemTokens or redeemAmount is zero");
890
+ // redeemAmount = exchangeRate * redeemTokens
891
+ redeemAmount = mul_ScalarTruncate(exchangeRate, redeemTokens);
892
+
893
+ // Revert if amount is zero
894
+ if (redeemAmount == 0) {
895
+ revert("redeemAmount is zero");
874
896
  }
875
897
 
876
898
  /* Fail if redeem not allowed */
@@ -7,6 +7,11 @@ import { ResilientOracleInterface } from "@venusprotocol/oracle/contracts/interf
7
7
  import { ComptrollerInterface } from "./ComptrollerInterface.sol";
8
8
  import { InterestRateModel } from "./InterestRateModel.sol";
9
9
 
10
+ /**
11
+ * @title VTokenStorage
12
+ * @author Venus
13
+ * @notice Storage layout used by the `VToken` contract
14
+ */
10
15
  // solhint-disable-next-line max-states-count
11
16
  contract VTokenStorage {
12
17
  /**
@@ -130,6 +135,11 @@ contract VTokenStorage {
130
135
  uint256[50] private __gap;
131
136
  }
132
137
 
138
+ /**
139
+ * @title VTokenInterface
140
+ * @author Venus
141
+ * @notice Interface implemented by the `VToken` contract
142
+ */
133
143
  abstract contract VTokenInterface is VTokenStorage {
134
144
  struct RiskManagementInit {
135
145
  address shortfall;
@@ -90,7 +90,7 @@ contract WhitePaperInterestRateModel is InterestRateModel {
90
90
  uint256 reserves,
91
91
  uint256 badDebt
92
92
  ) public pure returns (uint256) {
93
- // Utilization rate is 0 when there are no borrows
93
+ // Utilization rate is 0 when there are no borrows and badDebt
94
94
  if ((borrows + badDebt) == 0) {
95
95
  return 0;
96
96
  }
@@ -0,0 +1,11 @@
1
+ // SPDX-License-Identifier: BSD-3-Clause
2
+ pragma solidity 0.8.13;
3
+
4
+ // This file is needed to make hardhat and typechain generate artifacts for
5
+ // contracts we depend on (e.g. in tests or deployments) but not use directly.
6
+ // Another way to do this would be to use hardhat-dependency-compiler, but
7
+ // since we only have a couple of dependencies, installing a separate package
8
+ // seems an overhead.
9
+
10
+ import { UpgradeableBeacon } from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
11
+ import { BeaconProxy } from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
@@ -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 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,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const deploymentConfig_1 = require("../helpers/deploymentConfig");
4
+ const func = async function (hre) {
5
+ const { deployments, getNamedAccounts } = hre;
6
+ const { deploy } = deployments;
7
+ const { deployer } = await getNamedAccounts();
8
+ const { tokensConfig } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
9
+ for (const token of tokensConfig) {
10
+ if (token.isMock) {
11
+ const contractName = `Mock${token.symbol}`;
12
+ await deploy(contractName, {
13
+ from: deployer,
14
+ contract: "MockToken",
15
+ args: [token.name, token.symbol, token.decimals],
16
+ log: true,
17
+ autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
18
+ });
19
+ }
20
+ }
21
+ };
22
+ func.tags = ["MockTokens"];
23
+ exports.default = func;
@@ -0,0 +1,2 @@
1
+ import deployOracle from "@venusprotocol/oracle/dist/deploy/1-deploy-oracles";
2
+ export default deployOracle;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _1_deploy_oracles_1 = __importDefault(require("@venusprotocol/oracle/dist/deploy/1-deploy-oracles"));
7
+ _1_deploy_oracles_1.default.tags = ["OracleDeploy"];
8
+ _1_deploy_oracles_1.default.skip = async (hre) => hre.network.live;
9
+ exports.default = _1_deploy_oracles_1.default;
@@ -0,0 +1,2 @@
1
+ import configureOracleFeeds from "@venusprotocol/oracle/dist/deploy/2-configure-feeds";
2
+ export default configureOracleFeeds;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _2_configure_feeds_1 = __importDefault(require("@venusprotocol/oracle/dist/deploy/2-configure-feeds"));
7
+ _2_configure_feeds_1.default.tags = ["Oracle"];
8
+ _2_configure_feeds_1.default.skip = async (hre) => hre.network.live;
9
+ exports.default = _2_configure_feeds_1.default;
@@ -1,5 +1,2 @@
1
1
  import deployOracle from "@venusprotocol/venus-protocol/deploy/005-deploy-swaprouter";
2
-
3
- deployOracle.tags = ["SwapRouter", "il"];
4
-
5
2
  export default deployOracle;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _005_deploy_swaprouter_1 = __importDefault(require("@venusprotocol/venus-protocol/deploy/005-deploy-swaprouter"));
7
+ _005_deploy_swaprouter_1.default.tags = ["SwapRouter", "il"];
8
+ exports.default = _005_deploy_swaprouter_1.default;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { deployments, getNamedAccounts } = hre;
5
+ const { deploy } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ await deploy("AccessControlManager", {
8
+ from: deployer,
9
+ args: [],
10
+ log: true,
11
+ autoMine: true,
12
+ });
13
+ };
14
+ func.tags = ["AccessControl", "il"];
15
+ func.skip = async (hre) => hre.network.live;
16
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;