Skip to content

Commit

Permalink
test: add swapExactSyForPt, swapExactYtForSy handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Jun 21, 2024
1 parent 8d27bd4 commit 8bd62ef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/invariant/RMMHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,19 @@ contract RMMHandler is CommonBase, StdUtils, StdCheats {
vm.stopPrank();
}

function swapExactSyForPt() public createActor countCall(this.swapExactSyForPt.selector) {}
function swapExactSyForPt() public createActor countCall(this.swapExactSyForPt.selector) {
deal(address(SY), currentActor, 1 ether);
vm.startPrank(currentActor);
SY.approve(address(rmm), 1 ether);
rmm.swapExactSyForPt(1 ether, 0, address(currentActor));
vm.stopPrank();
}

function swapExactYtForSy() public createActor countCall(this.swapExactYtForSy.selector) {}
function swapExactYtForSy() public createActor countCall(this.swapExactYtForSy.selector) {
deal(address(YT), currentActor, 1 ether);
vm.startPrank(currentActor);
YT.approve(address(rmm), 1 ether);
rmm.swapExactYtForSy(1 ether, 0, address(currentActor));
vm.stopPrank();
}
}
3 changes: 3 additions & 0 deletions test/invariant/RMMInvariants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ contract RMMInvariantsTest is SetUp {
console.log("SwapExactPtForSy: ", handler.calls(RMMHandler.swapExactPtForSy.selector));
}

/// forge-config: default.invariant.runs = 100
/// forge-config: default.invariant.depth = 2
/// forge-config: default.invariant.fail-on-revert = false
function invariant_TradingFunction() public {
IPYieldToken YT = handler.YT();
PYIndex index = YT.newIndex();
Expand Down

0 comments on commit 8bd62ef

Please sign in to comment.