diff --git a/cli/getting_started.md b/cli/getting_started.md index 41f7299d..c3d6e7fc 100644 --- a/cli/getting_started.md +++ b/cli/getting_started.md @@ -38,9 +38,11 @@ Creating a vault requires: - ``: Fee for withdrawing ST - ``: Fee taken when ST rewards are sent to the vault - ``: Decimals of the newly created VRT. ( 9 is Recommended ) +- ``: The amount of tokens to initialize the vault with ( in the smallest unit ) +- ``: The file path of VRT mint address (**Optional**) ```bash -jito-restaking-cli --rpc-url vault vault initialize +jito-restaking-cli --rpc-url vault vault initialize ``` Note the resulting Vault Pubkey. diff --git a/cli/src/vault.rs b/cli/src/vault.rs index cb14c305..1d91b54a 100644 --- a/cli/src/vault.rs +++ b/cli/src/vault.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use clap::{command, Subcommand}; use solana_program::pubkey::Pubkey; @@ -48,6 +50,8 @@ pub enum VaultActions { decimals: u8, /// The amount of tokens to initialize the vault with ( in the smallest unit ) initialize_token_amount: u64, + /// The file path of VRT mint address + vrt_mint_address_file_path: Option, }, /// Creates token metadata for the vault's LRT token CreateTokenMetadata { diff --git a/cli/src/vault_handler.rs b/cli/src/vault_handler.rs index 87318998..fb5e9c47 100644 --- a/cli/src/vault_handler.rs +++ b/cli/src/vault_handler.rs @@ -1,4 +1,4 @@ -use std::str::FromStr; +use std::{path::PathBuf, str::FromStr}; use anyhow::{anyhow, Result}; use base64::{engine::general_purpose, Engine}; @@ -35,7 +35,7 @@ use solana_rpc_client_api::{ filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, }; use solana_sdk::{ - signature::{Keypair, Signer}, + signature::{read_keypair_file, Keypair, Signer}, transaction::Transaction, }; use spl_associated_token_account::{ @@ -127,6 +127,7 @@ impl VaultCliHandler { reward_fee_bps, decimals, initialize_token_amount, + vrt_mint_address_file_path, }, } => { self.initialize_vault( @@ -136,6 +137,7 @@ impl VaultCliHandler { reward_fee_bps, decimals, initialize_token_amount, + vrt_mint_address_file_path, ) .await } @@ -278,6 +280,7 @@ impl VaultCliHandler { Ok(()) } + #[allow(clippy::too_many_arguments)] pub async fn initialize_vault( &self, token_mint: String, @@ -286,6 +289,7 @@ impl VaultCliHandler { reward_fee_bps: u16, decimals: u8, initialize_token_amount: u64, + vrt_mint_address_file_path: Option, ) -> Result<()> { let token_mint = Pubkey::from_str(&token_mint)?; let keypair = self @@ -295,12 +299,20 @@ impl VaultCliHandler { .ok_or_else(|| anyhow!("Keypair not provided"))?; let rpc_client = self.get_rpc_client(); - let admin = keypair.pubkey(); - let base = Keypair::new(); let vault = Vault::find_program_address(&self.vault_program_id, &base.pubkey()).0; - let vrt_mint = Keypair::new(); + let admin = keypair.pubkey(); + + let vrt_mint = match vrt_mint_address_file_path { + Some(file_path) => { + let keypair = read_keypair_file(file_path) + .map_err(|e| anyhow!("Could not read VRT mint address file path: {e}"))?; + info!("Found VRT mint address: {}", keypair.pubkey()); + keypair + } + None => Keypair::new(), + }; let admin_st_token_account = get_associated_token_address(&admin, &token_mint); let vault_st_token_account = get_associated_token_address(&vault, &token_mint); @@ -319,16 +331,16 @@ impl VaultCliHandler { .st_mint(token_mint) .admin(admin) .base(base.pubkey()) - .deposit_fee_bps(deposit_fee_bps) - .withdrawal_fee_bps(withdrawal_fee_bps) - .reward_fee_bps(reward_fee_bps) .admin_st_token_account(admin_st_token_account) .vault_st_token_account(vault_st_token_account) .burn_vault(burn_vault) .burn_vault_vrt_token_account(burn_vault_vrt_token_account) .associated_token_program(spl_associated_token_account::id()) - .initialize_token_amount(initialize_token_amount) - .decimals(decimals); + .deposit_fee_bps(deposit_fee_bps) + .withdrawal_fee_bps(withdrawal_fee_bps) + .reward_fee_bps(reward_fee_bps) + .decimals(decimals) + .initialize_token_amount(initialize_token_amount); let admin_st_token_account_ix = create_associated_token_account_idempotent(&admin, &admin, &token_mint, &spl_token::ID); diff --git a/docs/_tools/00_cli.md b/docs/_tools/00_cli.md index 3e7e9340..b428e03a 100644 --- a/docs/_tools/00_cli.md +++ b/docs/_tools/00_cli.md @@ -498,7 +498,7 @@ Vault commands Creates a new vault -**Usage:** `jito-restaking-cli vault vault initialize ` +**Usage:** `jito-restaking-cli vault vault initialize [VRT_MINT_ADDRESS_FILE_PATH]` ###### **Arguments:** @@ -508,6 +508,7 @@ Creates a new vault * `` — The reward fee in bips * `` — The decimals of the token * `` — The amount of tokens to initialize the vault with ( in the smallest unit ) +* `` — The file path of VRT mint address