Skip to content

Commit

Permalink
Cleaned up code and added 2 additional calls to swap
Browse files Browse the repository at this point in the history
  • Loading branch information
chuacw committed Sep 25, 2024
1 parent 6e8d24b commit d2e31a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
3 changes: 0 additions & 3 deletions script/HookDonation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {Currency} from "v4-core/types/Currency.sol";
import {HookMiner} from "../test/utils/HookMiner.sol";
// import {HookMiner} from "../test/HookMiner.sol";
// import {BasicHook} from "../src/BasicHook.sol";
import {AfterSwapDonationHook} from "../src/HookDonation.sol";
import {SwapHelper} from "../src/SwapHelper.sol";
import "forge-std/console.sol";
// K:\Development\Ethereum\UniswapHook-Donations\lib\v4-periphery\lib\v4-core\src\libraries\Hooks.sol
import "@uniswap/v4-core/src/libraries/Hooks.sol";

contract AfterSwapHookDonationDeployScript is Script {
Expand Down
19 changes: 4 additions & 15 deletions test/HookDonation.t.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

// import "lib/v4-periphery/lib/v4-core/lib/forge-std/src/Test.sol";
// import {console} from "lib/v4-periphery/lib/v4-core/lib/forge-std/src/console.sol";
// import {Hooks} from "lib/v4-core/src/libraries/Hooks.sol";
// import {Deployers} from "lib/v4-core/test/utils/Deployers.sol";
// import {IPoolManager} from "lib/v4-core/src/interfaces/IPoolManager.sol";
// import {AfterSwapDonationHook} from "../src/HookDonation.sol";
// import {Currency, CurrencyLibrary} from "lib/v4-core/src/types/Currency.sol";
// import {MockERC20} from "lib/v4-core/lib/solmate/src/test/utils/mocks/MockERC20.sol"; // ...
// import {PoolKey} from "lib/v4-core/src/types/PoolKey.sol";
// import {IHooks} from "lib/v4-core/src/interfaces/IHooks.sol";
// import {HookMiner} from "./utils/HookMiner.sol";
// import {PoolSwapTest} from "lib/v4-core/src/test/PoolSwapTest.sol";
// import {BaseHook} from "lib/v4-periphery/src/base/hooks/BaseHook.sol";
// import {IHooks} from "lib/v4-core/src/interfaces/IHooks.sol";

import "forge-std/Test.sol";
import "@uniswap/v4-core/test/utils/Deployers.sol";
import {AfterSwapDonationHook} from "../src/HookDonation.sol";
Expand Down Expand Up @@ -145,6 +130,10 @@ contract DonationTest is Test, Deployers {
bool zeroForOne = true;
int256 amountToSwap = 1 ether;
bytes memory data = abi.encode(msg.sender);

swap(pool, zeroForOne, amountToSwap, data);
swap(pool, !zeroForOne, -amountToSwap, data);
swap(pool, zeroForOne, -amountToSwap, data);
console.log("Swapped 3 times!");
}
}

0 comments on commit d2e31a1

Please sign in to comment.