Skip to content

Commit

Permalink
chore: fix emission module interface to seperate claiming and updatin…
Browse files Browse the repository at this point in the history
…g usage
  • Loading branch information
mootz12 committed Jan 4, 2024
1 parent b60ace8 commit 88f66f1
Show file tree
Hide file tree
Showing 7 changed files with 414 additions and 100 deletions.
2 changes: 1 addition & 1 deletion backstop/src/backstop/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn execute_deposit(e: &Env, from: &Address, pool_address: &Address, amount:
require_is_from_pool_factory(e, pool_address, pool_balance.shares);
let mut user_balance = storage::get_user_balance(e, pool_address, from);

emissions::update_emissions(e, pool_address, &pool_balance, from, &user_balance, false);
emissions::update_emissions(e, pool_address, &pool_balance, from, &user_balance);

let backstop_token_client = TokenClient::new(e, &storage::get_backstop_token(e));
backstop_token_client.transfer(from, &e.current_contract_address(), &amount);
Expand Down
4 changes: 2 additions & 2 deletions backstop/src/backstop/withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn execute_queue_withdrawal(
let mut user_balance = storage::get_user_balance(e, pool_address, from);

// update emissions
emissions::update_emissions(e, pool_address, &pool_balance, from, &user_balance, false);
emissions::update_emissions(e, pool_address, &pool_balance, from, &user_balance);

user_balance.queue_shares_for_withdrawal(e, amount);
pool_balance.queue_for_withdraw(amount);
Expand All @@ -36,7 +36,7 @@ pub fn execute_dequeue_withdrawal(e: &Env, from: &Address, pool_address: &Addres
let mut user_balance = storage::get_user_balance(e, pool_address, from);

// update emissions
emissions::update_emissions(e, pool_address, &pool_balance, from, &user_balance, false);
emissions::update_emissions(e, pool_address, &pool_balance, from, &user_balance);

user_balance.dequeue_shares_for_withdrawal(e, amount, false);
user_balance.add_shares(amount);
Expand Down
4 changes: 2 additions & 2 deletions backstop/src/emissions/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use soroban_sdk::{
panic_with_error, vec, Address, Env, IntoVal, Map, Symbol, Val, Vec,
};

use super::update_emissions;
use super::distributor::claim_emissions;

/// Perform a claim for backstop deposit emissions by a user from the backstop module
pub fn execute_claim(e: &Env, from: &Address, pool_addresses: &Vec<Address>, to: &Address) -> i128 {
Expand All @@ -18,7 +18,7 @@ pub fn execute_claim(e: &Env, from: &Address, pool_addresses: &Vec<Address>, to:
for pool_id in pool_addresses.iter() {
let pool_balance = storage::get_pool_balance(e, &pool_id);
let user_balance = storage::get_user_balance(e, &pool_id, from);
let claim_amt = update_emissions(e, &pool_id, &pool_balance, from, &user_balance, true);
let claim_amt = claim_emissions(e, &pool_id, &pool_balance, from, &user_balance);

claimed += claim_amt;
claims.set(pool_id, claim_amt);
Expand Down
Loading

0 comments on commit 88f66f1

Please sign in to comment.