Skip to content

Commit

Permalink
Pangolin V3 added
Browse files Browse the repository at this point in the history
  • Loading branch information
canarydeveloper committed Nov 20, 2024
1 parent 1d07c4a commit a3c771f
Show file tree
Hide file tree
Showing 156 changed files with 654 additions and 469 deletions.
13 changes: 0 additions & 13 deletions .env.example

This file was deleted.

9 changes: 9 additions & 0 deletions addresses/fuji.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Deployed `PangolinV3Factory`: 0xa2C8Cc50C82C9CA44470869f2214cf48a0c45F6b
Deployed `NFTDescriptor` library: 0xE63b2C046fb4cd38E4a0fD8Cb5a700FD878B7392
Deployed `NonfungibleTokenPositionDescriptor`: 0x27be1406540392a4d4ff1cfDf0bdB211676c3efa
Deployed `NonfungiblePositionManager`: 0xffb8250c9cE730cC84B40cBdAce2FF7DFA8e6ef9
Deployed `SwapRouter`: 0x1d5A17D62c68A09A0F8FBa7d585Ce6AA99CB60Dd
Deployed `PangolinV3Migrator`: 0xC50f7aD420E2c273Eaf9A6BCD90C3Df6295a3570
Deployed `PangolinV3InterfaceMulticall`: 0x7CadfB320dFF982a65F8Ab15E4D0AC27d666873C
Deployed `PangolinV3Quoter`: 0x45c3Dc3728D0EA76d77D89Fe7a649dd77eD26d63
Deployed `TickLens`: 0x9573A023DE6A9f22BA67D2A1C3B029f5f93fF19f
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ pragma solidity =0.7.6;

import "openzeppelin-contracts-solc-0.7/proxy/Clones.sol";

import "./interfaces/IElixirFactory.sol";
import "./interfaces/IElixirPool.sol";
import "./interfaces/IPangolinV3Factory.sol";
import "./interfaces/IPangolinV3Pool.sol";

/// @title Canonical Elixir factory
/// @notice Deploys Elixir pools and manages ownership and control over pool protocol fees
contract ElixirFactory is IElixirFactory {
/// @inheritdoc IElixirFactory
/// @title Canonical PangolinV3 factory
/// @notice Deploys PangolinV3 pools and manages ownership and control over pool protocol fees
contract PangolinV3Factory is IPangolinV3Factory {
/// @inheritdoc IPangolinV3Factory
address public immutable override implementation;

/// @inheritdoc IElixirFactory
/// @inheritdoc IPangolinV3Factory
address public override owner;

/// @inheritdoc IElixirFactory
/// @inheritdoc IPangolinV3Factory
mapping(uint24 => int24) public override feeAmountTickSpacing;
/// @inheritdoc IElixirFactory
/// @inheritdoc IPangolinV3Factory
mapping(address => mapping(address => mapping(uint24 => address)))
public
override getPool;
Expand All @@ -28,15 +28,17 @@ contract ElixirFactory is IElixirFactory {
owner = msg.sender;
emit OwnerChanged(address(0), msg.sender);

feeAmountTickSpacing[100] = 1;
emit FeeAmountEnabled(100, 1);
feeAmountTickSpacing[500] = 10;
emit FeeAmountEnabled(500, 10);
feeAmountTickSpacing[3000] = 60;
emit FeeAmountEnabled(3000, 60);
feeAmountTickSpacing[10000] = 200;
emit FeeAmountEnabled(10000, 200);
feeAmountTickSpacing[2500] = 60;
emit FeeAmountEnabled(2500, 60);
feeAmountTickSpacing[8000] = 200;
emit FeeAmountEnabled(8000, 200);
}

/// @inheritdoc IElixirFactory
/// @inheritdoc IPangolinV3Factory
function createPool(
address tokenA,
address tokenB,
Expand All @@ -54,21 +56,21 @@ contract ElixirFactory is IElixirFactory {
implementation,
keccak256(abi.encode(token0, token1, fee))
);
IElixirPool(pool).initialize(token0, token1, fee, tickSpacing);
IPangolinV3Pool(pool).initialize(token0, token1, fee, tickSpacing);
getPool[token0][token1][fee] = pool;
// populate mapping in the reverse direction, deliberate choice to avoid the cost of comparing addresses
getPool[token1][token0][fee] = pool;
emit PoolCreated(token0, token1, fee, tickSpacing, pool);
}

/// @inheritdoc IElixirFactory
/// @inheritdoc IPangolinV3Factory
function setOwner(address _owner) external override {
require(msg.sender == owner);
emit OwnerChanged(owner, _owner);
owner = _owner;
}

/// @inheritdoc IElixirFactory
/// @inheritdoc IPangolinV3Factory
function enableFeeAmount(uint24 fee, int24 tickSpacing) public override {
require(msg.sender == owner);
require(fee < 1000000);
Expand All @@ -81,4 +83,31 @@ contract ElixirFactory is IElixirFactory {
feeAmountTickSpacing[fee] = tickSpacing;
emit FeeAmountEnabled(fee, tickSpacing);
}

function setFee(address _pool, uint24 _fee) external {
require(msg.sender == owner, "AUTH");
int24 tickSpacing = feeAmountTickSpacing[_fee];
require(tickSpacing != 0, "ERRTICK");
IPangolinV3Pool(_pool).setFee(_fee, tickSpacing);
}

function getFee(address _pool) external view returns (uint24) {
uint24 _fee = IPangolinV3Pool(_pool).fee();
return _fee;
}

function setFeeProtocol(address pool, uint8 feeProtocol0, uint8 feeProtocol1) external {
require(msg.sender == owner, "AUTH");
IPangolinV3Pool(pool).setFeeProtocol(feeProtocol0, feeProtocol1);
}

function collectProtocol(
address pool,
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external {
require(msg.sender == owner, "AUTH");
IPangolinV3Pool(pool).collectProtocol(recipient, amount0Requested, amount1Requested);
}
}
Loading

0 comments on commit a3c771f

Please sign in to comment.