Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gg/request redeem router target #416

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/recon-core/Properties.sol
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ abstract contract Properties is Setup, Asserts, ERC7540CentrifugeProperties {
return trancheToken.balanceOf(address(escrow))
== (
sumOfFullfilledDeposits[address(trancheToken)] + sumOfRedeemRequests[address(trancheToken)]
- sumOfClaimedDeposits[address(trancheToken)] - sumOfClaimedRedeemCancelations[address(trancheToken)]
- sumOfClaimedRequests[address(trancheToken)]
+ sumOfRedeemRequestsRouter[address(trancheToken)] - sumOfClaimedDeposits[address(trancheToken)]
- sumOfClaimedRedeemCancelations[address(trancheToken)] - sumOfClaimedRequests[address(trancheToken)]
);
}
}
Expand Down
1 change: 1 addition & 0 deletions test/recon-core/SharedStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,5 @@ abstract contract SharedStorage {
mapping(address => uint256) sumOfExecutedLockedDepositRequests;
// stores request data coming through the router
mapping(address => uint256) sumOfDepositRequestsRouter;
mapping(address => uint256) sumOfRedeemRequestsRouter;
}
39 changes: 39 additions & 0 deletions test/recon-core/targets/RouterFunctions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,45 @@ abstract contract RouterFunctions is BaseTargetFunctions, Properties {
}
}

function router_requestRedeem(uint256 shares) public {
address owner = actor;
address controller = actor;

uint256 balanceOfEscrowB4 = trancheToken.balanceOf(address(escrow));
uint256 balanceOfRouterEscrowB4 = trancheToken.balanceOf(address(routerEscrow));
uint256 balanceOfOwnerB4 = trancheToken.balanceOf(owner);
shares = between(shares, 0, balanceOfOwnerB4);

bool hasReverted;

trancheToken.approve(address(vault), shares);

try router.requestRedeem(address(vault), shares, controller, owner, 0) {
sumOfRedeemRequestsRouter[address(trancheToken)] += shares;
requestRedeemShares[actor][address(trancheToken)] += shares;
} catch {
hasReverted = true;
}
if (restrictionManager.isFrozen(address(trancheToken), controller)) {
t(hasReverted, "Router-Redeem-Frozen Must Revert");
}
// After Balances and Checks
uint256 balanceOfEscrowAfter = trancheToken.balanceOf(address(escrow));
uint256 balanceOfOwnerAfter = trancheToken.balanceOf(owner);
uint256 balanceOfRouterEscrowAfter = trancheToken.balanceOf(address(routerEscrow));

// NOTE: We only enforce the check if the tx didn't revert
if (!hasReverted) {
uint256 deltaEscrow = balanceOfEscrowAfter - balanceOfEscrowB4;
uint256 deltaOwner = balanceOfOwnerB4 - balanceOfOwnerAfter;
uint256 deltaRouterEscrow = balanceOfRouterEscrowB4 - balanceOfRouterEscrowAfter;

eq(deltaEscrow, shares, "Router-x");
eq(deltaOwner, shares, "Router-x");
eq(deltaRouterEscrow, 0, "Router-x");
}
}

// TODO: once we have multi actor support, include receiver != controller case
function router_claimDeposit(address sender) public {
// Bal b4
Expand Down
Loading