@venusprotocol/protocol-reserve 1.0.0-dev.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json +2 -2
- package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/{draft-IERC20PermitUpgradeable.sol → IERC20PermitUpgradeable.sol}/IERC20PermitUpgradeable.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol/SafeERC20Upgradeable.json +2 -2
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.json +2 -2
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.dbg.json +1 -1
- package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.dbg.json +1 -1
- package/artifacts/@venusprotocol/isolated-pools/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.dbg.json +1 -1
- package/artifacts/build-info/5e0d0fa03533470b2e430f8020bc271c.json +1 -0
- package/artifacts/contracts/Interfaces/ComptrollerInterface.sol/ComptrollerInterface.dbg.json +1 -1
- package/artifacts/contracts/Interfaces/IIncomeDestination.sol/IIncomeDestination.dbg.json +1 -1
- package/artifacts/contracts/Interfaces/IProtocolShareReserve.sol/IProtocolShareReserve.dbg.json +1 -1
- package/artifacts/contracts/Interfaces/IVToken.sol/IVToken.dbg.json +1 -1
- package/artifacts/contracts/Interfaces/PoolRegistryInterface.sol/PoolRegistryInterface.dbg.json +1 -1
- package/artifacts/contracts/ProtocolReserve/ProtocolShareReserve.sol/ProtocolShareReserve.dbg.json +1 -1
- package/artifacts/contracts/ProtocolReserve/ProtocolShareReserve.sol/ProtocolShareReserve.json +67 -56
- package/artifacts/contracts/Test/Mocks/MockToken.sol/MockToken.dbg.json +1 -1
- package/artifacts/contracts/Test/Mocks/MockToken.sol/MockToken.json +2 -2
- package/contracts/Interfaces/IProtocolShareReserve.sol +5 -1
- package/contracts/ProtocolReserve/ProtocolShareReserve.sol +70 -86
- package/contracts/Test/Mocks/MockToken.sol +5 -1
- package/deploy/1-deploy.ts +64 -0
- package/deployments/bscmainnet/.chainId +1 -0
- package/deployments/bscmainnet/DefaultProxyAdmin.json +257 -0
- package/deployments/bscmainnet/ProtocolShareReserve.json +1054 -0
- package/deployments/bscmainnet/ProtocolShareReserve_Implementation.json +1264 -0
- package/deployments/bscmainnet/ProtocolShareReserve_Proxy.json +277 -0
- package/deployments/bscmainnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json +78 -0
- package/deployments/bscmainnet/solcInputs/45a7e25696ff2229490239636d073de0.json +90 -0
- package/deployments/bscmainnet/solcInputs/c87a4970e440c0598abee31750358915.json +90 -0
- package/deployments/bscmainnet/solcInputs/f7c7133e4506082d7aa8242a8f52a4c9.json +87 -0
- package/deployments/bsctestnet/.chainId +1 -0
- package/deployments/bsctestnet/DefaultProxyAdmin.json +257 -0
- package/deployments/bsctestnet/ProtocolShareReserve.json +1054 -0
- package/deployments/bsctestnet/ProtocolShareReserve_Implementation.json +1264 -0
- package/deployments/bsctestnet/ProtocolShareReserve_Proxy.json +277 -0
- package/deployments/bsctestnet/solcInputs/0e89febeebc7444140de8e67c9067d2c.json +78 -0
- package/deployments/bsctestnet/solcInputs/45a7e25696ff2229490239636d073de0.json +90 -0
- package/deployments/bsctestnet/solcInputs/c87a4970e440c0598abee31750358915.json +90 -0
- package/deployments/bsctestnet/solcInputs/f7c7133e4506082d7aa8242a8f52a4c9.json +87 -0
- package/package.json +56 -61
- package/typechain/{@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.ts → AccessControlledV8.d.ts} +125 -128
- package/typechain/ComptrollerInterface.d.ts +101 -0
- package/typechain/ContextUpgradeable.d.ts +92 -0
- package/typechain/ERC20.d.ts +441 -0
- package/typechain/IAccessControl.d.ts +333 -0
- package/typechain/IAccessControlManagerV8.d.ts +504 -0
- package/typechain/IERC20.d.ts +324 -0
- package/typechain/{@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.ts → IERC20Metadata.d.ts} +146 -169
- package/typechain/IERC20PermitUpgradeable.d.ts +187 -0
- package/typechain/IERC20Upgradeable.d.ts +324 -0
- package/typechain/IIncomeDestination.d.ts +122 -0
- package/typechain/IProtocolShareReserve.d.ts +127 -0
- package/typechain/IVToken.d.ts +98 -0
- package/typechain/Initializable.d.ts +92 -0
- package/typechain/MaxLoopsLimitHelper.d.ts +128 -0
- package/typechain/MockToken.d.ts +469 -0
- package/typechain/{@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.ts → Ownable2StepUpgradeable.d.ts} +102 -105
- package/typechain/OwnableUpgradeable.d.ts +193 -0
- package/typechain/PoolRegistryInterface.d.ts +121 -0
- package/typechain/{contracts/ProtocolReserve/ProtocolShareReserve.ts → ProtocolShareReserve.d.ts} +538 -486
- package/typechain/ReentrancyGuardUpgradeable.d.ts +92 -0
- package/typechain/common.d.ts +35 -0
- package/typechain/factories/{@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8__factory.ts → AccessControlledV8__factory.ts} +5 -6
- package/typechain/factories/{contracts/Interfaces/ComptrollerInterface__factory.ts → ComptrollerInterface__factory.ts} +5 -6
- package/typechain/factories/{@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.ts → ContextUpgradeable__factory.ts} +5 -6
- package/typechain/factories/{@openzeppelin/contracts/token/ERC20/ERC20__factory.ts → ERC20__factory.ts} +21 -33
- package/typechain/factories/{@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8__factory.ts → IAccessControlManagerV8__factory.ts} +5 -6
- package/typechain/factories/{@openzeppelin/contracts/access/IAccessControl__factory.ts → IAccessControl__factory.ts} +5 -6
- package/typechain/factories/{@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata__factory.ts → IERC20Metadata__factory.ts} +5 -6
- package/typechain/factories/{@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable__factory.ts → IERC20PermitUpgradeable__factory.ts} +5 -6
- package/typechain/factories/{@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable__factory.ts → IERC20Upgradeable__factory.ts} +5 -6
- package/typechain/factories/{@openzeppelin/contracts/token/ERC20/IERC20__factory.ts → IERC20__factory.ts} +4 -8
- package/typechain/factories/{contracts/Interfaces/IIncomeDestination__factory.ts → IIncomeDestination__factory.ts} +5 -6
- package/typechain/factories/{contracts/Interfaces/IProtocolShareReserve__factory.ts → IProtocolShareReserve__factory.ts} +5 -6
- package/typechain/factories/{contracts/Interfaces/IVToken__factory.ts → IVToken__factory.ts} +4 -8
- package/typechain/factories/{@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.ts → Initializable__factory.ts} +4 -8
- package/typechain/factories/{@venusprotocol/isolated-pools/contracts/MaxLoopsLimitHelper__factory.ts → MaxLoopsLimitHelper__factory.ts} +5 -6
- package/typechain/factories/{contracts/Test/Mocks/MockToken__factory.ts → MockToken__factory.ts} +24 -36
- package/typechain/factories/{@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable__factory.ts → Ownable2StepUpgradeable__factory.ts} +5 -6
- package/typechain/factories/{@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.ts → OwnableUpgradeable__factory.ts} +5 -6
- package/typechain/factories/{contracts/Interfaces/PoolRegistryInterface__factory.ts → PoolRegistryInterface__factory.ts} +5 -6
- package/typechain/factories/ProtocolShareReserve__factory.ts +869 -0
- package/typechain/factories/{@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable__factory.ts → ReentrancyGuardUpgradeable__factory.ts} +5 -6
- package/typechain/index.ts +42 -55
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.dbg.json +0 -4
- package/artifacts/build-info/1b4d833fe9f0ac50f7e6ab5ae3115468.json +0 -1
- package/artifacts/contracts/Interfaces/IPrime.sol/IPrime.dbg.json +0 -4
- package/artifacts/contracts/Interfaces/IPrime.sol/IPrime.json +0 -74
- package/contracts/Interfaces/IPrime.sol +0 -12
- package/contracts/interfaces/IProtocolShareReserve.sol +0 -12
- package/contracts/test/Mocks/MockToken.sol +0 -22
- package/typechain/@openzeppelin/contracts/access/IAccessControl.ts +0 -343
- package/typechain/@openzeppelin/contracts/access/index.ts +0 -4
- package/typechain/@openzeppelin/contracts/index.ts +0 -11
- package/typechain/@openzeppelin/contracts/token/ERC20/ERC20.ts +0 -466
- package/typechain/@openzeppelin/contracts/token/ERC20/IERC20.ts +0 -344
- package/typechain/@openzeppelin/contracts/token/ERC20/extensions/index.ts +0 -4
- package/typechain/@openzeppelin/contracts/token/ERC20/index.ts +0 -10
- package/typechain/@openzeppelin/contracts/token/index.ts +0 -8
- package/typechain/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.ts +0 -190
- package/typechain/@openzeppelin/contracts-upgradeable/access/index.ts +0 -5
- package/typechain/@openzeppelin/contracts-upgradeable/index.ts +0 -20
- package/typechain/@openzeppelin/contracts-upgradeable/proxy/index.ts +0 -8
- package/typechain/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.ts +0 -72
- package/typechain/@openzeppelin/contracts-upgradeable/proxy/utils/index.ts +0 -4
- package/typechain/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.ts +0 -72
- package/typechain/@openzeppelin/contracts-upgradeable/security/index.ts +0 -4
- package/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.ts +0 -344
- package/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/IERC20PermitUpgradeable.ts +0 -195
- package/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/index.ts +0 -4
- package/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/index.ts +0 -8
- package/typechain/@openzeppelin/contracts-upgradeable/token/ERC20/index.ts +0 -9
- package/typechain/@openzeppelin/contracts-upgradeable/token/index.ts +0 -8
- package/typechain/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.ts +0 -72
- package/typechain/@openzeppelin/contracts-upgradeable/utils/index.ts +0 -4
- package/typechain/@openzeppelin/index.ts +0 -11
- package/typechain/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.ts +0 -530
- package/typechain/@venusprotocol/governance-contracts/contracts/Governance/index.ts +0 -5
- package/typechain/@venusprotocol/governance-contracts/contracts/index.ts +0 -8
- package/typechain/@venusprotocol/governance-contracts/index.ts +0 -8
- package/typechain/@venusprotocol/index.ts +0 -11
- package/typechain/@venusprotocol/isolated-pools/contracts/MaxLoopsLimitHelper.ts +0 -119
- package/typechain/@venusprotocol/isolated-pools/contracts/index.ts +0 -4
- package/typechain/@venusprotocol/isolated-pools/index.ts +0 -8
- package/typechain/common.ts +0 -48
- package/typechain/contracts/Interfaces/ComptrollerInterface.ts +0 -90
- package/typechain/contracts/Interfaces/IIncomeDestination.ts +0 -112
- package/typechain/contracts/Interfaces/IPrime.ts +0 -205
- package/typechain/contracts/Interfaces/IProtocolShareReserve.ts +0 -122
- package/typechain/contracts/Interfaces/IVToken.ts +0 -87
- package/typechain/contracts/Interfaces/PoolRegistryInterface.ts +0 -110
- package/typechain/contracts/Interfaces/index.ts +0 -9
- package/typechain/contracts/ProtocolReserve/index.ts +0 -4
- package/typechain/contracts/Test/Mocks/MockToken.ts +0 -498
- package/typechain/contracts/Test/Mocks/index.ts +0 -4
- package/typechain/contracts/Test/index.ts +0 -8
- package/typechain/contracts/index.ts +0 -14
- package/typechain/factories/@openzeppelin/contracts/access/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts/index.ts +0 -5
- package/typechain/factories/@openzeppelin/contracts/token/ERC20/extensions/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts/token/ERC20/index.ts +0 -6
- package/typechain/factories/@openzeppelin/contracts/token/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts-upgradeable/access/index.ts +0 -5
- package/typechain/factories/@openzeppelin/contracts-upgradeable/index.ts +0 -8
- package/typechain/factories/@openzeppelin/contracts-upgradeable/proxy/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts-upgradeable/security/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts-upgradeable/token/ERC20/index.ts +0 -5
- package/typechain/factories/@openzeppelin/contracts-upgradeable/token/index.ts +0 -4
- package/typechain/factories/@openzeppelin/contracts-upgradeable/utils/index.ts +0 -4
- package/typechain/factories/@openzeppelin/index.ts +0 -5
- package/typechain/factories/@venusprotocol/governance-contracts/contracts/Governance/index.ts +0 -5
- package/typechain/factories/@venusprotocol/governance-contracts/contracts/index.ts +0 -4
- package/typechain/factories/@venusprotocol/governance-contracts/index.ts +0 -4
- package/typechain/factories/@venusprotocol/index.ts +0 -5
- package/typechain/factories/@venusprotocol/isolated-pools/contracts/index.ts +0 -4
- package/typechain/factories/@venusprotocol/isolated-pools/index.ts +0 -4
- package/typechain/factories/contracts/Interfaces/IPrime__factory.ts +0 -87
- package/typechain/factories/contracts/Interfaces/index.ts +0 -9
- package/typechain/factories/contracts/ProtocolReserve/ProtocolShareReserve__factory.ts +0 -867
- package/typechain/factories/contracts/ProtocolReserve/index.ts +0 -4
- package/typechain/factories/contracts/Test/Mocks/index.ts +0 -4
- package/typechain/factories/contracts/Test/index.ts +0 -4
- package/typechain/factories/contracts/index.ts +0 -6
- package/typechain/factories/index.ts +0 -6
- package/typechain/hardhat.d.ts +0 -231
|
@@ -9,7 +9,6 @@ import { MaxLoopsLimitHelper } from "@venusprotocol/isolated-pools/contracts/Max
|
|
|
9
9
|
import { IProtocolShareReserve } from "../Interfaces/IProtocolShareReserve.sol";
|
|
10
10
|
import { ComptrollerInterface } from "../Interfaces/ComptrollerInterface.sol";
|
|
11
11
|
import { PoolRegistryInterface } from "../Interfaces/PoolRegistryInterface.sol";
|
|
12
|
-
import { IPrime } from "../Interfaces/IPrime.sol";
|
|
13
12
|
import { IVToken } from "../Interfaces/IVToken.sol";
|
|
14
13
|
import { IIncomeDestination } from "../Interfaces/IIncomeDestination.sol";
|
|
15
14
|
|
|
@@ -27,17 +26,17 @@ contract ProtocolShareReserve is
|
|
|
27
26
|
using SafeERC20Upgradeable for IERC20Upgradeable;
|
|
28
27
|
|
|
29
28
|
/// @notice protocol income is categorized into two schemas.
|
|
30
|
-
/// The first schema is
|
|
31
|
-
/// The second schema is for
|
|
29
|
+
/// The first schema is for spread income
|
|
30
|
+
/// The second schema is for liquidation income
|
|
32
31
|
enum Schema {
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
PROTOCOL_RESERVES,
|
|
33
|
+
ADDITIONAL_REVENUE
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
struct DistributionConfig {
|
|
38
37
|
Schema schema;
|
|
39
38
|
/// @dev percenatge is represented without any scale
|
|
40
|
-
|
|
39
|
+
uint8 percentage;
|
|
41
40
|
address destination;
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -53,13 +52,10 @@ contract ProtocolShareReserve is
|
|
|
53
52
|
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
54
53
|
address public immutable vBNB;
|
|
55
54
|
|
|
56
|
-
/// @notice address of Prime contract
|
|
57
|
-
address public prime;
|
|
58
|
-
|
|
59
55
|
/// @notice address of pool registry contract
|
|
60
56
|
address public poolRegistry;
|
|
61
57
|
|
|
62
|
-
|
|
58
|
+
uint8 public constant MAX_PERCENT = 100;
|
|
63
59
|
|
|
64
60
|
/// @notice comptroller => asset => schema => balance
|
|
65
61
|
mapping(address => mapping(address => mapping(Schema => uint256))) public assetsReserves;
|
|
@@ -73,9 +69,6 @@ contract ProtocolShareReserve is
|
|
|
73
69
|
/// @notice Emitted when pool registry address is updated
|
|
74
70
|
event PoolRegistryUpdated(address indexed oldPoolRegistry, address indexed newPoolRegistry);
|
|
75
71
|
|
|
76
|
-
/// @notice Emitted when prime address is updated
|
|
77
|
-
event PrimeUpdated(address indexed oldPrime, address indexed newPrime);
|
|
78
|
-
|
|
79
72
|
/// @notice Event emitted after the updation of the assets reserves.
|
|
80
73
|
event AssetsReservesUpdated(
|
|
81
74
|
address indexed comptroller,
|
|
@@ -106,13 +99,16 @@ contract ProtocolShareReserve is
|
|
|
106
99
|
/// @notice Event emitted when distribution configuration is updated
|
|
107
100
|
event DistributionConfigUpdated(
|
|
108
101
|
address indexed destination,
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
uint8 oldPercentage,
|
|
103
|
+
uint8 newPercentage,
|
|
111
104
|
Schema schema
|
|
112
105
|
);
|
|
113
106
|
|
|
114
107
|
/// @notice Event emitted when distribution configuration is added
|
|
115
|
-
event DistributionConfigAdded(address indexed destination,
|
|
108
|
+
event DistributionConfigAdded(address indexed destination, uint8 percentage, Schema schema);
|
|
109
|
+
|
|
110
|
+
/// @notice Event emitted when distribution configuration is removed
|
|
111
|
+
event DistributionConfigRemoved(address indexed destination, uint8 percentage, Schema schema);
|
|
116
112
|
|
|
117
113
|
/**
|
|
118
114
|
* @dev Constructor to initialize the immutable variables
|
|
@@ -121,7 +117,11 @@ contract ProtocolShareReserve is
|
|
|
121
117
|
* @param _vbnb The address of vBNB
|
|
122
118
|
*/
|
|
123
119
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
124
|
-
constructor(
|
|
120
|
+
constructor(
|
|
121
|
+
address _corePoolComptroller,
|
|
122
|
+
address _wbnb,
|
|
123
|
+
address _vbnb
|
|
124
|
+
) {
|
|
125
125
|
if (_corePoolComptroller == address(0)) revert InvalidAddress();
|
|
126
126
|
if (_wbnb == address(0)) revert InvalidAddress();
|
|
127
127
|
if (_vbnb == address(0)) revert InvalidAddress();
|
|
@@ -156,30 +156,16 @@ contract ProtocolShareReserve is
|
|
|
156
156
|
poolRegistry = _poolRegistry;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
/**
|
|
160
|
-
* @dev Prime contract address setter.
|
|
161
|
-
* @param _prime Address of the prime contract
|
|
162
|
-
*/
|
|
163
|
-
function setPrime(address _prime) external onlyOwner {
|
|
164
|
-
if (_prime == address(0)) revert InvalidAddress();
|
|
165
|
-
emit PrimeUpdated(prime, _prime);
|
|
166
|
-
prime = _prime;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
159
|
/**
|
|
170
160
|
* @dev Add or update destination targets based on destination address
|
|
171
161
|
* @param configs configurations of the destinations.
|
|
172
162
|
*/
|
|
173
|
-
function addOrUpdateDistributionConfigs(DistributionConfig[]
|
|
163
|
+
function addOrUpdateDistributionConfigs(DistributionConfig[] calldata configs) external nonReentrant {
|
|
174
164
|
_checkAccessAllowed("addOrUpdateDistributionConfigs(DistributionConfig[])");
|
|
175
165
|
|
|
176
|
-
//we need to accrue and release funds to prime before updating the distribution configuration
|
|
177
|
-
//because prime relies on getUnreleasedFunds and its return value may change after config update
|
|
178
|
-
_accrueAndReleaseFundsToPrime();
|
|
179
|
-
|
|
180
166
|
for (uint256 i = 0; i < configs.length; ) {
|
|
181
167
|
DistributionConfig memory _config = configs[i];
|
|
182
|
-
|
|
168
|
+
if (_config.destination == address(0)) revert InvalidAddress();
|
|
183
169
|
|
|
184
170
|
bool updated = false;
|
|
185
171
|
uint256 distributionTargetsLength = distributionTargets.length;
|
|
@@ -217,14 +203,50 @@ contract ProtocolShareReserve is
|
|
|
217
203
|
_ensureMaxLoops(distributionTargets.length);
|
|
218
204
|
}
|
|
219
205
|
|
|
206
|
+
/**
|
|
207
|
+
* @dev Remove destionation target if percentage is 0
|
|
208
|
+
* @param schema schema of the configuration
|
|
209
|
+
* @param destination destination address of the configuration
|
|
210
|
+
*/
|
|
211
|
+
function removeDistributionConfig(Schema schema, address destination) external {
|
|
212
|
+
_checkAccessAllowed("removeDistributionConfig(Schema,address)");
|
|
213
|
+
|
|
214
|
+
uint256 distributionIndex;
|
|
215
|
+
bool found = false;
|
|
216
|
+
for (uint256 i = 0; i < distributionTargets.length; ) {
|
|
217
|
+
DistributionConfig storage config = distributionTargets[i];
|
|
218
|
+
|
|
219
|
+
if (schema == config.schema && destination == config.destination && config.percentage == 0) {
|
|
220
|
+
found = true;
|
|
221
|
+
distributionIndex = i;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
unchecked {
|
|
226
|
+
++i;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (found) {
|
|
231
|
+
emit DistributionConfigRemoved(
|
|
232
|
+
distributionTargets[distributionIndex].destination,
|
|
233
|
+
distributionTargets[distributionIndex].percentage,
|
|
234
|
+
distributionTargets[distributionIndex].schema
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
distributionTargets[distributionIndex] = distributionTargets[distributionTargets.length - 1];
|
|
238
|
+
distributionTargets.pop();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
_ensurePercentages();
|
|
242
|
+
}
|
|
243
|
+
|
|
220
244
|
/**
|
|
221
245
|
* @dev Release funds
|
|
222
246
|
* @param comptroller the comptroller address of the pool
|
|
223
247
|
* @param assets assets to be released to distribution targets
|
|
224
248
|
*/
|
|
225
|
-
function releaseFunds(address comptroller, address[]
|
|
226
|
-
_accruePrimeInterest();
|
|
227
|
-
|
|
249
|
+
function releaseFunds(address comptroller, address[] calldata assets) external nonReentrant {
|
|
228
250
|
for (uint256 i = 0; i < assets.length; ) {
|
|
229
251
|
_releaseFund(comptroller, assets[i]);
|
|
230
252
|
|
|
@@ -307,7 +329,7 @@ contract ProtocolShareReserve is
|
|
|
307
329
|
PoolRegistryInterface(poolRegistry).getVTokenForAsset(comptroller, asset) == address(0)
|
|
308
330
|
) revert InvalidAddress();
|
|
309
331
|
|
|
310
|
-
Schema schema =
|
|
332
|
+
Schema schema = _getSchema(incomeType);
|
|
311
333
|
uint256 currentBalance = IERC20Upgradeable(asset).balanceOf(address(this));
|
|
312
334
|
uint256 assetReserve = totalAssetReserve[asset];
|
|
313
335
|
|
|
@@ -323,39 +345,6 @@ contract ProtocolShareReserve is
|
|
|
323
345
|
}
|
|
324
346
|
}
|
|
325
347
|
|
|
326
|
-
/**
|
|
327
|
-
* @dev Fetches the list of prime markets and then accrues interest and
|
|
328
|
-
* releases the funds to prime for each market
|
|
329
|
-
*/
|
|
330
|
-
function _accrueAndReleaseFundsToPrime() internal {
|
|
331
|
-
address[] memory markets = IPrime(prime).getAllMarkets();
|
|
332
|
-
for (uint256 i = 0; i < markets.length; ) {
|
|
333
|
-
address market = markets[i];
|
|
334
|
-
IPrime(prime).accrueInterest(market);
|
|
335
|
-
_releaseFund(CORE_POOL_COMPTROLLER, _getUnderlying(market));
|
|
336
|
-
|
|
337
|
-
unchecked {
|
|
338
|
-
++i;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* @dev Fetches the list of prime markets and then accrues interest
|
|
345
|
-
* to prime for each market
|
|
346
|
-
*/
|
|
347
|
-
function _accruePrimeInterest() internal {
|
|
348
|
-
address[] memory markets = IPrime(prime).getAllMarkets();
|
|
349
|
-
for (uint256 i = 0; i < markets.length; ) {
|
|
350
|
-
address market = markets[i];
|
|
351
|
-
IPrime(prime).accrueInterest(market);
|
|
352
|
-
|
|
353
|
-
unchecked {
|
|
354
|
-
++i;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
348
|
/**
|
|
360
349
|
* @dev asset from a particular pool to be release to distribution targets
|
|
361
350
|
* @param comptroller Comptroller address(pool)
|
|
@@ -385,10 +374,12 @@ contract ProtocolShareReserve is
|
|
|
385
374
|
uint256 transferAmount = (schemaBalances[uint256(_config.schema)] * _config.percentage) / MAX_PERCENT;
|
|
386
375
|
totalTransferAmounts[uint256(_config.schema)] += transferAmount;
|
|
387
376
|
|
|
388
|
-
|
|
389
|
-
|
|
377
|
+
if (transferAmount != 0) {
|
|
378
|
+
IERC20Upgradeable(asset).safeTransfer(_config.destination, transferAmount);
|
|
379
|
+
IIncomeDestination(_config.destination).updateAssetsState(comptroller, asset);
|
|
390
380
|
|
|
391
|
-
|
|
381
|
+
emit AssetReleased(_config.destination, asset, _config.schema, _config.percentage, transferAmount);
|
|
382
|
+
}
|
|
392
383
|
|
|
393
384
|
unchecked {
|
|
394
385
|
++i;
|
|
@@ -416,22 +407,15 @@ contract ProtocolShareReserve is
|
|
|
416
407
|
}
|
|
417
408
|
|
|
418
409
|
/**
|
|
419
|
-
* @dev Returns the schema based on
|
|
420
|
-
* @param comptroller Comptroller address(pool)
|
|
421
|
-
* @param asset Asset address.
|
|
410
|
+
* @dev Returns the schema based on income type
|
|
422
411
|
* @param incomeType type of income
|
|
423
412
|
* @return schema schema for distribution
|
|
424
413
|
*/
|
|
425
|
-
function
|
|
426
|
-
|
|
427
|
-
address asset,
|
|
428
|
-
IncomeType incomeType
|
|
429
|
-
) internal view returns (Schema schema) {
|
|
430
|
-
schema = Schema.DEFAULT;
|
|
431
|
-
address vToken = IPrime(prime).vTokenForAsset(asset);
|
|
414
|
+
function _getSchema(IncomeType incomeType) internal view returns (Schema schema) {
|
|
415
|
+
schema = Schema.ADDITIONAL_REVENUE;
|
|
432
416
|
|
|
433
|
-
if (
|
|
434
|
-
schema = Schema.
|
|
417
|
+
if (incomeType == IncomeType.SPREAD) {
|
|
418
|
+
schema = Schema.PROTOCOL_RESERVES;
|
|
435
419
|
}
|
|
436
420
|
}
|
|
437
421
|
|
|
@@ -440,7 +424,7 @@ contract ProtocolShareReserve is
|
|
|
440
424
|
*/
|
|
441
425
|
function _ensurePercentages() internal view {
|
|
442
426
|
uint256 totalSchemas = uint256(type(Schema).max) + 1;
|
|
443
|
-
|
|
427
|
+
uint8[] memory totalPercentages = new uint8[](totalSchemas);
|
|
444
428
|
|
|
445
429
|
uint256 distributionTargetsLength = distributionTargets.length;
|
|
446
430
|
for (uint256 i = 0; i < distributionTargetsLength; ) {
|
|
@@ -8,7 +8,11 @@ import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
|
8
8
|
contract MockToken is ERC20 {
|
|
9
9
|
uint8 private immutable _decimals;
|
|
10
10
|
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(
|
|
12
|
+
string memory name_,
|
|
13
|
+
string memory symbol_,
|
|
14
|
+
uint8 decimals_
|
|
15
|
+
) ERC20(name_, symbol_) {
|
|
12
16
|
_decimals = decimals_;
|
|
13
17
|
}
|
|
14
18
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import mainnetDeployments from "@venusprotocol/venus-protocol/networks/mainnet.json";
|
|
2
|
+
import testnetDeployments from "@venusprotocol/venus-protocol/networks/testnet.json";
|
|
3
|
+
import hre, { ethers } from "hardhat";
|
|
4
|
+
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
5
|
+
|
|
6
|
+
const ADDRESSES: any = {
|
|
7
|
+
bsctestnet: {
|
|
8
|
+
vBNBAddress: testnetDeployments.Contracts.vBNB,
|
|
9
|
+
comptroller: testnetDeployments.Contracts.Unitroller,
|
|
10
|
+
WBNBAddress: "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
|
|
11
|
+
timelock: testnetDeployments.Contracts.Timelock,
|
|
12
|
+
acm: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
|
|
13
|
+
},
|
|
14
|
+
bscmainnet: {
|
|
15
|
+
vBNBAddress: mainnetDeployments.Contracts.vBNB,
|
|
16
|
+
comptroller: mainnetDeployments.Contracts.Unitroller,
|
|
17
|
+
WBNBAddress: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
|
|
18
|
+
timelock: mainnetDeployments.Contracts.Timelock,
|
|
19
|
+
acm: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
|
|
20
|
+
},
|
|
21
|
+
sepolia: {
|
|
22
|
+
vBNBAddress: ethers.constants.AddressZero,
|
|
23
|
+
comptroller: ethers.constants.AddressZero,
|
|
24
|
+
WBNBAddress: ethers.constants.AddressZero,
|
|
25
|
+
timelock: ethers.constants.AddressZero,
|
|
26
|
+
acm: ethers.constants.AddressZero,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => {
|
|
31
|
+
const { deploy } = deployments;
|
|
32
|
+
const { deployer } = await getNamedAccounts();
|
|
33
|
+
|
|
34
|
+
const networkName = network.name;
|
|
35
|
+
|
|
36
|
+
const { vBNBAddress, comptroller, WBNBAddress, timelock, acm } = ADDRESSES[networkName];
|
|
37
|
+
const loopsLimit = 20;
|
|
38
|
+
|
|
39
|
+
await deploy("ProtocolShareReserve", {
|
|
40
|
+
from: deployer,
|
|
41
|
+
log: true,
|
|
42
|
+
deterministicDeployment: false,
|
|
43
|
+
args: [comptroller, WBNBAddress, vBNBAddress],
|
|
44
|
+
proxy: {
|
|
45
|
+
owner: timelock,
|
|
46
|
+
proxyContract: "OpenZeppelinTransparentProxy",
|
|
47
|
+
execute: {
|
|
48
|
+
methodName: "initialize",
|
|
49
|
+
args: [acm, loopsLimit],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const psr = await hre.ethers.getContract("ProtocolShareReserve");
|
|
55
|
+
const psrOwner = await psr.owner();
|
|
56
|
+
|
|
57
|
+
if (psrOwner === deployer) {
|
|
58
|
+
const tx = await psr.transferOwnership(ADDRESSES[networkName].timelock);
|
|
59
|
+
await tx.wait();
|
|
60
|
+
console.log("Transferred ownership of PSR to Timelock");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports.tags = ["deploy"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
56
|