Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Flip-Liquid committed Nov 17, 2022
1 parent d657249 commit f2c1d34
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/OptionSettlement.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -399,26 +399,29 @@ contract OptionSettlementTest is Test, NFTreceiver {
emit log_named_int("claimId1 exercise", engine.underlying(claimId1).exercisePosition);
emit log_named_int("claimId1 underlying", engine.underlying(claimId1).underlyingPosition);

assertEq(engine.underlying(claimId1).exercisePosition, 0);
_assertClaimAmountExercised(claimId1, 69);
_assertClaimAmountExercised(claimId2, 1);

// Jump ahead to option expiry
vm.warp(1 + option.expiryTimestamp);
vm.startPrank(ALICE);
uint256 aliceBalanceExerciseAsset = ERC20(option.exerciseAsset).balanceOf(ALICE);
uint256 aliceBalanceUnderlyingAsset = ERC20(option.underlyingAsset).balanceOf(ALICE);
// Alice's first claim should be completely unexercised
// Alice's first claim should be completely exercised
engine.redeem(claimId1);
assertEq(aliceBalanceExerciseAsset, ERC20(option.exerciseAsset).balanceOf(ALICE));
assertEq(ERC20(option.exerciseAsset).balanceOf(ALICE), aliceBalanceExerciseAsset + 69 * option.exerciseAmount);
assertEq(aliceBalanceUnderlyingAsset, ERC20(option.underlyingAsset).balanceOf(ALICE));

aliceBalanceExerciseAsset = ERC20(option.exerciseAsset).balanceOf(ALICE);
aliceBalanceUnderlyingAsset = ERC20(option.underlyingAsset).balanceOf(ALICE);

// BOB exercised 70 options
// ALICE should retrieve 70 * exerciseAmount of the exercise asset
// ALICE should retrieve (100-70) * underlyingAmount of the underlying asset
engine.redeem(claimId2);
assertEq(ERC20(option.exerciseAsset).balanceOf(ALICE), aliceBalanceExerciseAsset + 70 * option.exerciseAmount);
assertEq(ERC20(option.exerciseAsset).balanceOf(ALICE), aliceBalanceExerciseAsset + 1 * option.exerciseAmount);
assertEq(
ERC20(option.underlyingAsset).balanceOf(ALICE), aliceBalanceUnderlyingAsset + 30 * option.underlyingAmount
ERC20(option.underlyingAsset).balanceOf(ALICE), aliceBalanceUnderlyingAsset + 99 * option.underlyingAmount
);
}

Expand Down

0 comments on commit f2c1d34

Please sign in to comment.