Skip to content

Commit

Permalink
cleanup and add custom tick spacing error
Browse files Browse the repository at this point in the history
  • Loading branch information
emmaguo13 committed Aug 10, 2023
1 parent 032027c commit da2b0e6
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/add liquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
440343
440321
2 changes: 1 addition & 1 deletion .forge-snapshots/initialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
891626
878400
2 changes: 1 addition & 1 deletion .forge-snapshots/remove liquidity and rebalance.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
442540
442584
2 changes: 1 addition & 1 deletion .forge-snapshots/remove liquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
112996
113040
3 changes: 2 additions & 1 deletion contracts/hooks/examples/FullRange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract FullRange is BaseHook, ILockCallback {

/// @notice Thrown when trying to interact with a non-initialized pool
error PoolNotInitialized();
error TickSpacingNotDefault();

/// @dev Min tick for full range with tick spacing of 60
int24 internal constant MIN_TICK = -887220;
Expand Down Expand Up @@ -154,7 +155,7 @@ contract FullRange is BaseHook, ILockCallback {
}

function beforeInitialize(address, PoolKey calldata key, uint160) external override returns (bytes4) {
require(key.tickSpacing == 60, "Tick spacing must be default");
if (key.tickSpacing != 60) revert TickSpacingNotDefault();

PoolId poolId = key.toId();

Expand Down
8 changes: 0 additions & 8 deletions contracts/libraries/UniswapV4ERC20.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
pragma solidity ^0.8.19;

// import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
// import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

import {ERC20} from "solmate/tokens/ERC20.sol";
import {Owned} from "solmate/auth/Owned.sol";

contract UniswapV4ERC20 is ERC20, Owned {
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

constructor(string memory name, string memory symbol) ERC20(name, symbol, 18) Owned(msg.sender) {}

function mint(address account, uint256 amount) external onlyOwner {
Expand Down
4 changes: 1 addition & 3 deletions test/FullRange.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {FullRangeImplementation} from "./shared/implementation/FullRangeImplemen
import {PoolManager} from "@uniswap/v4-core/contracts/PoolManager.sol";
import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol";
import {Deployers} from "@uniswap/v4-core/test/foundry-tests/utils/Deployers.sol";
// import {TestERC20} from "@uniswap/v4-core/contracts/test/TestERC20.sol";
import {MockERC20} from "@uniswap/v4-core/test/foundry-tests/utils/MockERC20.sol";
import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Currency.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
Expand Down Expand Up @@ -50,7 +49,6 @@ contract TestFullRange is Test, Deployers, GasSnapshot {
);

int24 constant TICK_SPACING = 60;
uint160 constant SQRT_RATIO_2_1 = 112045541949572279837463876454;
uint256 constant MAX_DEADLINE = 12329839823;

/// @dev Min tick for full range with tick spacing of 60
Expand Down Expand Up @@ -130,7 +128,7 @@ contract TestFullRange is Test, Deployers, GasSnapshot {
PoolKey memory wrongKey =
PoolKey(Currency.wrap(address(token0)), Currency.wrap(address(token1)), 0, TICK_SPACING + 1, fullRange);

vm.expectRevert("Tick spacing must be default");
vm.expectRevert(FullRange.TickSpacingNotDefault.selector);
manager.initialize(wrongKey, SQRT_RATIO_1_1);
}

Expand Down

0 comments on commit da2b0e6

Please sign in to comment.