Skip to content

Commit

Permalink
ensure tokens are ordered properly by using salts
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed Feb 15, 2024
1 parent 400e302 commit a0599a1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/Quoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {PoolManager} from "@uniswap/v4-core/src/PoolManager.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol";
import {TickMath} from "@uniswap/v4-core/src/libraries/TickMath.sol";
import {console2} from "forge-std/console2.sol";

contract QuoterTest is Test, Deployers {
using SafeCast for *;
Expand Down Expand Up @@ -53,14 +54,15 @@ contract QuoterTest is Test, Deployers {
quoter = new Quoter(address(manager));
positionManager = new PoolModifyPositionTest(manager);

// salts are chosen so that address(token0) < address(token2) && address(1) < address(token2)
bytes32 salt1 = "ffff";
bytes32 salt2 = "gm";
token0 = new MockERC20{salt: salt1}("Test0", "0", 18);
// salts are chosen so that address(token0) < address(token1) && address(token1) < address(token2)
bytes32 salt0 = "1234";
bytes32 salt1 = "gm uniswap";
bytes32 salt2 = "ffff";
token0 = new MockERC20{salt: salt0}("Test0", "0", 18);
token0.mint(address(this), 2 ** 128);
token1 = new MockERC20{salt: salt2}("Test1", "1", 18);
token1 = new MockERC20{salt: salt1}("Test1", "1", 18);
token1.mint(address(this), 2 ** 128);
token2 = new MockERC20("Test2", "2", 18);
token2 = new MockERC20{salt: salt2}("Test2", "2", 18);
token2.mint(address(this), 2 ** 128);

key01 = createPoolKey(token0, token1, address(0));
Expand Down Expand Up @@ -295,6 +297,9 @@ contract QuoterTest is Test, Deployers {
}

function testQuoter_quoteExactInput_0to2to1() public {
console2.log(address(token0));
console2.log(address(token1));
console2.log(address(token2));
tokenPath.push(token0);
tokenPath.push(token2);
tokenPath.push(token1);
Expand Down

0 comments on commit a0599a1

Please sign in to comment.