Biatec DEX API Documentation

website·Indexed 32 days ago

https://docs.dex.biatec.io

Developer documentation for the Biatec decentralized exchange, featuring the BiatecClammPoolClient and BiatecPoolProviderClient. The API provides tools for concentrated liquidity AMM (CLAMM) operations, including swapping, liquidity management, and a comprehensive suite of tick grid utility functions for price snapping, boundary calculation, and precision management.

Tokens
45.9K
Snippets
289
Records
390
Agent score
47%

What's inside Biatec

  1. Overview of Biatec Concentrated Liquidity AMM

    Biatec provides a concentrated liquidity Automated Market Maker (AMM) on the Algorand blockchain. Unlike traditional AMMs, it allows liquidity providers to specify custom price ranges for their assets, which can lead to higher yields and a reduction in impermanent loss.
  2. Overview of Biatec CLAMM

    Biatec CLAMM is a Concentrated Liquidity Automated Market Maker (CLAMM) built on the Algorand blockchain. Unlike traditional AMMs, it allows liquidity providers to allocate capital within specific price ranges, which increases capital efficiency and reduces impermanent loss. Key features include support for interest-bearing tokens via staking pools, built-in KYC verification for compliance, and a sustainable fee structure with protocol revenue sharing.
  3. Access BiatecPoolProviderClient properties

    The client provides several accessors to retrieve metadata about the linked smart contract instance and the underlying Algorand client.
    const id = client.appId;           // The ID of the app instance
    const address = client.appAddress; // The app address
    const name = client.appName;       // The name of the app
    const spec = client.appSpec;       // The ARC-56 app spec
    const algo = client.algorand;       // Reference to the AlgorandClient
  4. Understand the Biatec CLAMM Tick Grid

    Biatec CLAMM uses a canonical logarithmic tick grid to ensure liquidity is concentrated in shared pools rather than fragmented. The grid is absolute and decade-periodic, meaning boundaries are fixed and do not depend on market price or UI state.

    There are three named tick widths:

    • wide: Anchors at 1, 2, 5 (approx 100% steps).
    • normal: Recommended default. Ticks are approx 10% of the price.
    • narrow: Ticks are approx 1% of the price.

    Lower precision results in wider ticks. This system ensures that a price (e.g., 1500) always falls into the same bin regardless of when or where it is calculated.

    import { TICK_TYPES, DEFAULT_TICK_TYPE, TickType } from 'biatec-concentrated-liquidity-amm';
    
    console.log(TICK_TYPES); // ['wide', 'normal', 'narrow']
    console.log(DEFAULT_TICK_TYPE); // 'normal'
  5. Access BiatecConfigProviderClient instance properties

    The client provides read-only accessors to retrieve metadata about the linked app instance and the underlying Algorand client.
    const id = client.appId;           // The ID of the app instance
    const address = client.appAddress; // The app address
    const name = client.appName;       // The name of the app
    const spec = client.appSpec;       // The ARC-56 app spec being used
    const algoClient = client.algorand; // Reference to the underlying AlgorandClient
  6. Understand BiatecCLAMM fee types

    BiatecCLAMM uses a multi-tier fee system consisting of two primary categories:

    1. Protocol Fees: Trading fees collected during swaps. These are split between Liquidity Providers (LPs) and the Biatec protocol (currently 20% of LP fees go to Biatec).
    2. Network Fees: Standard Algorand blockchain fees paid in ALGO to cover transaction processing costs.
  7. Understand BiatecCLAMM error code formats

    BiatecCLAMM smart contract error codes follow a consistent naming convention to help developers debug issues. They typically appear as short codes (3-4 characters) prefixed with either E_ or ERR- (e.g., E_CONFIG, ERR-LOW-VER).
  8. Access BiatecClammPoolClient app properties

    The BiatecClammPoolClient provides several read-only accessors to retrieve metadata about the linked application instance and the underlying Algorand client.
    const appId = client.appId;           // The ID of the app instance
    const appAddress = client.appAddress;   // The app address
    const appName = client.appName;         // The name of the app
    const appSpec = client.appSpec;         // The ARC-56 app spec
    const algoClient = client.algorand;    // Reference to the AlgorandClient
  9. Implement Concentrated Liquidity with Biatec CLAMM

    Biatec CLAMM allows liquidity providers (LPs) to allocate capital within specific price ranges rather than across the entire 0-∞ range. This increases capital efficiency, reduces slippage for traders, and can result in significantly higher yields (300-400%) for LPs.
    // Example of calculating concentrated liquidity based on asset amounts and price boundaries
    const liquidity = calculateConcentratedLiquidity(assetAAmount, assetBAmount, priceMin, priceMax);
  10. AppPoolInfo object definition

    The AppPoolInfo object provides detailed information about a liquidity pool, including the assets involved, current price, and performance metrics (volume, fees, VWAP) across four distinct time periods (period1 through period4). All numeric properties are represented as bigint.
    interface AppPoolInfo {
      assetA: bigint;
      assetB: bigint;
      verificationClass: bigint;
      latestPrice: bigint;
      // Period 1
      period1Duration: bigint;
      period1NowVolumeA: bigint;
      period1NowVolumeB: bigint;
      period1NowFeeA: bigint;
      period1NowFeeB: bigint;
      period1NowVwap: bigint;
      period1NowTime: bigint;
      period1PrevVolumeA: bigint;
      period1PrevVolumeB: bigint;
      period1PrevFeeA: bigint;
      period1PrevFeeB: bigint;
      period1PrevVwap: bigint;
      period1PrevTime: bigint;
      // Period 2
      period2Duration: bigint;
      period2NowVolumeA: bigint;
      period2NowVolumeB: bigint;
      period2NowFeeA: bigint;
      period2NowFeeB: bigint;
      period2NowVwap: bigint;
      period2NowTime: bigint;
      period2PrevVolumeA: bigint;
      period2PrevVolumeB: bigint;
      period2PrevFeeA: bigint;
      period2PrevFeeB: bigint;
      period2PrevVwap: bigint;
      period2PrevTime: bigint;
      // Period 3
      period3Duration: bigint;
      period3NowVolumeA: bigint;
      period3NowVolumeB: bigint;
      period3NowFeeA: bigint;
      period3NowFeeB: bigint;
      period3NowVwap: bigint;
      period3NowTime: bigint;
      period3PrevVolumeA: bigint;
      period3PrevVolumeB: bigint;
      period3PrevFeeA: bigint;
      period3PrevFeeB: bigint;
      period3PrevVwap: bigint;
      period3PrevTime: bigint;
      // Period 4
      period4Duration: bigint;
      period4NowVolumeA: bigint;
      period4NowVolumeB: bigint;
      period4NowFeeA: bigint;
      period4NowFeeB: bigint;
      period4NowVwap: bigint;
      period4NowTime: bigint;
      period4PrevVolumeA: bigint;
      period4PrevVolumeB: bigint;
      period4PrevFeeA: bigint;
      period4PrevFeeB: bigint;
      period4PrevVwap: bigint;
      period4PrevTime: bigint;
    }
  11. Understand Concentrated Liquidity AMM (CLAMM) on Biatec

    Biatec uses a Concentrated Liquidity AMM (CLAMM) model. Unlike traditional AMMs that spread liquidity from 0 to infinity, CLAMM allows liquidity providers (LPs) to specify a precise price range (e.g., $0.90 - $1.10). Capital is only utilized when the market price is within this range, which can make capital efficiency up to 4000x higher than traditional AMMs, resulting in significantly higher fee earnings for the same amount of deposited assets.
  12. Create Interest-Bearing Token Staking Pools

    Biatec CLAMM supports same-asset pools (e.g., ALGO/ALGO) to generate interest-bearing tokens (e.g., B-ALGO). These pools can be used for native token staking, asset staking for lending protocols, or revenue sharing.
    // Create B-ALGO staking pool
    const stakingPool = await createStakingPool({
      assetA: 0n, // ALGO
      assetB: 0n, // ALGO
      tokenName: 'B-ALGO',
    });