πŸ“šAPI Reference

Complete reference for LiquidCore - the world's first DEX protocol to integrate Hyperliquid's HyperEVM read precompiles as price oracles. This groundbreaking smart contract harnesses CoreWriter's precompile technology for unprecedented trading security.

Contract Address

LiquidCore Pool: 0xA7478A5ff7cB27A8008D6D90785db10223bc6087

Functions

Liquidity Management

deposit

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

Adds liquidity to the pool and mints LP tokens.

Parameter
Type
Description

amount0

uint256

Amount of token0 to deposit (can be 0)

amount1

uint256

Amount of token1 to deposit (can be 0)

Returns: lpTokens - Number of LP tokens minted (non-transferable)

Requirements:

  • At least one amount must be > 0

  • Sufficient token approvals

  • Tokens transferred successfully


withdraw

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

Removes liquidity from pool and burns LP tokens.

Parameter
Type
Description

lpTokens

uint256

Number of LP tokens to burn

Returns:

  • amount0 - Amount of token0 received

  • amount1 - Amount of token1 received

Requirements:

  • lpTokens > 0

  • Sufficient LP token balance

  • Cannot withdraw in same block as deposit

  • Automatically claims fees before withdrawal


Trading

swap

function swap(
    address tokenIn,
    address tokenOut,
    uint256 amountIn,
    uint256 minAmountOut
) external nonReentrant returns (uint256 amountOut)

Executes token swap with slippage protection.

Parameter
Type
Description

tokenIn

address

Input token address

tokenOut

address

Output token address

amountIn

uint256

Amount of input tokens

minAmountOut

uint256

Minimum output amount (slippage protection)

Returns: amountOut - Actual amount of output tokens received

Requirements:

  • Valid token pair (USDT0/WHYPE)

  • amountIn > 0

  • Sufficient reserves

  • Output >= minAmountOut

  • Pool price validated against Hyperliquid's HyperEVM read precompile oracle


Fee Management

claimUserFees

function claimUserFees() external nonReentrant returns (uint256 amount0, uint256 amount1)

Claims accumulated trading fees for the caller.

Returns:

  • amount0 - Token0 fees claimed

  • amount1 - Token1 fees claimed

Requirements:

  • User has LP tokens

  • Unclaimed fees available


compoundFees

function compoundFees() external nonReentrant returns (uint256 lpTokens)

Compounds accumulated fees into additional LP tokens.

Returns: lpTokens - New LP tokens minted from fees

Requirements:

  • User has LP tokens

  • Unclaimed fees available


View Functions

Pool Information

getTokens

function getTokens() external view returns (address token0, address token1)

Returns the two token addresses supported by the pool.

getReserves

function getReserves() external view returns (uint256 reserve0, uint256 reserve1)

Returns current token reserves in the pool.

getSpotPrices

function getSpotPrices() public view returns (uint64 forwardPrice, uint64 inversePrice)

Returns current spot prices.

  • forwardPrice: token0/token1 price

  • inversePrice: token1/token0 price


Fee Information

getUserPosition

function getUserPosition(address user) external view returns (
    uint256 lpBalance,
    uint256 claimableFee0,
    uint256 claimableFee1,
    uint256 shareOfPool,
    uint256 withdrawAmount0,
    uint256 withdrawAmount1
)

Returns complete user position information.

Note: LP tokens are non-transferable and cannot be moved between addresses.

Return Value
Description

lpBalance

User's LP token balance

claimableFee0

Claimable token0 fees

claimableFee1

Claimable token1 fees

shareOfPool

Pool ownership percentage

withdrawAmount0

Token0 from withdrawing all LP

withdrawAmount1

Token1 from withdrawing all LP

getPoolFees

function getPoolFees() external view returns (uint256 feeToken0In, uint256 feeToken1In)

Returns current dynamic fees for each trading direction.


Estimation Functions

estimateDeposit

function estimateDeposit(uint256 amount0, uint256 amount1) external view returns (uint256 lpTokens)

Estimates LP tokens that would be minted for a deposit.

estimateWithdraw

function estimateWithdraw(uint256 lpTokens) external view returns (uint256 amount0, uint256 amount1)

Estimates tokens that would be received for withdrawing LP tokens.

estimateSwap

function estimateSwap(
    address tokenIn,
    address tokenOut,
    uint256 amountIn
) external view returns (uint256 amountOut)

Estimates output amount for a swap.


Events

Deposit

event Deposit(
    address indexed user,
    uint256 amount0,
    uint256 amount1,
    uint256 lpTokens,
    uint256 reserve0,
    uint256 reserve1
)

Emitted when liquidity is added.

Withdraw

event Withdraw(
    address indexed user,
    uint256 amount0,
    uint256 amount1,
    uint256 lpTokens,
    uint256 reserve0,
    uint256 reserve1
)

Emitted when liquidity is removed.

Swap

event Swap(
    address indexed user,
    address tokenIn,
    address tokenOut,
    uint256 amountIn,
    uint256 amountOut,
    uint256 fee,
    uint256 reserve0,
    uint256 reserve1
)

Emitted when a swap is executed.

UserFeesClaimed

event UserFeesClaimed(address indexed user, uint256 amount0, uint256 amount1)

Emitted when user claims trading fees.

CompoundFees

event CompoundFees(
    address indexed user,
    uint256 amount0,
    uint256 amount1,
    uint256 lpTokens
)

Emitted when fees are compounded into LP tokens.


Error Types

error InvalidToken();               // Token not supported by pool  
error InsufficientReserve();        // Pool lacks sufficient liquidity
error TransferFailed();             // Token transfer failed
error ZeroAmount();                 // Amount parameter is zero
error SlippageExceeded();           // Output below minimum expected
error InsufficientLPBalance();      // Insufficient LP tokens for withdrawal
error PriceDeviationTooLarge();     // Pool price too far from Hyperliquid HyperEVM oracle price

Last updated