added aperture
This commit is contained in:
parent
fbb074e0a2
commit
f1d9104d24
2 changed files with 9 additions and 11 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
|
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
|
||||||
@uniswap/v3-core/=lib/v3-core/
|
@uniswap/v3-core/=lib/v3-core/
|
||||||
@uniswap/v3-periphery/=lib/v3-periphery/
|
@uniswap/v3-periphery/=lib/v3-periphery/
|
||||||
|
@aperture/uni-v3-lib/=lib/uni-v3-lib/src/
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
pragma solidity ^0.8.20;
|
pragma solidity ^0.8.20;
|
||||||
|
|
||||||
import {BloodX} from 'src/BloodX.sol';
|
import '@aperture/uni-v3-lib/TickMath.sol';
|
||||||
import '@uniswap/v3-core/contracts/libraries/TickMath.sol';
|
import '@aperture/uni-v3-lib/LiquidityAmounts.sol';
|
||||||
import '@uniswap/v3-periphery/contracts/libraries/LiquidityAmounts.sol';
|
import '@aperture/uni-v3-lib/PoolAddress.sol';
|
||||||
import '@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol';
|
import '@aperture/uni-v3-lib/CallbackValidation.sol';
|
||||||
import '@uniswap/v3-periphery/contracts/libraries/PositionKey.sol';
|
import '@uniswap/v3-periphery/contracts/libraries/PositionKey.sol';
|
||||||
import '@uniswap/v3-core/contracts/libraries/FixedPoint128.sol';
|
import '@uniswap/v3-core/contracts/libraries/FixedPoint128.sol';
|
||||||
import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol';
|
import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol';
|
||||||
|
|
@ -131,9 +131,8 @@ contract LiquidityManager {
|
||||||
uint256 amount1Owed,
|
uint256 amount1Owed,
|
||||||
bytes calldata data
|
bytes calldata data
|
||||||
) external {
|
) external {
|
||||||
PoolAddress.PoolKey memory poolKey = abi.decode(data, (PoolAddress.PoolKey));
|
PoolKey memory poolKey = abi.decode(data, (PoolKey));
|
||||||
IUniswapV3Pool pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));
|
CallbackValidation.verifyCallback(factory, poolKey);
|
||||||
require(msg.sender == address(pool));
|
|
||||||
|
|
||||||
if (amount0Owed > 0) IERC20(poolKey.token0).transfer(msg.sender, amount0Owed);
|
if (amount0Owed > 0) IERC20(poolKey.token0).transfer(msg.sender, amount0Owed);
|
||||||
if (amount1Owed > 0) IERC20(poolKey.token1).transfer(msg.sender, amount1Owed);
|
if (amount1Owed > 0) IERC20(poolKey.token1).transfer(msg.sender, amount1Owed);
|
||||||
|
|
@ -141,8 +140,7 @@ contract LiquidityManager {
|
||||||
|
|
||||||
/// @notice Add liquidity to an initialized pool
|
/// @notice Add liquidity to an initialized pool
|
||||||
function addLiquidity(AddLiquidityParams memory params) external checkDeadline(params.deadline) {
|
function addLiquidity(AddLiquidityParams memory params) external checkDeadline(params.deadline) {
|
||||||
PoolAddress.PoolKey memory poolKey =
|
PoolKey memory poolKey = PoolAddress.getPoolKey(params.token0, params.token1, FEE);
|
||||||
PoolAddress.PoolKey({token0: params.token0, token1: params.token1, fee: FEE});
|
|
||||||
IUniswapV3Pool pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));
|
IUniswapV3Pool pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));
|
||||||
|
|
||||||
// compute the liquidity amount
|
// compute the liquidity amount
|
||||||
|
|
@ -223,8 +221,7 @@ contract LiquidityManager {
|
||||||
uint128 positionLiquidity = position.liquidity;
|
uint128 positionLiquidity = position.liquidity;
|
||||||
require(positionLiquidity >= params.liquidity);
|
require(positionLiquidity >= params.liquidity);
|
||||||
|
|
||||||
PoolAddress.PoolKey memory poolKey =
|
PoolKey memory poolKey = PoolAddress.getPoolKey(params.token0, params.token1, FEE);
|
||||||
PoolAddress.PoolKey({token0: params.token0, token1: params.token1, fee: FEE});
|
|
||||||
IUniswapV3Pool pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));
|
IUniswapV3Pool pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));
|
||||||
|
|
||||||
(amount0, amount1) = pool.burn(params.tickLower, params.tickUpper, params.liquidity);
|
(amount0, amount1) = pool.burn(params.tickLower, params.tickUpper, params.liquidity);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue