Skip to content

Commit

Permalink
✅ test_withdrawCollateral_wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Oct 8, 2024
1 parent 102f05c commit 79b4264
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions test/Collateral.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ contract DepositCollateral is CollateralTest {
engine.modifyCollateralWrap({
_accountId: accountId,
_amount: int256(SMALLER_AMOUNT),
_tolerance: SMALLER_AMOUNT - 3,
_tolerance: SMALLER_AMOUNT,
_collateral: WETH,
_synthMarketId: 4
});
Expand All @@ -167,11 +167,10 @@ contract DepositCollateral is CollateralTest {
engine.modifyCollateralWrap({
_accountId: accountId,
_amount: int256(SMALLEST_AMOUNT),
_tolerance: SMALLEST_AMOUNT - 3,
_tolerance: SMALLEST_AMOUNT,
_collateral: USDC,
_synthMarketId: 2
});

}

function test_depositCollateral_ETH() public {
Expand Down Expand Up @@ -348,27 +347,33 @@ contract WithdrawCollateral is CollateralTest {
}

function test_withdrawCollateral_wrap() public {
//uint256 decimalsFactor = 10 ** (18 - USDC.decimals());

deal(address(WETH), ACTOR, SMALLEST_AMOUNT);
deal(address(WETH), ACTOR, SMALLER_AMOUNT);
uint256 preBalance = WETH.balanceOf(ACTOR);

vm.startPrank(ACTOR);

WETH.approve(address(engine), type(uint256).max);

engine.modifyCollateralWrap({
_accountId: accountId,
_amount: -int256(SMALLEST_AMOUNT),
_tolerance: SMALLEST_AMOUNT - 3,
_amount: int256(SMALLER_AMOUNT),
_tolerance: SMALLER_AMOUNT,
_collateral: WETH,
_synthMarketId: 4
});

engine.modifyCollateralWrap({
_accountId: accountId,
_amount: -int256(SMALLER_AMOUNT),
_tolerance: SMALLER_AMOUNT,
_collateral: WETH,
_synthMarketId: 4
});

vm.stopPrank();

// int256 availableMargin = perpsMarketProxy.getAvailableMargin(accountId);
// int256 expectedMargin = int256(SMALLEST_AMOUNT) * int256(decimalsFactor);
// assertWithinTolerance(expectedMargin, availableMargin, 3);
uint256 postBalance = WETH.balanceOf(ACTOR);
assertEq(postBalance, preBalance);
}

function test_withdrawCollateral_ETH() public {
Expand Down

0 comments on commit 79b4264

Please sign in to comment.