@@ -9,6 +9,7 @@ import {TransparentUpgradeableProxy} from "@openzeppelin/proxy/transparent/Trans
99import {ATokenVault} from "./ATokenVault.sol " ;
1010import {SafeERC20} from "@openzeppelin/token/ERC20/utils/SafeERC20.sol " ;
1111import {ProxyAdmin} from "@openzeppelin/proxy/transparent/ProxyAdmin.sol " ;
12+ import {ATokenVaultRevenueSplitterOwner} from "./ATokenVaultRevenueSplitterOwner.sol " ;
1213
1314/**
1415 * @title ATokenVaultImplDeploymentLib
@@ -59,6 +60,20 @@ contract ATokenVaultFactory {
5960 VaultParams params
6061 );
6162
63+ /**
64+ * @dev Emitted when a new revenue splitter owner is deployed
65+ * @param revenueSplitterOwner The address of the deployed revenue splitter owner
66+ * @param vault The address of the vault to split the revenue from
67+ * @param owner The address of the owner of the revenue splitter, effective owner of the vault
68+ * @param revenueRecipients The recipients of the revenue
69+ */
70+ event RevenueSplitterOwnerDeployed (
71+ address indexed revenueSplitterOwner ,
72+ address indexed vault ,
73+ address indexed owner ,
74+ ATokenVaultRevenueSplitterOwner.Recipient[] revenueRecipients
75+ );
76+
6277 /*//////////////////////////////////////////////////////////////
6378 CONSTANTS
6479 //////////////////////////////////////////////////////////////*/
@@ -83,6 +98,7 @@ contract ATokenVaultFactory {
8398 string shareName;
8499 string shareSymbol;
85100 uint256 initialLockDeposit;
101+ ATokenVaultRevenueSplitterOwner.Recipient[] revenueRecipients;
86102 }
87103
88104 /*//////////////////////////////////////////////////////////////
@@ -133,10 +149,19 @@ contract ATokenVaultFactory {
133149 ""
134150 ));
135151
152+ address vaultOwner = params.owner;
153+ if (params.revenueRecipients.length > 0 ) {
154+ vaultOwner = _deployRevenueSplitterOwner (
155+ vault,
156+ params.owner,
157+ params.revenueRecipients
158+ );
159+ }
160+
136161 IERC20 (params.underlying).safeApprove (vault, params.initialLockDeposit);
137162
138163 ATokenVault (vault).initialize (
139- params.owner ,
164+ vaultOwner ,
140165 params.initialFee,
141166 params.shareName,
142167 params.shareSymbol,
@@ -151,4 +176,29 @@ contract ATokenVaultFactory {
151176 params
152177 );
153178 }
179+
180+ /**
181+ * @notice Deploys a new ATokenVaultRevenueSplitterOwner with the given parameters
182+ * @param vaultAddress The address of the vault to split the revenue from
183+ * @param owner The address of the owner of the revenue splitter, effective owner of the vault
184+ * @param revenueRecipients The recipients of the revenue
185+ * @return revenueSplitter The address of the deployed revenue splitter
186+ */
187+ function deployRevenueSplitterOwner (
188+ address vaultAddress ,
189+ address owner ,
190+ ATokenVaultRevenueSplitterOwner.Recipient[] memory revenueRecipients
191+ ) external returns (address ) {
192+ return _deployRevenueSplitterOwner (vaultAddress, owner, revenueRecipients);
193+ }
194+
195+ function _deployRevenueSplitterOwner (
196+ address vaultAddress ,
197+ address owner ,
198+ ATokenVaultRevenueSplitterOwner.Recipient[] memory revenueRecipients
199+ ) internal returns (address ) {
200+ address revenueSplitter = address (new ATokenVaultRevenueSplitterOwner (vaultAddress, owner, revenueRecipients));
201+ emit RevenueSplitterOwnerDeployed (revenueSplitter, vaultAddress, owner, revenueRecipients);
202+ return revenueSplitter;
203+ }
154204}
0 commit comments