Skip to content

Enable liquidity providers#1703

Merged
sam0x17 merged 270 commits intodevnet-readyfrom
feat/uniswapv3-lp
Jun 18, 2025
Merged

Enable liquidity providers#1703
sam0x17 merged 270 commits intodevnet-readyfrom
feat/uniswapv3-lp

Conversation

@gztensor
Copy link
Contributor

@gztensor gztensor commented May 30, 2025

Description

Introduce LP capability inspired by Uniswap v3. Adds a new pallet with the following extrinsics:

add_liquidity

Allows a user who owns some TAO and some Alpha stake to provide their TAO and/or Alpha stake as a liquidity position between low and high price of their choise. Other users will be able to consume this liquidity when they add or remove stake.

remove_liquidity

Removes user liquidity position and credits TAO and Alpha stake back to the user account (including accrued fees).

modify_position

Updates user liquidity position and:

  • Credits TAO and Alpha to user account if liquidity is removed with accrued position fees
  • Uses user TAO and Alpha stake (less accrued position fees) to increase position liquidity

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

New field in SubnetHyperparamsV2: user_liquidity_enabled: bool at the end of the struct.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run cargo fmt and cargo clippy to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • 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
  • Any dependent changes have been merged and published in downstream modules

gztensor and others added 30 commits March 14, 2025 18:08
Fix conversion and Fixed::checked_pow issues
Tests and fixes for add_liquidity and remove_liquidity
@tutacrypto
Copy link

tutacrypto commented Jun 12, 2025

Hey @l0r1s @gztensor
Who should we ask for details about the implementation?
What's the main file(s) to look at?

@ales-otf
Copy link
Contributor

Hey @l0r1s @gztensor Who should we ask for details about the implementation? What's the main file(s) to look at?

For details ask Greg (@gztensor) and you can refer to Uniswap V3 documentation. The entire implementation is done inside pallet-subtensor-swap (pallets/swap). And the most of it is inside of pallets/swap/src/pallet/impls.rs.

@ales-otf
Copy link
Contributor

closes #1494

@sam0x17 sam0x17 merged commit b54cdac into devnet-ready Jun 18, 2025
51 of 54 checks passed
This was referenced Jun 18, 2025
@sam0x17 sam0x17 mentioned this pull request Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants