Skip to content

Commit 76790d1

Browse files
committed
fixes after rebase
1 parent 985527a commit 76790d1

File tree

11 files changed

+104
-61
lines changed

11 files changed

+104
-61
lines changed

test/integration/recon-end-to-end/BeforeAfter.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@ abstract contract BeforeAfter is Setup {
291291
BeforeAfterVars storage _structToUpdate = before ? _before : _after;
292292

293293
if (_getShareToken() != address(0)) {
294-
_structToUpdate.escrowShareTokenBalance = MockERC20(_getShareToken()).balanceOf(address(globalEscrow));
294+
_structToUpdate.escrowShareTokenBalance = MockERC20(_getShareToken()).balanceOf(_getPoolEscrowAddress());
295295
_structToUpdate.totalShareSupply = MockERC20(_getShareToken()).totalSupply();
296296
}
297297

298298
if (address(_getVault()) != address(0)) {
299299
_structToUpdate.escrowAssetBalance[address(_getVault())] =
300-
MockERC20(_getVault().asset()).balanceOf(address(globalEscrow));
300+
MockERC20(_getVault().asset()).balanceOf(_getPoolEscrowForVault(_getVault()));
301301
_structToUpdate.poolEscrowAssetBalance =
302302
MockERC20(_getVault().asset()).balanceOf(address(poolEscrowFactory.escrow(_getVault().poolId())));
303303
_structToUpdate.actualAssets = MockERC20(_getVault().asset()).balanceOf(address(_getVault()));

test/integration/recon-end-to-end/CryticToFoundry.sol

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,22 @@ contract CryticToFoundry is Test, TargetFunctions, FoundryAsserts {
193193
// Reproducer: echidna/reproducers/9143144158582049584.txt
194194
// Async vault: deploy → deposit_queue_cancel → hub_notifyDeposit → maxDeposit
195195
function test_vault_maxDeposit_12() public {
196-
shortcut_deployNewTokenPoolAndShare(58, 3725620682615936983603445291889200717745835437975087272030550155022530317057, false, true, true, false);
196+
shortcut_deployNewTokenPoolAndShare(
197+
58, 3725620682615936983603445291889200717745835437975087272030550155022530317057, false, true, true, false
198+
);
197199

198200
balanceSheet_submitQueuedShares(2986799447496935121812250855886100387);
199201

200202
switch_actor(270);
201203

202-
shortcut_deposit_queue_cancel(4662387785827488946, 238, 1577203754821733349138040342627210308022144620756482427698354874963446062794, 326587208, 53058427172526584712949480, 124879742162045852864037660195030038286);
204+
shortcut_deposit_queue_cancel(
205+
4662387785827488946,
206+
238,
207+
1577203754821733349138040342627210308022144620756482427698354874963446062794,
208+
326587208,
209+
53058427172526584712949480,
210+
124879742162045852864037660195030038286
211+
);
203212

204213
switch_share_class(7);
205214

test/integration/recon-end-to-end/Setup.sol

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {ReconAssetIdManager} from "./managers/ReconAssetIdManager.sol";
1313
import {ReconShareClassManager} from "./managers/ReconShareClassManager.sol";
1414
import {BatchRequestManagerHarness} from "./mocks/BatchRequestManagerHarness.sol";
1515

16-
import {Escrow} from "../../../src/misc/Escrow.sol";
1716
import {D18, d18} from "../../../src/misc/types/D18.sol";
1817

1918
import {MockAdapter} from "../../core/mocks/MockAdapter.sol";
@@ -54,16 +53,18 @@ import {FullRestrictions} from "../../../src/hooks/FullRestrictions.sol";
5453
import {IdentityValuation} from "../../../src/valuations/IdentityValuation.sol";
5554

5655
import {SyncManager} from "../../../src/vaults/SyncManager.sol";
56+
import {IBaseVault} from "../../../src/vaults/interfaces/IBaseVault.sol";
5757
import {AsyncRequestManager} from "../../../src/vaults/AsyncRequestManager.sol";
5858
import {AsyncVaultFactory} from "../../../src/vaults/factories/AsyncVaultFactory.sol";
59-
import {RefundEscrowFactory} from "../../../src/vaults/factories/RefundEscrowFactory.sol";
6059
import {SyncDepositVaultFactory} from "../../../src/vaults/factories/SyncDepositVaultFactory.sol";
6160

6261
import {vm} from "@chimera/Hevm.sol";
6362
import {Utils} from "@recon/Utils.sol";
6463
import {BaseSetup} from "@chimera/BaseSetup.sol";
6564
import {ActorManager} from "@recon/ActorManager.sol";
6665
import {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));

test/integration/recon-end-to-end/mocks/BatchRequestManagerHarness.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ contract BatchRequestManagerHarness is BatchRequestManager {
6969
})
7070
),
7171
0, // extraGasLimit
72+
false, // unpaidMode
7273
refund
7374
);
7475
}
@@ -127,6 +128,7 @@ contract BatchRequestManagerHarness is BatchRequestManager {
127128
})
128129
),
129130
0, // extraGasLimit
131+
false, // unpaidMode
130132
refund
131133
);
132134
}

test/integration/recon-end-to-end/mocks/MockGateway.sol

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,26 @@ contract MockGateway {
3535
function rely(address user) public {}
3636

3737
// Mock implementation of repay
38-
function repay(uint16 centrifugeId, bytes memory batch) public payable {}
38+
function repay(uint16 centrifugeId, bytes memory batch, address refund) public payable {}
3939

4040
// Mock implementation of retry
4141
function retry(uint16 centrifugeId, bytes memory message) public {}
4242

4343
// Mock implementation of send
44-
function send(uint16 centrifugeId, bytes memory message) public {}
44+
function send(uint16 centrifugeId, bytes memory message, bool unpaidMode, address refund) public payable {}
4545

46-
// Mock implementation of setUnpaidMode
47-
function setUnpaidMode(bool enabled) public {}
46+
// Mock implementation of withBatch
47+
function withBatch(bytes memory callbackData, uint256 callbackValue, address refund) external payable {}
48+
function withBatch(bytes memory callbackData, address refund) external payable {}
49+
50+
// Mock implementation of lockCallback
51+
function lockCallback() external {}
52+
53+
// Mock implementation of updateManager
54+
function updateManager(uint64 poolId, address who, bool canManage) external {}
55+
56+
// Mock implementation of blockOutgoing
57+
function blockOutgoing(uint16 centrifugeId, uint64 poolId, bool canSend) external {}
4858

4959
// Mock implementation of setRefundAddress
5060
function setRefundAddress(uint64 poolId, address refund) public {}

test/integration/recon-end-to-end/properties/Properties.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ abstract contract Properties is BeforeAfter, Asserts, VaultProperties {
144144
_getVault()
145145
)][_getActor()].claimableCancelDepositRequest
146146
- _after.investments[address(_getVault())][_getActor()].claimableCancelDepositRequest;
147-
// claiming a cancel deposit request means that the globalEscrow token balance decreases
147+
// claiming a cancel deposit request means that the PoolEscrow token balance decreases
148148
uint256 escrowAssetBalanceDelta =
149149
_before.escrowAssetBalance[address(_getVault())] - _after.escrowAssetBalance[address(_getVault())];
150150
eq(
@@ -173,7 +173,7 @@ abstract contract Properties is BeforeAfter, Asserts, VaultProperties {
173173
_getVault()
174174
)][_getActor()].claimableCancelRedeemRequest
175175
- _after.investments[address(_getVault())][_getActor()].claimableCancelRedeemRequest;
176-
// claiming a cancel redeem request means that the globalEscrow tranche token balance decreases
176+
// claiming a cancel redeem request means that the PoolEscrow tranche token balance decreases
177177
uint256 escrowTrancheTokenBalanceDelta = _before.escrowShareTokenBalance - _after.escrowShareTokenBalance;
178178
eq(
179179
claimableCancelRedeemRequestDelta,
@@ -452,7 +452,7 @@ abstract contract Properties is BeforeAfter, Asserts, VaultProperties {
452452
}
453453

454454
IBaseVault vault = _getVault();
455-
uint256 max = IShareToken(vault.share()).balanceOf(address(globalEscrow));
455+
uint256 max = IShareToken(vault.share()).balanceOf(_getPoolEscrowForVault(vault));
456456
address[] memory actors = _getActors();
457457

458458
uint256 acc; // Use acc to get maxMint for each actor
@@ -1090,7 +1090,7 @@ abstract contract Properties is BeforeAfter, Asserts, VaultProperties {
10901090
/// @dev Can we donate to this address?
10911091
/// We explicitly preventing donations since we check for exact balances
10921092
function _canDonate(address to) internal view returns (bool) {
1093-
if (to == address(globalEscrow)) {
1093+
if (to == _getPoolEscrowAddress()) {
10941094
return false;
10951095
}
10961096

@@ -1749,7 +1749,7 @@ abstract contract Properties is BeforeAfter, Asserts, VaultProperties {
17491749
try spoke.shareToken(poolId, scId) returns (IShareToken shareToken) {
17501750
uint256 actualSupply = shareToken.totalSupply();
17511751
// escrow holds tokens that have been redeemed
1752-
uint256 balancesSummed = shareToken.balanceOf(address(asyncRequestManager.globalEscrow()));
1752+
uint256 balancesSummed = shareToken.balanceOf(_getPoolEscrowAddress());
17531753
// Check 2: Sum of balances equals total supply
17541754
address[] memory actors = _getActors();
17551755
for (uint256 k = 0; k < actors.length; k++) {

test/integration/recon-end-to-end/properties/VaultProperties.sol

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pragma solidity 0.8.28;
44
import {ERC7540Properties} from "./ERC7540Properties.sol";
55

66
import {D18} from "../../../../src/misc/types/D18.sol";
7-
import {IERC20, IERC20Metadata} from "../../../../src/misc/interfaces/IERC20.sol";
87
import {CastLib} from "../../../../src/misc/libraries/CastLib.sol";
98
import {MathLib} from "../../../../src/misc/libraries/MathLib.sol";
9+
import {IERC20, IERC20Metadata} from "../../../../src/misc/interfaces/IERC20.sol";
1010

1111
import {PoolId} from "../../../../src/core/types/PoolId.sol";
1212
import {AssetId} from "../../../../src/core/types/AssetId.sol";
@@ -119,7 +119,7 @@ abstract contract VaultProperties is Setup, Asserts, ERC7540Properties {
119119
/// @dev Property: depositing maxDeposit blocks the user from depositing more
120120
/// @dev Property: depositing maxDeposit does not increase the pendingDeposit
121121
/// @dev Property: depositing maxDeposit doesn't mint more than maxMint shares
122-
/// @dev Property: For async vaults, validates globalEscrow share transfers
122+
/// @dev Property: For async vaults, validates PoolEscrow share transfers
123123
/// @dev Property: For sync vaults, validates PoolEscrow state changes
124124
function vault_maxDeposit(
125125
uint64,
@@ -161,7 +161,7 @@ abstract contract VaultProperties is Setup, Asserts, ERC7540Properties {
161161
uint256 maxDepositAfter = _getVault().maxDeposit(_getActor());
162162

163163
if (isAsyncVault) {
164-
// For async vaults, validate globalEscrow share transfers instead of poolEscrow
164+
// For async vaults, validate PoolEscrow share transfers
165165
claimState.sharesReturned = shares;
166166
_updateAsyncClaimStateAfter(claimState, _getVault(), _getActor());
167167
_validateAsyncVaultClaim(claimState, "vault_maxDeposit");
@@ -455,11 +455,10 @@ abstract contract VaultProperties is Setup, Asserts, ERC7540Properties {
455455
}
456456

457457
/// @notice Tracks share balances for async vault claim operations
458-
/// @dev During claim operations (vault.deposit/mint), shares transfer from globalEscrow to receiver
459-
/// @dev PoolEscrow does NOT change during claims
458+
/// @dev During claim operations (vault.deposit/mint), shares transfer from PoolEscrow to receiver
460459
struct AsyncClaimState {
461-
uint256 globalEscrowSharesBefore;
462-
uint256 globalEscrowSharesAfter;
460+
uint256 poolEscrowSharesBefore;
461+
uint256 poolEscrowSharesAfter;
463462
uint256 receiverSharesBefore;
464463
uint256 receiverSharesAfter;
465464
uint256 sharesReturned;
@@ -723,16 +722,16 @@ abstract contract VaultProperties is Setup, Asserts, ERC7540Properties {
723722
}
724723

725724
/// @dev Captures async claim state before vault.deposit() operation
726-
/// @notice Tracks globalEscrow and receiver share balances
725+
/// @notice Tracks PoolEscrow and receiver share balances
727726
function _captureAsyncClaimStateBefore(IBaseVault vault, address receiver)
728727
internal
729728
view
730729
returns (AsyncClaimState memory state)
731730
{
732731
address shareToken = vault.share();
733-
address globalEscrowAddr = address(asyncRequestManager.globalEscrow());
732+
address poolEscrowAddr = _getPoolEscrowForVault(vault);
734733

735-
state.globalEscrowSharesBefore = IERC20(shareToken).balanceOf(globalEscrowAddr);
734+
state.poolEscrowSharesBefore = IERC20(shareToken).balanceOf(poolEscrowAddr);
736735
state.receiverSharesBefore = IERC20(shareToken).balanceOf(receiver);
737736

738737
(state.maxMintBefore,,,,,,,,,) = asyncRequestManager.investments(vault, _getActor());
@@ -746,34 +745,34 @@ abstract contract VaultProperties is Setup, Asserts, ERC7540Properties {
746745
view
747746
{
748747
address shareToken = vault.share();
749-
address globalEscrowAddr = address(asyncRequestManager.globalEscrow());
748+
address poolEscrowAddr = _getPoolEscrowForVault(vault);
750749

751-
state.globalEscrowSharesAfter = IERC20(shareToken).balanceOf(globalEscrowAddr);
750+
state.poolEscrowSharesAfter = IERC20(shareToken).balanceOf(poolEscrowAddr);
752751
state.receiverSharesAfter = IERC20(shareToken).balanceOf(receiver);
753752

754753
(state.maxMintAfter,,,,,,,,,) = asyncRequestManager.investments(vault, _getActor());
755754
}
756755

757756
/// @dev Validates async vault claim operations
758-
/// @notice During claims, globalEscrow shares transfer to receiver, PoolEscrow does NOT change
757+
/// @notice During claims, PoolEscrow shares transfer to receiver
759758
/// @notice This validation works for all cases including when sharesReturned == 0
760759
function _validateAsyncVaultClaim(AsyncClaimState memory state, string memory operationName) internal {
761-
uint256 globalEscrowDecrease = state.globalEscrowSharesBefore - state.globalEscrowSharesAfter;
760+
uint256 poolEscrowDecrease = state.poolEscrowSharesBefore - state.poolEscrowSharesAfter;
762761
uint256 receiverIncrease = state.receiverSharesAfter - state.receiverSharesBefore;
763762
eq(
764-
globalEscrowDecrease,
763+
poolEscrowDecrease,
765764
state.sharesReturned,
766-
string.concat(operationName, ": globalEscrow must decrease by exact shares returned")
765+
string.concat(operationName, ": PoolEscrow must decrease by exact shares returned")
767766
);
768767
eq(
769768
receiverIncrease,
770769
state.sharesReturned,
771770
string.concat(operationName, ": receiver must receive exact shares returned")
772771
);
773772
eq(
774-
globalEscrowDecrease,
773+
poolEscrowDecrease,
775774
receiverIncrease,
776-
string.concat(operationName, ": shares leaving globalEscrow must equal shares received")
775+
string.concat(operationName, ": shares leaving PoolEscrow must equal shares received")
777776
);
778777

779778
uint128 maxMintDecrease = state.maxMintBefore - state.maxMintAfter;

0 commit comments

Comments
 (0)