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. Validly

Deposits and Withdrawals

The entry-point for LP deposits and withdrawals is the Validly contract itself.

Deposits

On deposits, the user first calls Validly's deposit function:

    /**
     * @notice Deposit liquidity into `pool` and mint LP tokens.
     * @param _amount0 Amount of token0 deposited.
     * @param _amount1 Amount of token1 deposited.
     * @param _minShares Minimum amount of shares to mint.
     * @param _deadline Block timestamp after which this call reverts.
     * @param _recipient Address to mint LP tokens for.
     * @param _verificationContext Bytes encoded payload, in case `pool` has a Verifier Module.
     * @return shares Amount of shares minted.
     */
    function deposit(
        uint256 _amount0,
        uint256 _amount1,
        uint256 _minShares,
        uint256 _deadline,
        address _recipient,
        bytes calldata _verificationContext
    )
        external
        returns (uint256 shares, uint256 amount0, uint256 amount1);

Withdrawals

On withdrawals, Validly's withdraw function is the first to get called:

function withdraw(
        uint256 _shares,
        uint256 _amount0Min,
        uint256 _amount1Min,
        uint256 _deadline,
        address _recipient,
        bytes calldata _verificationContext
    ) external returns (uint256 amount0, uint256 amount1);
PreviousSwapNextDeployments

Last updated 7 months ago

Was this helpful?

The deposit function contains most of the business logic, including minting shares worth of LP tokens in the Validly contract, representing pro-rata ownership of the liquidity pool. The actual token balances are stored in the Sovereign Pool. Source:

The LP can call withdraw to redeem _shares worth of liquidity for the equivalent amount of token0 and token1 balances. Upon burning the LP tokens, token0 and token1 amounts get transferred from the Sovereign Pool into _recipient. Source:

https://github.com/ValantisLabs/Validly/blob/main/src/Validly.sol#L123-L191
https://github.com/ValantisLabs/Validly/blob/main/src/Validly.sol#L193-L237