🌅
Sunrise / Gluon Docs
  • Home
    • 👋Sunrise
  • 📜Learn
    • 🌆Sunrise
      • Proof of Liquidity
      • Fee Abstraction
      • Data Availability
      • Gauges Voting
      • Liquidity Pool
      • Liquidity Incentive
      • Swap
      • TokenConverter
      • Fee
      • Lockup Account
      • Bribes
    • 💴$RISE
      • Allocations
    • 🏦Gluon
    • 💴$GLU
    • 🎓Thesis
      • App chain thesis
      • Interoperability
  • 🛠️Build
    • 🚀Quick Start
    • Client
    • L2 Blockchains
      • Rollkit
        • Sunrise Data
        • Rollkit L2 Chain
      • OP Stack
        • Sunrise Data
        • OP Stack L2 Chain
    • Validators
      • Proof of Data Availability
      • Self Delegation
  • 🏗️Run a Sunrise Node
    • Networks
    • Types of Nodes
      • Consensus
        • Full Consensus Node
        • Validator Node (Genesis)
        • Validator Node
        • Setup Cosmovisor
      • IBC Relayers
    • Resources
      • Upgrade
      • Environment
  • 🏗️Run a Gluon Node
    • Networks
    • Node
      • Validator Node
  • 🔗Links
    • GitHub
    • Discord
    • X (Twitter)
    • Medium
    • dev.to
  • 📓Deprecated (UnUniFi)
    • IBC Channels
    • Security
    • CosmWasm
      • Tutorial
      • Create Project
    • IYA Strategy
      • Interface
      • External CosmWasm chain with IBCHooks
      • External EVM chain with Axelar
    • Frontend
      • Cosmos Client TS
    • Resources
    • Setup ununifid
    • ununifid
      • Basic Commands
      • Module Commands
        • wasm
    • Build a Node
    • Build a Validator Node
    • Setup Cosmovisor
    • Mainnet Upgrades
    • IBC Relayer
Powered by GitBook
On this page
  • Key Features
  • Core Functionality
  • Pool Management
  • Tick System
  • Workflow: Creating and Using Positions
  • Messages
  • MsgCreatePool
  • MsgCreatePosition
  • MsgIncreaseLiquidity
  • MsgDecreaseLiquidity
  • MsgClaimRewards
  • Example Usage
  • Queries
  1. Learn
  2. Sunrise

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

  1. 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.

  2. Position-Based Liquidity:

    • Users create positions with defined price ranges (ticks).

    • Each position has a unique ID and tracks the liquidity provider's contribution.

  3. 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.

  4. 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

Note: The following section covers advanced topics intended for experienced users or developers.

Pool Management

Each pool is defined by several parameters:

  • id: Unique identifier for the pool

  • denom_base & denom_quote: The token pair denominations

  • fee_rate: The fee charged on swaps within the pool

  • tick_params: Parameters defining the tick system

  • current_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

Note: The following section covers advanced topics intended for experienced users or developers.

Messages

MsgCreatePool

Creates a new liquidity pool with specified parameters.

type MsgCreatePool struct {
    Authority   string
    DenomBase   string
    DenomQuote  string
    FeeRate     string
    PriceRatio  string
    BaseOffset  string
}

MsgCreatePosition

Creates a position within a price range in a pool.

type MsgCreatePosition struct {
    Sender         string
    PoolId         uint64
    LowerTick      int64
    UpperTick      int64
    TokenBase      sdk.Coin
    TokenQuote     sdk.Coin
    MinAmountBase  string
    MinAmountQuote string
}

MsgIncreaseLiquidity

Adds liquidity to an existing position.

type MsgIncreaseLiquidity struct {
    Sender         string
    Id             uint64
    AmountBase     string
    AmountQuote    string
    MinAmountBase  string
    MinAmountQuote string
}

MsgDecreaseLiquidity

Removes liquidity from an existing position.

type MsgDecreaseLiquidity struct {
    Sender    string
    Id        uint64
    Liquidity string
}

MsgClaimRewards

Claims accumulated fees and incentives for positions.

type MsgClaimRewards struct {
    Sender      string
    PositionIds []uint64
}

Example Usage

Create a Position

import { SunriseClient } from "@sunriselayer/client";
import { MsgCreatePosition } from "@sunriselayer/client/types";

async function createPosition() {
    const client = await SunriseClient.connect("https://rpc.sunriselayer.io");
    
    const msgCreatePosition = {
        sender: "sunrise1...",
        poolId: 1,
        lowerTick: -4155,  // Approximately price 0.66
        upperTick: 4054,   // Approximately price 1.5
        tokenBase: { denom: "urise", amount: "1000000" },
        tokenQuote: { denom: "uusdc", amount: "1000000" },
        minAmountBase: "0",
        minAmountQuote: "0"
    };
    
    const result = await client.executeTransaction(msgCreatePosition);
    console.log("Position created:", result);
}

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

PreviousGauges VotingNextLiquidity Incentive

Last updated 7 days ago

price(tick)=price_ratiotick−base_offset\mathrm{price}(\mathrm{tick}) = \mathrm{price\_ratio}^{\mathrm{tick} - \mathrm{base\_offset}}price(tick)=price_ratiotick−base_offset
price(tick)=1.0001tick\mathrm{price}(\mathrm{tick}) = 1.0001^{\mathrm{tick}}price(tick)=1.0001tick

See for details.

📜
🌆
Github