Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinsoza committed Dec 17, 2024
1 parent cb549ee commit ad64b30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
7 changes: 2 additions & 5 deletions apps/contracts/vault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,8 @@ impl VaultTrait for DeFindexVault {
let (_, strategy_allocations) = fetch_invested_funds_for_asset(&e, &asset);

for strategy_allocation in strategy_allocations.iter() {
let mut report = get_report(&e, &strategy_allocation.strategy_address);
report.report(strategy_allocation.amount);
set_report(&e, &strategy_allocation.strategy_address, &report);

reports.push_back(report);
let report_result = report::report(&e, &strategy_allocation.strategy_address, &strategy_allocation.amount);
reports.push_back(report_result);
}
}

Expand Down
18 changes: 18 additions & 0 deletions apps/contracts/vault/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,22 @@ impl Report {
self.gains_or_losses += gains_or_losses;
self.prev_balance = current_balance;
}
}

/// Reports the gains or losses for a strategy based on the current balance.
///
/// # Arguments
/// * `e` - A reference to the environment.
/// * `strategy` - The address of the strategy.
/// * `current_balance` - A reference to the current balance.
///
/// # Returns
/// Report struct containing the previous balance, gains or losses, and locked fee.
pub fn report(e: &Env, strategy: &Address, current_balance: &i128) -> Report {
let mut report = get_report(e, strategy);

report.report(current_balance.clone());
set_report(e, strategy, &report);

report
}

0 comments on commit ad64b30

Please sign in to comment.