XChains
  • 💡Introduction
  • Understanding XChains
    • Getting Started
    • Actors
      • Liquidity Providers
      • Swappers
      • Bridgers
    • 9CP (IXCP)
  • How it works
    • Technology
    • Fees
    • Govenance
    • Tokenomics
  • Roadmaps
    • Product Roadmap
    • Business Roadmap
  • One-page Pitch Deck
  • 🏛️XChains Architecture
    • Design Strategy
    • Hashed Time-Locked Contracts (HTLCs)
    • Cross-chain Communication
      • Oracle
      • Relay Network
  • 🛠️XChains Implementation
    • Smart Contracts
      • Private Liquidity Pool Contracts
      • Bridge Contracts
    • Atomic Swap Protocol
    • Cross-Chain Transfer Flow
    • Security Considerations
    • Public Pool Integration
  • 🔐XChains Liquidity
    • Private Liquidity Pools
    • Shared Liquidity Pools
    • XChains Formula
  • 📬Contact Us
    • Email
    • Website
    • Telegram Channel
    • Telegram Chat
Powered by GitBook
On this page
  • Considerations:
  • XChains Formula
  • Swap Formula:
  • Characteristics:
  • Considerations:
  1. XChains Liquidity

XChains Formula

An effective swap formula for maintaining liquidity

Designing an effective swap formula for maintaining liquidity in a cross-chain bridge with the synthetic middleman token - 9CP requires careful consideration of factors such as liquidity depth, slippage, and market efficiency. The chosen formula should aim to balance these factors while ensuring fair and efficient token swaps between different assets and chains.

Considerations:

  1. Liquidity Depth: Choose a formula that encourages deep liquidity pools to accommodate large trades with minimal slippage.

  2. Market Efficiency: Aim for the formula that provides fair and efficient token swaps, ensuring that prices accurately reflect market conditions.

  3. Complexity: Balance the simplicity of the formula with its effectiveness in maintaining liquidity and mitigating slippage.

  4. Adaptability: Be prepared to adjust parameters and fine-tune the formula based on evolving market dynamics and user preferences.

XChains Formula is a modified version of the constant product formula used in Uniswap, tailored to optimize these factors. Here's a formula that aims to strike a balance between those objectives:

XChains Formula

The modified constant product formula adjusts the original 𝑥×𝑦=𝐾𝑥×𝑦=𝐾x×y=K formula used in Uniswap to incorporate a square root function, which can help reduce slippage for larger trades while still maintaining deep liquidity pools.

The formula is:

y=K×xx+Xy = K \times \sqrt{x \above{1px} x+X}y=K×x+Xx​​

Where:

  • 𝑥𝑥x is the balance of one token in the pool.

  • 𝑦𝑦y is the balance of the other token in the pool.

  • K is a constant value representing the initial product of the token balances.

  • 𝑋𝑋X is a constant representing the initial balance of the token.

Swap Formula:

When a user swaps an amount 𝑑𝑥𝑑𝑥dx of token A for token B:

  1. Calculate the new balance of token A: 𝑥′=x+dx𝑥′=x+dxx′=x+dx.

  2. Calculate the new balance of token B: y′=K×x′x′+Xy' = K \times \sqrt{x' \above{1px} x'+X}y′=K×x′+Xx′​​.

  3. Determine the amount of token B to receive: 𝑑𝑦=y−y′𝑑𝑦=y−y′dy=y−y′.

Characteristics:

  • Liquidity Depth: The modified constant product formula maintains deep liquidity pools, similar to the original constant product formula, by incentivizing liquidity providers to maintain a balanced token ratio.

  • Reduced Slippage: The square root function introduces a non-linear relationship between token balances, which can help reduce slippage for larger trades compared to the original constant product formula.

  • Market Efficiency: By balancing liquidity depth and slippage reduction, the formula aims to provide efficient and fair token swaps that accurately reflect market conditions.

Considerations:

  1. Parameter Tuning: Adjust the constants 𝐾𝐾K and 𝑋𝑋X based on factors such as expected trading volume, asset volatility, and desired liquidity depth. Fine-tuning these parameters can optimize the formula for specific market conditions.

  2. Empirical Testing: Conduct empirical testing and analysis to evaluate the formula's performance in real-world trading scenarios. Monitor metrics such as slippage, trading volume, and liquidity depth to assess effectiveness and make adjustments as needed.

  3. User Experience: Prioritize user experience by ensuring that token swaps are executed quickly and efficiently, with minimal slippage and fair pricing.

PreviousShared Liquidity Pools

Last updated 11 months ago

🔐
XChains Formula with K = 1000000 and X = 10000