Skip to content

Commit

Permalink
feat: remove Uniswap/v2-core
Browse files Browse the repository at this point in the history
  • Loading branch information
thaixuandang committed Jul 25, 2024
1 parent 7f6170e commit 55f075a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "lib/base64"]
path = lib/base64
url = https://github.com/Brechtpd/base64
[submodule "lib/v2-core"]
path = lib/v2-core
url = https://github.com/Uniswap/v2-core
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
1 change: 0 additions & 1 deletion lib/v2-core
Submodule v2-core deleted from 4dd590
6 changes: 3 additions & 3 deletions src/periphery/V3Migrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ pragma solidity =0.7.6;
pragma abicoder v2;

import "@katana/v3-contracts/core/libraries/LowGasSafeMath.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

import "./interfaces/INonfungiblePositionManager.sol";

import "./libraries/TransferHelper.sol";

import "./interfaces/IV3Migrator.sol";
import "./interfaces/IKatanaV2Pair.sol";
import "./base/PeripheryImmutableState.sol";
import "./base/Multicall.sol";
import "./base/SelfPermit.sol";
Expand Down Expand Up @@ -37,8 +37,8 @@ contract V3Migrator is IV3Migrator, PeripheryImmutableState, PoolInitializer, Mu
require(params.percentageToMigrate <= 100, "Percentage too large");

// burn v2 liquidity to this address
IUniswapV2Pair(params.pair).transferFrom(msg.sender, params.pair, params.liquidityToMigrate);
(uint256 amount0V2, uint256 amount1V2) = IUniswapV2Pair(params.pair).burn(address(this));
IKatanaV2Pair(params.pair).transferFrom(msg.sender, params.pair, params.liquidityToMigrate);
(uint256 amount0V2, uint256 amount1V2) = IKatanaV2Pair(params.pair).burn(address(this));

// calculate the amounts to migrate to v3
uint256 amount0V2ToMigrate = amount0V2.mul(params.percentageToMigrate) / 100;
Expand Down
53 changes: 53 additions & 0 deletions src/periphery/interfaces/IKatanaV2Pair.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
pragma solidity >=0.5.0;

interface IKatanaV2Pair {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);

function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);

function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);

function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint256);

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
external;

event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
event Swap(
address indexed sender,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);

function MINIMUM_LIQUIDITY() external pure returns (uint256);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint256);
function price1CumulativeLast() external view returns (uint256);
function kLast() external view returns (uint256);

function mint(address to) external returns (uint256 liquidity);
function burn(address to) external returns (uint256 amount0, uint256 amount1);
function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;

function initialize(address, address) external;
}
1 change: 0 additions & 1 deletion src/periphery/lens/MixedRouteQuoterV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import "@katana/v3-contracts/core/interfaces/callback/IKatanaV3SwapCallback.sol"
import "@katana/v3-contracts/periphery/libraries/Path.sol";
import "@katana/v3-contracts/periphery/libraries/PoolAddress.sol";
import "@katana/v3-contracts/periphery/libraries/CallbackValidation.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

import "../base/ImmutableState.sol";
import "../interfaces/IMixedRouteQuoterV1.sol";
Expand Down
1 change: 0 additions & 1 deletion src/periphery/lens/MixedRouteQuoterV1Testnet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import "@katana/v3-contracts/core/interfaces/callback/IKatanaV3SwapCallback.sol"
import "@katana/v3-contracts/periphery/libraries/Path.sol";
import "@katana/v3-contracts/periphery/libraries/PoolAddress.sol";
import "@katana/v3-contracts/periphery/libraries/CallbackValidation.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

import "../base/ImmutableState.sol";
import "../interfaces/IMixedRouteQuoterV1.sol";
Expand Down
4 changes: 2 additions & 2 deletions src/periphery/libraries/KatanaV2Library.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "@katana/v3-contracts/core/libraries/LowGasSafeMath.sol";
import "../interfaces/IKatanaV2Pair.sol";

library KatanaV2Library {
using LowGasSafeMath for uint256;
Expand Down Expand Up @@ -38,7 +38,7 @@ library KatanaV2Library {
returns (uint256 reserveA, uint256 reserveB)
{
(address token0,) = sortTokens(tokenA, tokenB);
(uint256 reserve0, uint256 reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(uint256 reserve0, uint256 reserve1,) = IKatanaV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}

Expand Down
4 changes: 2 additions & 2 deletions src/periphery/libraries/KatanaV2LibraryTestnet.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "@katana/v3-contracts/core/libraries/LowGasSafeMath.sol";
import "../interfaces/IKatanaV2Pair.sol";

library KatanaV2Library {
using LowGasSafeMath for uint256;
Expand Down Expand Up @@ -38,7 +38,7 @@ library KatanaV2Library {
returns (uint256 reserveA, uint256 reserveB)
{
(address token0,) = sortTokens(tokenA, tokenB);
(uint256 reserve0, uint256 reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(uint256 reserve0, uint256 reserve1,) = IKatanaV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}

Expand Down

0 comments on commit 55f075a

Please sign in to comment.