πŸ’§Liquidity Management

LiquidCore provides flexible liquidity management powered by Hyperliquid's native HyperEVM read precompiles - the first DEX protocol ever to leverage this technology. Features include value-based deposits, proportional withdrawals, and automatic fee accrual for LP token holders.

Adding Liquidity

Flexible Deposit System

Unlike traditional AMM pools that require exact token ratios, LiquidCore allows deposits of any combination of the supported tokens:

function deposit(uint256 amount0, uint256 amount1) external returns (uint256 lpTokens)

Parameters

Parameter
Type
Description

amount0

uint256

Amount of USDT0 to deposit (can be 0)

amount1

uint256

Amount of WHYPE to deposit (can be 0)

Returns: Number of LP tokens minted

LP Token Minting

LP tokens are minted to represent your share of the pool:

  1. Deposit Processing: Token deposits are processed automatically

  2. LP Token Minting: Receive LP tokens representing your pool contribution

  3. Pool Ownership: LP tokens represent your ownership stake in the pool

Fee Handling on Deposit

When you deposit liquidity:

  • Existing LP holders: Automatically claim any unclaimed fees before deposit

  • New LP holders: Fee tracking starts from current cumulative fee level

  • No immediate fees: New deposits don't generate fees until trading occurs

Removing Liquidity

Proportional Withdrawals

Withdrawals are always proportional to current pool composition:

function withdraw(uint256 lpTokens) external returns (uint256 amount0, uint256 amount1)

Parameters

Parameter
Type
Description

lpTokens

uint256

Number of LP tokens to burn

Returns: Amounts of USDT0 and WHYPE received

Withdrawal Mechanics

  1. Proportional Calculation: Withdrawals proportional to LP token ownership

  2. Token Distribution: Receive both tokens based on current pool composition

  3. Fee Auto-Claim: All unclaimed fees are automatically claimed before withdrawal

  4. Same-Block Protection: Cannot withdraw in the same block as deposit

Estimating Deposits and Withdrawals

Preview Functions

Before executing transactions, you can estimate outcomes:

// Estimate LP tokens for deposit
function estimateDeposit(uint256 amount0, uint256 amount1) external view returns (uint256 lpTokens)

// Estimate tokens received for withdrawal  
function estimateWithdraw(uint256 lpTokens) external view returns (uint256 amount0, uint256 amount1)

LP Token Information

ERC20-Like Interface

LP tokens implement standard ERC20 view functions but are non-transferable:

function name() external view returns (string memory)        // e.g., "USDT0-WHYPE LP"
function symbol() external view returns (string memory)      // e.g., "USDT0-WHYPE"  
function decimals() external pure returns (uint8)           // LP token decimals
function totalSupply() external view returns (uint256)      // Total LP tokens minted
function balanceOf(address account) external view returns (uint256) // User's LP balance
// Note: transfer(), transferFrom(), and approve() are not available

Position Tracking

Get detailed information about a user's position:

function getUserPosition(address user) external view returns (
    uint256 lpBalance,        // User's LP token balance
    uint256 claimableFee0,    // Claimable USDT0 fees  
    uint256 claimableFee1,    // Claimable WHYPE fees
    uint256 shareOfPool,      // Share of pool percentage
    uint256 withdrawAmount0,  // USDT0 that would be received if withdrawing all LP
    uint256 withdrawAmount1   // WHYPE that would be received if withdrawing all LP
);

Important Considerations

Same-Block Restrictions

  • Deposit Protection: Cannot withdraw in the same block as deposit

  • Flash Loan Prevention: Prevents flash loan attacks on the pool

  • Wait One Block: Must wait for next block after deposit before withdrawing

Token Approvals

Before depositing, ensure sufficient token approvals for the pool contract.

Gas Optimization

  • Batch Operations: Consider batching deposits with fee claims

  • Single Token Deposits: May be more gas efficient than balanced deposits

  • Estimate First: Use view functions to estimate outcomes and avoid reverts

Pool Balancing

Since deposits can be single-sided, consider:

  • Pool Composition: Single-sided deposits may affect pool balance

  • Fee Impact: Pool state may influence trading fees

  • Optimal Strategy: Monitor pool composition for best deposit timing

This flexible liquidity system enables capital efficient deployment while maintaining fair value distribution among all LP token holders.

Last updated