Liquidity Pool
The x/liquiditypool
module implements a concentrated liquidity automated market maker (AMM) mechanism for the Sunrise blockchain. This module enables users to create liquidity pools, add positions with specific price ranges, and earn rewards from trading fees and incentives.
Key Features
Concentrated Liquidity AMM:
Follows a similar model to Uniswap V3, allowing liquidity providers to concentrate their assets within specific price ranges.
Improves capital efficiency compared to traditional constant product AMMs.
Position-Based Liquidity:
Users create positions with defined price ranges (ticks).
Each position has a unique ID and tracks the liquidity provider's contribution.
Fee Generation:
Positions earn fees from trades that occur within their price range.
Fees are collected in the base and quote denominations of the pool.
vRISE
Incentives:Liquidity providers earn vRISE tokens as additional incentives.
These tokens can be used for DA Fee Abstraction in the Sunrise ecosystem.
Core Functionality
Pool Management
Each pool is defined by several parameters:
id
: Unique identifier for the pooldenom_base
&denom_quote
: The token pair denominationsfee_rate
: The fee charged on swaps within the pooltick_params
: Parameters defining the tick systemcurrent_tick
,current_tick_liquidity
,current_sqrt_price
: Current state variables
Tick System
The tick system is based on a price ratio formula:
In the typical case with price_ratio = 1.0001
and base_offset = 0
:
This allows for precise positioning of liquidity within specific price ranges.
Workflow: Creating and Using Positions
Messages
MsgCreatePool
Creates a new liquidity pool with specified parameters.
MsgCreatePosition
Creates a position within a price range in a pool.
MsgIncreaseLiquidity
Adds liquidity to an existing position.
MsgDecreaseLiquidity
Removes liquidity from an existing position.
MsgClaimRewards
Claims accumulated fees and incentives for positions.
Example Usage
Create a Position
Queries
The module provides various query endpoints:
Params: Query module parameters
Pools: List all liquidity pools
Pool: Get details of a specific pool
Positions: List all positions
Position: Get details of a specific position
PoolPositions: List positions in a specific pool
AddressPositions: List positions owned by an address
PositionFees: Get accrued fees for a position
CalculationCreatePosition: Preview position creation
CalculationIncreaseLiquidity: Preview liquidity increase
See Github for details.
Last updated