diff --git a/apps/contracts/factory/src/test.rs b/apps/contracts/factory/src/test.rs index dc9e065d..0a3d4368 100644 --- a/apps/contracts/factory/src/test.rs +++ b/apps/contracts/factory/src/test.rs @@ -43,7 +43,7 @@ mod defindex_vault_contract { // Create Test Token pub(crate) fn create_token_contract<'a>(e: &Env, admin: &Address) -> SorobanTokenClient<'a> { - SorobanTokenClient::new(e, &e.register_stellar_asset_contract(admin.clone())) + SorobanTokenClient::new(e, &e.register_stellar_asset_contract_v2(admin.clone()).address()) } pub(crate) fn get_token_admin_client<'a>( diff --git a/apps/contracts/factory/src/test/all_flow.rs b/apps/contracts/factory/src/test/all_flow.rs index fa0e5e9b..52405f9d 100644 --- a/apps/contracts/factory/src/test/all_flow.rs +++ b/apps/contracts/factory/src/test/all_flow.rs @@ -1,4 +1,4 @@ -use soroban_sdk::{vec, BytesN, Map, String, Vec}; +use soroban_sdk::{vec, BytesN, String}; use crate::test::{create_asset_params, defindex_vault_contract::{self, Investment}, DeFindexFactoryTest}; diff --git a/apps/contracts/factory/src/test/initialize.rs b/apps/contracts/factory/src/test/initialize.rs index 7455baff..64cd8abc 100644 --- a/apps/contracts/factory/src/test/initialize.rs +++ b/apps/contracts/factory/src/test/initialize.rs @@ -1,4 +1,4 @@ -use soroban_sdk::{vec, Address, BytesN, String, Vec}; +use soroban_sdk::{BytesN, String}; use crate::error::FactoryError; use crate::test::{create_asset_params, DeFindexFactoryTest}; diff --git a/apps/contracts/vault/src/lib.rs b/apps/contracts/vault/src/lib.rs index 69a52ada..6f45c7c1 100755 --- a/apps/contracts/vault/src/lib.rs +++ b/apps/contracts/vault/src/lib.rs @@ -33,7 +33,7 @@ use models::{ OptionalSwapDetailsExactOut, }; use storage::{ - get_assets, set_asset, set_defindex_protocol_fee_receiver, set_factory, set_last_fee_assesment, + get_assets, set_asset, set_defindex_protocol_fee_receiver, set_factory, set_total_assets, set_vault_fee, extend_instance_ttl }; use strategies::{ diff --git a/apps/contracts/vault/src/test/deposit.rs b/apps/contracts/vault/src/test/deposit.rs index 0da6e6a0..35626a23 100644 --- a/apps/contracts/vault/src/test/deposit.rs +++ b/apps/contracts/vault/src/test/deposit.rs @@ -71,7 +71,7 @@ fn deposit_amounts_desired_more_length() { let test = DeFindexVaultTest::setup(); test.env.mock_all_auths(); let strategy_params_token0 = create_strategy_params_token0(&test); - let strategy_params_token1 = create_strategy_params_token1(&test); + // let strategy_params_token1 = create_strategy_params_token1(&test); // initialize with 2 assets let assets: Vec = sorobanvec![ @@ -669,7 +669,7 @@ fn deposit_several_assets_min_greater_than_optimal() { assert_eq!(deposit_result, Err(Ok(ContractError::InsufficientAmount))); // now we manage to deposit - let deposit_result=test.defindex_contract.deposit( + test.defindex_contract.deposit( &sorobanvec![&test.env, amount0, amount1], &sorobanvec![&test.env, amount0, amount1], &users[0], diff --git a/apps/contracts/vault/src/test/initialize.rs b/apps/contracts/vault/src/test/initialize.rs index 4c5faf24..9c9e5fa0 100644 --- a/apps/contracts/vault/src/test/initialize.rs +++ b/apps/contracts/vault/src/test/initialize.rs @@ -86,7 +86,7 @@ fn test_initialize_with_unsupported_strategy() { #[test] fn test_initialize_with_empty_asset_allocation() { let test = DeFindexVaultTest::setup(); - let strategy_params_token0 = create_strategy_params_token0(&test); + // let strategy_params_token0 = create_strategy_params_token0(&test); let assets: Vec = sorobanvec![&test.env]; diff --git a/apps/contracts/vault/src/token/mod.rs b/apps/contracts/vault/src/token/mod.rs index 77d0ace3..869bda67 100644 --- a/apps/contracts/vault/src/token/mod.rs +++ b/apps/contracts/vault/src/token/mod.rs @@ -8,6 +8,6 @@ mod storage_types; mod total_supply; pub use contract::VaultToken; -pub use contract::VaultTokenClient; +// pub use contract::VaultTokenClient; pub use contract::{internal_burn, internal_mint}; pub use metadata::write_metadata; diff --git a/apps/contracts/vault/src/utils.rs b/apps/contracts/vault/src/utils.rs index d8f9bad5..fd893167 100644 --- a/apps/contracts/vault/src/utils.rs +++ b/apps/contracts/vault/src/utils.rs @@ -83,40 +83,40 @@ pub fn calculate_asset_amounts_for_dftokens( asset_amounts } -pub fn calculate_dftokens_from_asset_amounts( - env: &Env, - asset_amounts: Map, // The input asset amounts - total_managed_funds: Map, // The total managed funds for each asset -) -> Result { - let total_supply = VaultToken::total_supply(env.clone()); // Total dfToken supply - - // Initialize the minimum dfTokens corresponding to each asset - let mut min_df_tokens: Option = None; - - // Iterate over each asset in the input map - for (asset_address, input_amount) in asset_amounts.iter() { - // Get the total managed amount for this asset - let managed_amount = total_managed_funds.get(asset_address.clone()).unwrap_or(0); - - // Ensure the managed amount is not zero to prevent division by zero - if managed_amount == 0 { - return Err(ContractError::InsufficientManagedFunds); - } - - // Calculate the dfTokens corresponding to this asset's amount - let df_tokens_for_asset = (input_amount * total_supply) / managed_amount; - - // If this is the first asset or if the calculated df_tokens_for_asset is smaller, update the minimum df_tokens - if let Some(current_min_df_tokens) = min_df_tokens { - min_df_tokens = Some(current_min_df_tokens.min(df_tokens_for_asset)); - } else { - min_df_tokens = Some(df_tokens_for_asset); - } - } - - // Return the minimum dfTokens across all assets - min_df_tokens.ok_or(ContractError::NoAssetsProvided) -} +// pub fn calculate_dftokens_from_asset_amounts( +// env: &Env, +// asset_amounts: Map, // The input asset amounts +// total_managed_funds: Map, // The total managed funds for each asset +// ) -> Result { +// let total_supply = VaultToken::total_supply(env.clone()); // Total dfToken supply + +// // Initialize the minimum dfTokens corresponding to each asset +// let mut min_df_tokens: Option = None; + +// // Iterate over each asset in the input map +// for (asset_address, input_amount) in asset_amounts.iter() { +// // Get the total managed amount for this asset +// let managed_amount = total_managed_funds.get(asset_address.clone()).unwrap_or(0); + +// // Ensure the managed amount is not zero to prevent division by zero +// if managed_amount == 0 { +// return Err(ContractError::InsufficientManagedFunds); +// } + +// // Calculate the dfTokens corresponding to this asset's amount +// let df_tokens_for_asset = (input_amount * total_supply) / managed_amount; + +// // If this is the first asset or if the calculated df_tokens_for_asset is smaller, update the minimum df_tokens +// if let Some(current_min_df_tokens) = min_df_tokens { +// min_df_tokens = Some(current_min_df_tokens.min(df_tokens_for_asset)); +// } else { +// min_df_tokens = Some(df_tokens_for_asset); +// } +// } + +// // Return the minimum dfTokens across all assets +// min_df_tokens.ok_or(ContractError::NoAssetsProvided) +// } pub fn calculate_optimal_amounts_and_shares_with_enforced_asset( e: &Env,