|
| 1 | +# VenusERC4626Factory |
| 2 | + |
| 3 | +### Overview |
| 4 | + |
| 5 | +`VenusERC4626Factory` is a factory contract for deploying upgradeable VenusERC4626 vaults as BeaconProxy instances. It manages the deployment, registry, and configuration of vaults, and controls access to sensitive operations via the AccessControlManager (ACM). |
| 6 | + |
| 7 | +# Solidity API |
| 8 | + |
| 9 | +### State Variables |
| 10 | + |
| 11 | +- **`SALT`** (`bytes32`, public constant): |
| 12 | + A constant salt value used for deterministic contract deployment. |
| 13 | + |
| 14 | +- **`beacon`** (`UpgradeableBeacon`, public): |
| 15 | + The beacon contract for VenusERC4626 proxies. |
| 16 | + |
| 17 | +- **`poolRegistry`** (`PoolRegistryInterface`, public): |
| 18 | + The Pool Registry contract. |
| 19 | + |
| 20 | +- **`rewardRecipient`** (`address`, public): |
| 21 | + The address that receives the liquidity mining rewards. |
| 22 | + |
| 23 | +- **`createdVaults`** (`mapping(address vToken => ERC4626Upgradeable vault)`, public): |
| 24 | + Mapping of vaults created by this factory. |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +### Events |
| 29 | + |
| 30 | +- **`CreateERC4626(VTokenInterface indexed vToken, ERC4626Upgradeable indexed vault)`** |
| 31 | + Emitted when a new ERC4626 vault is created. |
| 32 | + |
| 33 | + - `vToken`: The vToken used by the vault. |
| 34 | + - `vault`: The vault that was created. |
| 35 | + |
| 36 | +- **`RewardRecipientUpdated(address indexed oldRecipient, address indexed newRecipient)`** |
| 37 | + Emitted when the reward recipient address is updated. |
| 38 | + - `oldRecipient`: The previous reward recipient address. |
| 39 | + - `newRecipient`: The new reward recipient address. |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +### Errors |
| 44 | + |
| 45 | +- **`VenusERC4626Factory__InvalidVToken()`** |
| 46 | + Thrown when the provided vToken is not registered in the PoolRegistry. |
| 47 | + |
| 48 | +- **`VenusERC4626Factory__ERC4626AlreadyExists()`** |
| 49 | + Thrown when a VenusERC4626 vault already exists for the specified vToken. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +#### Constructor |
| 54 | + |
| 55 | +**@custom:oz-upgrades-unsafe-allow constructor** |
| 56 | +Disables initializers for the upgradeable contract pattern. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +### Functions |
| 61 | + |
| 62 | +### initialize |
| 63 | + |
| 64 | +Initializes the VenusERC4626Factory contract with the required configuration parameters. |
| 65 | + |
| 66 | +```solidity |
| 67 | +function initialize( |
| 68 | + address accessControlManager, |
| 69 | + address poolRegistryAddress, |
| 70 | + address rewardRecipientAddress, |
| 71 | + address venusERC4626Implementation, |
| 72 | + uint256 loopsLimitNumber |
| 73 | +) external initializer |
| 74 | +``` |
| 75 | + |
| 76 | +#### Parameters |
| 77 | + |
| 78 | +| Name | Type | Description | |
| 79 | +| -------------------------- | ------- | --------------------------------------------------------- | |
| 80 | +| accessControlManager | address | Address of the Access Control Manager (ACM) contract. | |
| 81 | +| poolRegistryAddress | address | Address of the Pool Registry contract. | |
| 82 | +| rewardRecipientAddress | address | Address that receives liquidity mining rewards. | |
| 83 | +| venusERC4626Implementation | address | Address of the VenusERC4626 implementation contract. | |
| 84 | +| loopsLimitNumber | uint256 | The maximum number of loops for the MaxLoopsLimit helper. | |
| 85 | + |
| 86 | +#### Notes |
| 87 | + |
| 88 | +- Can only be called once. |
| 89 | +- Disables initializers for the upgradeable contract pattern. |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +### setRewardRecipient |
| 94 | + |
| 95 | +Sets the reward recipient address. |
| 96 | + |
| 97 | +```solidity |
| 98 | +function setRewardRecipient(address newRecipient) external |
| 99 | +``` |
| 100 | + |
| 101 | +#### Parameters |
| 102 | + |
| 103 | +| Name | Type | Description | |
| 104 | +| ------------ | ------- | ---------------------------------------- | |
| 105 | +| newRecipient | address | The address of the new reward recipient. | |
| 106 | + |
| 107 | +#### Notes |
| 108 | + |
| 109 | +- Controlled by the ACM. |
| 110 | +- Reverts with `ZeroAddressNotAllowed` if the new recipient address is zero. |
| 111 | +- Emits the `RewardRecipientUpdated` event on update. |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +### setMaxLoopsLimit |
| 116 | + |
| 117 | +Sets the maximum loops limit for internal operations. |
| 118 | + |
| 119 | +```solidity |
| 120 | +function setMaxLoopsLimit(uint256 loopsLimit) external |
| 121 | +``` |
| 122 | + |
| 123 | +#### Parameters |
| 124 | + |
| 125 | +| Name | Type | Description | |
| 126 | +| ---------- | ------- | ---------------------------------------- | |
| 127 | +| loopsLimit | uint256 | The new maximum number of loops allowed. | |
| 128 | + |
| 129 | +#### Notes |
| 130 | + |
| 131 | +- Controlled by the ACM. |
| 132 | +- Emits the `MaxLoopsLimitUpdated` event on success. |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +### createERC4626 |
| 137 | + |
| 138 | +Creates a new ERC4626 vault for the specified vToken. |
| 139 | + |
| 140 | +```solidity |
| 141 | +function createERC4626(address vToken) external returns (ERC4626Upgradeable vault) |
| 142 | +``` |
| 143 | + |
| 144 | +#### Parameters |
| 145 | + |
| 146 | +| Name | Type | Description | |
| 147 | +| ------ | ------- | ------------------------------------------ | |
| 148 | +| vToken | address | The vToken for which the vault is created. | |
| 149 | + |
| 150 | +#### Returns |
| 151 | + |
| 152 | +| Name | Type | Description | |
| 153 | +| ----- | ------------------ | -------------------------------- | |
| 154 | +| vault | ERC4626Upgradeable | The deployed VenusERC4626 vault. | |
| 155 | + |
| 156 | +#### Notes |
| 157 | + |
| 158 | +- Reverts with `ZeroAddressNotAllowed` if the vToken address is zero. |
| 159 | +- Reverts with `VenusERC4626Factory__InvalidVToken` if the vToken is not valid. |
| 160 | +- Reverts with `VenusERC4626Factory__ERC4626AlreadyExists` if the vault already exists. |
| 161 | +- Emits the `CreateERC4626` event on successful creation. |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +### computeVaultAddress |
| 166 | + |
| 167 | +Computes the deterministic address of the vault for a specified vToken. |
| 168 | + |
| 169 | +```solidity |
| 170 | +function computeVaultAddress(address vToken) public view returns (address) |
| 171 | +``` |
| 172 | + |
| 173 | +#### Parameters |
| 174 | + |
| 175 | +| Name | Type | Description | |
| 176 | +| ------ | ------- | -------------------------------------------- | |
| 177 | +| vToken | address | The vToken for which to compute the address. | |
| 178 | + |
| 179 | +#### Returns |
| 180 | + |
| 181 | +| Name | Type | Description | |
| 182 | +| ------- | ------- | --------------------------- | |
| 183 | +| address | address | The computed vault address. | |
0 commit comments