Skip to content

Commit

Permalink
WIP performance fees
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinsoza committed Dec 12, 2024
1 parent 51736ee commit 4139c62
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/contracts/vault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod funds;
mod interface;
mod investment;
mod models;
mod report;
mod storage;
mod strategies;
mod test;
Expand Down
23 changes: 23 additions & 0 deletions apps/contracts/vault/src/report.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use soroban_sdk::{Address, Env};

use crate::funds::fetch_strategy_invested_funds;

pub fn report(e: &Env, strategy: Address) -> (i128, i128) {
let current_balance = fetch_strategy_invested_funds(e, &strategy);
let prev_balance = get_prev_balance(strategy);
let previous_gains_or_losses = get_gains_or_losses(strategy);

let gains_or_losses = current_balance - prev_balance;
let current_gains_or_losses = previous_gains_or_losses + gains_or_losses;

store_gains_or_losses(strategy, current_gains_or_losses);
store_prev_balance(strategy, current_balance);

(0,0)
}

pub fn report_all_strategies() {
for strategy in strategies {
report(strategy);
}
}
10 changes: 7 additions & 3 deletions apps/contracts/vault/src/strategies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn invest_in_strategy(
asset_address: &Address,
strategy_address: &Address,
amount: &i128,
) -> Result<(), ContractError> {
) -> Result<i128, ContractError> {

// Now we will handle funds on behalf of the contract, not the caller (manager or user)

Expand All @@ -165,7 +165,11 @@ pub fn invest_in_strategy(

let strategy_client = get_strategy_client(&e, strategy_address.clone());

strategy_client.deposit(amount, &e.current_contract_address());
let strategy_funds = strategy_client.deposit(amount, &e.current_contract_address());

// Reports
// Store Strategy invested funds for reports


Ok(())
Ok(strategy_funds)
}

0 comments on commit 4139c62

Please sign in to comment.