Skip to content

Commit

Permalink
building
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed Dec 9, 2023
1 parent 023a298 commit 86f9a3e
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 98 deletions.
10 changes: 5 additions & 5 deletions forge-test/Counter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ pragma solidity ^0.8.19;
// TODO: update to v4-periphery/BaseHook.sol when its compatible
import {BaseHook} from "./forks/BaseHook.sol";

import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
import {BalanceDelta} from "@uniswap/v4-core/contracts/types/BalanceDelta.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "v4-core/types/PoolId.sol";
import {BalanceDelta} from "v4-core/types/BalanceDelta.sol";

contract Counter is BaseHook {
using PoolIdLibrary for PoolKey;
Expand Down
18 changes: 9 additions & 9 deletions forge-test/Counter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
pragma solidity ^0.8.19;

import "forge-std/Test.sol";
import {IHooks} from "@uniswap/v4-core/contracts/interfaces/IHooks.sol";
import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {TickMath} from "@uniswap/v4-core/contracts/libraries/TickMath.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {BalanceDelta} from "@uniswap/v4-core/contracts/types/BalanceDelta.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
import {Constants} from "@uniswap/v4-core/contracts/../test/utils/Constants.sol";
import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Currency.sol";
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";
import {TickMath} from "v4-core/libraries/TickMath.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {BalanceDelta} from "v4-core/types/BalanceDelta.sol";
import {PoolId, PoolIdLibrary} from "v4-core/types/PoolId.sol";
import {Constants} from "v4-core/../test/utils/Constants.sol";
import {CurrencyLibrary, Currency} from "v4-core/types/Currency.sol";
import {HookTest} from "./utils/HookTest.sol";
import {Counter} from "../src/Counter.sol";
import {HookMiner} from "./utils/HookMiner.sol";
Expand Down
18 changes: 9 additions & 9 deletions forge-test/FixedHookFee.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
pragma solidity ^0.8.19;

import "forge-std/Test.sol";
import {IHooks} from "@uniswap/v4-core/contracts/interfaces/IHooks.sol";
import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {TickMath} from "@uniswap/v4-core/contracts/libraries/TickMath.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {BalanceDelta} from "@uniswap/v4-core/contracts/types/BalanceDelta.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
import {Constants} from "@uniswap/v4-core/contracts/../test/utils/Constants.sol";
import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Currency.sol";
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";
import {TickMath} from "v4-core/libraries/TickMath.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {BalanceDelta} from "v4-core/types/BalanceDelta.sol";
import {PoolId, PoolIdLibrary} from "v4-core/types/PoolId.sol";
import {Constants} from "v4-core/../test/utils/Constants.sol";
import {CurrencyLibrary, Currency} from "v4-core/types/Currency.sol";
import {HookTest} from "../utils/HookTest.sol";
import {FixedHookFee} from "../../src/examples/FixedHookFee.sol";
import {HookMiner} from "../utils/HookMiner.sol";
Expand Down
18 changes: 9 additions & 9 deletions forge-test/NoOpSwap.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
pragma solidity ^0.8.19;

import "forge-std/Test.sol";
import {IHooks} from "@uniswap/v4-core/contracts/interfaces/IHooks.sol";
import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {TickMath} from "@uniswap/v4-core/contracts/libraries/TickMath.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {BalanceDelta} from "@uniswap/v4-core/contracts/types/BalanceDelta.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
import {Constants} from "@uniswap/v4-core/contracts/../test/utils/Constants.sol";
import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Currency.sol";
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";
import {TickMath} from "v4-core/libraries/TickMath.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {BalanceDelta} from "v4-core/types/BalanceDelta.sol";
import {PoolId, PoolIdLibrary} from "v4-core/types/PoolId.sol";
import {Constants} from "v4-core/../test/utils/Constants.sol";
import {CurrencyLibrary, Currency} from "v4-core/types/Currency.sol";
import {HookTest} from "./utils/HookTest.sol";
import {NoOpSwap} from "../src/pages/hooks/no-op/NoOpSwap.sol";
import {HookMiner} from "./utils/HookMiner.sol";
Expand Down
20 changes: 10 additions & 10 deletions forge-test/utils/HookTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ pragma solidity ^0.8.19;

import "forge-std/Test.sol";

import {PoolManager} from "@uniswap/v4-core/contracts/PoolManager.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {BalanceDelta} from "@uniswap/v4-core/contracts/types/BalanceDelta.sol";
import {PoolInitializeTest} from "@uniswap/v4-core/contracts/test/PoolInitializeTest.sol";
import {PoolModifyPositionTest} from "@uniswap/v4-core/contracts/test/PoolModifyPositionTest.sol";
import {PoolSwapTest} from "@uniswap/v4-core/contracts/test/PoolSwapTest.sol";
import {PoolDonateTest} from "@uniswap/v4-core/contracts/test/PoolDonateTest.sol";
import {PoolManager} from "v4-core/PoolManager.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {BalanceDelta} from "v4-core/types/BalanceDelta.sol";
import {PoolInitializeTest} from "v4-core/test/PoolInitializeTest.sol";
import {PoolModifyPositionTest} from "v4-core/test/PoolModifyPositionTest.sol";
import {PoolSwapTest} from "v4-core/test/PoolSwapTest.sol";
import {PoolDonateTest} from "v4-core/test/PoolDonateTest.sol";

import {TestERC20} from "@uniswap/v4-core/contracts/test/TestERC20.sol";
import {TickMath} from "@uniswap/v4-core/contracts/libraries/TickMath.sol";
import {TestERC20} from "v4-core/test/TestERC20.sol";
import {TickMath} from "v4-core/libraries/TickMath.sol";

/// @notice Contract to initialize some test helpers
/// @dev Minimal initialization. Inheriting contract should set up pools and provision liquidity
Expand Down
27 changes: 10 additions & 17 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
@v4-by-example/=contracts/src/
@openzeppelin/contracts/=contracts/lib/v4-periphery/lib/openzeppelin-contracts/contracts/
@uniswap/v4-core/contracts/=contracts/lib/v4-core/src/
ds-test/=contracts/lib/forge-std/lib/ds-test/src/
forge-gas-snapshot/=contracts/lib/v4-periphery/lib/forge-gas-snapshot/src/
forge-std/=contracts/lib/forge-std/src/
openzeppelin-contracts/=contracts/lib/v4-periphery/lib/openzeppelin-contracts/
solmate/=contracts/lib/v4-core/lib/solmate/src/
v4-periphery/=contracts/lib/v4-periphery/contracts/
lib/forge-std:ds-test/=contracts/lib/forge-std/lib/ds-test/src/
lib/v4-periphery:@openzeppelin/contracts/=contracts/lib/v4-periphery/lib/openzeppelin-contracts/contracts/
lib/v4-periphery:@uniswap/v4-core/contracts/=contracts/lib/v4-core/src/
lib/v4-periphery:ds-test/=contracts/lib/v4-periphery/lib/forge-std/lib/ds-test/src/
lib/v4-periphery:forge-gas-snapshot/=contracts/lib/v4-periphery/lib/forge-gas-snapshot/src/
lib/v4-periphery:forge-std/=contracts/lib/forge-std/src/
lib/v4-periphery:openzeppelin-contracts/=contracts/lib/v4-periphery/lib/openzeppelin-contracts/
lib/v4-periphery:solmate/=contracts/lib/v4-core/lib/solmate/src/
@v4-by-example=src/solidity-utils
@ensdomains/=forge-lib/v4-core/node_modules/@ensdomains/
@openzeppelin/=forge-lib/v4-core/lib/openzeppelin-contracts/
ds-test/=forge-lib/v4-core/lib/forge-std/lib/ds-test/src/
forge-gas-snapshot/=forge-lib/v4-core/lib/forge-gas-snapshot/src/
forge-std/=forge-lib/v4-core/lib/forge-std/src/
hardhat/=forge-lib/v4-core/node_modules/hardhat/
openzeppelin-contracts/=forge-lib/v4-core/lib/openzeppelin-contracts/contracts/
solmate/=forge-lib/v4-core/lib/solmate/src/
v4-core/=forge-lib/v4-core/src/
8 changes: 4 additions & 4 deletions src/pages/create-liquidity/CreateLiquidity.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {PoolModifyPositionTest} from "@uniswap/v4-core/contracts/test/PoolModifyPositionTest.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {PoolModifyPositionTest} from "v4-core/test/PoolModifyPositionTest.sol";

contract CreateLiquidity {
// set the router address
PoolModifyPositionTest lpRouter = PoolModifyPositionTest(0x01);
PoolModifyPositionTest lpRouter = PoolModifyPositionTest(address(0x01));

function createLiquidity(
PoolKey memory poolKey,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PoolModifyPositionTest} from "@uniswap/v4-core/contracts/test/PoolModifyPositionTest.sol";
import {PoolModifyPositionTest} from "v4-core/test/PoolModifyPositionTest.sol";

PoolModifyPositionTest lpRouter = PoolModifyPositionTest(0x01);
address token0 = address(0x11);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/fees/fixed-hook-fee/EnableAccessLock.solsnippet
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";

function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
return Hooks.Permissions({
Expand Down
18 changes: 10 additions & 8 deletions src/pages/fees/fixed-hook-fee/FixedHookFee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
pragma solidity ^0.8.19;

// TODO: update to v4-periphery/BaseHook.sol when its compatible
import {BaseHook} from "@v4-by-example/forks/BaseHook.sol";
import {BaseHook} from "@v4-by-example/BaseHook.sol";

import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
import {BalanceDelta} from "@uniswap/v4-core/contracts/types/BalanceDelta.sol";
import {Currency, CurrencyLibrary} from "@uniswap/v4-core/contracts/types/Currency.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "v4-core/types/PoolId.sol";
import {BalanceDelta} from "v4-core/types/BalanceDelta.sol";
import {Currency, CurrencyLibrary} from "v4-core/types/Currency.sol";

contract FixedHookFee is BaseHook {
using PoolIdLibrary for PoolKey;
Expand Down Expand Up @@ -49,7 +49,9 @@ contract FixedHookFee is BaseHook {

/// @dev Hook fees are kept as PoolManager claims, so collecting ERC20s will require locking
function collectFee(address recipient, Currency currency) external returns (uint256 amount) {
amount = abi.decode(poolManager.lock(abi.encodeCall(this.handleCollectFee, (recipient, currency))), (uint256));
amount = abi.decode(
poolManager.lock(address(this), abi.encodeCall(this.handleCollectFee, (recipient, currency))), (uint256)
);
}

/// @dev requires the lock pattern in order to call poolManager.burn
Expand Down
2 changes: 1 addition & 1 deletion src/pages/hooks/no-op/EnableNoOp.solsnippet
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";

function getHooksCalls() public pure override returns (Hooks.Calls memory) {
return Hooks.Calls({
Expand Down
13 changes: 7 additions & 6 deletions src/pages/hooks/no-op/NoOpSwap.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {BaseHook} from "v4-periphery/BaseHook.sol";
import {BaseHook} from "@v4-by-example/BaseHook.sol";

import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "v4-core/types/PoolId.sol";

contract NoOpSwap is BaseHook {
using PoolIdLibrary for PoolKey;
Expand All @@ -26,7 +26,8 @@ contract NoOpSwap is BaseHook {
afterSwap: false,
beforeDonate: false,
afterDonate: false,
noOp: true // -- ENABLE NO-OP -- //
noOp: true, // -- ENABLE NO-OP -- //
accessLock: false
});
}

Expand Down
12 changes: 6 additions & 6 deletions src/pages/initialize/PoolInitialize.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolInitializeTest} from "@uniswap/v4-core/contracts/test/PoolInitializeTest.sol";
import {IHooks} from "@uniswap/v4-core/contracts/interfaces/IHooks.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Currency.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolInitializeTest} from "v4-core/test/PoolInitializeTest.sol";
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {CurrencyLibrary, Currency} from "v4-core/types/Currency.sol";

contract PoolInitialize {
using CurrencyLibrary for Currency;

// set the initialize router
PoolInitializeTest initializeRouter = PoolInitializeTest(0x02);
PoolInitializeTest initializeRouter = PoolInitializeTest(address(0x02));

function init(
address token0,
Expand Down
12 changes: 6 additions & 6 deletions src/pages/swap/Swap.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {PoolSwapTest} from "@uniswap/v4-core/contracts/test/PoolSwapTest.sol";
import {TickMath} from "@uniswap/v4-core/contracts/libraries/TickMath.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {PoolSwapTest} from "v4-core/test/PoolSwapTest.sol";
import {TickMath} from "v4-core/libraries/TickMath.sol";

contract Swap {
// set the router address
PoolSwapTest swapRouter = PoolSwapTest(0x01);
PoolSwapTest swapRouter = PoolSwapTest(address(0x01));

// slippage tolerance to allow for unlimited price impact
uint160 public constant MIN_PRICE_LIMIT = TickMath.MIN_SQRT_RATIO + 1;
Expand All @@ -29,7 +29,7 @@ contract Swap {
// in v4, users have the option to receieve native ERC20s or wrapped ERC1155 tokens
// here, we'll take the ERC20s
PoolSwapTest.TestSettings memory testSettings =
PoolSwapTest.TestSettings({withdrawTokens: true, settleUsingTransfer: true});
PoolSwapTest.TestSettings({withdrawTokens: true, settleUsingTransfer: true, currencyAlreadySent: false});

swapRouter.swap(key, params, testSettings, hookData);
}
Expand Down
12 changes: 6 additions & 6 deletions src/solidity-utils/BaseHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {IHooks} from "@uniswap/v4-core/contracts/interfaces/IHooks.sol";
import {BalanceDelta} from "@uniswap/v4-core/contracts/types/BalanceDelta.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {BalanceDelta} from "v4-core/types/BalanceDelta.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";

abstract contract BaseHook is IHooks {
error NotPoolManager();
Expand Down Expand Up @@ -55,7 +55,7 @@ abstract contract BaseHook is IHooks {
Hooks.validateHookPermissions(_this, getHookPermissions());
}

function lockAcquired(bytes calldata data) external virtual poolManagerOnly returns (bytes memory) {
function lockAcquired(address, bytes calldata data) external virtual poolManagerOnly returns (bytes memory) {
(bool success, bytes memory returnData) = address(this).call(data);
if (success) return returnData;
if (returnData.length == 0) revert LockFailure();
Expand Down

0 comments on commit 86f9a3e

Please sign in to comment.