wip
This commit is contained in:
parent
f232e9e51b
commit
e28688f3dd
2 changed files with 19 additions and 8 deletions
|
|
@ -1 +1,3 @@
|
|||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
|
||||
@uniswap/v3-core/=lib/v3-core/
|
||||
@uniswap/v3-periphery/=lib/v3-periphery/
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ pragma solidity ^0.8.20;
|
|||
import {BloodX} from "src/BloodX.sol";
|
||||
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
|
||||
import "@uniswap/v3-periphery/contracts/libraries/LiquidityAmounts.sol";
|
||||
import "@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol";
|
||||
import "@uniswap/v3-periphery/contracts/libraries/CallbackValidation.sol";
|
||||
import '@uniswap/v3-periphery/contracts/base/PeripheryImmutableState.sol';
|
||||
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
|
||||
|
|
@ -12,7 +15,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|||
* protects the communities liquidity while allowing a manager role to
|
||||
* take strategic liqudity positions.
|
||||
*/
|
||||
contract LiquidityManager {
|
||||
contract LiquidityManager is PeripheryImmutableState {
|
||||
|
||||
// default fee of 1%
|
||||
uint24 constant FEE = uint24(10_000);
|
||||
|
|
@ -63,10 +66,18 @@ contract LiquidityManager {
|
|||
/// @dev The token ID position data
|
||||
mapping(bytes32 => TokenPosition) private _positions;
|
||||
|
||||
constructor(address _weth) {
|
||||
constructor(
|
||||
address _factory,
|
||||
address _WETH9
|
||||
) {
|
||||
WETH = _weth;
|
||||
}
|
||||
|
||||
modifier checkDeadline(uint256 deadline) {
|
||||
require(block.timestamp <= deadline, 'Transaction too old');
|
||||
_;
|
||||
}
|
||||
|
||||
function getToken(address token0, address token1) internal view returns (address) {
|
||||
bool token0isWeth = (token0 == WETH);
|
||||
require(token0isWeth || token1 == WETH, "token error");
|
||||
|
|
@ -83,18 +94,18 @@ contract LiquidityManager {
|
|||
feesOwed.ethOwed += token0isEth ? tokensOwed0 : tokensOwed1);
|
||||
}
|
||||
|
||||
function posKey(address _token, uint24 _tickLower, uint24, tickUpper) internal pure returns (uint256) {
|
||||
return uint160(_token) << 48 + tickLower << 24 + tickUpper;
|
||||
function posKey(address token, uint24 tickLower, uint24 tickUpper) internal pure returns (uint256) {
|
||||
return uint160(token) << 48 + tickLower << 24 + tickUpper;
|
||||
}
|
||||
|
||||
function positions(address _token, int24 _tickLower, int24 _tickUpper) external view
|
||||
function positions(address token, int24 tickLower, int24 tickUpper) external view
|
||||
returns (
|
||||
uint128 liquidity,
|
||||
uint256 feeGrowthInside0LastX128,
|
||||
uint256 feeGrowthInside1LastX128
|
||||
)
|
||||
{
|
||||
TokenPosition memory position = _positions[posKey(_token, tickLower, tickUpper)];
|
||||
TokenPosition memory position = _positions[posKey(token, tickLower, tickUpper)];
|
||||
return (
|
||||
position.liquidity,
|
||||
position.feeGrowthInside0LastX128,
|
||||
|
|
@ -102,7 +113,6 @@ contract LiquidityManager {
|
|||
);
|
||||
}
|
||||
|
||||
/// @inheritdoc IUniswapV3MintCallback
|
||||
function uniswapV3MintCallback(
|
||||
uint256 amount0Owed,
|
||||
uint256 amount1Owed,
|
||||
|
|
@ -193,7 +203,6 @@ contract LiquidityManager {
|
|||
emit IncreaseLiquidity(tokenId, liquidity, amount0, amount1);
|
||||
}
|
||||
|
||||
/// @inheritdoc INonfungiblePositionManager
|
||||
function decreaseLiquidity(DecreaseLiquidityParams calldata params)
|
||||
external
|
||||
payable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue