@@ -13,7 +13,6 @@ import {ReconAssetIdManager} from "./managers/ReconAssetIdManager.sol";
1313import {ReconShareClassManager} from "./managers/ReconShareClassManager.sol " ;
1414import {BatchRequestManagerHarness} from "./mocks/BatchRequestManagerHarness.sol " ;
1515
16- import {Escrow} from "../../../src/misc/Escrow.sol " ;
1716import {D18, d18} from "../../../src/misc/types/D18.sol " ;
1817
1918import {MockAdapter} from "../../core/mocks/MockAdapter.sol " ;
@@ -54,16 +53,18 @@ import {FullRestrictions} from "../../../src/hooks/FullRestrictions.sol";
5453import {IdentityValuation} from "../../../src/valuations/IdentityValuation.sol " ;
5554
5655import {SyncManager} from "../../../src/vaults/SyncManager.sol " ;
56+ import {IBaseVault} from "../../../src/vaults/interfaces/IBaseVault.sol " ;
5757import {AsyncRequestManager} from "../../../src/vaults/AsyncRequestManager.sol " ;
5858import {AsyncVaultFactory} from "../../../src/vaults/factories/AsyncVaultFactory.sol " ;
59- import {RefundEscrowFactory} from "../../../src/vaults/factories/RefundEscrowFactory.sol " ;
6059import {SyncDepositVaultFactory} from "../../../src/vaults/factories/SyncDepositVaultFactory.sol " ;
6160
6261import {vm} from "@chimera/Hevm.sol " ;
6362import {Utils} from "@recon/Utils.sol " ;
6463import {BaseSetup} from "@chimera/BaseSetup.sol " ;
6564import {ActorManager} from "@recon/ActorManager.sol " ;
6665import {AssetManager} from "@recon/AssetManager.sol " ;
66+ import {SubsidyManager} from "../../../src/utils/SubsidyManager.sol " ;
67+ import {RefundEscrowFactory} from "../../../src/utils/RefundEscrowFactory.sol " ;
6768
6869// Hub
6970
@@ -99,7 +100,7 @@ abstract contract Setup is
99100 FullRestrictions fullRestrictions;
100101 IRoot root;
101102 BalanceSheet balanceSheet;
102- Escrow globalEscrow ;
103+ SubsidyManager subsidyManager ;
103104
104105 // Mocks
105106 MessageDispatcher messageDispatcher;
@@ -192,22 +193,27 @@ abstract contract Setup is
192193 // Dependencies
193194 root = new Root (48 hours, address (this ));
194195 gateway = new MockGateway ();
195- globalEscrow = new Escrow (address (this ));
196- root.endorse (address (globalEscrow));
197196
198197 balanceSheet = new BalanceSheet (root, address (this ));
199- fullRestrictions = new FullRestrictions (
200- address (root), address (spoke), address (balanceSheet), address (globalEscrow), address (spoke), address (this )
201- );
202198 refundEscrowFactory = new RefundEscrowFactory (address (this ));
203- asyncRequestManager = new AsyncRequestManager (globalEscrow, refundEscrowFactory, address (this ));
199+ subsidyManager = new SubsidyManager (refundEscrowFactory, address (this ));
200+ asyncRequestManager = new AsyncRequestManager (subsidyManager, address (this ));
204201 syncManager = new SyncManager (address (this ));
205202 asyncVaultFactory = new AsyncVaultFactory (address (this ), asyncRequestManager, address (this ));
206203 syncVaultFactory = new SyncDepositVaultFactory (address (root), syncManager, asyncRequestManager, address (this ));
207204 tokenFactory = new TokenFactory (address (this ), address (this ));
208205 poolEscrowFactory = new PoolEscrowFactory (address (root), address (this ));
209206 vaultRegistry = new VaultRegistry (address (this ));
210207 spoke = new Spoke (tokenFactory, address (this ));
208+ fullRestrictions = new FullRestrictions (
209+ address (root),
210+ address (spoke),
211+ address (balanceSheet),
212+ address (spoke), // crosschainSource_ (same chain = spoke)
213+ address (this ),
214+ address (poolEscrowFactory),
215+ address (0 ) // poolEscrow_
216+ );
211217
212218 tokenRecoverer = new TokenRecoverer (IRoot (address (root)), address (this ));
213219 Root (address (root)).rely (address (tokenRecoverer));
@@ -238,7 +244,6 @@ abstract contract Setup is
238244 balanceSheet.file ("poolEscrowProvider " , address (poolEscrowFactory));
239245
240246 balanceSheet.file ("gateway " , address (gateway));
241- poolEscrowFactory.file ("gateway " , address (gateway));
242247 poolEscrowFactory.file ("balanceSheet " , address (balanceSheet));
243248 address [] memory tokenWards = new address [](2 );
244249 tokenWards[0 ] = address (spoke);
@@ -347,6 +352,16 @@ abstract contract Setup is
347352
348353 /// === Helper Functions === ///
349354
355+ /// @dev Returns the PoolEscrow address for the current pool
356+ function _getPoolEscrowAddress () internal view returns (address ) {
357+ return address (poolEscrowFactory.escrow (_getPool ()));
358+ }
359+
360+ /// @dev Returns the PoolEscrow address for a specific vault's pool
361+ function _getPoolEscrowForVault (IBaseVault vault ) internal view returns (address ) {
362+ return address (poolEscrowFactory.escrow (vault.poolId ()));
363+ }
364+
350365 /// @dev Returns a random actor from the list of actors
351366 /// @dev This is useful for cases where we want to have caller and recipient be different actors
352367 /// @param entropy The determines which actor is chosen from the array
@@ -367,7 +382,6 @@ abstract contract Setup is
367382 // Root endorsements (from CommonDeployer and SpokeDeployer)
368383 root.endorse (address (balanceSheet));
369384 root.endorse (address (asyncRequestManager));
370- root.endorse (address (globalEscrow));
371385
372386 // Rely Spoke (from SpokeDeployer)
373387 asyncVaultFactory.rely (address (spoke));
@@ -383,7 +397,6 @@ abstract contract Setup is
383397 vaultRegistry.rely (address (spoke));
384398
385399 // Rely async requests manager
386- globalEscrow.rely (address (asyncRequestManager));
387400 asyncRequestManager.rely (address (asyncVaultFactory));
388401 asyncRequestManager.rely (address (syncVaultFactory));
389402 asyncRequestManager.rely (address (messageDispatcher));
@@ -408,19 +421,20 @@ abstract contract Setup is
408421 balanceSheet.rely (address (syncManager));
409422 balanceSheet.rely (address (messageDispatcher));
410423 balanceSheet.rely (address (gateway));
411- // Rely global escrow
412- globalEscrow.rely (address (asyncRequestManager));
413- globalEscrow.rely (address (syncManager));
414- globalEscrow.rely (address (spoke));
415- globalEscrow.rely (address (balanceSheet));
424+
425+ // Rely SubsidyManager and RefundEscrowFactory
426+ subsidyManager.rely (address (root));
427+ subsidyManager.rely (address (asyncRequestManager));
428+ refundEscrowFactory.rely (address (subsidyManager));
429+ refundEscrowFactory.file ("controller " , address (asyncRequestManager));
430+ refundEscrowFactory.file ("root " , address (root));
416431
417432 // Rely Root (from all deployers)
418433 spoke.rely (address (root));
419434 spoke.rely (address (vaultRegistry));
420435 asyncRequestManager.rely (address (root));
421436 syncManager.rely (address (root));
422437 balanceSheet.rely (address (root));
423- globalEscrow.rely (address (root));
424438 asyncVaultFactory.rely (address (root));
425439 syncVaultFactory.rely (address (root));
426440 tokenFactory.rely (address (root));
0 commit comments