Skip to content

Commit

Permalink
beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
chopan123 committed Nov 29, 2024
1 parent 18789c5 commit 6165def
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions apps/contracts/vault/src/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
use common::models::AssetStrategySet;
use soroban_sdk::{panic_with_error, token::TokenClient, Address, Env, Vec};

use crate::{funds::{fetch_invested_funds_for_asset, fetch_invested_funds_for_strategy, fetch_total_managed_funds}, investment::check_and_execute_investments, models::{AssetInvestmentAllocation, AssetStrategySet, StrategyInvestment}, storage::get_assets, token::{internal_mint, VaultToken}, utils::{calculate_deposit_amounts_and_shares_to_mint, check_nonnegative_amount}, ContractError, MINIMUM_LIQUIDITY};
use crate::{
funds::{
fetch_invested_funds_for_asset, fetch_invested_funds_for_strategy,
fetch_total_managed_funds,
},
investment::check_and_execute_investments,
models::{AssetInvestmentAllocation, StrategyInvestment},
storage::get_assets,
token::{internal_mint, VaultToken},
utils::{calculate_deposit_amounts_and_shares_to_mint, check_nonnegative_amount},
ContractError, MINIMUM_LIQUIDITY,
};

/// Common logic for processing deposits.
pub fn process_deposit(
Expand Down Expand Up @@ -63,8 +75,11 @@ fn calculate_single_asset_shares(
VaultToken::total_supply(e.clone())
.checked_mul(amounts_desired.get(0).unwrap())
.unwrap_or_else(|| panic_with_error!(&e, ContractError::ArithmeticError))
.checked_div(total_managed_funds.get(get_assets(&e).get(0).unwrap().address.clone())
.unwrap())
.checked_div(
total_managed_funds
.get(get_assets(&e).get(0).unwrap().address.clone())
.unwrap(),
)
.unwrap_or_else(|| panic_with_error!(&e, ContractError::ArithmeticError))
};
Ok((amounts_desired.clone(), shares))
Expand Down Expand Up @@ -137,4 +152,4 @@ pub fn generate_and_execute_investments(

check_and_execute_investments(e.clone(), assets.clone(), asset_investments)?;
Ok(())
}
}

0 comments on commit 6165def

Please sign in to comment.