Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add liquidity calcs for getting alpha and liquidity amounts given an … #1456

Open
wants to merge 1 commit into
base: feat/uniswapv3-lp
Choose a base branch
from

Conversation

0xcacti
Copy link

@0xcacti 0xcacti commented Mar 25, 2025

Description

This PR adds two new auxiliary functions to calculate liquidity amounts for Uniswap V3-style liquidity provision:

  1. get_tao_based_liquidity: Calculates the Alpha amount and liquidity given an amount of TAO and a price range
  2. get_alpha_based_liquidity: Calculates the TAO amount and liquidity given an amount of Alpha and a price range

These functions enable users to determine the correct token quantities when providing liquidity within specific price ranges, handling different scenarios based on the current price relative to the range (within range, above range, below range).

Related Issue(s)

  • Part of the UniswapV3-style LP feature implementation

Type of Change

  • New feature (non-breaking change which adds functionality)

Breaking Change

No breaking changes.

Checklist

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

The implementation includes comprehensive test coverage for different scenarios:

  • Current price within the range
  • Current price above the range
  • Current price below the range
  • Handling zero amount inputs

…amount of tao and a range, or getting tao and liquidity amounts given amount of alpha and a range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant