Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emission cycle fix #153

Merged
merged 5 commits into from
Dec 5, 2023
Merged

Emission cycle fix #153

merged 5 commits into from
Dec 5, 2023

Conversation

mootz12
Copy link
Contributor

@mootz12 mootz12 commented Dec 1, 2023

  • Add queue/timelock for emissions swaps
    • Can cancel at any point during the timelock
  • Update emitter to track distributions on a backstop basis to ensure no missed emissions during a swap
  • Remove emission cycle logic and distribute exact amounts instead
    • Update backstop to stop calculating EPS when distributing emissions to pools, causing emissions to get missed
    • Update pool to consume emissions from backstop, and distribute them to reserves
  • Fix integration tests

@mootz12 mootz12 requested a review from markuspluna December 1, 2023 20:14
markuspluna
markuspluna previously approved these changes Dec 4, 2023
Copy link
Contributor

@markuspluna markuspluna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - spent some time on it and I agree this eliminates like all the edge cases I could think of and feels more robust

Left a few comments just about code documentation and leftover commented out lines - feel free to fix now or we could fix as part of a wider codebase cleanup

@@ -217,6 +244,16 @@ pub fn set_user_balance(e: &Env, pool: &Address, user: &Address, balance: &UserB
/// * `pool` - The pool the deposit is associated with
pub fn get_pool_balance(e: &Env, pool: &Address) -> PoolBalance {
let key = BackstopDataKey::PoolBalance(pool.clone());
// if let Some(result) = e.storage().persistent().get::<BackstopDataKey, PoolBalance>(&key) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably remove this commented out section as it could be confusing

pub fn get_pool_eps(e: &Env, pool: &Address) -> i128 {
let key = BackstopDataKey::PoolEPS(pool.clone());
pub fn get_pool_emissions(e: &Env, pool: &Address) -> i128 {
let key = BackstopDataKey::PoolEmis(pool.clone());
get_persistent_default(e, &key, 0i128, LEDGER_THRESHOLD_SHARED, LEDGER_BUMP_SHARED)
}

/// Set the current emissions EPS the backstop is distributing to the pool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of references to EPS in the backstop that are confusing now as we don't store eps in the backstop anymore

@mootz12 mootz12 merged commit f6991ff into main Dec 5, 2023
3 checks passed
@mootz12 mootz12 deleted the emission_cycle_fix branch December 5, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants