IntegrationsQuick StartSingle Asset Zap

Functions


This guide explains how to interact with the Hyperswap Single Asset Zap contract.

It covers the constructor setup, liquidity provisioning functions, and receiving native tokens.

📚 Notes

  • Slippage values are expressed in basis points. (Example: 100 = 1%)

  • The Zap contract assumes pools already exist and have enough liquidity.

  • For V3 Zaps, liquidity is always provided with a max range (full range).


Constructor

constructor(_config: Config)

Initializes the contract by setting up all required external contracts and addresses.

Parameters:

  • v2PoolFactory: Address of the Uniswap V2 (or equivalent) factory used to fetch V2 liquidity pools.

  • v3PoolFactory: Address of the Uniswap V3 (or equivalent) factory used to fetch V3 liquidity pools.

  • v3PositionManager: Address of the Non-Fungible Position Manager for managing V3 LP NFTs.

  • v2Router: Address of the router used to swap and add liquidity for V2 pools.

  • v3Router: Address of the router used to swap and add liquidity for V3 pools.

  • v3Quoter: Address of the quoter contract used to estimate V3 swap outputs.

  • wrappedNative: Address of the wrapped native token (e.g., WETH or WBNB).

Returns:

Nothing. Initializes the internal configuration.


Functions

provideLiquidityV2 (params: LiquidityParamsV2):

Provides liquidity to a V2 pool using a single token.

The contract automatically swaps and balances tokens before adding liquidity.


Parameters:

  • tokenA: Address of the first token in the liquidity pair. This is the token you provide.

  • tokenB: Address of the second token in the liquidity pair.

  • amountA: Amount of tokenA you want to use for the liquidity provision.

  • slippage: Maximum acceptable slippage, expressed in basis points (100 = 1%).


Returns:

  • liquidity: Amount of liquidity tokens (LP tokens) received after the provision.

  • amount0Used: Actual amount of tokenA used during the process.

  • amount1Used: Actual amount of tokenB used during the process.


provideLiquidityV3 (params: LiquidityParamsV3)

Provides liquidity to a V3 pool using a single token.

The contract automatically swaps and balances tokens, then mints a V3 liquidity position NFT.

Parameters:

  • tokenA: Address of the first token in the liquidity pair. This is the token you provide.

  • tokenB: Address of the second token in the liquidity pair.

  • amountA: Amount of tokenA you want to use for the liquidity provision.

  • fee: Fee tier of the V3 pool (e.g., 500 = 0.05%, 3000 = 0.3%).

  • slippage: Maximum acceptable slippage, expressed in basis points (100 = 1%).

Returns:

  • tokenId: ID of the minted V3 liquidity position NFT.

  • liquidity: Amount of liquidity provided (in V3-specific liquidity units).

  • amount0Used: Actual amount of tokenA used during the process.

  • amount1Used: Actual amount of tokenB used during the process.

On this page