Popcorn-Limited / vaultcraft-sdk

0 stars 2 forks source link

VaultFactory should allow adapter and vault deployment #34

Open RedVeil opened 10 months ago

RedVeil commented 10 months ago

The VaultFactory class should allow deployment for adapter and vaults. It should have a straight forward wrapper of the contract functions to deploy vault or adapter and more convience functions to get strategy defaults and encode data before actually deploying.

Use this PR as the basis: https://github.com/Popcorn-Limited/vaultcraft-sdk/pull/36 but move the function and test into a new VaultFactory class

RedVeil commented 10 months ago

Task 1: Create a deployVault function that deploys a vault with an adapter and strategy (reference this function https://github.com/Popcorn-Limited/vaultcraft/blob/main/lib/vaults/deployVault.ts). Essentially just a wrapper around the contract write function

  1. Look into deployVault and ruhums createVault function
  2. Create a function that deploys a vault with an adapter and strategy (similar to deployVault) given that you get all the data required for the call as input params as structs or already encoded.
  3. Add a test for the function that deploys a USDC vaults with an Idle Adapter.
RedVeil commented 10 months ago

Task 2: Create a deployVault-function that only requires a chainId, asset, fees and strategyKey from the user and fetches + encodes all required data itself before deploying the vault.

  1. Copy of the strategyDefaults and strategyEncoding resolver from the vaultcraft repo.
  2. Check out getStrategyDefaults in /pages/easy/basics.tsx (vaultcraft repo) to reuse the logic of fetching a strategy config
  3. Check out encodeStrategyData in /components/review/Review.tsx (vaultcraft repo) to reuse the logic of encoding or previously fetched strategy config.
  4. Use the userInputs + this encoded data to deploy a vault with adapter and strategy.