Skip to content

Commit

Permalink
correct smart vault withdrawal test to account for protocol + uniswap…
Browse files Browse the repository at this point in the history
… fees
  • Loading branch information
ewansheldon committed Oct 21, 2024
1 parent 67f6b07 commit c7966fc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/foundry/SmartVault.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;

import {Test, stdError} from "forge-std/Test.sol";
import {Test, stdError, console} from "forge-std/Test.sol";

import {IHypervisor} from "contracts/interfaces/IHypervisor.sol";
import {ERC20Mock} from "src/test_utils/ERC20Mock.sol";
Expand Down Expand Up @@ -454,7 +454,11 @@ contract SmartVaultTest is SmartVaultFixture, Test {
emit Withdraw(address(smartVault), address(weth), address(usdsHypervisor), 0);
smartVault.withdrawYield(address(usdsHypervisor), NATIVE, 5e4, block.timestamp + 60);
vm.stopPrank();
assertGt(address(smartVault).balance, nativeAmount + wethAmount - nativeBefore);
uint256 fee = (nativeAmount + wethAmount) * PROTOCOL_FEE_RATE / 1e5;
uint256 maxUniswapFee = (nativeAmount + wethAmount) * 3000 / 1e6;
assertGt(address(smartVault).balance, nativeAmount + wethAmount - nativeBefore - fee - maxUniswapFee);
// approx assertion (1%) because there is some loss with uniswap fees
assertApproxEqAbs(weth.balanceOf(PROTOCOL), fee, fee / 100);
}

function test_yieldCollateralCheck() public {
Expand Down

0 comments on commit c7966fc

Please sign in to comment.