Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Liquidity Provisioning Utilities for Liquidity Providors + JIT Exploitation #26

Open
0xOsiris opened this issue Dec 14, 2022 · 4 comments
Labels

Comments

@0xOsiris
Copy link
Collaborator

I think adding liquidity provision helpers on the pools could be very appealing to liquidity providers monitoring and moving around large amounts of liquidity across CFMMs. This would allow liquidity providers to seamlessly automate their liquidity provision, and analytically optimize the profitability of their positions.

For Starters:

Mint Liquidity

function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

Collect Fees

function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

Remove Liquidity from a position

function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

Ranged Liquidity or Time Weighted Average price

function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

Seconds per Liquidity & Seconds inside a tick range

function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
        external
        view
        returns (
            int56 tickCumulativeInside,
            uint160 secondsPerLiquidityInsideX128,
            uint32 secondsInside
        );

The above function would also be helpful for calculating optimal JIT positions and amounts.

@0xKitsune
Copy link
Owner

Yeah lets, definitely add some functions to calculate JIT on pools. We can figure out what functionality we want and what those functions might look like after we get the rest of the lib tested.

@tim-schultz
Copy link

Have you all started on this yet? Would be happy to help out if not

@0xKitsune
Copy link
Owner

Hey, this has not been started yet. Feel free to take this on if you would like. I think we should add all of the helpful functions that a user might interact with for v2 and v3 pools. Feel free to drop any comments here for any brainstorming / feedback that you want along the way!

@tim-schultz
Copy link

👋 sounds great! I will let you know as I make progress

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants