Skip to content

Commit

Permalink
updating to next core-next
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilz committed Aug 7, 2023
1 parent 6fdd287 commit 87264b1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
1 change: 1 addition & 0 deletions lib/solmate
Submodule solmate added at bfc9c2
2 changes: 1 addition & 1 deletion lib/v4-core
Submodule v4-core updated 31 files
+1 −0 .forge-snapshots/getAmount0Delta_gasCostForAmount0WhereRoundUpIsFalse.snap
+1 −0 .forge-snapshots/getAmount0Delta_gasCostForAmount0WhereRoundUpIsTrue.snap
+1 −0 .forge-snapshots/getAmount1Delta_gasCostForAmount1WhereRoundUpIsFalse.snap
+1 −0 .forge-snapshots/getAmount1Delta_gasCostForAmount1WhereRoundUpIsTrue.snap
+1 −0 .forge-snapshots/getNextSqrtPriceFromInput_zeroForOneEqualsFalseGas.snap
+1 −0 .forge-snapshots/getNextSqrtPriceFromInput_zeroForOneEqualsTrueGas.snap
+1 −0 .forge-snapshots/getNextSqrtPriceFromOutput_zeroForOneEqualsFalseGas.snap
+1 −0 .forge-snapshots/getNextSqrtPriceFromOutput_zeroForOneEqualsTrueGas.snap
+1 −1 .forge-snapshots/initialize.snap
+1 −0 .gitmodules
+1 −0 contracts/PoolManager.sol
+3 −0 contracts/interfaces/IPoolManager.sol
+0 −61 contracts/test/FullMathEchidnaTest.sol
+0 −14 contracts/test/FullMathTest.sol
+14 −4 contracts/types/Currency.sol
+1 −1 remappings.txt
+0 −179 test/FullMath.spec.ts
+7 −2 test/PoolManager.gas.spec.ts
+0 −379 test/SqrtPriceMath.spec.ts
+1 −1 test/__snapshots__/PoolManager.gas.spec.ts.snap
+1 −1 test/__snapshots__/PoolManager.spec.ts.snap
+0 −17 test/__snapshots__/SqrtPriceMath.spec.ts.snap
+206 −0 test/foundry-tests/FullMath.t.sol
+13 −17 test/foundry-tests/Hooks.t.sol
+22 −3 test/foundry-tests/PoolManager.t.sol
+342 −0 test/foundry-tests/SqrtPriceMath.t.sol
+15 −0 test/foundry-tests/utils/Constants.sol
+18 −16 test/foundry-tests/utils/Deployers.sol
+5 −1 test/foundry-tests/utils/MockERC20.sol
+19 −0 test/foundry-tests/utils/SortTokens.sol
+4 −15 test/foundry-tests/utils/TokenFixture.sol
12 changes: 8 additions & 4 deletions test/GeomeanOracle.t.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import "forge-std/console.sol";
import {Test} from "forge-std/Test.sol";
import {GetSender} from "./shared/GetSender.sol";
import {Hooks} from "@uniswap/v4-core/contracts/libraries/Hooks.sol";
Expand All @@ -9,6 +10,7 @@ import {GeomeanOracleImplementation} from "./shared/implementation/GeomeanOracle
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 {TokenFixture} from "@uniswap/v4-core/test/foundry-tests/utils/TokenFixture.sol";
import {TestERC20} from "@uniswap/v4-core/contracts/test/TestERC20.sol";
import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Currency.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
Expand All @@ -17,7 +19,7 @@ import {TickMath} from "@uniswap/v4-core/contracts/libraries/TickMath.sol";
import {Oracle} from "../contracts/libraries/Oracle.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";

contract TestGeomeanOracle is Test, Deployers {
contract TestGeomeanOracle is Test, Deployers, TokenFixture {
using PoolIdLibrary for PoolKey;

int24 constant MAX_TICK_SPACING = 32767;
Expand All @@ -40,8 +42,10 @@ contract TestGeomeanOracle is Test, Deployers {
PoolModifyPositionTest modifyPositionRouter;

function setUp() public {
token0 = new TestERC20(2**128);
token1 = new TestERC20(2**128);
initializeTokens();
token0 = TestERC20(Currency.unwrap(currency0));
token1 = TestERC20(Currency.unwrap(currency1));

manager = new PoolManager(500000);

vm.record();
Expand All @@ -57,7 +61,7 @@ contract TestGeomeanOracle is Test, Deployers {
}
geomeanOracle.setTime(1);
key =
PoolKey(Currency.wrap(address(token0)), Currency.wrap(address(token1)), 0, MAX_TICK_SPACING, geomeanOracle);
PoolKey(currency0, currency1, 0, MAX_TICK_SPACING, geomeanOracle);
id = key.toId();

modifyPositionRouter = new PoolModifyPositionTest(manager);
Expand Down
15 changes: 9 additions & 6 deletions test/LimitOrder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import {LimitOrderImplementation} from "./shared/implementation/LimitOrderImplem
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 {TokenFixture} from "@uniswap/v4-core/test/foundry-tests/utils/TokenFixture.sol";
import {TestERC20} from "@uniswap/v4-core/contracts/test/TestERC20.sol";
import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Currency.sol";
import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/contracts/types/PoolId.sol";
import {PoolSwapTest} from "@uniswap/v4-core/contracts/test/PoolSwapTest.sol";
import {TickMath} from "@uniswap/v4-core/contracts/libraries/TickMath.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";

contract TestLimitOrder is Test, Deployers {
contract TestLimitOrder is Test, Deployers, TokenFixture {
using PoolIdLibrary for PoolKey;

uint160 constant SQRT_RATIO_10_1 = 250541448375047931186413801569;
Expand All @@ -31,8 +32,10 @@ contract TestLimitOrder is Test, Deployers {
PoolSwapTest swapRouter;

function setUp() public {
token0 = new TestERC20(2**128);
token1 = new TestERC20(2**128);
initializeTokens();
token0 = TestERC20(Currency.unwrap(currency0));
token1 = TestERC20(Currency.unwrap(currency1));

manager = new PoolManager(500000);

vm.record();
Expand All @@ -47,7 +50,7 @@ contract TestLimitOrder is Test, Deployers {
}
}

key = PoolKey(Currency.wrap(address(token0)), Currency.wrap(address(token1)), 3000, 60, limitOrder);
key = PoolKey(currency0, currency1, 3000, 60, limitOrder);
id = key.toId();
manager.initialize(key, SQRT_RATIO_1_1);

Expand Down Expand Up @@ -159,8 +162,8 @@ contract TestLimitOrder is Test, Deployers {
uint128 liquidityTotal
) = limitOrder.epochInfos(Epoch.wrap(1));
assertFalse(filled);
assertTrue(CurrencyLibrary.equals(currency0, Currency.wrap(address(token0))));
assertTrue(CurrencyLibrary.equals(currency1, Currency.wrap(address(token1))));
assertTrue(currency0 == Currency.wrap(address(token0)));
assertTrue(currency1 == Currency.wrap(address(token1)));
assertEq(token0Total, 0);
assertEq(token1Total, 0);
assertEq(liquidityTotal, liquidity * 2);
Expand Down
21 changes: 11 additions & 10 deletions test/TWAMM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.15;
import {Test} from "forge-std/Test.sol";
import {Vm} from "forge-std/Vm.sol";
import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol";
import {TestERC20} from "@uniswap/v4-core/contracts/test/TestERC20.sol";
import {MockERC20} from "@uniswap/v4-core/test/foundry-tests/utils/MockERC20.sol";
import {IERC20Minimal} from "@uniswap/v4-core/contracts/interfaces/external/IERC20Minimal.sol";
import {TWAMMImplementation} from "./shared/implementation/TWAMMImplementation.sol";
import {IHooks} from "@uniswap/v4-core/contracts/interfaces/IHooks.sol";
Expand Down Expand Up @@ -53,14 +53,15 @@ contract TWAMMTest is Test, Deployers, GasSnapshot {
PoolSwapTest swapRouter;
PoolDonateTest donateRouter;
address hookAddress;
TestERC20 token0;
TestERC20 token1;
MockERC20 token0;
MockERC20 token1;
PoolKey poolKey;
PoolId poolId;

function setUp() public {
token0 = new TestERC20(2**128);
token1 = new TestERC20(2**128);
initializeTokens();
token0 = MockERC20(Currency.unwrap(currency0));
token1 = MockERC20(Currency.unwrap(currency1));
manager = new PoolManager(500000);

TWAMMImplementation impl = new TWAMMImplementation(manager, 10_000, twamm);
Expand Down Expand Up @@ -381,8 +382,8 @@ contract TWAMMTest is Test, Deployers, GasSnapshot {
assertEq(earningsToken0, orderAmount / 2);
assertEq(earningsToken1, orderAmount / 2);

uint256 balance0BeforeTWAMM = TestERC20(Currency.unwrap(poolKey.currency0)).balanceOf(address(twamm));
uint256 balance1BeforeTWAMM = TestERC20(Currency.unwrap(poolKey.currency1)).balanceOf(address(twamm));
uint256 balance0BeforeTWAMM = MockERC20(Currency.unwrap(poolKey.currency0)).balanceOf(address(twamm));
uint256 balance1BeforeTWAMM = MockERC20(Currency.unwrap(poolKey.currency1)).balanceOf(address(twamm));
uint256 balance0BeforeThis = poolKey.currency0.balanceOfSelf();
uint256 balance1BeforeThis = poolKey.currency1.balanceOfSelf();

Expand All @@ -396,8 +397,8 @@ contract TWAMMTest is Test, Deployers, GasSnapshot {
assertEq(twamm.tokensOwed(poolKey.currency0, address(this)), 0);
assertEq(twamm.tokensOwed(poolKey.currency1, address(this)), 0);

uint256 balance0AfterTWAMM = TestERC20(Currency.unwrap(poolKey.currency0)).balanceOf(address(twamm));
uint256 balance1AfterTWAMM = TestERC20(Currency.unwrap(poolKey.currency1)).balanceOf(address(twamm));
uint256 balance0AfterTWAMM = MockERC20(Currency.unwrap(poolKey.currency0)).balanceOf(address(twamm));
uint256 balance1AfterTWAMM = MockERC20(Currency.unwrap(poolKey.currency1)).balanceOf(address(twamm));
uint256 balance0AfterThis = poolKey.currency0.balanceOfSelf();
uint256 balance1AfterThis = poolKey.currency1.balanceOfSelf();

Expand All @@ -410,7 +411,7 @@ contract TWAMMTest is Test, Deployers, GasSnapshot {
}

function newPoolKeyWithTWAMM(IHooks hooks) public returns (PoolKey memory, PoolId) {
TestERC20[] memory tokens = deployTokens(2, 2 ** 255);
MockERC20[] memory tokens = deployTokens(2, 2 ** 255);
PoolKey memory key = PoolKey(Currency.wrap(address(tokens[0])), Currency.wrap(address(tokens[1])), 0, 60, hooks);
return (key, key.toId());
}
Expand Down

0 comments on commit 87264b1

Please sign in to comment.