@venusprotocol/venus-protocol 3.0.0-dev.13 → 3.0.0-dev.14

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 (201) hide show
  1. package/README.md +46 -139
  2. package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
  3. package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +183 -0
  4. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +1 -1
  5. package/artifacts/@openzeppelin/contracts/access/Ownable2Step.sol/Ownable2Step.dbg.json +1 -1
  6. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
  7. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol/IERC20Permit.dbg.json +4 -0
  8. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/{draft-IERC20Permit.sol → IERC20Permit.sol}/IERC20Permit.json +1 -1
  9. package/artifacts/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol/SafeERC20.dbg.json +1 -1
  10. package/artifacts/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol/SafeERC20.json +2 -2
  11. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +1 -1
  12. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.json +2 -2
  13. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
  14. package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.dbg.json +1 -1
  15. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
  16. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
  17. package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.dbg.json +1 -1
  18. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json +1 -1
  19. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol/IERC20MetadataUpgradeable.dbg.json +4 -0
  20. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol/IERC20MetadataUpgradeable.json +233 -0
  21. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.dbg.json +4 -0
  22. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/{draft-IERC20PermitUpgradeable.sol → IERC20PermitUpgradeable.sol}/IERC20PermitUpgradeable.json +1 -1
  23. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.dbg.json +1 -1
  24. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.json +2 -2
  25. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
  26. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.json +2 -2
  27. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
  28. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.dbg.json +4 -0
  29. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.json +181 -0
  30. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.dbg.json +4 -0
  31. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.json +282 -0
  32. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +4 -0
  33. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.json +40 -0
  34. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +4 -0
  35. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.json +30 -0
  36. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +4 -0
  37. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.json +75 -0
  38. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +4 -0
  39. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.json +49 -0
  40. package/artifacts/build-info/ace314491952b59855cb85d2b2f6e8f3.json +1 -0
  41. package/artifacts/contracts/DelegateBorrowers/SwapDebtDelegate.sol/IComptroller.dbg.json +1 -1
  42. package/artifacts/contracts/DelegateBorrowers/SwapDebtDelegate.sol/IPriceOracle.dbg.json +1 -1
  43. package/artifacts/contracts/DelegateBorrowers/SwapDebtDelegate.sol/IVToken.dbg.json +1 -1
  44. package/artifacts/contracts/DelegateBorrowers/SwapDebtDelegate.sol/SwapDebtDelegate.dbg.json +1 -1
  45. package/artifacts/contracts/DelegateBorrowers/SwapDebtDelegate.sol/SwapDebtDelegate.json +2 -2
  46. package/artifacts/contracts/Liquidator/Interfaces.sol/IComptroller.dbg.json +1 -1
  47. package/artifacts/contracts/Liquidator/Interfaces.sol/IVAIController.dbg.json +1 -1
  48. package/artifacts/contracts/Liquidator/Interfaces.sol/IVBNB.dbg.json +1 -1
  49. package/artifacts/contracts/Liquidator/Interfaces.sol/IVBep20.dbg.json +1 -1
  50. package/artifacts/contracts/Liquidator/Interfaces.sol/IVToken.dbg.json +1 -1
  51. package/artifacts/contracts/Liquidator/Liquidator.sol/Liquidator.dbg.json +1 -1
  52. package/artifacts/contracts/Liquidator/Liquidator.sol/Liquidator.json +2 -2
  53. package/artifacts/contracts/PegStability/IVAI.sol/IVAI.dbg.json +4 -0
  54. package/artifacts/contracts/PegStability/IVAI.sol/IVAI.json +95 -0
  55. package/artifacts/contracts/PegStability/PegStability.sol/PegStability.dbg.json +4 -0
  56. package/artifacts/contracts/PegStability/PegStability.sol/PegStability.json +787 -0
  57. package/artifacts/contracts/Swap/IRouterHelper.sol/IRouterHelper.dbg.json +1 -1
  58. package/artifacts/contracts/Swap/RouterHelper.sol/RouterHelper.dbg.json +1 -1
  59. package/artifacts/contracts/Swap/SwapRouter.sol/SwapRouter.dbg.json +1 -1
  60. package/artifacts/contracts/Swap/SwapRouter.sol/SwapRouter.json +2 -2
  61. package/artifacts/contracts/Swap/interfaces/IPancakePair.sol/IPancakePair.dbg.json +1 -1
  62. package/artifacts/contracts/Swap/interfaces/IPancakeSwapV2Factory.sol/IPancakeSwapV2Factory.dbg.json +1 -1
  63. package/artifacts/contracts/Swap/interfaces/IPancakeSwapV2Router.sol/IPancakeSwapV2Router.dbg.json +1 -1
  64. package/artifacts/contracts/Swap/interfaces/IVBNB.sol/IVBNB.dbg.json +1 -1
  65. package/artifacts/contracts/Swap/interfaces/IVtoken.sol/IVToken.dbg.json +1 -1
  66. package/artifacts/contracts/Swap/interfaces/IWBNB.sol/IWBNB.dbg.json +1 -1
  67. package/artifacts/contracts/Swap/interfaces/InterfaceComptroller.sol/InterfaceComptroller.dbg.json +1 -1
  68. package/artifacts/contracts/Swap/lib/PancakeLibrary.sol/PancakeLibrary.dbg.json +1 -1
  69. package/artifacts/contracts/Swap/lib/TransferHelper.sol/TransferHelper.dbg.json +1 -1
  70. package/artifacts/contracts/test/LiquidatorHarness.sol/LiquidatorHarness.dbg.json +1 -1
  71. package/artifacts/contracts/test/LiquidatorHarness.sol/LiquidatorHarness.json +2 -2
  72. package/contracts/PegStability/IVAI.sol +12 -0
  73. package/contracts/PegStability/PegStability.sol +500 -0
  74. package/deployments/bscmainnet/DefaultProxyAdmin.json +257 -0
  75. package/deployments/bscmainnet/PegStability_USDT.json +945 -0
  76. package/deployments/bscmainnet/PegStability_USDT_Implementation.json +1076 -0
  77. package/deployments/bscmainnet/PegStability_USDT_Proxy.json +267 -0
  78. package/deployments/bscmainnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json +78 -0
  79. package/deployments/bscmainnet/solcInputs/822f68e7114df9df2dc3cc4555bcf616.json +132 -0
  80. package/deployments/bsctestnet/.migrations.json +3 -0
  81. package/deployments/bsctestnet/DefaultProxyAdmin.json +257 -0
  82. package/deployments/bsctestnet/PegStability_USDT.json +945 -0
  83. package/deployments/bsctestnet/PegStability_USDT_Implementation.json +1076 -0
  84. package/deployments/bsctestnet/PegStability_USDT_Proxy.json +267 -0
  85. package/deployments/bsctestnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json +78 -0
  86. package/deployments/bsctestnet/solcInputs/6f56db373f5e9158556be1af9ccf91fb.json +132 -0
  87. package/deployments/bsctestnet/solcInputs/70d128da5db4d0b45c404d3f3fe2c806.json +69 -0
  88. package/deployments/bsctestnet/solcInputs/76ea5ea1fe9239cc3ffbe46145aeead0.json +69 -0
  89. package/dist/deploy/006-deploy-psm.d.ts +3 -0
  90. package/dist/deploy/006-deploy-psm.js +65 -0
  91. package/dist/deploy/006-update-psm.d.ts +3 -0
  92. package/dist/deploy/006-update-psm.js +29 -0
  93. package/dist/hardhat.config.js +2 -2
  94. package/dist/typechain/@openzeppelin/contracts/access/IAccessControl.d.ts +145 -0
  95. package/dist/typechain/@openzeppelin/contracts/access/IAccessControl.js +3 -0
  96. package/dist/typechain/@openzeppelin/contracts/access/index.d.ts +1 -0
  97. package/dist/typechain/@openzeppelin/contracts/token/ERC20/extensions/{draft-IERC20Permit.sol/IERC20Permit.d.ts → IERC20Permit.d.ts} +1 -1
  98. package/dist/typechain/@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.js +3 -0
  99. package/dist/typechain/@openzeppelin/contracts/token/ERC20/extensions/index.d.ts +1 -2
  100. package/dist/typechain/@openzeppelin/contracts/token/ERC20/extensions/index.js +0 -1
  101. package/dist/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.d.ts +166 -0
  102. package/dist/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/{draft-IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.d.ts → IERC20PermitUpgradeable.d.ts} +1 -1
  103. package/dist/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/index.d.ts +2 -2
  104. package/dist/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/index.js +0 -1
  105. package/dist/typechain/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.d.ts +172 -0
  106. package/dist/typechain/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.js +3 -0
  107. package/dist/typechain/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.d.ts +205 -0
  108. package/dist/typechain/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.js +3 -0
  109. package/dist/typechain/@venusprotocol/governance-contracts/contracts/Governance/index.d.ts +2 -0
  110. package/dist/typechain/@venusprotocol/index.d.ts +2 -0
  111. package/dist/typechain/@venusprotocol/oracle/contracts/index.d.ts +2 -0
  112. package/dist/typechain/@venusprotocol/oracle/contracts/index.js +3 -0
  113. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.d.ts +46 -0
  114. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.js +3 -0
  115. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.d.ts +42 -0
  116. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.js +3 -0
  117. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.d.ts +82 -0
  118. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.js +3 -0
  119. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.d.ts +58 -0
  120. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.js +3 -0
  121. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/index.d.ts +4 -0
  122. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/index.d.ts +2 -0
  123. package/dist/typechain/@venusprotocol/oracle/contracts/interfaces/index.js +3 -0
  124. package/dist/typechain/@venusprotocol/oracle/index.d.ts +2 -0
  125. package/dist/typechain/@venusprotocol/oracle/index.js +3 -0
  126. package/dist/typechain/contracts/PegStability/IVAI.d.ts +102 -0
  127. package/dist/typechain/contracts/PegStability/IVAI.js +3 -0
  128. package/dist/typechain/contracts/PegStability/PegStability.d.ts +564 -0
  129. package/dist/typechain/contracts/PegStability/PegStability.js +3 -0
  130. package/dist/typechain/contracts/PegStability/index.d.ts +2 -0
  131. package/dist/typechain/contracts/index.d.ts +2 -0
  132. package/dist/typechain/factories/@openzeppelin/contracts/access/IAccessControl__factory.d.ts +142 -0
  133. package/dist/typechain/factories/@openzeppelin/contracts/access/IAccessControl__factory.js +189 -0
  134. package/dist/typechain/factories/@openzeppelin/contracts/access/index.d.ts +1 -0
  135. package/dist/typechain/factories/@openzeppelin/contracts/access/index.js +3 -1
  136. package/dist/typechain/factories/@openzeppelin/contracts/token/ERC20/extensions/{draft-IERC20Permit.sol/IERC20Permit__factory.d.ts → IERC20Permit__factory.d.ts} +1 -1
  137. package/dist/typechain/factories/@openzeppelin/contracts/token/ERC20/extensions/index.d.ts +1 -1
  138. package/dist/typechain/factories/@openzeppelin/contracts/token/ERC20/extensions/index.js +3 -25
  139. package/dist/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable__factory.d.ts +178 -0
  140. package/dist/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable__factory.js +239 -0
  141. package/dist/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/{draft-IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable__factory.d.ts → IERC20PermitUpgradeable__factory.d.ts} +1 -1
  142. package/dist/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/index.d.ts +2 -1
  143. package/dist/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/index.js +5 -25
  144. package/dist/typechain/factories/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8__factory.d.ts +141 -0
  145. package/dist/typechain/factories/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8__factory.js +187 -0
  146. package/dist/typechain/factories/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8__factory.d.ts +218 -0
  147. package/dist/typechain/factories/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8__factory.js +288 -0
  148. package/dist/typechain/factories/@venusprotocol/governance-contracts/contracts/Governance/index.d.ts +2 -0
  149. package/dist/typechain/factories/@venusprotocol/governance-contracts/contracts/Governance/index.js +5 -1
  150. package/dist/typechain/factories/@venusprotocol/index.d.ts +1 -0
  151. package/dist/typechain/factories/@venusprotocol/index.js +2 -1
  152. package/dist/typechain/factories/@venusprotocol/oracle/contracts/index.d.ts +1 -0
  153. package/dist/typechain/factories/@venusprotocol/oracle/contracts/index.js +30 -0
  154. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface__factory.d.ts +30 -0
  155. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface__factory.js +46 -0
  156. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface__factory.d.ts +22 -0
  157. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface__factory.js +36 -0
  158. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface__factory.d.ts +56 -0
  159. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface__factory.js +81 -0
  160. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface__factory.d.ts +36 -0
  161. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface__factory.js +55 -0
  162. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/index.d.ts +4 -0
  163. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/index.js +14 -0
  164. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/index.d.ts +1 -0
  165. package/dist/typechain/factories/@venusprotocol/oracle/contracts/interfaces/index.js +30 -0
  166. package/dist/typechain/factories/@venusprotocol/oracle/index.d.ts +1 -0
  167. package/dist/typechain/factories/@venusprotocol/oracle/index.js +30 -0
  168. package/dist/typechain/factories/contracts/DelegateBorrowers/SwapDebtDelegate.sol/SwapDebtDelegate__factory.d.ts +1 -1
  169. package/dist/typechain/factories/contracts/DelegateBorrowers/SwapDebtDelegate.sol/SwapDebtDelegate__factory.js +1 -1
  170. package/dist/typechain/factories/contracts/Liquidator/Liquidator__factory.d.ts +1 -1
  171. package/dist/typechain/factories/contracts/Liquidator/Liquidator__factory.js +1 -1
  172. package/dist/typechain/factories/contracts/PegStability/IVAI__factory.d.ts +72 -0
  173. package/dist/typechain/factories/contracts/PegStability/IVAI__factory.js +101 -0
  174. package/dist/typechain/factories/contracts/PegStability/PegStability__factory.d.ts +625 -0
  175. package/dist/typechain/factories/contracts/PegStability/PegStability__factory.js +816 -0
  176. package/dist/typechain/factories/contracts/PegStability/index.d.ts +2 -0
  177. package/dist/typechain/factories/contracts/PegStability/index.js +10 -0
  178. package/dist/typechain/factories/contracts/Swap/SwapRouter__factory.d.ts +1 -1
  179. package/dist/typechain/factories/contracts/Swap/SwapRouter__factory.js +1 -1
  180. package/dist/typechain/factories/contracts/index.d.ts +1 -0
  181. package/dist/typechain/factories/contracts/index.js +2 -1
  182. package/dist/typechain/factories/contracts/test/LiquidatorHarness__factory.d.ts +1 -1
  183. package/dist/typechain/factories/contracts/test/LiquidatorHarness__factory.js +1 -1
  184. package/dist/typechain/index.d.ts +24 -4
  185. package/dist/typechain/index.js +27 -7
  186. package/package.json +2 -1
  187. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol/IERC20Permit.dbg.json +0 -4
  188. package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.dbg.json +0 -4
  189. package/artifacts/build-info/7ba4636f17a9306e510e09b5ee7b87c3.json +0 -1
  190. package/dist/typechain/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol/index.d.ts +0 -1
  191. package/dist/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/index.d.ts +0 -1
  192. package/dist/typechain/factories/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol/index.d.ts +0 -1
  193. package/dist/typechain/factories/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol/index.js +0 -8
  194. package/dist/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/index.d.ts +0 -1
  195. package/dist/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/index.js +0 -8
  196. /package/dist/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/{draft-IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.js → IERC20MetadataUpgradeable.js} +0 -0
  197. /package/dist/typechain/@openzeppelin/{contracts/token/ERC20/extensions/draft-IERC20Permit.sol/IERC20Permit.js → contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.js} +0 -0
  198. /package/dist/typechain/{@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol → @venusprotocol/oracle/contracts/interfaces/OracleInterface.sol}/index.js +0 -0
  199. /package/dist/typechain/{@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol → contracts/PegStability}/index.js +0 -0
  200. /package/dist/typechain/factories/@openzeppelin/contracts/token/ERC20/extensions/{draft-IERC20Permit.sol/IERC20Permit__factory.js → IERC20Permit__factory.js} +0 -0
  201. /package/dist/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/{draft-IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable__factory.js → IERC20PermitUpgradeable__factory.js} +0 -0
@@ -0,0 +1,69 @@
1
+ {
2
+ "language": "Solidity",
3
+ "sources": {
4
+ "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": {
5
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n function __Ownable2Step_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable2Step_init_unchained() internal onlyInitializing {\n }\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
6
+ },
7
+ "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
8
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
9
+ },
10
+ "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
11
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
12
+ },
13
+ "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": {
14
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
15
+ },
16
+ "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": {
17
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
18
+ },
19
+ "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
20
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
21
+ },
22
+ "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": {
23
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n"
24
+ },
25
+ "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
26
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
27
+ },
28
+ "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
29
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
30
+ },
31
+ "@openzeppelin/contracts/access/IAccessControl.sol": {
32
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n"
33
+ },
34
+ "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol": {
35
+ "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\n\nimport \"./IAccessControlManagerV8.sol\";\n\n/**\n * @title Venus Access Control Contract.\n * @dev The AccessControlledV8 contract is a wrapper around the OpenZeppelin AccessControl contract\n * It provides a standardized way to control access to methods within the Venus Smart Contract Ecosystem.\n * The contract allows the owner to set an AccessControlManager contract address.\n * It can restrict method calls based on the sender's role and the method's signature.\n */\n\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\n /// @notice Access control manager contract\n IAccessControlManagerV8 private _accessControlManager;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when access control manager contract address is changed\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n /// @notice Thrown when the action is prohibited by AccessControlManager\n error Unauthorized(address sender, address calledContract, string methodSignature);\n\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\n __Ownable2Step_init();\n __AccessControlled_init_unchained(accessControlManager_);\n }\n\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Sets the address of AccessControlManager\n * @dev Admin function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n * @custom:event Emits NewAccessControlManager event\n * @custom:access Only Governance\n */\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Returns the address of the access control manager contract\n */\n function accessControlManager() external view returns (IAccessControlManagerV8) {\n return _accessControlManager;\n }\n\n /**\n * @dev Internal function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n */\n function _setAccessControlManager(address accessControlManager_) internal {\n require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n address oldAccessControlManager = address(_accessControlManager);\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n }\n\n /**\n * @notice Reverts if the call is not allowed by AccessControlManager\n * @param signature Method signature\n */\n function _checkAccessAllowed(string memory signature) internal view {\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n if (!isAllowedToCall) {\n revert Unauthorized(msg.sender, address(this), signature);\n }\n }\n}\n"
36
+ },
37
+ "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol": {
38
+ "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/access/IAccessControl.sol\";\n\ninterface IAccessControlManagerV8 is IAccessControl {\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) external;\n\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) external view returns (bool);\n}\n"
39
+ },
40
+ "contracts/PegStability/PegStability.sol": {
41
+ "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ninterface VAI {\n function balanceOf(address usr) external returns (uint256);\n\n function transferFrom(address src, address dst, uint amount) external returns (bool);\n\n function mint(address usr, uint wad) external;\n\n function burn(address usr, uint wad) external;\n}\n\ninterface IPriceOracle {\n function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface IVTokenUnderlying {\n function underlying() external view returns (address);\n}\n\ninterface OracleProviderInterface {\n function oracle() external view returns (address);\n}\n\ninterface DecimalProvider {\n function decimals() external view returns (uint8);\n}\n\n/**\n * @title Peg Stability Contract\n * @notice Contract for swapping stable token for VAI token and vice versa to maintain the peg stability between them.\n * @author Venus Protocol\n */\ncontract PegStability is AccessControlledV8, ReentrancyGuardUpgradeable {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n // Helper enum for calculation of the fee\n enum FeeDirection {\n IN,\n OUT\n }\n uint256 public constant BASIS_POINTS_DIVISOR = 10000; // fee is in basis points\n uint256 public constant MANTISSA_ONE = 1e18;\n uint256 public immutable ONE_DOLLAR; // Our oracle is returning amount depending on the number of decimals of the stable token. (36 - asset_decimals). E.g. 8 decimal asset = 1e28\n address public immutable VAI_ADDRESS;\n address public immutable STABLE_TOKEN_ADDRESS;\n address public immutable VTOKEN_ADDRESS; // vToken having as underlying the stableToken\n address public comptroller; // used as a single point of truth for oracle address\n address public venusTreasury;\n uint256 public feeIn; // incoming VAI fee\n uint256 public feeOut; // outgoing VAI fee\n uint256 public vaiMintCap; // max amount of VAI that can be minted through this contract\n uint256 public vaiMinted;\n bool public isPaused;\n\n /// @notice Event emitted when contract is paused\n event PSMPaused(address indexed admin);\n\n /// @notice Event emitted when the contract is resumed after pause\n event PSMResumed(address indexed admin);\n\n /// @notice Event emitted when feeIn state var is modified\n event FeeInChanged(uint256 oldFeeIn, uint256 newFeeIn);\n\n /// @notice Event emitted when feeOut state var is modified\n event FeeOutChanged(uint256 oldFeeOut, uint256 newFeeOut);\n\n /// @notice Event emitted when vaiMintCap state var is modified\n event VaiMintCapChanged(uint256 oldCap, uint256 newCap);\n\n /// @notice Event emitted when venusTreasury state var is modified\n event VenusTreasuryChanged(address indexed oldTreasury, address indexed newTreasury);\n\n /// @notice Event emitted when comptroller state var is modified\n event ComptrollerChanged(address indexed oldComptroller, address indexed newComptroller);\n\n /// @notice Event emitted when stable token is swapped for VAI\n event StableForVAISwapped(uint256 stableIn, uint256 vaiOut, uint256 fee);\n\n /// @notice Event emitted when stable token is swapped for VAI\n event VaiForStableSwapped(uint256 vaiBurnt, uint256 vaiFee, uint256 stableOut);\n\n /**\n * @dev Prevents functions to execute when contract is paused.\n */\n modifier isActive() {\n require(!isPaused, \"Contract is paused.\");\n _;\n }\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address vTokenAddress_, address vaiAddress_) {\n ensureNonzeroAddress(vTokenAddress_);\n ensureNonzeroAddress(vaiAddress_);\n\n address stableTokenAddress_ = IVTokenUnderlying(vTokenAddress_).underlying();\n uint256 decimals_ = DecimalProvider(stableTokenAddress_).decimals();\n require(decimals_ <= 18, \"too much decimals\");\n ONE_DOLLAR = 10 ** (36 - decimals_); // 1$ scaled to the decimals returned by our Oracle\n\n VTOKEN_ADDRESS = vTokenAddress_;\n STABLE_TOKEN_ADDRESS = stableTokenAddress_;\n VAI_ADDRESS = vaiAddress_;\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract via Proxy Contract with the required parameters\n * @param accessControlManager_ The address of the AccessControlManager contract\n * @param venusTreasury_ The address where fees will be sent\n * @param comptroller_ The address of the Comptroller contract\n * @param feeIn_ The percentage of fees to be applied to a stablecoin -> VAI swap\n * @param feeOut_ The percentage of fees to be applied to a VAI -> stablecoin swap\n * @param vaiMintCap_ The cap for the total amount of VAI that can be minted\n */\n function initialize(\n address accessControlManager_,\n address venusTreasury_,\n address comptroller_,\n uint256 feeIn_,\n uint256 feeOut_,\n uint256 vaiMintCap_\n ) external initializer {\n ensureNonzeroAddress(accessControlManager_);\n ensureNonzeroAddress(venusTreasury_);\n ensureNonzeroAddress(comptroller_);\n ensureNonzeroAddress(OracleProviderInterface(comptroller_).oracle());\n __AccessControlled_init(accessControlManager_);\n __ReentrancyGuard_init();\n\n require(feeIn_ < BASIS_POINTS_DIVISOR, \"Invalid fee in.\");\n require(feeOut_ < BASIS_POINTS_DIVISOR, \"Invalid fee out.\");\n\n feeIn = feeIn_;\n feeOut = feeOut_;\n vaiMintCap = vaiMintCap_;\n venusTreasury = venusTreasury_;\n comptroller = comptroller_;\n }\n\n /*** Swap Functions ***/\n\n /**\n * @notice Swaps VAI for a stable token\n * @param receiver The address where the stablecoin will be sent\n * @param stableTknAmount The amount of stable tokens to receive\n */\n // @custom:event Emits VaiForStableSwapped event\n function swapVAIForStable(address receiver, uint256 stableTknAmount) external isActive nonReentrant {\n ensureNonzeroAddress(receiver);\n require(stableTknAmount > 0, \"Amount must be greater than zero.\");\n\n // calculate USD value of the stable token amount scaled in 18 decimals\n uint256 stableTknAmountUSD = previewTokenUSDAmount(stableTknAmount, FeeDirection.OUT);\n uint256 fee = _calculateFee(stableTknAmountUSD, FeeDirection.OUT);\n\n require(VAI(VAI_ADDRESS).balanceOf(msg.sender) >= stableTknAmountUSD + fee, \"Not enough VAI.\");\n require(vaiMinted >= stableTknAmountUSD, \"Can't burn more VAI than minted.\");\n\n unchecked {\n vaiMinted -= stableTknAmountUSD;\n }\n\n if (fee != 0) {\n bool success = VAI(VAI_ADDRESS).transferFrom(msg.sender, venusTreasury, fee);\n require(success, \"VAI fee transfer failed.\");\n }\n\n VAI(VAI_ADDRESS).burn(msg.sender, stableTknAmountUSD);\n IERC20Upgradeable(STABLE_TOKEN_ADDRESS).safeTransfer(receiver, stableTknAmount);\n emit VaiForStableSwapped(stableTknAmountUSD, fee, stableTknAmount);\n }\n\n /**\n * @notice Swaps stable tokens for VAI with fees.\n * @dev This function adds support to fee-on-transfer tokens. The actualTransferAmt is calculated, by recording token balance state before and after the transfer.\n * @param receiver The address that will receive the VAI tokens.\n * @param stableTknAmount The amount of stable tokens to be swapped.\n */\n // @custom:event Emits StableForVAISwapped event\n function swapStableForVAI(address receiver, uint256 stableTknAmount) external isActive nonReentrant {\n ensureNonzeroAddress(receiver);\n require(stableTknAmount > 0, \"Amount must be greater than zero.\");\n\n // transfer IN, supporting fee-on-transfer tokens\n uint256 balanceBefore = IERC20Upgradeable(STABLE_TOKEN_ADDRESS).balanceOf(address(this));\n IERC20Upgradeable(STABLE_TOKEN_ADDRESS).safeTransferFrom(msg.sender, address(this), stableTknAmount);\n uint256 balanceAfter = IERC20Upgradeable(STABLE_TOKEN_ADDRESS).balanceOf(address(this));\n\n //calculate actual transfered amount (in case of fee-on-transfer tokens)\n uint256 actualTransferAmt = balanceAfter - balanceBefore;\n\n // calculate USD value of the stable token amount scaled in 18 decimals\n uint256 actualTransferAmtInUSD = previewTokenUSDAmount(actualTransferAmt, FeeDirection.IN);\n\n //calculate feeIn\n uint256 fee = _calculateFee(actualTransferAmtInUSD, FeeDirection.IN);\n uint256 vaiToMint = actualTransferAmtInUSD - fee;\n\n require(vaiMinted + actualTransferAmtInUSD <= vaiMintCap, \"VAI mint cap reached.\");\n unchecked {\n vaiMinted += actualTransferAmtInUSD;\n }\n\n // mint VAI to receiver\n VAI(VAI_ADDRESS).mint(receiver, vaiToMint);\n\n // mint VAI fee to venus treasury\n if (fee != 0) {\n VAI(VAI_ADDRESS).mint(venusTreasury, fee);\n }\n\n emit StableForVAISwapped(actualTransferAmt, vaiToMint, fee);\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Pause the PSM contract\n * @dev Reverts if the contract is already paused\n */\n // @custom:event Emits PSMPaused event\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!isPaused, \"PSM is already paused.\");\n isPaused = true;\n emit PSMPaused(msg.sender);\n }\n\n /**\n * @notice Resume the PSM contract\n * @dev Reverts if the contract is not paused\n */\n // @custom:event Emits PSMResumed event\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(isPaused, \"PSM is not paused.\");\n isPaused = false;\n emit PSMResumed(msg.sender);\n }\n\n /**\n * @notice Set the fee percentage for incoming swaps\n * @dev Reverts if the new fee percentage is invalid (greater than or equal to BASIS_POINTS_DIVISOR)\n * @param feeIn_ The new fee percentage for incoming swaps\n */\n // @custom:event Emits FeeInChanged event\n function setFeeIn(uint256 feeIn_) external {\n _checkAccessAllowed(\"setFeeIn(uint256)\");\n // feeIn = 10000 = 100%\n require(feeIn_ < BASIS_POINTS_DIVISOR, \"Invalid fee.\");\n uint256 oldFeeIn = feeIn;\n feeIn = feeIn_;\n emit FeeInChanged(oldFeeIn, feeIn_);\n }\n\n /**\n * @notice Set the fee percentage for outgoing swaps\n * @dev Reverts if the new fee percentage is invalid (greater than or equal to BASIS_POINTS_DIVISOR)\n * @param feeOut_ The new fee percentage for outgoing swaps\n */\n // @custom:event Emits FeeOutChanged event\n function setFeeOut(uint256 feeOut_) external {\n _checkAccessAllowed(\"setFeeOut(uint256)\");\n // feeOut = 10000 = 100%\n require(feeOut_ < BASIS_POINTS_DIVISOR, \"Invalid fee.\");\n uint256 oldFeeOut = feeOut;\n feeOut = feeOut_;\n emit FeeOutChanged(oldFeeOut, feeOut_);\n }\n\n /**\n * @dev Set the maximum amount of VAI that can be minted through this contract\n * @param vaiMintCap_ The new maximum amount of VAI that can be minted\n */\n // @custom:event Emits VaiMintCapChanged event\n function setVaiMintCap(uint256 vaiMintCap_) external {\n _checkAccessAllowed(\"setVaiMintCap(uint256)\");\n uint256 oldVaiMintCap = vaiMintCap;\n vaiMintCap = vaiMintCap_;\n emit VaiMintCapChanged(oldVaiMintCap, vaiMintCap_);\n }\n\n /**\n * @notice Set the address of the Venus Treasury contract\n * @dev Reverts if the new address is zero\n * @param venusTreasury_ The new address of the Venus Treasury contract\n */\n // @custom:event Emits VenusTreasuryChanged event\n function setVenusTreasury(address venusTreasury_) external {\n _checkAccessAllowed(\"setVenusTreasury(address)\");\n ensureNonzeroAddress(venusTreasury_);\n address oldTreasuryAddress = venusTreasury;\n venusTreasury = venusTreasury_;\n emit VenusTreasuryChanged(oldTreasuryAddress, venusTreasury_);\n }\n\n /**\n * @notice Set the address of the Comptroller contract from which we obtain the oracle address\n * @dev Reverts if the new address is zero or the oracle address returned from Comptroller is zero\n * @param comptroller_ The new address of the Comptroller contract\n */\n // @custom:event Emits ComptrollerChanged event\n function setComptroller(address comptroller_) external {\n _checkAccessAllowed(\"setComptroller(address)\");\n ensureNonzeroAddress(comptroller_);\n ensureNonzeroAddress(OracleProviderInterface(comptroller_).oracle());\n address oldComptrollerAddress = comptroller;\n comptroller = comptroller_;\n emit ComptrollerChanged(oldComptrollerAddress, comptroller_);\n }\n\n /*** Helper Functions ***/\n\n /**\n * @dev Calculates the USD value of the given amount of stable tokens depending on the swap direction.\n * @param amount The amount of stable tokens.\n * @param direction The direction of the swap.\n * @return The USD value of the given amount of stable tokens scaled by 1e18 taking into account the direction of the swap\n */\n function previewTokenUSDAmount(uint256 amount, FeeDirection direction) internal view returns (uint256) {\n return (amount * getPriceInUSD(direction)) / MANTISSA_ONE;\n }\n\n /**\n * @notice Get the price of stable token in USD\n * @dev This function returns either min(1$,oraclePrice) or max(1$,oraclePrice) with a decimal scale (36 - asset_decimals). E.g. for 8 decimal token 1$ will be 1e28\n * @param direction The direction of the swap: FeeDirection.IN or FeeDirection.OUT\n * @return The price in USD, adjusted based on the selected direction\n */\n function getPriceInUSD(FeeDirection direction) internal view returns (uint256) {\n address priceOracleAddress = OracleProviderInterface(comptroller).oracle();\n // get price with a scale = (36 - asset_decimals)\n uint256 price = IPriceOracle(priceOracleAddress).getUnderlyingPrice(VTOKEN_ADDRESS);\n\n if (direction == FeeDirection.IN) {\n // MIN(1, price)\n return price < ONE_DOLLAR ? price : ONE_DOLLAR;\n } else {\n // MAX(1, price)\n return price > ONE_DOLLAR ? price : ONE_DOLLAR;\n }\n }\n\n /**\n * @notice Calculate the fee amount based on the input amount and fee percentage\n * @dev Reverts if the fee percentage calculation results in rounding down to 0\n * @param amount The input amount to calculate the fee from\n * @param direction The direction of the fee: FeeDirection.IN or FeeDirection.OUT\n * @return The fee amount\n */\n function _calculateFee(uint256 amount, FeeDirection direction) internal view returns (uint256) {\n uint256 feePercent;\n if (direction == FeeDirection.IN) {\n feePercent = feeIn;\n } else {\n feePercent = feeOut;\n }\n if (feePercent == 0) {\n return 0;\n } else {\n // checking if the percent calculation will result in rounding down to 0\n require(amount * feePercent >= BASIS_POINTS_DIVISOR, \"Amount too small.\");\n return (amount * feePercent) / BASIS_POINTS_DIVISOR;\n }\n }\n\n /**\n * @notice Checks that the address is not the zero address\n * @param someone The address to check\n */\n function ensureNonzeroAddress(address someone) private pure {\n require(someone != address(0), \"Can't be zero address.\");\n }\n}\n"
42
+ }
43
+ },
44
+ "settings": {
45
+ "optimizer": {
46
+ "enabled": true,
47
+ "runs": 10000
48
+ },
49
+ "outputSelection": {
50
+ "*": {
51
+ "*": [
52
+ "storageLayout",
53
+ "abi",
54
+ "evm.bytecode",
55
+ "evm.deployedBytecode",
56
+ "evm.methodIdentifiers",
57
+ "metadata",
58
+ "devdoc",
59
+ "userdoc",
60
+ "evm.gasEstimates"
61
+ ],
62
+ "": ["ast"]
63
+ }
64
+ },
65
+ "metadata": {
66
+ "useLiteralContent": true
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "language": "Solidity",
3
+ "sources": {
4
+ "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": {
5
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n function __Ownable2Step_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable2Step_init_unchained() internal onlyInitializing {\n }\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
6
+ },
7
+ "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
8
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
9
+ },
10
+ "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
11
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
12
+ },
13
+ "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": {
14
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
15
+ },
16
+ "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": {
17
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
18
+ },
19
+ "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
20
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
21
+ },
22
+ "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": {
23
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n"
24
+ },
25
+ "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
26
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
27
+ },
28
+ "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
29
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
30
+ },
31
+ "@openzeppelin/contracts/access/IAccessControl.sol": {
32
+ "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n"
33
+ },
34
+ "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol": {
35
+ "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\n\nimport \"./IAccessControlManagerV8.sol\";\n\n/**\n * @title Venus Access Control Contract.\n * @dev The AccessControlledV8 contract is a wrapper around the OpenZeppelin AccessControl contract\n * It provides a standardized way to control access to methods within the Venus Smart Contract Ecosystem.\n * The contract allows the owner to set an AccessControlManager contract address.\n * It can restrict method calls based on the sender's role and the method's signature.\n */\n\nabstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {\n /// @notice Access control manager contract\n IAccessControlManagerV8 private _accessControlManager;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n\n /// @notice Emitted when access control manager contract address is changed\n event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);\n\n /// @notice Thrown when the action is prohibited by AccessControlManager\n error Unauthorized(address sender, address calledContract, string methodSignature);\n\n function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {\n __Ownable2Step_init();\n __AccessControlled_init_unchained(accessControlManager_);\n }\n\n function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Sets the address of AccessControlManager\n * @dev Admin function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n * @custom:event Emits NewAccessControlManager event\n * @custom:access Only Governance\n */\n function setAccessControlManager(address accessControlManager_) external onlyOwner {\n _setAccessControlManager(accessControlManager_);\n }\n\n /**\n * @notice Returns the address of the access control manager contract\n */\n function accessControlManager() external view returns (IAccessControlManagerV8) {\n return _accessControlManager;\n }\n\n /**\n * @dev Internal function to set address of AccessControlManager\n * @param accessControlManager_ The new address of the AccessControlManager\n */\n function _setAccessControlManager(address accessControlManager_) internal {\n require(address(accessControlManager_) != address(0), \"invalid acess control manager address\");\n address oldAccessControlManager = address(_accessControlManager);\n _accessControlManager = IAccessControlManagerV8(accessControlManager_);\n emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);\n }\n\n /**\n * @notice Reverts if the call is not allowed by AccessControlManager\n * @param signature Method signature\n */\n function _checkAccessAllowed(string memory signature) internal view {\n bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);\n\n if (!isAllowedToCall) {\n revert Unauthorized(msg.sender, address(this), signature);\n }\n }\n}\n"
36
+ },
37
+ "@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol": {
38
+ "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts/access/IAccessControl.sol\";\n\ninterface IAccessControlManagerV8 is IAccessControl {\n function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;\n\n function revokeCallPermission(\n address contractAddress,\n string calldata functionSig,\n address accountToRevoke\n ) external;\n\n function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);\n\n function hasPermission(\n address account,\n address contractAddress,\n string calldata functionSig\n ) external view returns (bool);\n}\n"
39
+ },
40
+ "contracts/PegStability/PegStability.sol": {
41
+ "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.13;\n\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ninterface VAI {\n function balanceOf(address usr) external returns (uint256);\n\n function transferFrom(address src, address dst, uint amount) external returns (bool);\n\n function mint(address usr, uint wad) external;\n\n function burn(address usr, uint wad) external;\n}\n\ninterface IPriceOracle {\n function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface IVTokenUnderlying {\n function underlying() external view returns (address);\n}\n\ninterface OracleProviderInterface {\n function oracle() external view returns (address);\n}\n\ninterface DecimalProvider {\n function decimals() external view returns (uint8);\n}\n\n/**\n * @title Peg Stability Contract\n * @notice Contract for swapping stable token for VAI token and vice versa to maintain the peg stability between them.\n * @author Venus Protocol\n */\ncontract PegStability is AccessControlledV8, ReentrancyGuardUpgradeable {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n // Helper enum for calculation of the fee\n enum FeeDirection {\n IN,\n OUT\n }\n uint256 public constant BASIS_POINTS_DIVISOR = 10000; // fee is in basis points\n uint256 public constant MANTISSA_ONE = 1e18;\n uint256 public immutable ONE_DOLLAR; // Our oracle is returning amount depending on the number of decimals of the stable token. (36 - asset_decimals). E.g. 8 decimal asset = 1e28\n address public immutable VAI_ADDRESS;\n address public immutable STABLE_TOKEN_ADDRESS;\n address public immutable VTOKEN_ADDRESS; // vToken having as underlying the stableToken\n address public comptroller; // used as a single point of truth for oracle address\n address public venusTreasury;\n uint256 public feeIn; // incoming VAI fee\n uint256 public feeOut; // outgoing VAI fee\n uint256 public vaiMintCap; // max amount of VAI that can be minted through this contract\n uint256 public vaiMinted;\n bool public isPaused;\n\n /// @notice Event emitted when contract is paused\n event PSMPaused(address indexed admin);\n\n /// @notice Event emitted when the contract is resumed after pause\n event PSMResumed(address indexed admin);\n\n /// @notice Event emitted when feeIn state var is modified\n event FeeInChanged(uint256 oldFeeIn, uint256 newFeeIn);\n\n /// @notice Event emitted when feeOut state var is modified\n event FeeOutChanged(uint256 oldFeeOut, uint256 newFeeOut);\n\n /// @notice Event emitted when vaiMintCap state var is modified\n event VaiMintCapChanged(uint256 oldCap, uint256 newCap);\n\n /// @notice Event emitted when venusTreasury state var is modified\n event VenusTreasuryChanged(address indexed oldTreasury, address indexed newTreasury);\n\n /// @notice Event emitted when comptroller state var is modified\n event ComptrollerChanged(address indexed oldComptroller, address indexed newComptroller);\n\n /// @notice Event emitted when stable token is swapped for VAI\n event StableForVAISwapped(uint256 stableIn, uint256 vaiOut, uint256 fee);\n\n /// @notice Event emitted when stable token is swapped for VAI\n event VaiForStableSwapped(uint256 vaiBurnt, uint256 vaiFee, uint256 stableOut);\n\n /**\n * @dev Prevents functions to execute when contract is paused.\n */\n modifier isActive() {\n require(!isPaused, \"Contract is paused.\");\n _;\n }\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address vTokenAddress_, address vaiAddress_) {\n ensureNonzeroAddress(vTokenAddress_);\n ensureNonzeroAddress(vaiAddress_);\n\n address stableTokenAddress_ = IVTokenUnderlying(vTokenAddress_).underlying();\n uint256 decimals_ = DecimalProvider(stableTokenAddress_).decimals();\n require(decimals_ <= 18, \"too much decimals\");\n ONE_DOLLAR = 10 ** (36 - decimals_); // 1$ scaled to the decimals returned by our Oracle\n\n VTOKEN_ADDRESS = vTokenAddress_;\n STABLE_TOKEN_ADDRESS = stableTokenAddress_;\n VAI_ADDRESS = vaiAddress_;\n _disableInitializers();\n }\n\n /**\n * @notice Initializes the contract via Proxy Contract with the required parameters\n * @param accessControlManager_ The address of the AccessControlManager contract\n * @param venusTreasury_ The address where fees will be sent\n * @param comptroller_ The address of the Comptroller contract\n * @param feeIn_ The percentage of fees to be applied to a stablecoin -> VAI swap\n * @param feeOut_ The percentage of fees to be applied to a VAI -> stablecoin swap\n * @param vaiMintCap_ The cap for the total amount of VAI that can be minted\n */\n function initialize(\n address accessControlManager_,\n address venusTreasury_,\n address comptroller_,\n uint256 feeIn_,\n uint256 feeOut_,\n uint256 vaiMintCap_\n ) external initializer {\n ensureNonzeroAddress(accessControlManager_);\n ensureNonzeroAddress(venusTreasury_);\n ensureNonzeroAddress(comptroller_);\n ensureNonzeroAddress(OracleProviderInterface(comptroller_).oracle());\n __AccessControlled_init(accessControlManager_);\n __ReentrancyGuard_init();\n\n require(feeIn_ < BASIS_POINTS_DIVISOR, \"Invalid fee in.\");\n require(feeOut_ < BASIS_POINTS_DIVISOR, \"Invalid fee out.\");\n\n feeIn = feeIn_;\n feeOut = feeOut_;\n vaiMintCap = vaiMintCap_;\n venusTreasury = venusTreasury_;\n comptroller = comptroller_;\n }\n\n /*** Swap Functions ***/\n\n /**\n * @notice Swaps VAI for a stable token\n * @param receiver The address where the stablecoin will be sent\n * @param stableTknAmount The amount of stable tokens to receive\n */\n // @custom:event Emits VaiForStableSwapped event\n function swapVAIForStable(address receiver, uint256 stableTknAmount) external isActive nonReentrant {\n ensureNonzeroAddress(receiver);\n require(stableTknAmount > 0, \"Amount must be greater than zero.\");\n\n // calculate USD value of the stable token amount scaled in 18 decimals\n uint256 stableTknAmountUSD = previewTokenUSDAmount(stableTknAmount, FeeDirection.OUT);\n uint256 fee = _calculateFee(stableTknAmountUSD, FeeDirection.OUT);\n\n require(VAI(VAI_ADDRESS).balanceOf(msg.sender) >= stableTknAmountUSD + fee, \"Not enough VAI.\");\n require(vaiMinted >= stableTknAmountUSD, \"Can't burn more VAI than minted.\");\n\n unchecked {\n vaiMinted -= stableTknAmountUSD;\n }\n\n if (fee != 0) {\n bool success = VAI(VAI_ADDRESS).transferFrom(msg.sender, venusTreasury, fee);\n require(success, \"VAI fee transfer failed.\");\n }\n\n VAI(VAI_ADDRESS).burn(msg.sender, stableTknAmountUSD);\n IERC20Upgradeable(STABLE_TOKEN_ADDRESS).safeTransfer(receiver, stableTknAmount);\n emit VaiForStableSwapped(stableTknAmountUSD, fee, stableTknAmount);\n }\n\n /**\n * @notice Swaps stable tokens for VAI with fees.\n * @dev This function adds support to fee-on-transfer tokens. The actualTransferAmt is calculated, by recording token balance state before and after the transfer.\n * @param receiver The address that will receive the VAI tokens.\n * @param stableTknAmount The amount of stable tokens to be swapped.\n */\n // @custom:event Emits StableForVAISwapped event\n function swapStableForVAI(address receiver, uint256 stableTknAmount) external isActive nonReentrant {\n ensureNonzeroAddress(receiver);\n require(stableTknAmount > 0, \"Amount must be greater than zero.\");\n\n // transfer IN, supporting fee-on-transfer tokens\n uint256 balanceBefore = IERC20Upgradeable(STABLE_TOKEN_ADDRESS).balanceOf(address(this));\n IERC20Upgradeable(STABLE_TOKEN_ADDRESS).safeTransferFrom(msg.sender, address(this), stableTknAmount);\n uint256 balanceAfter = IERC20Upgradeable(STABLE_TOKEN_ADDRESS).balanceOf(address(this));\n\n //calculate actual transfered amount (in case of fee-on-transfer tokens)\n uint256 actualTransferAmt = balanceAfter - balanceBefore;\n\n // calculate USD value of the stable token amount scaled in 18 decimals\n uint256 actualTransferAmtInUSD = previewTokenUSDAmount(actualTransferAmt, FeeDirection.IN);\n\n //calculate feeIn\n uint256 fee = _calculateFee(actualTransferAmtInUSD, FeeDirection.IN);\n uint256 vaiToMint = actualTransferAmtInUSD - fee;\n\n require(vaiMinted + actualTransferAmtInUSD <= vaiMintCap, \"VAI mint cap reached.\");\n unchecked {\n vaiMinted += actualTransferAmtInUSD;\n }\n\n // mint VAI to receiver\n VAI(VAI_ADDRESS).mint(receiver, vaiToMint);\n\n // mint VAI fee to venus treasury\n if (fee != 0) {\n VAI(VAI_ADDRESS).mint(venusTreasury, fee);\n }\n\n emit StableForVAISwapped(actualTransferAmt, vaiToMint, fee);\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Pause the PSM contract\n * @dev Reverts if the contract is already paused\n */\n // @custom:event Emits PSMPaused event\n function pause() external {\n _checkAccessAllowed(\"pause()\");\n require(!isPaused, \"PSM is already paused.\");\n isPaused = true;\n emit PSMPaused(msg.sender);\n }\n\n /**\n * @notice Resume the PSM contract\n * @dev Reverts if the contract is not paused\n */\n // @custom:event Emits PSMResumed event\n function resume() external {\n _checkAccessAllowed(\"resume()\");\n require(isPaused, \"PSM is not paused.\");\n isPaused = false;\n emit PSMResumed(msg.sender);\n }\n\n /**\n * @notice Set the fee percentage for incoming swaps\n * @dev Reverts if the new fee percentage is invalid (greater than or equal to BASIS_POINTS_DIVISOR)\n * @param feeIn_ The new fee percentage for incoming swaps\n */\n // @custom:event Emits FeeInChanged event\n function setFeeIn(uint256 feeIn_) external {\n _checkAccessAllowed(\"setFeeIn(uint256)\");\n // feeIn = 10000 = 100%\n require(feeIn_ < BASIS_POINTS_DIVISOR, \"Invalid fee.\");\n uint256 oldFeeIn = feeIn;\n feeIn = feeIn_;\n emit FeeInChanged(oldFeeIn, feeIn_);\n }\n\n /**\n * @notice Set the fee percentage for outgoing swaps\n * @dev Reverts if the new fee percentage is invalid (greater than or equal to BASIS_POINTS_DIVISOR)\n * @param feeOut_ The new fee percentage for outgoing swaps\n */\n // @custom:event Emits FeeOutChanged event\n function setFeeOut(uint256 feeOut_) external {\n _checkAccessAllowed(\"setFeeOut(uint256)\");\n // feeOut = 10000 = 100%\n require(feeOut_ < BASIS_POINTS_DIVISOR, \"Invalid fee.\");\n uint256 oldFeeOut = feeOut;\n feeOut = feeOut_;\n emit FeeOutChanged(oldFeeOut, feeOut_);\n }\n\n /**\n * @dev Set the maximum amount of VAI that can be minted through this contract\n * @param vaiMintCap_ The new maximum amount of VAI that can be minted\n */\n // @custom:event Emits VaiMintCapChanged event\n function setVaiMintCap(uint256 vaiMintCap_) external {\n _checkAccessAllowed(\"setVaiMintCap(uint256)\");\n uint256 oldVaiMintCap = vaiMintCap;\n vaiMintCap = vaiMintCap_;\n emit VaiMintCapChanged(oldVaiMintCap, vaiMintCap_);\n }\n\n /**\n * @notice Set the address of the Venus Treasury contract\n * @dev Reverts if the new address is zero\n * @param venusTreasury_ The new address of the Venus Treasury contract\n */\n // @custom:event Emits VenusTreasuryChanged event\n function setVenusTreasury(address venusTreasury_) external {\n _checkAccessAllowed(\"setVenusTreasury(address)\");\n ensureNonzeroAddress(venusTreasury_);\n address oldTreasuryAddress = venusTreasury;\n venusTreasury = venusTreasury_;\n emit VenusTreasuryChanged(oldTreasuryAddress, venusTreasury_);\n }\n\n /**\n * @notice Set the address of the Comptroller contract from which we obtain the oracle address\n * @dev Reverts if the new address is zero or the oracle address returned from Comptroller is zero\n * @param comptroller_ The new address of the Comptroller contract\n */\n // @custom:event Emits ComptrollerChanged event\n function setComptroller(address comptroller_) external {\n _checkAccessAllowed(\"setComptroller(address)\");\n ensureNonzeroAddress(comptroller_);\n ensureNonzeroAddress(OracleProviderInterface(comptroller_).oracle());\n address oldComptrollerAddress = comptroller;\n comptroller = comptroller_;\n emit ComptrollerChanged(oldComptrollerAddress, comptroller_);\n }\n\n /*** Helper Functions ***/\n\n /**\n * @dev Calculates the USD value of the given amount of stable tokens depending on the swap direction.\n * @param amount The amount of stable tokens.\n * @param direction The direction of the swap.\n * @return The USD value of the given amount of stable tokens scaled by 1e18 taking into account the direction of the swap\n */\n function previewTokenUSDAmount(uint256 amount, FeeDirection direction) internal view returns (uint256) {\n return (amount * getPriceInUSD(direction)) / MANTISSA_ONE;\n }\n\n /**\n * @notice Get the price of stable token in USD\n * @dev This function returns either min(1$,oraclePrice) or max(1$,oraclePrice) with a decimal scale (36 - asset_decimals). E.g. for 8 decimal token 1$ will be 1e28\n * @param direction The direction of the swap: FeeDirection.IN or FeeDirection.OUT\n * @return The price in USD, adjusted based on the selected direction\n */\n function getPriceInUSD(FeeDirection direction) internal view returns (uint256) {\n address priceOracleAddress = OracleProviderInterface(comptroller).oracle();\n // get price with a scale = (36 - asset_decimals)\n uint256 price = IPriceOracle(priceOracleAddress).getUnderlyingPrice(VTOKEN_ADDRESS);\n\n if (direction == FeeDirection.IN) {\n // MIN(1, price)\n return price < ONE_DOLLAR ? price : ONE_DOLLAR;\n } else {\n // MAX(1, price)\n return price > ONE_DOLLAR ? price : ONE_DOLLAR;\n }\n }\n\n /**\n * @notice Calculate the fee amount based on the input amount and fee percentage\n * @dev Reverts if the fee percentage calculation results in rounding down to 0\n * @param amount The input amount to calculate the fee from\n * @param direction The direction of the fee: FeeDirection.IN or FeeDirection.OUT\n * @return The fee amount\n */\n function _calculateFee(uint256 amount, FeeDirection direction) internal view returns (uint256) {\n uint256 feePercent;\n if (direction == FeeDirection.IN) {\n feePercent = feeIn;\n } else {\n feePercent = feeOut;\n }\n if (feePercent == 0) {\n return 0;\n } else {\n // checking if the percent calculation will result in rounding down to 0\n require(amount * feePercent >= BASIS_POINTS_DIVISOR, \"Amount too small.\");\n return (amount * feePercent) / BASIS_POINTS_DIVISOR;\n }\n }\n\n /**\n * @notice Checks that the address is not the zero address\n * @param someone The address to check\n */\n function ensureNonzeroAddress(address someone) private pure {\n require(someone != address(0), \"Can't be zero address.\");\n }\n}"
42
+ }
43
+ },
44
+ "settings": {
45
+ "optimizer": {
46
+ "enabled": true,
47
+ "runs": 10000
48
+ },
49
+ "outputSelection": {
50
+ "*": {
51
+ "*": [
52
+ "storageLayout",
53
+ "abi",
54
+ "evm.bytecode",
55
+ "evm.deployedBytecode",
56
+ "evm.methodIdentifiers",
57
+ "metadata",
58
+ "devdoc",
59
+ "userdoc",
60
+ "evm.gasEstimates"
61
+ ],
62
+ "": ["ast"]
63
+ }
64
+ },
65
+ "metadata": {
66
+ "useLiteralContent": true
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("ethers/lib/utils");
4
+ const hardhat_1 = require("hardhat");
5
+ const mainnet_json_1 = require("../networks/mainnet.json");
6
+ const testnet_json_1 = require("../networks/testnet.json");
7
+ const ADDRESSES = {
8
+ bsctestnet: testnet_json_1.Contracts,
9
+ bscmainnet: mainnet_json_1.Contracts,
10
+ };
11
+ const func = async function (hre) {
12
+ const { deployments, network, getNamedAccounts } = hre;
13
+ const { deploy } = deployments;
14
+ const { deployer } = await getNamedAccounts();
15
+ const networkName = network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
16
+ const USDTAddress = ADDRESSES[networkName].USDT;
17
+ const VAIAddress = ADDRESSES[networkName].VAI;
18
+ const FEE_IN = 0;
19
+ const FEE_OUT = 10; // 10bps
20
+ const VAI_MINT_CAP = (0, utils_1.parseUnits)("5000000", 18); // 5M
21
+ const treasuryAddresses = {
22
+ bsctestnet: "0xFEA1c651A47FE29dB9b1bf3cC1f224d8D9CFF68C",
23
+ bscmainnet: "0xF322942f644A996A617BD29c16bd7d231d9F35E9", // Venus Treasury
24
+ };
25
+ const oracleAddresses = {
26
+ bsctestnet: "0x3cD69251D04A28d887Ac14cbe2E14c52F3D57823",
27
+ bscmainnet: "0x6592b5DE802159F3E74B2486b091D11a8256ab8A",
28
+ };
29
+ const acmAddresses = {
30
+ bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
31
+ bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
32
+ };
33
+ await deploy("PegStability_USDT", {
34
+ contract: "PegStability",
35
+ from: deployer,
36
+ args: [USDTAddress, VAIAddress],
37
+ log: true,
38
+ autoMine: true,
39
+ proxy: {
40
+ owner: ADDRESSES[networkName].Timelock,
41
+ proxyContract: "OpenZeppelinTransparentProxy",
42
+ execute: {
43
+ methodName: "initialize",
44
+ args: [
45
+ acmAddresses[networkName],
46
+ treasuryAddresses[networkName],
47
+ oracleAddresses[networkName],
48
+ FEE_IN,
49
+ FEE_OUT,
50
+ VAI_MINT_CAP,
51
+ ],
52
+ },
53
+ },
54
+ });
55
+ const psm = await hardhat_1.ethers.getContract("PegStability_USDT");
56
+ if (network.name !== "hardhat") {
57
+ const timelockAddress = ADDRESSES[networkName].Timelock;
58
+ await psm.transferOwnership(timelockAddress);
59
+ console.log(`PSM Contract (${psm.address}) owner changed from ${deployer} to ${timelockAddress}`);
60
+ }
61
+ return hre.network.live; // when live network, record the script as executed to prevent rexecution
62
+ };
63
+ func.id = "psm_initial_deploy"; // id required to prevent re-execution
64
+ func.tags = ["PSM"];
65
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mainnet_json_1 = require("../networks/mainnet.json");
4
+ const testnet_json_1 = require("../networks/testnet.json");
5
+ const ADDRESSES = {
6
+ bsctestnet: testnet_json_1.Contracts,
7
+ bscmainnet: mainnet_json_1.Contracts,
8
+ };
9
+ const func = async function (hre) {
10
+ const { deployments, network, getNamedAccounts } = hre;
11
+ const { deploy, catchUnknownSigner } = deployments;
12
+ const { deployer } = await getNamedAccounts();
13
+ const networkName = network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
14
+ const USDTAddress = ADDRESSES[networkName].USDT;
15
+ const VAIAddress = ADDRESSES[networkName].VAI;
16
+ await catchUnknownSigner(deploy("PegStability_USDT", {
17
+ contract: "PegStability",
18
+ from: deployer,
19
+ args: [USDTAddress, VAIAddress],
20
+ log: true,
21
+ autoMine: true,
22
+ proxy: {
23
+ owner: ADDRESSES[networkName].Timelock,
24
+ proxyContract: "OpenZeppelinTransparentProxy",
25
+ },
26
+ }));
27
+ };
28
+ func.tags = ["PSM"];
29
+ exports.default = func;
@@ -90,7 +90,7 @@ const config = {
90
90
  networks: {
91
91
  hardhat: isFork(),
92
92
  bsctestnet: {
93
- url: process.env.BSC_TESTNET_NODE || "https://data-seed-prebsc-1-s1.binance.org:8545",
93
+ url: process.env.BSC_ARCHIVE_NODE_URL || "https://data-seed-prebsc-1-s1.binance.org:8545",
94
94
  chainId: 97,
95
95
  accounts: {
96
96
  mnemonic: process.env.MNEMONIC || "",
@@ -147,7 +147,7 @@ function isFork() {
147
147
  allowUnlimitedContractSize: false,
148
148
  loggingEnabled: false,
149
149
  forking: {
150
- url: process.env.BSC_ARCHIVE_NODE || "",
150
+ url: process.env.BSC_ARCHIVE_NODE_URL || "",
151
151
  blockNumber: 21068448,
152
152
  },
153
153
  accounts: {