Valantis Documentation
Valantis Website
  • Welcome to Valantis
  • Sovereign Pool
    • The Modules
      • Pool Manager
      • Liquidity Module
      • Swap Fee Module
      • Verifier Module
      • Oracle Module
      • Sovereign Vault
        • Rebase token support
      • Gauge
    • Interacting with Pools
      • Swap Parameters
      • Swap Steps
      • Multi Token Support
      • Deposit Liquidity
      • Withdraw Liquidity
      • Flash Loans
  • Hybrid Order Type (HOT)
    • Understanding HOT: A Graphical Overview
    • HOT API
      • HTTP request parameters
      • HTTP request response
      • Reasoning for Request structure
      • Solver Integration
      • Market Maker integration
    • HOT Smart Contracts
      • Interfaces
      • State variables and roles
      • AMM
      • HOT Swap
      • AMM Swap
      • Hybrid Order Type (HOT) struct parameters
      • Alternating Nonce Bitmap
      • Deposits
      • Withdrawals
      • Deployment Assumptions
    • Liquidity Manager Docs
      • Reference Oracle
      • Deposit
      • Withdraw
      • Signature
    • Swap
      • Swap Context
      • AMM Swap
      • HOT Swap
      • HOT Quote Parameters
        • Bitmap Nonce Instructions
    • Solver Docs
      • Solver Request
      • Simple HOT Swap Example
      • Partial Fill HOT Swap Example
    • Risks and Trust Assumptions
      • Roles
        • Sovereign Pool Manager
        • HOT Manager
        • HOT Signer
        • Liquidity Provider
      • Threats
        • Deposit Sandwich
        • Malicious Price Bound
        • Malicious Signer
        • Mispriced HOT Quote
  • Validly
    • Understanding Validly
    • Swap
    • Deposits and Withdrawals
    • Deployments
  • Stake Exchange (stHYPE AMM)
    • Swap
      • Instant Withdrawals (LST -> Native Token)
      • New Stake (Native Token -> LST)
    • LP Positions
      • LP Withdrawals Instant
      • LP Withdrawal Queued
    • Ratio Fee
    • Lending of Reserves
    • Smart contracts
      • STEXAMM.sol
      • StHYPEWithdrawalModule.sol
      • StexRatioSwapFeeModule.sol
      • DepositWrapper.sol
      • AaveLendingModule.sol
    • Risks and Trust Assumptions
    • Integration examples
  • Deploy and Build
  • Resources
    • Audits
    • Links
    • Get HYPE on HyperEVM
Powered by GitBook
On this page

Was this helpful?

  1. Sovereign Pool
  2. Interacting with Pools

Swap Parameters

The swap function contains _swapParams as input, whose type is the following struct:

struct SovereignPoolSwapParams {
    bool isSwapCallback;
    bool isZeroToOne;
    uint256 amountIn;
    uint256 amountOutMin;
    uint256 deadline;
    address recipient;
    address swapTokenOut;
    SovereignPoolSwapContextData swapContext;
}
  • _swapParams.isSwapCallback True if msg.sender expects a callback to claim input token amounts after all swap amounts have been determined (analogous to the swap callback in UniswapV3 pools). If False, input token claiming will happen via ERC20.transferFrom

  • _swapParams.isZeroToOne Direction of the swap

  • _swapParams.amountIn Maximum amount of input token which the user wants to trade.

  • _swapParams.amountOutMin Minimum required amount of output token.

  • _swapParams.deadline Block height at which the swap becomes invalid.

  • _swapParams.recipient Address which should receive the output token amount.

  • _swapParams.swapTokenOut Token which the user wants to receive as output. Does not necessarily need to be token0 or token1.

  • _swapParams.swapContext Struct containing external byte encoded calldata for the Liquidity Module, Swap Fee Module, Verifier Module and swap callback, if applicable.

Swap Context

The swapContext struct includes 4 fields optionally utilized by different modules during swap execution.

struct SovereignPoolSwapContextData {
    bytes externalContext;
    bytes verifierContext;
    bytes swapCallbackContext;
    bytes swapFeeModuleContext;
}
  • _swapParams.swapContext.externalContext Is sent to the Liquidity Module during the getLiquidityQuote call, this context is likely used to inform the Liquidity Module about any external data it should use for pricing.

  • _swapParams.swapContext.verifierContext Is sent to the Verifier Module before a swap is made. The verifier module can revert or produce verifierContext sent to the Liquidity Module during the getLiquidityQuote call.

  • _swapParams.swapContext.swapCallbackContext Is sent to the Liquidity Module after a swap has been made. This allows the AMM to update state according to external data post swap.

  • _swapParams.swapContext.swapFeeModuleContext Is sent to the Swap Fee Module before a swap to compute the fees.

PreviousInteracting with PoolsNextSwap Steps

Last updated 1 year ago

Was this helpful?