Hyperion Docs
  • Home
  • Overview
    • Introduction
    • Contact
    • Glossary
    • Roadmap
  • Concepts
    • Concentrated Liquidity
    • Fees
    • Swap
    • Liquidity Mining
    • Range Order
    • Drips
  • Guides
    • FAQ
    • How to Swap
    • How to Create New Position
    • How to Add/Remove Liquidity
    • How to Create a New Pool
    • How to Place a Limit Order
  • Developer
    • Dev Overview
    • via SDK
      • Getting Started
      • Prerequisites
      • Features Available
        • Get pools
        • Get positions
        • Get ticks
        • Create pool
        • Add Liquidity
        • Remove Liquidity
        • Fee & Rewards
        • Swap
        • Types
    • via Contract
      • Get Started
      • Data structure
      • Features available
        • Create pool
        • Swap
        • Open position
        • Add liquidity
        • Remove liquidity
        • Collect fees
        • Collect rewards
    • via API
    • Contract ErrorCode
  • Security
    • Audits
  • Resource
    • Brand Asset
Powered by GitBook
On this page
  • exact input
  • Function params
  • exact output
  • Function params
  1. Developer
  2. via Contract
  3. Features available

Swap

exact input

For exact input swap, use the exact_input_swap_entry function in the router_v3 module.

 public entry fun exact_input_swap_entry(
        user: &signer,
        fee_tier: u8,
        amount_in: u64,
        amount_out_min: u64,
        sqrt_price_limit: u128,
        from_token: Object<Metadata>,
        to_token: Object<Metadata>,
        recipient: address,
        _deadline: u64
    ) {
    ...
    }

Function params

amount_out_min: the threshold value of token output.

sqrt_price_limit: a x64 fixed-point number, indicate price impact limit after swap

recipient: output token receiver

exact output

For exact output swap, use the exact_output_swap_entry function in the router_v3 module.

  public entry fun exact_output_swap_entry(
        user: &signer,
        fee_tier: u8,
        amount_in_max: u64,
        amount_out: u64,
        sqrt_price_limit: u128,
        from_token: Object<Metadata>,
        to_token: Object<Metadata>,
        recipient: address,
        _deadline: u64
    ) {
    ...
    }

Function params

amount_in_max: the threshold value of token input.

sqrt_price_limit: a x64 fixed-point number, indicate price impact limit after swap

recipient: output token receiver

PreviousCreate poolNextOpen position

Last updated 4 months ago