Skip to content

Commit b21060d

Browse files
committed
fix: further impros on property_availableGtQueued
1 parent 54f1812 commit b21060d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,27 +1524,32 @@ abstract contract Properties is BeforeAfter, Asserts, VaultProperties {
15241524

15251525
/// @dev Property: Asset queue cannot create assets from nothing.
15261526
/// @notice queuedAssets tracks already-executed escrow movements pending hub notification.
1527-
/// Since withdrawals decrease and deposits increase the escrow balance,
1528-
/// the invariant is: available + queuedWithdrawals >= queuedDeposits
1529-
/// (i.e., the escrow balance before the queued period was non-negative).
1527+
/// noteDeposit increases holding.total AND queuedDeposits atomically;
1528+
/// noteWithdraw decreases holding.total AND increases queuedWithdrawals atomically.
1529+
/// We use holding.total (not availableBalanceOf) because reserve/unreserve
1530+
/// affect available but do NOT update the queue.
1531+
/// Invariant: total + queuedWithdrawals >= queuedDeposits
1532+
/// (i.e., the escrow total before the queued period was non-negative).
15301533
function property_availableGtQueued() public {
15311534
PoolId poolId = _getPool();
15321535
ShareClassId scId = _getShareClassId();
15331536
AssetId assetId = _getAssetId();
15341537
address asset = _getVault().asset();
15351538

1536-
// Get current available balance (after all queued ops already executed on escrow)
1537-
uint128 available = balanceSheet.availableBalanceOf(poolId, scId, asset, 0);
1539+
// Use holding.total (not availableBalanceOf) since reserve/unreserve
1540+
// affect available but don't update the queue
1541+
PoolEscrow poolEscrow = PoolEscrow(address(balanceSheet.escrow(poolId)));
1542+
(uint128 total,) = poolEscrow.holding(scId, asset, 0);
15381543

15391544
// Get queued amounts (already-executed, pending hub notification)
15401545
(uint128 queuedDeposits, uint128 queuedWithdrawals) = balanceSheet.queuedAssets(poolId, scId, assetId);
15411546

1542-
// available = previousAvailable + queuedDeposits - queuedWithdrawals
1543-
// => previousAvailable = available + queuedWithdrawals - queuedDeposits >= 0
1547+
// total = total_before_queue + queuedDeposits - queuedWithdrawals
1548+
// => total_before_queue = total + queuedWithdrawals - queuedDeposits >= 0
15441549
gte(
1545-
uint256(available) + uint256(queuedWithdrawals),
1550+
uint256(total) + uint256(queuedWithdrawals),
15461551
uint256(queuedDeposits),
1547-
"Asset queue net exceeds prior available balance"
1552+
"Asset queue net exceeds prior escrow total"
15481553
);
15491554
}
15501555

0 commit comments

Comments
 (0)