Skip to content

Commit

Permalink
Merge pull request #36 from blend-capital/backfill-emissions
Browse files Browse the repository at this point in the history
Backfill emissions
  • Loading branch information
mootz12 authored Jan 20, 2025
2 parents 4eb23b8 + 657e50b commit 3e42b84
Show file tree
Hide file tree
Showing 9 changed files with 644 additions and 46 deletions.
4 changes: 4 additions & 0 deletions backstop/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ pub const MAX_Q4W_SIZE: u32 = 21;

/// The time in seconds that a Q4W entry is locked for (21 days).
pub const Q4W_LOCK_TIME: u64 = 21 * 24 * 60 * 60;

/// The maximum amount of backfilled emissions that can be emitted.
/// Represents between 3-4 months worth of token emissions.
pub const MAX_BACKFILLED_EMISSIONS: i128 = 10_000_000 * SCALAR_7;
14 changes: 13 additions & 1 deletion backstop/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{
backstop::{self, load_pool_backstop_data, PoolBackstopData, UserBalance, Q4W},
constants::{MAX_BACKFILLED_EMISSIONS, SCALAR_7},
dependencies::EmitterClient,
emissions,
errors::BackstopError,
Expand Down Expand Up @@ -190,6 +191,13 @@ impl BackstopContract {
storage::set_blnd_token(&e, &blnd_token);
storage::set_usdc_token(&e, &usdc_token);
storage::set_pool_factory(&e, &pool_factory);
let mut drop_total: i128 = 0;
for (_, amount) in drop_list.iter() {
drop_total += amount;
}
if drop_total + MAX_BACKFILLED_EMISSIONS > 50_000_000 * SCALAR_7 {
panic_with_error!(&e, BackstopError::BadRequest);
}
storage::set_drop_list(&e, &drop_list);
storage::set_emitter(&e, &emitter);
}
Expand Down Expand Up @@ -297,7 +305,11 @@ impl Backstop for BackstopContract {
}

fn drop(e: Env) {
EmitterClient::new(&e, &storage::get_emitter(&e)).drop(&storage::get_drop_list(&e))
let mut drop_list = storage::get_drop_list(&e);
let backfilled_emissions = storage::get_backfill_emissions(&e);
drop_list.push_back((e.current_contract_address(), backfilled_emissions));
let emitter_client = EmitterClient::new(&e, &storage::get_emitter(&e));
emitter_client.drop(&drop_list)
}

/********** Fund Management *********/
Expand Down
Loading

0 comments on commit 3e42b84

Please sign in to comment.