@venusprotocol/protocol-reserve 1.0.0-converters.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/README.md +75 -0
  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/token/ERC20/ERC20.sol/ERC20.dbg.json +4 -0
  7. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json +297 -0
  8. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +4 -0
  9. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.json +194 -0
  10. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +4 -0
  11. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.json +233 -0
  12. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
  13. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
  14. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
  15. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +10 -0
  16. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
  17. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
  18. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
  19. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
  20. package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
  21. package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
  22. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +4 -0
  23. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +10 -0
  24. package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.dbg.json +4 -0
  25. package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +115 -0
  26. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +4 -0
  27. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.json +76 -0
  28. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +4 -0
  29. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.json +24 -0
  30. package/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json +4 -0
  31. package/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.json +63 -0
  32. package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.dbg.json +4 -0
  33. package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.json +24 -0
  34. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json +4 -0
  35. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.json +194 -0
  36. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.dbg.json +4 -0
  37. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.json +86 -0
  38. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.dbg.json +4 -0
  39. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.json +10 -0
  40. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +4 -0
  41. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.json +10 -0
  42. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +4 -0
  43. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.json +24 -0
  44. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.dbg.json +4 -0
  45. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.json +181 -0
  46. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.dbg.json +4 -0
  47. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.json +282 -0
  48. package/artifacts/@venusprotocol/isolated-pools/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.dbg.json +4 -0
  49. package/artifacts/@venusprotocol/isolated-pools/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.json +59 -0
  50. package/artifacts/@venusprotocol/oracle/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +4 -0
  51. package/artifacts/@venusprotocol/oracle/contracts/ResilientOracle.sol/ResilientOracle.json +649 -0
  52. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +4 -0
  53. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.json +40 -0
  54. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +4 -0
  55. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.json +30 -0
  56. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +4 -0
  57. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.json +75 -0
  58. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +4 -0
  59. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.json +49 -0
  60. package/artifacts/@venusprotocol/oracle/contracts/interfaces/VBep20Interface.sol/VBep20Interface.dbg.json +4 -0
  61. package/artifacts/@venusprotocol/oracle/contracts/interfaces/VBep20Interface.sol/VBep20Interface.json +246 -0
  62. package/artifacts/@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.dbg.json +4 -0
  63. package/artifacts/@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.json +59 -0
  64. package/artifacts/build-info/09a7fbe40ee8fdfd62afe79292e77863.json +1 -0
  65. package/artifacts/contracts/Interfaces/IComptroller.sol/IComptroller.dbg.json +4 -0
  66. package/artifacts/contracts/Interfaces/IComptroller.sol/IComptroller.json +56 -0
  67. package/artifacts/contracts/Interfaces/IConverterNetwork.sol/IConverterNetwork.dbg.json +4 -0
  68. package/artifacts/contracts/Interfaces/IConverterNetwork.sol/IConverterNetwork.json +127 -0
  69. package/artifacts/contracts/Interfaces/IIncomeDestination.sol/IIncomeDestination.dbg.json +4 -0
  70. package/artifacts/contracts/Interfaces/IIncomeDestination.sol/IIncomeDestination.json +29 -0
  71. package/artifacts/contracts/Interfaces/IPoolRegistry.sol/IPoolRegistry.dbg.json +4 -0
  72. package/artifacts/contracts/Interfaces/IPoolRegistry.sol/IPoolRegistry.json +54 -0
  73. package/artifacts/contracts/Interfaces/IPrime.sol/IPrime.dbg.json +4 -0
  74. package/artifacts/contracts/Interfaces/IPrime.sol/IPrime.json +74 -0
  75. package/artifacts/contracts/Interfaces/IProtocolShareReserve.sol/IProtocolShareReserve.dbg.json +4 -0
  76. package/artifacts/contracts/Interfaces/IProtocolShareReserve.sol/IProtocolShareReserve.json +34 -0
  77. package/artifacts/contracts/Interfaces/IRiskFund.sol/IRiskFund.dbg.json +4 -0
  78. package/artifacts/contracts/Interfaces/IRiskFund.sol/IRiskFund.json +77 -0
  79. package/artifacts/contracts/Interfaces/IRiskFund.sol/IRiskFundGetters.dbg.json +4 -0
  80. package/artifacts/contracts/Interfaces/IRiskFund.sol/IRiskFundGetters.json +24 -0
  81. package/artifacts/contracts/Interfaces/IRiskFundConverter.sol/IRiskFundConverter.dbg.json +4 -0
  82. package/artifacts/contracts/Interfaces/IRiskFundConverter.sol/IRiskFundConverter.json +48 -0
  83. package/artifacts/contracts/Interfaces/IShortfall.sol/IShortfall.dbg.json +4 -0
  84. package/artifacts/contracts/Interfaces/IShortfall.sol/IShortfall.json +24 -0
  85. package/artifacts/contracts/Interfaces/IVToken.sol/IVToken.dbg.json +4 -0
  86. package/artifacts/contracts/Interfaces/IVToken.sol/IVToken.json +24 -0
  87. package/artifacts/contracts/Interfaces/IXVSVault.sol/IXVSVault.dbg.json +4 -0
  88. package/artifacts/contracts/Interfaces/IXVSVault.sol/IXVSVault.json +24 -0
  89. package/artifacts/contracts/ProtocolReserve/ProtocolShareReserve.sol/ProtocolShareReserve.dbg.json +4 -0
  90. package/artifacts/contracts/ProtocolReserve/ProtocolShareReserve.sol/ProtocolShareReserve.json +892 -0
  91. package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/MaxLoopsLimitHelpersStorage.dbg.json +4 -0
  92. package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/MaxLoopsLimitHelpersStorage.json +24 -0
  93. package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/ReserveHelpersStorage.dbg.json +4 -0
  94. package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/ReserveHelpersStorage.json +139 -0
  95. package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/RiskFundV1Storage.dbg.json +4 -0
  96. package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/RiskFundV1Storage.json +178 -0
  97. package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/RiskFundV2Storage.dbg.json +4 -0
  98. package/artifacts/contracts/ProtocolReserve/RiskFundStorage.sol/RiskFundV2Storage.json +191 -0
  99. package/artifacts/contracts/ProtocolReserve/RiskFundV2.sol/RiskFundV2.dbg.json +4 -0
  100. package/artifacts/contracts/ProtocolReserve/RiskFundV2.sol/RiskFundV2.json +582 -0
  101. package/artifacts/contracts/ProtocolReserve/XVSVaultTreasury.sol/XVSVaultTreasury.dbg.json +4 -0
  102. package/artifacts/contracts/ProtocolReserve/XVSVaultTreasury.sol/XVSVaultTreasury.json +315 -0
  103. package/artifacts/contracts/Test/Mocks/MockACM.sol/MockACM.dbg.json +4 -0
  104. package/artifacts/contracts/Test/Mocks/MockACM.sol/MockACM.json +369 -0
  105. package/artifacts/contracts/Test/Mocks/MockArraySorter.sol/MockArraySorter.dbg.json +4 -0
  106. package/artifacts/contracts/Test/Mocks/MockArraySorter.sol/MockArraySorter.json +40 -0
  107. package/artifacts/contracts/Test/Mocks/MockConverter.sol/MockConverter.dbg.json +4 -0
  108. package/artifacts/contracts/Test/Mocks/MockConverter.sol/MockConverter.json +1199 -0
  109. package/artifacts/contracts/Test/Mocks/MockDeflationaryToken.sol/MockDeflatingToken.dbg.json +4 -0
  110. package/artifacts/contracts/Test/Mocks/MockDeflationaryToken.sol/MockDeflatingToken.json +332 -0
  111. package/artifacts/contracts/Test/Mocks/MockRiskFundConverter.sol/MockRiskFundConverter.dbg.json +4 -0
  112. package/artifacts/contracts/Test/Mocks/MockRiskFundConverter.sol/MockRiskFundConverter.json +1559 -0
  113. package/artifacts/contracts/Test/Mocks/MockToken.sol/MockToken.dbg.json +4 -0
  114. package/artifacts/contracts/Test/Mocks/MockToken.sol/MockToken.json +333 -0
  115. package/artifacts/contracts/TokenConverter/AbstractTokenConverter.sol/AbstractTokenConverter.dbg.json +4 -0
  116. package/artifacts/contracts/TokenConverter/AbstractTokenConverter.sol/AbstractTokenConverter.json +1085 -0
  117. package/artifacts/contracts/TokenConverter/ConverterNetwork.sol/ConverterNetwork.dbg.json +4 -0
  118. package/artifacts/contracts/TokenConverter/ConverterNetwork.sol/ConverterNetwork.json +457 -0
  119. package/artifacts/contracts/TokenConverter/IAbstractTokenConverter.sol/IAbstractTokenConverter.dbg.json +4 -0
  120. package/artifacts/contracts/TokenConverter/IAbstractTokenConverter.sol/IAbstractTokenConverter.json +344 -0
  121. package/artifacts/contracts/TokenConverter/RiskFundConverter.sol/RiskFundConverter.dbg.json +4 -0
  122. package/artifacts/contracts/TokenConverter/RiskFundConverter.sol/RiskFundConverter.json +1429 -0
  123. package/artifacts/contracts/TokenConverter/SingleTokenConverter.sol/SingleTokenConverter.dbg.json +4 -0
  124. package/artifacts/contracts/TokenConverter/SingleTokenConverter.sol/SingleTokenConverter.json +1145 -0
  125. package/contracts/Interfaces/IComptroller.sol +10 -0
  126. package/contracts/Interfaces/IConverterNetwork.sol +46 -0
  127. package/contracts/Interfaces/IIncomeDestination.sol +6 -0
  128. package/contracts/Interfaces/IPoolRegistry.sol +10 -0
  129. package/contracts/Interfaces/IPrime.sol +12 -0
  130. package/contracts/Interfaces/IProtocolShareReserve.sol +16 -0
  131. package/contracts/Interfaces/IRiskFund.sol +28 -0
  132. package/contracts/Interfaces/IRiskFundConverter.sol +8 -0
  133. package/contracts/Interfaces/IShortfall.sol +11 -0
  134. package/contracts/Interfaces/IVToken.sol +6 -0
  135. package/contracts/Interfaces/IXVSVault.sol +9 -0
  136. package/contracts/ProtocolReserve/ProtocolShareReserve.sol +547 -0
  137. package/contracts/ProtocolReserve/RiskFundStorage.sol +67 -0
  138. package/contracts/ProtocolReserve/RiskFundV2.sol +220 -0
  139. package/contracts/ProtocolReserve/XVSVaultTreasury.sol +95 -0
  140. package/contracts/Test/Mocks/MockACM.sol +93 -0
  141. package/contracts/Test/Mocks/MockArraySorter.sol +14 -0
  142. package/contracts/Test/Mocks/MockConverter.sol +69 -0
  143. package/contracts/Test/Mocks/MockDeflationaryToken.sol +113 -0
  144. package/contracts/Test/Mocks/MockRiskFundConverter.sol +45 -0
  145. package/contracts/Test/Mocks/MockToken.sol +30 -0
  146. package/contracts/TokenConverter/AbstractTokenConverter.sol +1022 -0
  147. package/contracts/TokenConverter/ConverterNetwork.sol +242 -0
  148. package/contracts/TokenConverter/IAbstractTokenConverter.sol +132 -0
  149. package/contracts/TokenConverter/RiskFundConverter.sol +436 -0
  150. package/contracts/TokenConverter/SingleTokenConverter.sol +77 -0
  151. package/contracts/Utils/ArrayHelpers.sol +41 -0
  152. package/contracts/Utils/Constants.sol +11 -0
  153. package/contracts/Utils/Validators.sol +26 -0
  154. package/deploy/001-risk-fund-converter.ts +124 -0
  155. package/deploy/1-deploy.ts +64 -0
  156. package/deployments/bscmainnet/.chainId +1 -0
  157. package/deployments/bscmainnet/DefaultProxyAdmin.json +257 -0
  158. package/deployments/bscmainnet/ProtocolShareReserve.json +1126 -0
  159. package/deployments/bscmainnet/ProtocolShareReserve_Implementation.json +1400 -0
  160. package/deployments/bscmainnet/ProtocolShareReserve_Proxy.json +261 -0
  161. package/deployments/bscmainnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json +78 -0
  162. package/deployments/bscmainnet/solcInputs/aee5f1db1180ece295e59c8f036fe600.json +90 -0
  163. package/deployments/bsctestnet/.chainId +1 -0
  164. package/deployments/bsctestnet/DefaultProxyAdmin.json +257 -0
  165. package/deployments/bsctestnet/ProtocolShareReserve.json +1126 -0
  166. package/deployments/bsctestnet/ProtocolShareReserve_Implementation.json +1400 -0
  167. package/deployments/bsctestnet/ProtocolShareReserve_Proxy.json +261 -0
  168. package/deployments/bsctestnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json +78 -0
  169. package/deployments/bsctestnet/solcInputs/aee5f1db1180ece295e59c8f036fe600.json +90 -0
  170. package/package.json +119 -0
  171. package/typechain/AbstractTokenConverter.d.ts +1516 -0
  172. package/typechain/AccessControl.d.ts +388 -0
  173. package/typechain/AccessControlledV8.d.ts +341 -0
  174. package/typechain/BoundValidatorInterface.d.ts +126 -0
  175. package/typechain/ContextUpgradeable.d.ts +92 -0
  176. package/typechain/ConverterNetwork.d.ts +721 -0
  177. package/typechain/ERC165.d.ts +116 -0
  178. package/typechain/ERC20.d.ts +441 -0
  179. package/typechain/IAbstractTokenConverter.d.ts +606 -0
  180. package/typechain/IAccessControl.d.ts +333 -0
  181. package/typechain/IAccessControlManagerV8.d.ts +504 -0
  182. package/typechain/IComptroller.d.ts +136 -0
  183. package/typechain/IConverterNetwork.d.ts +292 -0
  184. package/typechain/IERC165.d.ts +116 -0
  185. package/typechain/IERC20.d.ts +324 -0
  186. package/typechain/IERC20Metadata.d.ts +363 -0
  187. package/typechain/IERC20PermitUpgradeable.d.ts +187 -0
  188. package/typechain/IERC20Upgradeable.d.ts +324 -0
  189. package/typechain/IIncomeDestination.d.ts +122 -0
  190. package/typechain/IPoolRegistry.d.ts +155 -0
  191. package/typechain/IPrime.d.ts +197 -0
  192. package/typechain/IProtocolShareReserve.d.ts +127 -0
  193. package/typechain/IRiskFund.d.ts +200 -0
  194. package/typechain/IRiskFundConverter.d.ts +138 -0
  195. package/typechain/IRiskFundGetters.d.ts +103 -0
  196. package/typechain/IShortfall.d.ts +110 -0
  197. package/typechain/IVToken.d.ts +98 -0
  198. package/typechain/IXVSVault.d.ts +95 -0
  199. package/typechain/Initializable.d.ts +92 -0
  200. package/typechain/MaxLoopsLimitHelper.d.ts +128 -0
  201. package/typechain/MaxLoopsLimitHelpersStorage.d.ts +101 -0
  202. package/typechain/MockACM.d.ts +615 -0
  203. package/typechain/MockArraySorter.d.ts +118 -0
  204. package/typechain/MockConverter.d.ts +1705 -0
  205. package/typechain/MockDeflatingToken.d.ts +486 -0
  206. package/typechain/MockRiskFundConverter.d.ts +2193 -0
  207. package/typechain/MockToken.d.ts +505 -0
  208. package/typechain/OracleInterface.d.ts +98 -0
  209. package/typechain/Ownable2StepUpgradeable.d.ts +261 -0
  210. package/typechain/OwnableUpgradeable.d.ts +193 -0
  211. package/typechain/PausableUpgradeable.d.ts +129 -0
  212. package/typechain/ProtocolShareReserve.d.ts +1332 -0
  213. package/typechain/ReentrancyGuardUpgradeable.d.ts +92 -0
  214. package/typechain/ReserveHelpersStorage.d.ts +300 -0
  215. package/typechain/ResilientOracle.d.ts +1022 -0
  216. package/typechain/ResilientOracleInterface.d.ts +192 -0
  217. package/typechain/RiskFundConverter.d.ts +1949 -0
  218. package/typechain/RiskFundV1Storage.d.ts +353 -0
  219. package/typechain/RiskFundV2.d.ts +893 -0
  220. package/typechain/RiskFundV2Storage.d.ts +372 -0
  221. package/typechain/SingleTokenConverter.d.ts +1598 -0
  222. package/typechain/TwapInterface.d.ts +124 -0
  223. package/typechain/VBep20Interface.d.ts +379 -0
  224. package/typechain/XVSVaultTreasury.d.ts +515 -0
  225. package/typechain/common.d.ts +35 -0
  226. package/typechain/factories/AbstractTokenConverter__factory.ts +1105 -0
  227. package/typechain/factories/AccessControl__factory.ts +227 -0
  228. package/typechain/factories/AccessControlledV8__factory.ts +196 -0
  229. package/typechain/factories/BoundValidatorInterface__factory.ts +59 -0
  230. package/typechain/factories/ContextUpgradeable__factory.ts +39 -0
  231. package/typechain/factories/ConverterNetwork__factory.ts +502 -0
  232. package/typechain/factories/ERC165__factory.ts +39 -0
  233. package/typechain/factories/ERC20__factory.ts +340 -0
  234. package/typechain/factories/IAbstractTokenConverter__factory.ts +364 -0
  235. package/typechain/factories/IAccessControlManagerV8__factory.ts +301 -0
  236. package/typechain/factories/IAccessControl__factory.ts +198 -0
  237. package/typechain/factories/IComptroller__factory.ts +68 -0
  238. package/typechain/factories/IConverterNetwork__factory.ts +142 -0
  239. package/typechain/factories/IERC165__factory.ts +42 -0
  240. package/typechain/factories/IERC20Metadata__factory.ts +248 -0
  241. package/typechain/factories/IERC20PermitUpgradeable__factory.ts +105 -0
  242. package/typechain/factories/IERC20Upgradeable__factory.ts +209 -0
  243. package/typechain/factories/IERC20__factory.ts +203 -0
  244. package/typechain/factories/IIncomeDestination__factory.ts +44 -0
  245. package/typechain/factories/IPoolRegistry__factory.ts +66 -0
  246. package/typechain/factories/IPrime__factory.ts +83 -0
  247. package/typechain/factories/IProtocolShareReserve__factory.ts +53 -0
  248. package/typechain/factories/IRiskFundConverter__factory.ts +63 -0
  249. package/typechain/factories/IRiskFundGetters__factory.ts +39 -0
  250. package/typechain/factories/IRiskFund__factory.ts +89 -0
  251. package/typechain/factories/IShortfall__factory.ts +36 -0
  252. package/typechain/factories/IVToken__factory.ts +36 -0
  253. package/typechain/factories/IXVSVault__factory.ts +36 -0
  254. package/typechain/factories/Initializable__factory.ts +36 -0
  255. package/typechain/factories/MaxLoopsLimitHelper__factory.ts +74 -0
  256. package/typechain/factories/MaxLoopsLimitHelpersStorage__factory.ts +75 -0
  257. package/typechain/factories/MockACM__factory.ts +411 -0
  258. package/typechain/factories/MockArraySorter__factory.ts +85 -0
  259. package/typechain/factories/MockConverter__factory.ts +1242 -0
  260. package/typechain/factories/MockDeflatingToken__factory.ts +389 -0
  261. package/typechain/factories/MockRiskFundConverter__factory.ts +1625 -0
  262. package/typechain/factories/MockToken__factory.ts +398 -0
  263. package/typechain/factories/OracleInterface__factory.ts +45 -0
  264. package/typechain/factories/Ownable2StepUpgradeable__factory.ts +134 -0
  265. package/typechain/factories/OwnableUpgradeable__factory.ts +91 -0
  266. package/typechain/factories/PausableUpgradeable__factory.ts +78 -0
  267. package/typechain/factories/ProtocolShareReserve__factory.ts +957 -0
  268. package/typechain/factories/ReentrancyGuardUpgradeable__factory.ts +43 -0
  269. package/typechain/factories/ReserveHelpersStorage__factory.ts +188 -0
  270. package/typechain/factories/ResilientOracleInterface__factory.ts +94 -0
  271. package/typechain/factories/ResilientOracle__factory.ts +710 -0
  272. package/typechain/factories/RiskFundConverter__factory.ts +1491 -0
  273. package/typechain/factories/RiskFundV1Storage__factory.ts +223 -0
  274. package/typechain/factories/RiskFundV2Storage__factory.ts +236 -0
  275. package/typechain/factories/RiskFundV2__factory.ts +624 -0
  276. package/typechain/factories/SingleTokenConverter__factory.ts +1200 -0
  277. package/typechain/factories/TwapInterface__factory.ts +61 -0
  278. package/typechain/factories/VBep20Interface__factory.ts +261 -0
  279. package/typechain/factories/XVSVaultTreasury__factory.ts +365 -0
  280. package/typechain/index.ts +112 -0
@@ -0,0 +1,547 @@
1
+ // SPDX-License-Identifier: BSD-3-Clause
2
+ pragma solidity 0.8.13;
3
+
4
+ import { SafeERC20Upgradeable, IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
5
+ import { AccessControlledV8 } from "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol";
6
+ import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
7
+ import { MaxLoopsLimitHelper } from "@venusprotocol/isolated-pools/contracts/MaxLoopsLimitHelper.sol";
8
+
9
+ import { IProtocolShareReserve } from "../Interfaces/IProtocolShareReserve.sol";
10
+ import { IComptroller } from "../Interfaces/IComptroller.sol";
11
+ import { IPoolRegistry } from "../Interfaces/IPoolRegistry.sol";
12
+ import { IPrime } from "../Interfaces/IPrime.sol";
13
+ import { IVToken } from "../Interfaces/IVToken.sol";
14
+ import { IIncomeDestination } from "../Interfaces/IIncomeDestination.sol";
15
+
16
+ error InvalidAddress();
17
+ error UnsupportedAsset();
18
+ error InvalidTotalPercentage();
19
+ error InvalidMaxLoopsLimit();
20
+
21
+ contract ProtocolShareReserve is
22
+ AccessControlledV8,
23
+ ReentrancyGuardUpgradeable,
24
+ MaxLoopsLimitHelper,
25
+ IProtocolShareReserve
26
+ {
27
+ using SafeERC20Upgradeable for IERC20Upgradeable;
28
+
29
+ /// @notice protocol income is categorized into two schemas.
30
+ /// The first schema is the default one
31
+ /// The second schema is for spread income from prime markets in core protocol
32
+ enum Schema {
33
+ DEFAULT,
34
+ SPREAD_PRIME_CORE
35
+ }
36
+
37
+ struct DistributionConfig {
38
+ Schema schema;
39
+ /// @dev percenatge is represented without any scale
40
+ uint8 percentage;
41
+ address destination;
42
+ }
43
+
44
+ /// @notice address of core pool comptroller contract
45
+ /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
46
+ address public immutable CORE_POOL_COMPTROLLER;
47
+
48
+ /// @notice address of WBNB contract
49
+ /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
50
+ address public immutable WBNB;
51
+
52
+ /// @notice address of vBNB contract
53
+ /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
54
+ address public immutable vBNB;
55
+
56
+ /// @notice address of Prime contract
57
+ address public prime;
58
+
59
+ /// @notice address of pool registry contract
60
+ address public poolRegistry;
61
+
62
+ uint8 private constant MAX_PERCENT = 100;
63
+
64
+ /// @notice comptroller => asset => schema => balance
65
+ mapping(address => mapping(address => mapping(Schema => uint256))) public assetsReserves;
66
+
67
+ /// @notice asset => balance
68
+ mapping(address => uint256) public totalAssetReserve;
69
+
70
+ /// @notice configuration for different income distribution targets
71
+ DistributionConfig[] public distributionTargets;
72
+
73
+ /// @notice asset => boolean
74
+ mapping(address => bool) public isInPrime;
75
+
76
+ /// @notice Emitted when pool registry address is updated
77
+ event PoolRegistryUpdated(address indexed oldPoolRegistry, address indexed newPoolRegistry);
78
+
79
+ /// @notice Emitted when prime address is updated
80
+ event PrimeUpdated(address indexed oldPrime, address indexed newPrime);
81
+
82
+ /// @notice Emitted when an asset is added to prime program
83
+ event PrimeAssetUpdated(address indexed asset, bool isPrimeAsset);
84
+
85
+ /// @notice Event emitted after updating of the assets reserves.
86
+ event AssetsReservesUpdated(
87
+ address indexed comptroller,
88
+ address indexed asset,
89
+ uint256 amount,
90
+ IncomeType incomeType,
91
+ Schema schema
92
+ );
93
+
94
+ /// @notice Event emitted when an asset is released to a target
95
+ event AssetReleased(
96
+ address indexed destination,
97
+ address indexed asset,
98
+ Schema schema,
99
+ uint256 percent,
100
+ uint256 amount
101
+ );
102
+
103
+ /// @notice Event emitted when asset reserves state is updated
104
+ event ReservesUpdated(
105
+ address indexed comptroller,
106
+ address indexed asset,
107
+ Schema schema,
108
+ uint256 oldBalance,
109
+ uint256 newBalance
110
+ );
111
+
112
+ /// @notice Event emitted when distribution configuration is updated
113
+ event DistributionConfigUpdated(
114
+ address indexed destination,
115
+ uint8 oldPercentage,
116
+ uint8 newPercentage,
117
+ Schema schema
118
+ );
119
+
120
+ /// @notice Event emitted when distribution configuration is added
121
+ event DistributionConfigAdded(address indexed destination, uint8 percentage, Schema schema);
122
+
123
+ /// @notice Event emitted when distribution configuration is removed
124
+ event DistributionConfigRemoved(address indexed destination, uint8 percentage, Schema schema);
125
+
126
+ /**
127
+ * @dev Constructor to initialize the immutable variables
128
+ * @param _corePoolComptroller The address of core pool comptroller
129
+ * @param _wbnb The address of WBNB
130
+ * @param _vbnb The address of vBNB
131
+ */
132
+ /// @custom:oz-upgrades-unsafe-allow constructor
133
+ constructor(
134
+ address _corePoolComptroller,
135
+ address _wbnb,
136
+ address _vbnb
137
+ ) {
138
+ if (_corePoolComptroller == address(0)) revert InvalidAddress();
139
+ if (_wbnb == address(0)) revert InvalidAddress();
140
+ if (_vbnb == address(0)) revert InvalidAddress();
141
+
142
+ CORE_POOL_COMPTROLLER = _corePoolComptroller;
143
+ WBNB = _wbnb;
144
+ vBNB = _vbnb;
145
+
146
+ // Note that the contract is upgradeable. Use initialize() or reinitializers
147
+ // to set the state variables.
148
+ _disableInitializers();
149
+ }
150
+
151
+ /**
152
+ * @dev Initializes the deployer to owner.
153
+ * @param _accessControlManager The address of ACM contract
154
+ * @param _loopsLimit Limit for the loops in the contract to avoid DOS
155
+ */
156
+ function initialize(address _accessControlManager, uint256 _loopsLimit) external initializer {
157
+ __AccessControlled_init(_accessControlManager);
158
+ __ReentrancyGuard_init();
159
+ _setMaxLoopsLimit(_loopsLimit);
160
+ }
161
+
162
+ /**
163
+ * @dev Pool registry setter.
164
+ * @param _poolRegistry Address of the pool registry
165
+ * @custom:error ZeroAddressNotAllowed is thrown when pool registry address is zero
166
+ */
167
+ function setPoolRegistry(address _poolRegistry) external onlyOwner {
168
+ if (_poolRegistry == address(0)) revert InvalidAddress();
169
+ emit PoolRegistryUpdated(poolRegistry, _poolRegistry);
170
+ poolRegistry = _poolRegistry;
171
+ }
172
+
173
+ /**
174
+ * @dev Prime contract address setter.
175
+ * @param _prime Address of the prime contract
176
+ */
177
+ function setPrime(address _prime) external onlyOwner {
178
+ if (_prime == address(0)) revert InvalidAddress();
179
+ emit PrimeUpdated(prime, _prime);
180
+ prime = _prime;
181
+ }
182
+
183
+ /**
184
+ * @dev Add/Remove asset to prime program.
185
+ * @param asset Address of the asset
186
+ * @param isPrimeAsset Boolean to add/remove asset from prime program
187
+ */
188
+ function addOrRemoveAssetFromPrime(address asset, bool isPrimeAsset) external {
189
+ _checkAccessAllowed("addOrRemoveAssetFromPrime(address,bool)");
190
+ if (asset == address(0)) revert InvalidAddress();
191
+ emit PrimeAssetUpdated(asset, isPrimeAsset);
192
+ isInPrime[asset] = isPrimeAsset;
193
+ }
194
+
195
+ /**
196
+ * @dev Add or update destination targets based on destination address
197
+ * @param configs configurations of the destinations.
198
+ */
199
+ function addOrUpdateDistributionConfigs(DistributionConfig[] calldata configs) external nonReentrant {
200
+ _checkAccessAllowed("addOrUpdateDistributionConfigs(DistributionConfig[])");
201
+
202
+ //we need to accrue and release funds to prime before updating the distribution configuration
203
+ //because prime relies on getUnreleasedFunds and its return value may change after config update
204
+ _accrueAndReleaseFundsToPrime();
205
+
206
+ for (uint256 i = 0; i < configs.length; ) {
207
+ DistributionConfig memory _config = configs[i];
208
+ if (_config.destination == address(0)) revert InvalidAddress();
209
+
210
+ bool updated = false;
211
+ uint256 distributionTargetsLength = distributionTargets.length;
212
+ for (uint256 j = 0; j < distributionTargetsLength; ) {
213
+ DistributionConfig storage config = distributionTargets[j];
214
+
215
+ if (_config.schema == config.schema && config.destination == _config.destination) {
216
+ emit DistributionConfigUpdated(
217
+ _config.destination,
218
+ config.percentage,
219
+ _config.percentage,
220
+ _config.schema
221
+ );
222
+ config.percentage = _config.percentage;
223
+ updated = true;
224
+ break;
225
+ }
226
+
227
+ unchecked {
228
+ ++j;
229
+ }
230
+ }
231
+
232
+ if (!updated) {
233
+ distributionTargets.push(_config);
234
+ emit DistributionConfigAdded(_config.destination, _config.percentage, _config.schema);
235
+ }
236
+
237
+ unchecked {
238
+ ++i;
239
+ }
240
+ }
241
+
242
+ _ensurePercentages();
243
+ _ensureMaxLoops(distributionTargets.length);
244
+ }
245
+
246
+ /**
247
+ * @dev Remove destionation target if percentage is 0
248
+ * @param schema schema of the configuration
249
+ * @param destination destination address of the configuration
250
+ */
251
+ function removeDistributionConfig(Schema schema, address destination) external {
252
+ _checkAccessAllowed("removeDistributionConfig(Schema,address)");
253
+
254
+ uint256 distributionIndex;
255
+ bool found = false;
256
+ for (uint256 i = 0; i < distributionTargets.length; ) {
257
+ DistributionConfig storage config = distributionTargets[i];
258
+
259
+ if (schema == config.schema && destination == config.destination && config.percentage == 0) {
260
+ found = true;
261
+ distributionIndex = i;
262
+ break;
263
+ }
264
+
265
+ unchecked {
266
+ ++i;
267
+ }
268
+ }
269
+
270
+ if (found) {
271
+ emit DistributionConfigRemoved(
272
+ distributionTargets[distributionIndex].destination,
273
+ distributionTargets[distributionIndex].percentage,
274
+ distributionTargets[distributionIndex].schema
275
+ );
276
+
277
+ distributionTargets[distributionIndex] = distributionTargets[distributionTargets.length - 1];
278
+ distributionTargets.pop();
279
+ }
280
+
281
+ _ensurePercentages();
282
+ }
283
+
284
+ /**
285
+ * @dev Release funds
286
+ * @param comptroller the comptroller address of the pool
287
+ * @param assets assets to be released to distribution targets
288
+ */
289
+ function releaseFunds(address comptroller, address[] calldata assets) external nonReentrant {
290
+ _accruePrimeInterest();
291
+
292
+ for (uint256 i = 0; i < assets.length; ) {
293
+ _releaseFund(comptroller, assets[i]);
294
+
295
+ unchecked {
296
+ ++i;
297
+ }
298
+ }
299
+ }
300
+
301
+ /**
302
+ * @dev Used to find out the amount of funds that's going to be released when release funds is called.
303
+ * @param comptroller the comptroller address of the pool
304
+ * @param schema the schema of the distribution target
305
+ * @param destination the destination address of the distribution target
306
+ * @param asset the asset address which will be released
307
+ */
308
+ function getUnreleasedFunds(
309
+ address comptroller,
310
+ Schema schema,
311
+ address destination,
312
+ address asset
313
+ ) external view returns (uint256) {
314
+ uint256 distributionTargetsLength = distributionTargets.length;
315
+ for (uint256 i = 0; i < distributionTargetsLength; ) {
316
+ DistributionConfig storage _config = distributionTargets[i];
317
+ if (_config.schema == schema && _config.destination == destination) {
318
+ uint256 total = assetsReserves[comptroller][asset][schema];
319
+ return (total * _config.percentage) / MAX_PERCENT;
320
+ }
321
+
322
+ unchecked {
323
+ ++i;
324
+ }
325
+ }
326
+ }
327
+
328
+ /**
329
+ * @dev Returns the total number of distribution targets
330
+ */
331
+ function totalDistributions() external view returns (uint256) {
332
+ return distributionTargets.length;
333
+ }
334
+
335
+ /**
336
+ * @dev Used to find out the percentage distribution for a particular destination based on schema
337
+ * @param destination the destination address of the distribution target
338
+ * @param schema the schema of the distribution target
339
+ * @return percentage percentage distribution
340
+ */
341
+ function getPercentageDistribution(address destination, Schema schema) external view returns (uint256) {
342
+ uint256 distributionTargetsLength = distributionTargets.length;
343
+ for (uint256 i = 0; i < distributionTargetsLength; ) {
344
+ DistributionConfig memory config = distributionTargets[i];
345
+
346
+ if (config.destination == destination && config.schema == schema) {
347
+ return config.percentage;
348
+ }
349
+
350
+ unchecked {
351
+ ++i;
352
+ }
353
+ }
354
+ }
355
+
356
+ /**
357
+ * @dev Update the reserve of the asset for the specific pool after transferring to the protocol share reserve.
358
+ * @param comptroller Comptroller address (pool)
359
+ * @param asset Asset address.
360
+ * @param incomeType type of income
361
+ */
362
+ function updateAssetsState(
363
+ address comptroller,
364
+ address asset,
365
+ IncomeType incomeType
366
+ ) public override(IProtocolShareReserve) nonReentrant {
367
+ if (!IComptroller(comptroller).isComptroller()) revert InvalidAddress();
368
+ if (asset == address(0)) revert InvalidAddress();
369
+ if (
370
+ comptroller != CORE_POOL_COMPTROLLER &&
371
+ IPoolRegistry(poolRegistry).getVTokenForAsset(comptroller, asset) == address(0)
372
+ ) revert InvalidAddress();
373
+
374
+ Schema schema = _getSchema(comptroller, asset, incomeType);
375
+ uint256 currentBalance = IERC20Upgradeable(asset).balanceOf(address(this));
376
+ uint256 assetReserve = totalAssetReserve[asset];
377
+
378
+ if (currentBalance > assetReserve) {
379
+ uint256 balanceDifference;
380
+ unchecked {
381
+ balanceDifference = currentBalance - assetReserve;
382
+ }
383
+
384
+ assetsReserves[comptroller][asset][schema] += balanceDifference;
385
+ totalAssetReserve[asset] += balanceDifference;
386
+ emit AssetsReservesUpdated(comptroller, asset, balanceDifference, incomeType, schema);
387
+ }
388
+ }
389
+
390
+ /**
391
+ * @dev Fetches the list of prime markets and then accrues interest and
392
+ * releases the funds to prime for each market
393
+ */
394
+ function _accrueAndReleaseFundsToPrime() internal {
395
+ if (prime == address(0)) {
396
+ return;
397
+ }
398
+
399
+ address[] memory markets = IPrime(prime).getAllMarkets();
400
+ for (uint256 i = 0; i < markets.length; ) {
401
+ address market = markets[i];
402
+ IPrime(prime).accrueInterest(market);
403
+ _releaseFund(CORE_POOL_COMPTROLLER, _getUnderlying(market));
404
+
405
+ unchecked {
406
+ ++i;
407
+ }
408
+ }
409
+ }
410
+
411
+ /**
412
+ * @dev Fetches the list of prime markets and then accrues interest
413
+ * to prime for each market
414
+ */
415
+ function _accruePrimeInterest() internal {
416
+ if (prime == address(0)) {
417
+ return;
418
+ }
419
+
420
+ address[] memory markets = IPrime(prime).getAllMarkets();
421
+ for (uint256 i = 0; i < markets.length; ) {
422
+ address market = markets[i];
423
+ IPrime(prime).accrueInterest(market);
424
+
425
+ unchecked {
426
+ ++i;
427
+ }
428
+ }
429
+ }
430
+
431
+ /**
432
+ * @dev asset from a particular pool to be release to distribution targets
433
+ * @param comptroller Comptroller address(pool)
434
+ * @param asset Asset address.
435
+ */
436
+ function _releaseFund(address comptroller, address asset) internal {
437
+ uint256 totalSchemas = uint256(type(Schema).max) + 1;
438
+ uint256[] memory schemaBalances = new uint256[](totalSchemas);
439
+ uint256 totalBalance;
440
+ for (uint256 schemaValue; schemaValue < totalSchemas; ) {
441
+ schemaBalances[schemaValue] = assetsReserves[comptroller][asset][Schema(schemaValue)];
442
+ totalBalance += schemaBalances[schemaValue];
443
+
444
+ unchecked {
445
+ ++schemaValue;
446
+ }
447
+ }
448
+
449
+ if (totalBalance == 0) {
450
+ return;
451
+ }
452
+
453
+ uint256[] memory totalTransferAmounts = new uint256[](totalSchemas);
454
+ for (uint256 i = 0; i < distributionTargets.length; ) {
455
+ DistributionConfig memory _config = distributionTargets[i];
456
+
457
+ uint256 transferAmount = (schemaBalances[uint256(_config.schema)] * _config.percentage) / MAX_PERCENT;
458
+ totalTransferAmounts[uint256(_config.schema)] += transferAmount;
459
+
460
+ IERC20Upgradeable(asset).safeTransfer(_config.destination, transferAmount);
461
+ IIncomeDestination(_config.destination).updateAssetsState(comptroller, asset);
462
+
463
+ emit AssetReleased(_config.destination, asset, _config.schema, _config.percentage, transferAmount);
464
+
465
+ unchecked {
466
+ ++i;
467
+ }
468
+ }
469
+
470
+ uint256[] memory newSchemaBalances = new uint256[](totalSchemas);
471
+ for (uint256 schemaValue = 0; schemaValue < totalSchemas; ) {
472
+ newSchemaBalances[schemaValue] = schemaBalances[schemaValue] - totalTransferAmounts[schemaValue];
473
+ assetsReserves[comptroller][asset][Schema(schemaValue)] = newSchemaBalances[schemaValue];
474
+ totalAssetReserve[asset] = totalAssetReserve[asset] - totalTransferAmounts[schemaValue];
475
+
476
+ emit ReservesUpdated(
477
+ comptroller,
478
+ asset,
479
+ Schema(schemaValue),
480
+ schemaBalances[schemaValue],
481
+ newSchemaBalances[schemaValue]
482
+ );
483
+
484
+ unchecked {
485
+ ++schemaValue;
486
+ }
487
+ }
488
+ }
489
+
490
+ /**
491
+ * @dev Returns the schema based on comptroller, asset and income type
492
+ * @param comptroller Comptroller address(pool)
493
+ * @param asset Asset address.
494
+ * @param incomeType type of income
495
+ * @return schema schema for distribution
496
+ */
497
+ function _getSchema(
498
+ address comptroller,
499
+ address asset,
500
+ IncomeType incomeType
501
+ ) internal view returns (Schema schema) {
502
+ schema = Schema.DEFAULT;
503
+
504
+ if (isInPrime[asset] && comptroller == CORE_POOL_COMPTROLLER && incomeType == IncomeType.SPREAD) {
505
+ schema = Schema.SPREAD_PRIME_CORE;
506
+ }
507
+ }
508
+
509
+ /**
510
+ * @dev This ensures that the total percentage of all the distribution targets is 100% or 0%
511
+ */
512
+ function _ensurePercentages() internal view {
513
+ uint256 totalSchemas = uint256(type(Schema).max) + 1;
514
+ uint8[] memory totalPercentages = new uint8[](totalSchemas);
515
+
516
+ uint256 distributionTargetsLength = distributionTargets.length;
517
+ for (uint256 i = 0; i < distributionTargetsLength; ) {
518
+ DistributionConfig memory config = distributionTargets[i];
519
+ totalPercentages[uint256(config.schema)] += config.percentage;
520
+
521
+ unchecked {
522
+ ++i;
523
+ }
524
+ }
525
+ for (uint256 schemaValue = 0; schemaValue < totalSchemas; ) {
526
+ if (totalPercentages[schemaValue] != MAX_PERCENT && totalPercentages[schemaValue] != 0)
527
+ revert InvalidTotalPercentage();
528
+
529
+ unchecked {
530
+ ++schemaValue;
531
+ }
532
+ }
533
+ }
534
+
535
+ /**
536
+ * @dev Returns the underlying asset address for the vToken
537
+ * @param vToken vToken address
538
+ * @return asset address of asset
539
+ */
540
+ function _getUnderlying(address vToken) internal view returns (address) {
541
+ if (vToken == vBNB) {
542
+ return WBNB;
543
+ } else {
544
+ return IVToken(vToken).underlying();
545
+ }
546
+ }
547
+ }
@@ -0,0 +1,67 @@
1
+ // SPDX-License-Identifier: BSD-3-Clause
2
+ pragma solidity 0.8.13;
3
+
4
+ import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
5
+ import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
6
+
7
+ /// @title ReserveHelpersStorage
8
+ /// @author Venus
9
+ /// @dev Reserve helpers storage
10
+ /// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion
11
+ contract ReserveHelpersStorage is Ownable2StepUpgradeable {
12
+ /// @notice Deprecated slot for assetReserves mapping
13
+ bytes32 private __deprecatedSlot1;
14
+
15
+ /// @notice Available asset's fund per pool in RiskFund
16
+ /// Comptroller(pool) -> Asset -> amount
17
+ mapping(address => mapping(address => uint256)) public poolAssetsFunds;
18
+
19
+ /// @notice Deprecated slot for poolRegistry address
20
+ bytes32 private __deprecatedSlot2;
21
+ /// @notice Deprecated slot for status variable
22
+ bytes32 private __deprecatedSlot3;
23
+
24
+ /// @dev This empty reserved space is put in place to allow future versions to add new
25
+ /// variables without shifting down storage in the inheritance chain.
26
+ uint256[46] private __gap;
27
+ }
28
+
29
+ /// @title MaxLoopsLimitHelpersStorage
30
+ /// @author Venus
31
+ /// @dev Max loop limit helpers storage
32
+ /// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion
33
+ contract MaxLoopsLimitHelpersStorage {
34
+ /// @notice Limit for the loops to avoid the DOS
35
+ /// @notice This state is deprecated, using it to prevent storage collision
36
+ uint256 public maxLoopsLimit;
37
+
38
+ /// @dev This empty reserved space is put in place to allow future versions to add new
39
+ /// variables without shifting down storage in the inheritance chain.
40
+ /// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
41
+ uint256[49] private __gap;
42
+ }
43
+
44
+ /// @title RiskFundV1Storage
45
+ /// @author Venus
46
+ /// @dev Risk fund V1 storage
47
+ /// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion
48
+ contract RiskFundV1Storage is ReserveHelpersStorage, MaxLoopsLimitHelpersStorage {
49
+ /// @notice Address of base asset
50
+ address public convertibleBaseAsset;
51
+ /// @notice Address of shortfall contract
52
+ address public shortfall;
53
+
54
+ /// @notice This state is deprecated, using it to prevent storage collision
55
+ address private pancakeSwapRouter;
56
+ /// @notice This state is deprecated, using it to prevent storage collision
57
+ uint256 private minAmountToConvert;
58
+ }
59
+
60
+ /// @title RiskFundV2Storage
61
+ /// @author Venus
62
+ /// @dev Risk fund V2 storage
63
+ /// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion
64
+ contract RiskFundV2Storage is RiskFundV1Storage, ReentrancyGuardUpgradeable {
65
+ /// @notice Risk fund converter address
66
+ address public riskFundConverter;
67
+ }