Deploy Your ArrakisV2 Vault

Now we run a command to initialize a private ArrakisV2 Vault on the DAI/WETH token pair and deposit an initial 1 DAI into the vault:

yarn tutorial1-init --network goerli

Congrats! You instantiated a private ArrakisV2 vault. At the end of the script you should see the address of your newly created DAI/WETH vault:

Copy and keep this vault address and you are ready to move on.

What Does This Script Do?

Notice that 4 transactions were done to initialize a vault in the "private" setting:

  1. deployVault : called on the ArrakisV2Factory this deploys a fresh vault instance (sets initial vault params, for instance your EOA as the vault's owner and manager).

      const tx = await arrakisV2Factory.deployVault(
        {
          feeTiers: feeTiers, // [500, 3000]
          token0: token0, // DAI token address
          token1: token1, // WETH token address
          owner: userAddr, // your address
          init0: init0, // 1 DAI
          init1: init1, // 0 WETH
          manager: userAddr, // your address
          routers: [], // no swap routers
        },
        true // isBeacon = true (beacon proxy)
      );
  2. setRestrictedMint : called on the ArrakisV2 vault contract by the vault owner this restricts who can call the vault's mint function to a single address (your EOA), rendering the vault "private" (without this, anyone can add liquidity into your vault and mint vault shares).

      const tx2 = await vaultContract.setRestrictedMint(
        userAddr // your address
      );
  3. approve : called on the DAI token contract this approves 1 DAI to be transferred to the vault in the subsequent step.

      const tx3 = await daiTokenContract.approve(
        vault, // vault address
        oneDai // 1 DAI
      );
  4. mint : called on the ArrakisV2 vault, this mints the initial ArrakisV2 shares and deposits 1 DAI (because of #2, this only works from your address).

      const tx4 = await vaultContract.mint(
        oneDai, // 1 DAI
        userAddr // your address (recipient)
      );

Last updated