Quickstart: Public Vaults

To make the deposit process safe and simple we created the Arrakis Public Vault Router V2. This contract is in charge of getting the right amounts and tokens to deposit, as well as containing convenient functions with the ability to wrap assets and swap atomically before deposit. It also integrates the Permit 2 standard for gassless approvals.

WARNING: The vault composition may change between transaction submission and execution. Always set appropriate slippage tolerance (by passing min and max amounts in add/remove liquidity parameters) to account for these changes. Excessive slippage settings expose your transaction to frontrunning attacks and potential loss of funds.

Add Liquidity

The following provides a step-by-step explanation of depositing liquidity into an Arrakis Public Vault via the Router V2.

  1. Identify the Public Vault associated to the pair you want to participate in.

  2. Next step is use the Router to determine how many of each tokens you expect to need to join the Public Vault.

    • Use getMintAmounts to determine the exact amounts of token0 and token1 you expect to deposit, given the maximum of each token you would like to provide.
  3. In order to set token transfer authorizations before depositing, there are two alternatives:

    • Calling the standard ERC20 Approve (approve Router V2 to spend)
    • Set up Permit2 data and signature
  4. Now, in order to deposit into the pool there are multiple paths:

  5. Once your deposit transaction goes through, you obtain ERC20 LP shares of the vault you are depositing to.

Remove Liquidity

Removing Liquidity from an Arrakis Public Vault that you hold LP tokens of is easy.

  1. Ensure you have LP shares of the Public Vault you want to withdraw from.

  2. Determine how many shares you want to burn to withdraw liquidity. You can burn a partial amount or your entire balance.

    • Use getBurnAmounts to determine the amounts of token0 and token1 you expect to withdraw, given the amount of shares you would like to burn.
  3. In order to set token transfer authorizations for your LP tokens, there are two alternatives:

    • Calling the standard ERC20 Approve on your LP tokens (approve Router V2 to spend your shares)
    • Set up Permit2 data and signature for your LP tokens
  4. Now, in order to withdraw from the pool there are two paths:

    • If you set up ERC20 approvals:

      • Call removeLiquidity to burn your LP tokens and receive the underlying token0 and token1.
    • If you have set the correct Permit2 data and signature you should call removeLiquidityPermit2

  5. Once your withdrawal transaction goes through, your LP shares are burned and you receive the proportional amounts of the underlying token0 and token1 directly to your specified receiver address.