Skip to content

Commit

Permalink
add eth workflow, fix 0 fee using_eth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kinrezC committed Oct 23, 2024
1 parent 8374570 commit 990c84a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ jobs:
export PROTOCOL_FEE=50
forge test -vvv --via-ir
id: test2

- name: Run forge tests with usingEth (true)
run: |
export USING_ETH=TRUE
export FEE=0
export PROTOCOL_FEE=0
forge test -vvv --via-ir
id: test3
14 changes: 11 additions & 3 deletions test/unit/EarlyExit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {PoolManager} from "v4-core/src/PoolManager.sol";
import {PoolSwapTest} from "v4-core/src/test/PoolSwapTest.sol";
import {MaximumProceedsReached} from "src/Doppler.sol";
import {PoolModifyLiquidityTest} from "v4-core/src/test/PoolModifyLiquidityTest.sol";
import {Quoter, IQuoter} from "v4-periphery/src/lens/Quoter.sol";
import {CustomRouter} from "test/shared/CustomRouter.sol";
import "forge-std/console.sol";

using PoolIdLibrary for PoolKey;
Expand Down Expand Up @@ -71,11 +73,17 @@ contract EarlyExitTest is BaseTest {
// Note: Only used to validate that liquidity can't be manually modified
modifyLiquidityRouter = new PoolModifyLiquidityTest(manager);

// Approve the router to spend tokens on behalf of the test contract
TestERC20(token0).approve(address(swapRouter), type(uint256).max);
if (token0 != address(0)) {
// Approve the router to spend tokens on behalf of the test contract
TestERC20(token0).approve(address(swapRouter), type(uint256).max);
TestERC20(token0).approve(address(modifyLiquidityRouter), type(uint256).max);
}
TestERC20(token1).approve(address(swapRouter), type(uint256).max);
TestERC20(token0).approve(address(modifyLiquidityRouter), type(uint256).max);
TestERC20(token1).approve(address(modifyLiquidityRouter), type(uint256).max);

quoter = new Quoter(manager);

router = new CustomRouter(swapRouter, quoter, key, isToken0, usingEth);
}

function test_swap_RevertsIfMaximumProceedsReached() public {
Expand Down
11 changes: 1 addition & 10 deletions test/unit/Swap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,7 @@ contract SwapTest is BaseTest {

int256 minimumProceeds = int256(hook.getMinimumProceeds());

swapRouter.swap(
// Swap numeraire to asset
// If zeroForOne, we use max price limit (else vice versa)
key,
IPoolManager.SwapParams(
!isToken0, -minimumProceeds * 11 / 10, !isToken0 ? MIN_PRICE_LIMIT : MAX_PRICE_LIMIT
),
PoolSwapTest.TestSettings(true, false),
""
);
buy(-minimumProceeds * 11 / 10);

vm.warp(hook.getEndingTime() + 1); // 1 second after the end time

Expand Down

0 comments on commit 990c84a

Please sign in to comment.