@venusprotocol/isolated-pools 1.0.0-dev.7 → 1.0.0-dev.9

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 (227) hide show
  1. package/README.md +1 -11
  2. package/contracts/BaseJumpRateModelV2.sol +3 -2
  3. package/contracts/Comptroller.sol +22 -2
  4. package/contracts/ComptrollerInterface.sol +10 -0
  5. package/contracts/ComptrollerStorage.sol +5 -0
  6. package/contracts/ErrorReporter.sol +5 -0
  7. package/contracts/Lens/PoolLens.sol +13 -0
  8. package/contracts/MaxLoopsLimitHelper.sol +5 -0
  9. package/contracts/Pool/PoolRegistry.sol +58 -208
  10. package/contracts/Pool/PoolRegistryInterface.sol +12 -7
  11. package/contracts/Rewards/RewardsDistributor.sol +15 -0
  12. package/contracts/RiskFund/IProtocolShareReserve.sol +5 -0
  13. package/contracts/RiskFund/IRiskFund.sol +5 -0
  14. package/contracts/RiskFund/ProtocolShareReserve.sol +5 -0
  15. package/contracts/RiskFund/ReserveHelpers.sol +5 -0
  16. package/contracts/RiskFund/RiskFund.sol +3 -0
  17. package/contracts/Shortfall/IShortfall.sol +5 -0
  18. package/contracts/Shortfall/Shortfall.sol +10 -0
  19. package/contracts/VToken.sol +24 -2
  20. package/contracts/VTokenInterfaces.sol +10 -0
  21. package/contracts/lib/imports.sol +11 -0
  22. package/dist/deploy/006-deploy-factories.js +1 -32
  23. package/dist/deploy/007-access-control-configure.js +2 -6
  24. package/dist/deploy/009-deploy-pools.js +84 -23
  25. package/package.json +1 -1
  26. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +0 -4
  27. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +0 -215
  28. package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +0 -4
  29. package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +0 -183
  30. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +0 -4
  31. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.json +0 -63
  32. package/artifacts/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.dbg.json +0 -4
  33. package/artifacts/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.json +0 -56
  34. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.dbg.json +0 -4
  35. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.json +0 -24
  36. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol/ERC1967Upgrade.dbg.json +0 -4
  37. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol/ERC1967Upgrade.json +0 -56
  38. package/artifacts/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.dbg.json +0 -4
  39. package/artifacts/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.json +0 -19
  40. package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.dbg.json +0 -4
  41. package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.json +0 -80
  42. package/artifacts/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.dbg.json +0 -4
  43. package/artifacts/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.json +0 -24
  44. package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.dbg.json +0 -4
  45. package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.json +0 -113
  46. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +0 -4
  47. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json +0 -297
  48. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +0 -4
  49. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.json +0 -194
  50. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +0 -4
  51. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.json +0 -233
  52. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +0 -4
  53. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.json +0 -10
  54. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +0 -4
  55. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +0 -10
  56. package/artifacts/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.dbg.json +0 -4
  57. package/artifacts/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.json +0 -10
  58. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +0 -4
  59. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +0 -10
  60. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +0 -4
  61. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +0 -30
  62. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +0 -4
  63. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +0 -30
  64. package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +0 -4
  65. package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +0 -10
  66. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +0 -4
  67. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +0 -10
  68. package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.dbg.json +0 -4
  69. package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +0 -115
  70. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +0 -4
  71. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.json +0 -76
  72. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +0 -4
  73. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.json +0 -24
  74. package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.dbg.json +0 -4
  75. package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.json +0 -24
  76. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json +0 -4
  77. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.json +0 -194
  78. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.dbg.json +0 -4
  79. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.json +0 -86
  80. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.dbg.json +0 -4
  81. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.json +0 -10
  82. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +0 -4
  83. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.json +0 -10
  84. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +0 -4
  85. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.json +0 -24
  86. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol/AccessControlManager.dbg.json +0 -4
  87. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol/AccessControlManager.json +0 -369
  88. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.dbg.json +0 -4
  89. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.json +0 -181
  90. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.dbg.json +0 -4
  91. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.json +0 -282
  92. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +0 -4
  93. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.json +0 -40
  94. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +0 -4
  95. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.json +0 -30
  96. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +0 -4
  97. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.json +0 -43
  98. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +0 -4
  99. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.json +0 -49
  100. package/artifacts/build-info/eb7e5feedaca37f948646aa7bfff0291.json +0 -1
  101. package/artifacts/build-info/f19d689bc99e63a20dd2a17a14e2b84a.json +0 -1
  102. package/artifacts/contracts/BaseJumpRateModelV2.sol/BaseJumpRateModelV2.dbg.json +0 -4
  103. package/artifacts/contracts/BaseJumpRateModelV2.sol/BaseJumpRateModelV2.json +0 -276
  104. package/artifacts/contracts/Comptroller.sol/Comptroller.dbg.json +0 -4
  105. package/artifacts/contracts/Comptroller.sol/Comptroller.json +0 -1667
  106. package/artifacts/contracts/ComptrollerInterface.sol/ComptrollerInterface.dbg.json +0 -4
  107. package/artifacts/contracts/ComptrollerInterface.sol/ComptrollerInterface.json +0 -285
  108. package/artifacts/contracts/ComptrollerInterface.sol/ComptrollerViewInterface.dbg.json +0 -4
  109. package/artifacts/contracts/ComptrollerInterface.sol/ComptrollerViewInterface.json +0 -170
  110. package/artifacts/contracts/ComptrollerStorage.sol/ComptrollerStorage.dbg.json +0 -4
  111. package/artifacts/contracts/ComptrollerStorage.sol/ComptrollerStorage.json +0 -173
  112. package/artifacts/contracts/ErrorReporter.sol/TokenErrorReporter.dbg.json +0 -4
  113. package/artifacts/contracts/ErrorReporter.sol/TokenErrorReporter.json +0 -156
  114. package/artifacts/contracts/ExponentialNoError.sol/ExponentialNoError.dbg.json +0 -4
  115. package/artifacts/contracts/ExponentialNoError.sol/ExponentialNoError.json +0 -10
  116. package/artifacts/contracts/Factories/JumpRateModelFactory.sol/JumpRateModelFactory.dbg.json +0 -4
  117. package/artifacts/contracts/Factories/JumpRateModelFactory.sol/JumpRateModelFactory.json +0 -50
  118. package/artifacts/contracts/Factories/VTokenProxyFactory.sol/VTokenProxyFactory.dbg.json +0 -4
  119. package/artifacts/contracts/Factories/VTokenProxyFactory.sol/VTokenProxyFactory.json +0 -191
  120. package/artifacts/contracts/Factories/WhitePaperInterestRateModelFactory.sol/WhitePaperInterestRateModelFactory.dbg.json +0 -4
  121. package/artifacts/contracts/Factories/WhitePaperInterestRateModelFactory.sol/WhitePaperInterestRateModelFactory.json +0 -35
  122. package/artifacts/contracts/IPancakeswapV2Router.sol/IPancakeswapV2Router.dbg.json +0 -4
  123. package/artifacts/contracts/IPancakeswapV2Router.sol/IPancakeswapV2Router.json +0 -50
  124. package/artifacts/contracts/InterestRateModel.sol/InterestRateModel.dbg.json +0 -4
  125. package/artifacts/contracts/InterestRateModel.sol/InterestRateModel.json +0 -97
  126. package/artifacts/contracts/JumpRateModelV2.sol/JumpRateModelV2.dbg.json +0 -4
  127. package/artifacts/contracts/JumpRateModelV2.sol/JumpRateModelV2.json +0 -307
  128. package/artifacts/contracts/Lens/PoolLens.sol/PoolLens.dbg.json +0 -4
  129. package/artifacts/contracts/Lens/PoolLens.sol/PoolLens.json +0 -1087
  130. package/artifacts/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.dbg.json +0 -4
  131. package/artifacts/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.json +0 -59
  132. package/artifacts/contracts/Pool/PoolRegistry.sol/PoolRegistry.dbg.json +0 -4
  133. package/artifacts/contracts/Pool/PoolRegistry.sol/PoolRegistry.json +0 -923
  134. package/artifacts/contracts/Pool/PoolRegistryInterface.sol/PoolRegistryInterface.dbg.json +0 -4
  135. package/artifacts/contracts/Pool/PoolRegistryInterface.sol/PoolRegistryInterface.json +0 -176
  136. package/artifacts/contracts/Proxy/UpgradeableBeacon.sol/Beacon.dbg.json +0 -4
  137. package/artifacts/contracts/Proxy/UpgradeableBeacon.sol/Beacon.json +0 -113
  138. package/artifacts/contracts/Rewards/RewardsDistributor.sol/RewardsDistributor.dbg.json +0 -4
  139. package/artifacts/contracts/Rewards/RewardsDistributor.sol/RewardsDistributor.json +0 -928
  140. package/artifacts/contracts/RiskFund/IProtocolShareReserve.sol/IProtocolShareReserve.dbg.json +0 -4
  141. package/artifacts/contracts/RiskFund/IProtocolShareReserve.sol/IProtocolShareReserve.json +0 -29
  142. package/artifacts/contracts/RiskFund/IRiskFund.sol/IRiskFund.dbg.json +0 -4
  143. package/artifacts/contracts/RiskFund/IRiskFund.sol/IRiskFund.json +0 -101
  144. package/artifacts/contracts/RiskFund/ProtocolShareReserve.sol/ProtocolShareReserve.dbg.json +0 -4
  145. package/artifacts/contracts/RiskFund/ProtocolShareReserve.sol/ProtocolShareReserve.json +0 -296
  146. package/artifacts/contracts/RiskFund/ReserveHelpers.sol/ReserveHelpers.dbg.json +0 -4
  147. package/artifacts/contracts/RiskFund/ReserveHelpers.sol/ReserveHelpers.json +0 -83
  148. package/artifacts/contracts/RiskFund/RiskFund.sol/RiskFund.dbg.json +0 -4
  149. package/artifacts/contracts/RiskFund/RiskFund.sol/RiskFund.json +0 -615
  150. package/artifacts/contracts/Shortfall/IShortfall.sol/IShortfall.dbg.json +0 -4
  151. package/artifacts/contracts/Shortfall/IShortfall.sol/IShortfall.json +0 -24
  152. package/artifacts/contracts/Shortfall/Shortfall.sol/Shortfall.dbg.json +0 -4
  153. package/artifacts/contracts/Shortfall/Shortfall.sol/Shortfall.json +0 -756
  154. package/artifacts/contracts/VToken.sol/VToken.dbg.json +0 -4
  155. package/artifacts/contracts/VToken.sol/VToken.json +0 -1850
  156. package/artifacts/contracts/VTokenInterfaces.sol/VTokenInterface.dbg.json +0 -4
  157. package/artifacts/contracts/VTokenInterfaces.sol/VTokenInterface.json +0 -1398
  158. package/artifacts/contracts/VTokenInterfaces.sol/VTokenStorage.dbg.json +0 -4
  159. package/artifacts/contracts/VTokenInterfaces.sol/VTokenStorage.json +0 -219
  160. package/artifacts/contracts/WhitePaperInterestRateModel.sol/WhitePaperInterestRateModel.dbg.json +0 -4
  161. package/artifacts/contracts/WhitePaperInterestRateModel.sol/WhitePaperInterestRateModel.json +0 -192
  162. package/artifacts/contracts/test/ComptrollerHarness.sol/ComptrollerHarness.dbg.json +0 -4
  163. package/artifacts/contracts/test/ComptrollerHarness.sol/ComptrollerHarness.json +0 -1712
  164. package/artifacts/contracts/test/ComptrollerHarness.sol/EchoTypesComptroller.dbg.json +0 -4
  165. package/artifacts/contracts/test/ComptrollerHarness.sol/EchoTypesComptroller.json +0 -94
  166. package/artifacts/contracts/test/ComptrollerScenario.sol/ComptrollerScenario.dbg.json +0 -4
  167. package/artifacts/contracts/test/ComptrollerScenario.sol/ComptrollerScenario.json +0 -1744
  168. package/artifacts/contracts/test/ERC20.sol/ERC20.dbg.json +0 -4
  169. package/artifacts/contracts/test/ERC20.sol/ERC20.json +0 -194
  170. package/artifacts/contracts/test/ERC20.sol/ERC20Base.dbg.json +0 -4
  171. package/artifacts/contracts/test/ERC20.sol/ERC20Base.json +0 -141
  172. package/artifacts/contracts/test/ERC20.sol/ERC20Harness.dbg.json +0 -4
  173. package/artifacts/contracts/test/ERC20.sol/ERC20Harness.json +0 -351
  174. package/artifacts/contracts/test/ERC20.sol/ERC20NS.dbg.json +0 -4
  175. package/artifacts/contracts/test/ERC20.sol/ERC20NS.json +0 -182
  176. package/artifacts/contracts/test/ERC20.sol/NonStandardToken.dbg.json +0 -4
  177. package/artifacts/contracts/test/ERC20.sol/NonStandardToken.json +0 -247
  178. package/artifacts/contracts/test/ERC20.sol/StandardToken.dbg.json +0 -4
  179. package/artifacts/contracts/test/ERC20.sol/StandardToken.json +0 -259
  180. package/artifacts/contracts/test/EvilToken.sol/EvilToken.dbg.json +0 -4
  181. package/artifacts/contracts/test/EvilToken.sol/EvilToken.json +0 -303
  182. package/artifacts/contracts/test/FaucetToken.sol/FaucetNonStandardToken.dbg.json +0 -4
  183. package/artifacts/contracts/test/FaucetToken.sol/FaucetNonStandardToken.json +0 -265
  184. package/artifacts/contracts/test/FaucetToken.sol/FaucetToken.dbg.json +0 -4
  185. package/artifacts/contracts/test/FaucetToken.sol/FaucetToken.json +0 -277
  186. package/artifacts/contracts/test/FaucetToken.sol/FaucetTokenReEntrantHarness.dbg.json +0 -4
  187. package/artifacts/contracts/test/FaucetToken.sol/FaucetTokenReEntrantHarness.json +0 -313
  188. package/artifacts/contracts/test/FeeToken.sol/FeeToken.dbg.json +0 -4
  189. package/artifacts/contracts/test/FeeToken.sol/FeeToken.json +0 -313
  190. package/artifacts/contracts/test/HarnessMaxLoopsLimitHelper.sol/HarnessMaxLoopsLimitHelper.dbg.json +0 -4
  191. package/artifacts/contracts/test/HarnessMaxLoopsLimitHelper.sol/HarnessMaxLoopsLimitHelper.json +0 -85
  192. package/artifacts/contracts/test/MockDeflationaryToken.sol/MockDeflatingToken.dbg.json +0 -4
  193. package/artifacts/contracts/test/MockDeflationaryToken.sol/MockDeflatingToken.json +0 -332
  194. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IERC20.dbg.json +0 -4
  195. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IERC20.json +0 -233
  196. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeFactory.dbg.json +0 -4
  197. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeFactory.json +0 -187
  198. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakePair.dbg.json +0 -4
  199. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakePair.json +0 -668
  200. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeRouter01.dbg.json +0 -4
  201. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeRouter01.json +0 -760
  202. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeRouter02.dbg.json +0 -4
  203. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IPancakeRouter02.json +0 -962
  204. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IWETH.dbg.json +0 -4
  205. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/IWETH.json +0 -55
  206. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/PancakeLibrary.dbg.json +0 -4
  207. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/PancakeLibrary.json +0 -10
  208. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/PancakeRouter.dbg.json +0 -4
  209. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/PancakeRouter.json +0 -982
  210. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/SafeMath.dbg.json +0 -4
  211. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/SafeMath.json +0 -10
  212. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/TransferHelper.dbg.json +0 -4
  213. package/artifacts/contracts/test/Mocks/MockPancakeSwap.sol/TransferHelper.json +0 -10
  214. package/artifacts/contracts/test/Mocks/MockPriceOracle.sol/MockPriceOracle.dbg.json +0 -4
  215. package/artifacts/contracts/test/Mocks/MockPriceOracle.sol/MockPriceOracle.json +0 -85
  216. package/artifacts/contracts/test/Mocks/MockToken.sol/MockToken.dbg.json +0 -4
  217. package/artifacts/contracts/test/Mocks/MockToken.sol/MockToken.json +0 -315
  218. package/artifacts/contracts/test/SafeMath.sol/SafeMath.dbg.json +0 -4
  219. package/artifacts/contracts/test/SafeMath.sol/SafeMath.json +0 -10
  220. package/artifacts/contracts/test/UpgradedVToken.sol/UpgradedVToken.dbg.json +0 -4
  221. package/artifacts/contracts/test/UpgradedVToken.sol/UpgradedVToken.json +0 -1946
  222. package/artifacts/contracts/test/VTokenHarness.sol/VTokenHarness.dbg.json +0 -4
  223. package/artifacts/contracts/test/VTokenHarness.sol/VTokenHarness.json +0 -2306
  224. package/contracts/Factories/JumpRateModelFactory.sol +0 -26
  225. package/contracts/Factories/VTokenProxyFactory.sol +0 -53
  226. package/contracts/Factories/WhitePaperInterestRateModelFactory.sol +0 -12
  227. package/contracts/Proxy/UpgradeableBeacon.sol +0 -10
package/README.md CHANGED
@@ -12,20 +12,10 @@ The first generation of lending pools, including the Venus Core Pool, aggregate
12
12
 
13
13
  ### PoolRegistry
14
14
 
15
- The Isolated Pools architecture centers around the `PoolRegistry` contract. The `PoolRegistry` maintains a directory of isolated lending pools and can perform actions like creating and registering new pools, adding new markets to existing pools, setting and updating the pool's required metadata, and providing the getter methods to get information on the pools.
15
+ The Isolated Pools architecture centers around the `PoolRegistry` contract. The `PoolRegistry` maintains a directory of isolated lending pools and can perform actions like registering new pools, adding new markets to existing pools, setting and updating the pool's required metadata, and providing the getter methods to get information on the pools.
16
16
 
17
17
  ![image](https://user-images.githubusercontent.com/47150934/236290058-6b14a499-7afe-46e4-bca6-d72e3db8a28e.png)
18
18
 
19
- ### Factories
20
-
21
- There are three factory contracts:
22
-
23
- - JumpRateModelFactory
24
- - VTokenProxyFactory
25
- - WhiteRateInterestModelFactory
26
-
27
- These contracts are designed to deploy contracts when adding markets to a pool. In particular, the `JumpRateModelFactory` and `WhiteRateInterestModelFactory` deploy contracts for the rate model based on which was chosen for the market. The `VtokenProxyFactory` is used to generate a new `vToken` proxy for each market when it is added to a pool.
28
-
29
19
  ### Risk Fund
30
20
 
31
21
  The risk fund concerns three main contracts:
@@ -8,8 +8,9 @@ import { BLOCKS_PER_YEAR, EXP_SCALE, MANTISSA_ONE } from "./lib/constants.sol";
8
8
 
9
9
  /**
10
10
  * @title Logic for Compound's JumpRateModel Contract V2.
11
- * @author Compound (modified by Dharma Labs, refactored by Arr00)
12
- * @notice Version 2 modifies Version 1 by enabling updateable parameters.
11
+ * @author Compound (modified by Dharma Labs, Arr00 and Venus)
12
+ * @notice An interest rate model with a steep increase after a certain utilization threshold called **kink** is reached.
13
+ * The parameters of this interest rate model can be adjusted by the owner. Version 2 modifies Version 1 by enabling updateable parameters.
13
14
  */
14
15
  abstract contract BaseJumpRateModelV2 is InterestRateModel {
15
16
  /**
@@ -14,7 +14,27 @@ import { MaxLoopsLimitHelper } from "./MaxLoopsLimitHelper.sol";
14
14
  import { ensureNonzeroAddress } from "./lib/validators.sol";
15
15
 
16
16
  /**
17
- * @title Comptroller Contract
17
+ * @title Comptroller
18
+ * @author Venus
19
+ * @notice The Comptroller is designed to provide checks for all minting, redeeming, transferring, borrowing, lending, repaying, liquidating,
20
+ * and seizing done by the `vToken` contract. Each pool has one `Comptroller` checking these interactions across markets. When a user interacts
21
+ * with a given market by one of these main actions, a call is made to a corresponding hook in the associated `Comptroller`, which either allows
22
+ * or reverts the transaction. These hooks also update supply and borrow rewards as they are called. The comptroller holds the logic for assessing
23
+ * liquidity snapshots of an account via the collateral factor and liquidation threshold. This check determines the collateral needed for a borrow,
24
+ * as well as how much of a borrow may be liquidated. A user may borrow a portion of their collateral with the maximum amount determined by the
25
+ * markets collateral factor. However, if their borrowed amount exceeds an amount calculated using the market’s corresponding liquidation threshold,
26
+ * the borrow is eligible for liquidation.
27
+ *
28
+ * The `Comptroller` also includes two functions `liquidateAccount()` and `healAccount()`, which are meant to handle accounts that do not exceed
29
+ * the `minLiquidatableCollateral` for the `Comptroller`:
30
+ *
31
+ * - `healAccount()`: This function is called to seize all of a given user’s collateral, requiring the `msg.sender` repay a certain percentage
32
+ * of the debt calculated by `collateral/(borrows*liquidationIncentive)`. The function can only be called if the calculated percentage does not exceed
33
+ * 100%, because otherwise no `badDebt` would be created and `liquidateAccount()` should be used instead. The difference in the actual amount of debt
34
+ * and debt paid off is recorded as `badDebt` for each market, which can then be auctioned off for the risk reserves of the associated pool.
35
+ * - `liquidateAccount()`: This function can only be called if the collateral seized will cover all borrows of an account, as well as the liquidation
36
+ * incentive. Otherwise, the pool will incur bad debt, in which case the function `healAccount()` should be used instead. This function skips the logic
37
+ * verifying that the repay amount does not exceed the close factor.
18
38
  */
19
39
  contract Comptroller is
20
40
  Ownable2StepUpgradeable,
@@ -714,7 +734,7 @@ contract Comptroller is
714
734
  * @notice Sets the closeFactor to use when liquidating borrows
715
735
  * @param newCloseFactorMantissa New close factor, scaled by 1e18
716
736
  * @custom:event Emits NewCloseFactor on success
717
- * @custom:access Only Governance
737
+ * @custom:access Controlled by AccessControlManager
718
738
  */
719
739
  function setCloseFactor(uint256 newCloseFactorMantissa) external {
720
740
  _checkAccessAllowed("setCloseFactor(uint256)");
@@ -6,6 +6,11 @@ import { ResilientOracleInterface } from "@venusprotocol/oracle/contracts/interf
6
6
  import { VToken } from "./VToken.sol";
7
7
  import { RewardsDistributor } from "./Rewards/RewardsDistributor.sol";
8
8
 
9
+ /**
10
+ * @title ComptrollerInterface
11
+ * @author Venus
12
+ * @notice Interface implemented by the `Comptroller` contract.
13
+ */
9
14
  interface ComptrollerInterface {
10
15
  /*** Assets You Are In ***/
11
16
 
@@ -70,6 +75,11 @@ interface ComptrollerInterface {
70
75
  function getAllMarkets() external view returns (VToken[] memory);
71
76
  }
72
77
 
78
+ /**
79
+ * @title ComptrollerViewInterface
80
+ * @author Venus
81
+ * @notice Interface implemented by the `Comptroller` contract, including only some util view functions.
82
+ */
73
83
  interface ComptrollerViewInterface {
74
84
  function markets(address) external view returns (bool, uint256);
75
85
 
@@ -6,6 +6,11 @@ import { ResilientOracleInterface } from "@venusprotocol/oracle/contracts/interf
6
6
  import { VToken } from "./VToken.sol";
7
7
  import { RewardsDistributor } from "./Rewards/RewardsDistributor.sol";
8
8
 
9
+ /**
10
+ * @title ComptrollerStorage
11
+ * @author Venus
12
+ * @notice Storage layout for the `Comptroller` contract.
13
+ */
9
14
  contract ComptrollerStorage {
10
15
  struct LiquidationOrder {
11
16
  VToken vTokenCollateral;
@@ -1,6 +1,11 @@
1
1
  // SPDX-License-Identifier: BSD-3-Clause
2
2
  pragma solidity 0.8.13;
3
3
 
4
+ /**
5
+ * @title TokenErrorReporter
6
+ * @author Venus
7
+ * @notice Errors that can be thrown by the `VToken` contract.
8
+ */
4
9
  contract TokenErrorReporter {
5
10
  uint256 public constant NO_ERROR = 0; // support legacy return codes
6
11
 
@@ -12,6 +12,19 @@ import { PoolRegistryInterface } from "../Pool/PoolRegistryInterface.sol";
12
12
  import { PoolRegistry } from "../Pool/PoolRegistry.sol";
13
13
  import { RewardsDistributor } from "../Rewards/RewardsDistributor.sol";
14
14
 
15
+ /**
16
+ * @title PoolLens
17
+ * @author Venus
18
+ * @notice The `PoolLens` contract is designed to retrieve important information for each registered pool. A list of essential information
19
+ * for all pools within the lending protocol can be acquired through the function `getAllPools()`. Additionally, the following records can be
20
+ * looked up for specific pools and markets:
21
+ - the vToken balance of a given user;
22
+ - the pool data (oracle address, associated vToken, liquidation incentive, etc) of a pool via its associated comptroller address;
23
+ - the vToken address in a pool for a given asset;
24
+ - a list of all pools that support an asset;
25
+ - the underlying asset price of a vToken;
26
+ - the metadata (exchange/borrow/supply rate, total supply, collateral factor, etc) of any vToken.
27
+ */
15
28
  contract PoolLens is ExponentialNoError {
16
29
  /**
17
30
  * @dev Struct for PoolDetails.
@@ -1,6 +1,11 @@
1
1
  // SPDX-License-Identifier: BSD-3-Clause
2
2
  pragma solidity 0.8.13;
3
3
 
4
+ /**
5
+ * @title MaxLoopsLimitHelper
6
+ * @author Venus
7
+ * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.
8
+ */
4
9
  abstract contract MaxLoopsLimitHelper {
5
10
  // Limit for the loops to avoid the DOS
6
11
  uint256 public maxLoopsLimit;
@@ -2,54 +2,44 @@
2
2
  pragma solidity 0.8.13;
3
3
 
4
4
  import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
5
- import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
6
5
  import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
7
- import { BeaconProxy } from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
8
- import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
9
- import { ResilientOracleInterface } from "@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol";
10
- import { AccessControlManager } from "@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol";
6
+ import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
11
7
  import { AccessControlledV8 } from "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol";
12
8
 
13
9
  import { PoolRegistryInterface } from "./PoolRegistryInterface.sol";
14
10
  import { Comptroller } from "../Comptroller.sol";
15
- import { VTokenProxyFactory } from "../Factories/VTokenProxyFactory.sol";
16
- import { JumpRateModelFactory } from "../Factories/JumpRateModelFactory.sol";
17
- import { WhitePaperInterestRateModelFactory } from "../Factories/WhitePaperInterestRateModelFactory.sol";
18
- import { WhitePaperInterestRateModel } from "../WhitePaperInterestRateModel.sol";
19
11
  import { VToken } from "../VToken.sol";
20
- import { InterestRateModel } from "../InterestRateModel.sol";
21
- import { Shortfall } from "../Shortfall/Shortfall.sol";
22
- import { VTokenInterface } from "../VTokenInterfaces.sol";
23
12
  import { ensureNonzeroAddress } from "../lib/validators.sol";
24
13
 
25
14
  /**
26
15
  * @title PoolRegistry
27
- * @notice PoolRegistry is a registry for Venus interest rate pools.
16
+ * @author Venus
17
+ * @notice The Isolated Pools architecture centers around the `PoolRegistry` contract. The `PoolRegistry` maintains a directory of isolated lending
18
+ * pools and can perform actions like creating and registering new pools, adding new markets to existing pools, setting and updating the pool's required
19
+ * metadata, and providing the getter methods to get information on the pools.
20
+ *
21
+ * Isolated lending has three main components: PoolRegistry, pools, and markets. The PoolRegistry is responsible for managing pools.
22
+ * It can create new pools, update pool metadata and manage markets within pools. PoolRegistry contains getter methods to get the details of
23
+ * any existing pool like `getVTokenForAsset` and `getPoolsSupportedByAsset`. It also contains methods for updating pool metadata (`updatePoolMetadata`)
24
+ * and setting pool name (`setPoolName`).
25
+ *
26
+ * The directory of pools is managed through two mappings: `_poolByComptroller` which is a hashmap with the comptroller address as the key and `VenusPool` as
27
+ * the value and `_poolsByID` which is an array of comptroller addresses. Individual pools can be accessed by calling `getPoolByComptroller` with the pool's
28
+ * comptroller address. `_poolsByID` is used to iterate through all of the pools.
29
+ *
30
+ * PoolRegistry also contains a map of asset addresses called `_supportedPools` that maps to an array of assets suppored by each pool. This array of pools by
31
+ * asset is retrieved by calling `getPoolsSupportedByAsset`.
32
+ *
33
+ * PoolRegistry registers new isolated pools in the directory with the `createRegistryPool` method. Isolated pools are composed of independent markets with
34
+ * specific assets and custom risk management configurations according to their markets.
28
35
  */
29
36
  contract PoolRegistry is Ownable2StepUpgradeable, AccessControlledV8, PoolRegistryInterface {
30
37
  using SafeERC20Upgradeable for IERC20Upgradeable;
31
38
 
32
- enum InterestRateModels {
33
- WhitePaper,
34
- JumpRate
35
- }
36
-
37
39
  struct AddMarketInput {
38
- address comptroller;
39
- address asset;
40
- uint8 decimals;
41
- string name;
42
- string symbol;
43
- InterestRateModels rateModel;
44
- uint256 baseRatePerYear;
45
- uint256 multiplierPerYear;
46
- uint256 jumpMultiplierPerYear;
47
- uint256 kink_;
40
+ VToken vToken;
48
41
  uint256 collateralFactor;
49
42
  uint256 liquidationThreshold;
50
- uint256 reserveFactor;
51
- AccessControlManager accessControlManager;
52
- address beaconAddress;
53
43
  uint256 initialSupply;
54
44
  address vTokenReceiver;
55
45
  uint256 supplyCap;
@@ -58,31 +48,6 @@ contract PoolRegistry is Ownable2StepUpgradeable, AccessControlledV8, PoolRegist
58
48
 
59
49
  uint256 internal constant MAX_POOL_NAME_LENGTH = 100;
60
50
 
61
- /**
62
- * @notice VTokenProxyFactory contract address
63
- */
64
- VTokenProxyFactory public vTokenFactory;
65
-
66
- /**
67
- * @notice JumpRateModelFactory contract address
68
- */
69
- JumpRateModelFactory public jumpRateFactory;
70
-
71
- /**
72
- * @notice WhitePaperInterestRateModelFactory contract address
73
- */
74
- WhitePaperInterestRateModelFactory public whitePaperFactory;
75
-
76
- /**
77
- * @notice Shortfall contract address
78
- */
79
- Shortfall public shortfall;
80
-
81
- /**
82
- * @notice Shortfall contract address
83
- */
84
- address payable public protocolShareReserve;
85
-
86
51
  /**
87
52
  * @notice Maps pool's comptroller address to metadata.
88
53
  */
@@ -137,16 +102,6 @@ contract PoolRegistry is Ownable2StepUpgradeable, AccessControlledV8, PoolRegist
137
102
  */
138
103
  event MarketAdded(address indexed comptroller, address indexed vTokenAddress);
139
104
 
140
- /**
141
- * @notice Event emitted when shortfall contract address is changed
142
- */
143
- event NewShortfallContract(address indexed oldShortfall, address indexed newShortfall);
144
-
145
- /**
146
- * @notice Event emitted when protocol share reserve contract address is changed
147
- */
148
- event NewProtocolShareReserve(address indexed oldProtocolShareReserve, address indexed newProtocolShareReserve);
149
-
150
105
  /// @custom:oz-upgrades-unsafe-allow constructor
151
106
  constructor() {
152
107
  // Note that the contract is upgradeable. Use initialize() or reinitializers
@@ -156,163 +111,73 @@ contract PoolRegistry is Ownable2StepUpgradeable, AccessControlledV8, PoolRegist
156
111
 
157
112
  /**
158
113
  * @dev Initializes the deployer to owner
159
- * @param vTokenFactory_ vToken factory address
160
- * @param jumpRateFactory_ jump rate factory address
161
- * @param whitePaperFactory_ white paper factory address
162
- * @param protocolShareReserve_ protocol's shares reserve address
163
- * @param shortfall_ Shortfall contract address
164
114
  * @param accessControlManager_ AccessControlManager contract address
165
- * @custom:error ZeroAddressNotAllowed is thrown when shortfall contract address is zero
166
- * @custom:error ZeroAddressNotAllowed is thrown when protocol share reserve address is zero
167
115
  */
168
- function initialize(
169
- VTokenProxyFactory vTokenFactory_,
170
- JumpRateModelFactory jumpRateFactory_,
171
- WhitePaperInterestRateModelFactory whitePaperFactory_,
172
- Shortfall shortfall_,
173
- address payable protocolShareReserve_,
174
- address accessControlManager_
175
- ) external initializer {
116
+ function initialize(address accessControlManager_) external initializer {
176
117
  __Ownable2Step_init();
177
118
  __AccessControlled_init_unchained(accessControlManager_);
178
-
179
- vTokenFactory = vTokenFactory_;
180
- jumpRateFactory = jumpRateFactory_;
181
- whitePaperFactory = whitePaperFactory_;
182
- _setShortfallContract(shortfall_);
183
- _setProtocolShareReserve(protocolShareReserve_);
184
119
  }
185
120
 
186
121
  /**
187
- * @notice Sets protocol share reserve contract address
188
- * @param protocolShareReserve_ The address of the protocol share reserve contract
189
- * @custom:error ZeroAddressNotAllowed is thrown when protocol share reserve address is zero
190
- * @custom:access Only Governance
191
- */
192
- function setProtocolShareReserve(address payable protocolShareReserve_) external onlyOwner {
193
- _setProtocolShareReserve(protocolShareReserve_);
194
- }
195
-
196
- /**
197
- * @notice Sets shortfall contract address
198
- * @param shortfall_ The address of the shortfall contract
199
- * @custom:error ZeroAddressNotAllowed is thrown when shortfall contract address is zero
200
- * @custom:access Only Governance
201
- */
202
- function setShortfallContract(Shortfall shortfall_) external onlyOwner {
203
- _setShortfallContract(shortfall_);
204
- }
205
-
206
- /**
207
- * @dev Deploys a new Venus pool and adds to the directory.
122
+ * @notice Adds a new Venus pool to the directory
123
+ * @dev Price oracle must be configured before adding a pool
208
124
  * @param name The name of the pool
209
- * @param beaconAddress The upgradeable beacon contract address for Comptroller implementation
125
+ * @param comptroller Pool's Comptroller contract
210
126
  * @param closeFactor The pool's close factor (scaled by 1e18)
211
127
  * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18)
212
128
  * @param minLiquidatableCollateral Minimal collateral for regular (non-batch) liquidations flow
213
- * @param priceOracle The pool's price oracle address
214
- * @param maxLoopsLimit The maximum number of iterations the loops can perform
215
- * @param accessControlManager AccessControlManager contract address
216
129
  * @return index The index of the registered Venus pool
217
- * @return proxyAddress The the Comptroller proxy address
218
- * @custom:error ZeroAddressNotAllowed is thrown when Comptroller beacon address is zero
130
+ * @custom:error ZeroAddressNotAllowed is thrown when Comptroller address is zero
219
131
  * @custom:error ZeroAddressNotAllowed is thrown when price oracle address is zero
220
132
  */
221
- function createRegistryPool(
133
+ function addPool(
222
134
  string calldata name,
223
- address beaconAddress,
135
+ Comptroller comptroller,
224
136
  uint256 closeFactor,
225
137
  uint256 liquidationIncentive,
226
- uint256 minLiquidatableCollateral,
227
- address priceOracle,
228
- uint256 maxLoopsLimit,
229
- address accessControlManager
230
- ) external virtual returns (uint256 index, address proxyAddress) {
231
- _checkAccessAllowed("createRegistryPool(string,address,uint256,uint256,uint256,address,uint256,address)");
138
+ uint256 minLiquidatableCollateral
139
+ ) external virtual returns (uint256 index) {
140
+ _checkAccessAllowed("addPool(string,address,uint256,uint256,uint256)");
232
141
  // Input validation
233
- ensureNonzeroAddress(beaconAddress);
234
- ensureNonzeroAddress(priceOracle);
235
-
236
- BeaconProxy proxy = new BeaconProxy(
237
- beaconAddress,
238
- abi.encodeWithSelector(Comptroller.initialize.selector, maxLoopsLimit, accessControlManager)
239
- );
142
+ ensureNonzeroAddress(address(comptroller));
143
+ ensureNonzeroAddress(address(comptroller.oracle()));
240
144
 
241
- proxyAddress = address(proxy);
242
- Comptroller comptrollerProxy = Comptroller(proxyAddress);
243
-
244
- uint256 poolId = _registerPool(name, proxyAddress);
145
+ uint256 poolId = _registerPool(name, address(comptroller));
245
146
 
246
147
  // Set Venus pool parameters
247
- comptrollerProxy.setCloseFactor(closeFactor);
248
- comptrollerProxy.setLiquidationIncentive(liquidationIncentive);
249
- comptrollerProxy.setMinLiquidatableCollateral(minLiquidatableCollateral);
250
- comptrollerProxy.setPriceOracle(ResilientOracleInterface(priceOracle));
251
-
252
- // Start transferring ownership to msg.sender
253
- comptrollerProxy.transferOwnership(msg.sender);
148
+ comptroller.setCloseFactor(closeFactor);
149
+ comptroller.setLiquidationIncentive(liquidationIncentive);
150
+ comptroller.setMinLiquidatableCollateral(minLiquidatableCollateral);
254
151
 
255
- return (poolId, proxyAddress);
152
+ return poolId;
256
153
  }
257
154
 
258
155
  /**
259
- * @notice Add a market to an existing pool and then mint to provide initial supply.
260
- * @param input The structure describing the parameters for adding a market to a pool.
261
- * @custom:error ZeroAddressNotAllowed is thrown when Comptroller address is zero
262
- * @custom:error ZeroAddressNotAllowed is thrown when asset address is zero
263
- * @custom:error ZeroAddressNotAllowed is thrown when VToken beacon address is zero
156
+ * @notice Add a market to an existing pool and then mint to provide initial supply
157
+ * @param input The structure describing the parameters for adding a market to a pool
158
+ * @custom:error ZeroAddressNotAllowed is thrown when vToken address is zero
264
159
  * @custom:error ZeroAddressNotAllowed is thrown when vTokenReceiver address is zero
265
160
  */
266
161
  function addMarket(AddMarketInput memory input) external {
267
162
  _checkAccessAllowed("addMarket(AddMarketInput)");
268
- ensureNonzeroAddress(input.comptroller);
269
- ensureNonzeroAddress(input.asset);
270
- ensureNonzeroAddress(input.beaconAddress);
163
+ ensureNonzeroAddress(address(input.vToken));
271
164
  ensureNonzeroAddress(input.vTokenReceiver);
165
+ require(input.initialSupply > 0, "PoolRegistry: initialSupply is zero");
166
+
167
+ VToken vToken = input.vToken;
168
+ address vTokenAddress = address(vToken);
169
+ address comptrollerAddress = address(vToken.comptroller());
170
+ Comptroller comptroller = Comptroller(comptrollerAddress);
171
+ address underlyingAddress = vToken.underlying();
172
+ IERC20Upgradeable underlying = IERC20Upgradeable(underlyingAddress);
272
173
 
174
+ require(_poolByComptroller[comptrollerAddress].creator != address(0), "PoolRegistry: Pool not registered");
273
175
  // solhint-disable-next-line reason-string
274
176
  require(
275
- _vTokens[input.comptroller][input.asset] == address(0),
177
+ _vTokens[comptrollerAddress][underlyingAddress] == address(0),
276
178
  "PoolRegistry: Market already added for asset comptroller combination"
277
179
  );
278
180
 
279
- require(input.initialSupply > 0, "PoolRegistry: initialSupply is zero");
280
-
281
- InterestRateModel rate;
282
- if (input.rateModel == InterestRateModels.JumpRate) {
283
- rate = InterestRateModel(
284
- jumpRateFactory.deploy(
285
- input.baseRatePerYear,
286
- input.multiplierPerYear,
287
- input.jumpMultiplierPerYear,
288
- input.kink_,
289
- input.accessControlManager
290
- )
291
- );
292
- } else {
293
- rate = InterestRateModel(whitePaperFactory.deploy(input.baseRatePerYear, input.multiplierPerYear));
294
- }
295
-
296
- Comptroller comptroller = Comptroller(input.comptroller);
297
- uint256 underlyingDecimals = IERC20Metadata(input.asset).decimals();
298
-
299
- VTokenProxyFactory.VTokenArgs memory initializeArgs = VTokenProxyFactory.VTokenArgs(
300
- input.asset,
301
- comptroller,
302
- rate,
303
- 10**(underlyingDecimals + 18 - input.decimals),
304
- input.name,
305
- input.symbol,
306
- input.decimals,
307
- msg.sender,
308
- input.accessControlManager,
309
- VTokenInterface.RiskManagementInit(address(shortfall), protocolShareReserve),
310
- input.beaconAddress,
311
- input.reserveFactor
312
- );
313
-
314
- VToken vToken = vTokenFactory.deployVTokenProxy(initializeArgs);
315
-
316
181
  comptroller.supportMarket(vToken);
317
182
  comptroller.setCollateralFactor(vToken, input.collateralFactor, input.liquidationThreshold);
318
183
 
@@ -327,16 +192,15 @@ contract PoolRegistry is Ownable2StepUpgradeable, AccessControlledV8, PoolRegist
327
192
  comptroller.setMarketSupplyCaps(vTokens, newSupplyCaps);
328
193
  comptroller.setMarketBorrowCaps(vTokens, newBorrowCaps);
329
194
 
330
- _vTokens[input.comptroller][input.asset] = address(vToken);
331
- _supportedPools[input.asset].push(input.comptroller);
195
+ _vTokens[comptrollerAddress][underlyingAddress] = vTokenAddress;
196
+ _supportedPools[underlyingAddress].push(comptrollerAddress);
332
197
 
333
- IERC20Upgradeable token = IERC20Upgradeable(input.asset);
334
- uint256 amountToSupply = _transferIn(token, msg.sender, input.initialSupply);
335
- token.approve(address(vToken), 0);
336
- token.approve(address(vToken), amountToSupply);
198
+ uint256 amountToSupply = _transferIn(underlying, msg.sender, input.initialSupply);
199
+ underlying.approve(vTokenAddress, 0);
200
+ underlying.approve(vTokenAddress, amountToSupply);
337
201
  vToken.mintBehalf(input.vTokenReceiver, amountToSupply);
338
202
 
339
- emit MarketAdded(address(comptroller), address(vToken));
203
+ emit MarketAdded(comptrollerAddress, vTokenAddress);
340
204
  }
341
205
 
342
206
  /**
@@ -439,20 +303,6 @@ contract PoolRegistry is Ownable2StepUpgradeable, AccessControlledV8, PoolRegist
439
303
  return balanceAfter - balanceBefore;
440
304
  }
441
305
 
442
- function _setShortfallContract(Shortfall shortfall_) internal {
443
- ensureNonzeroAddress(address(shortfall_));
444
- address oldShortfall = address(shortfall);
445
- shortfall = shortfall_;
446
- emit NewShortfallContract(oldShortfall, address(shortfall_));
447
- }
448
-
449
- function _setProtocolShareReserve(address payable protocolShareReserve_) internal {
450
- ensureNonzeroAddress(protocolShareReserve_);
451
- address oldProtocolShareReserve = protocolShareReserve;
452
- protocolShareReserve = protocolShareReserve_;
453
- emit NewProtocolShareReserve(oldProtocolShareReserve, protocolShareReserve_);
454
- }
455
-
456
306
  function _ensureValidName(string calldata name) internal pure {
457
307
  require(bytes(name).length <= MAX_POOL_NAME_LENGTH, "Pool's name is too large");
458
308
  }
@@ -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