@@ -89,6 +89,109 @@ contract ATokenVaultFactoryTest is Test {
8989 assertEq (vaultContract.getFee (), 0 );
9090 }
9191
92+ function testDeployVaultWithRevenueSplitter () public {
93+ uint256 initialDeposit = 1000 * 1e18 ;
94+ deal (address (underlying), ALICE, initialDeposit);
95+
96+ vm.startPrank (ALICE);
97+ IERC20 (underlying).safeApprove (address (factory), initialDeposit);
98+
99+ VaultParams memory params = VaultParams ({
100+ underlying: address (underlying),
101+ referralCode: 42 ,
102+ poolAddressesProvider: IPoolAddressesProvider (address (poolAddrProvider)),
103+ owner: ALICE,
104+ initialFee: 0 ,
105+ shareName: "Test Vault " ,
106+ shareSymbol: "tVault " ,
107+ initialLockDeposit: initialDeposit,
108+ revenueRecipients: new ATokenVaultRevenueSplitterOwner.Recipient [](0 )
109+ });
110+
111+ address vault = factory.deployVault (params);
112+
113+ ATokenVaultRevenueSplitterOwner.Recipient[] memory revenueRecipients = new ATokenVaultRevenueSplitterOwner.Recipient [](2 );
114+ revenueRecipients[0 ] = ATokenVaultRevenueSplitterOwner.Recipient ({
115+ addr: BOB,
116+ shareInBps: 50_00
117+ });
118+ revenueRecipients[1 ] = ATokenVaultRevenueSplitterOwner.Recipient ({
119+ addr: CHARLIE,
120+ shareInBps: 50_00
121+ });
122+
123+ address revenueSplitter = factory.deployRevenueSplitterOwner (vault, ALICE, revenueRecipients);
124+
125+ assertEq (ATokenVaultRevenueSplitterOwner (payable (revenueSplitter)).owner (), ALICE);
126+ ATokenVaultRevenueSplitterOwner.Recipient[] memory actualRecipients = ATokenVaultRevenueSplitterOwner (payable (revenueSplitter)).getRecipients ();
127+ assertEq (actualRecipients.length , revenueRecipients.length );
128+ for (uint256 i = 0 ; i < actualRecipients.length ; i++ ) {
129+ assertEq (actualRecipients[i].addr, revenueRecipients[i].addr);
130+ assertEq (actualRecipients[i].shareInBps, revenueRecipients[i].shareInBps);
131+ }
132+
133+ assertEq (ATokenVault (payable (vault)).owner (), ALICE);
134+
135+ ATokenVault (payable (vault)).transferOwnership (revenueSplitter);
136+
137+ assertEq (ATokenVault (payable (vault)).owner (), revenueSplitter);
138+ }
139+
140+ function testDeployRevenueSplitter () public {
141+ uint256 initialDeposit = 1000 * 1e18 ;
142+ deal (address (underlying), ALICE, initialDeposit);
143+
144+ vm.startPrank (ALICE);
145+ IERC20 (underlying).safeApprove (address (factory), initialDeposit);
146+
147+ ATokenVaultRevenueSplitterOwner.Recipient[] memory revenueRecipients = new ATokenVaultRevenueSplitterOwner.Recipient [](3 );
148+ revenueRecipients[0 ] = ATokenVaultRevenueSplitterOwner.Recipient ({
149+ addr: ALICE,
150+ shareInBps: 20_00
151+ });
152+ revenueRecipients[1 ] = ATokenVaultRevenueSplitterOwner.Recipient ({
153+ addr: BOB,
154+ shareInBps: 20_00
155+ });
156+ revenueRecipients[2 ] = ATokenVaultRevenueSplitterOwner.Recipient ({
157+ addr: CHARLIE,
158+ shareInBps: 60_00
159+ });
160+
161+ VaultParams memory params = VaultParams ({
162+ underlying: address (underlying),
163+ referralCode: 42 ,
164+ poolAddressesProvider: IPoolAddressesProvider (address (poolAddrProvider)),
165+ owner: ALICE,
166+ initialFee: 0 ,
167+ shareName: "Test Vault " ,
168+ shareSymbol: "tVault " ,
169+ initialLockDeposit: initialDeposit,
170+ revenueRecipients: revenueRecipients
171+ });
172+
173+ address vault = factory.deployVault (params);
174+ vm.stopPrank ();
175+
176+ assertTrue (vault != address (0 ));
177+
178+ ATokenVault vaultContract = ATokenVault (vault);
179+ assertEq (address (vaultContract.UNDERLYING ()), address (underlying));
180+ assertEq (vaultContract.REFERRAL_CODE (), 42 );
181+ assertEq (vaultContract.name (), "Test Vault " );
182+ assertEq (vaultContract.symbol (), "tVault " );
183+ assertEq (vaultContract.getFee (), 0 );
184+
185+ address owner = vaultContract.owner ();
186+ assertEq (ATokenVaultRevenueSplitterOwner (payable (owner)).owner (), ALICE);
187+ ATokenVaultRevenueSplitterOwner.Recipient[] memory actualRecipients = ATokenVaultRevenueSplitterOwner (payable (owner)).getRecipients ();
188+ assertEq (actualRecipients.length , revenueRecipients.length );
189+ for (uint256 i = 0 ; i < actualRecipients.length ; i++ ) {
190+ assertEq (actualRecipients[i].addr, revenueRecipients[i].addr);
191+ assertEq (actualRecipients[i].shareInBps, revenueRecipients[i].shareInBps);
192+ }
193+ }
194+
92195 function testDeployVaultWithFee () public {
93196 uint256 initialDeposit = 1000 * 1e18 ;
94197 uint256 fee = 1e17 ; // 10%
0 commit comments