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

The White Paper is for informational purposes only. Nothing in the White Paper constitutes legal, financial or tax advice. Its content may be updated from time to time without express notice. You should seek your own professional advice before engaging in any activity in connection with Hyperion. See Legal Disclaimer.

Last updated