Skip to content

Commit

Permalink
feat: configurable debt minimums
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Aug 6, 2024
1 parent 4d1bff4 commit 833caec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use thegraph_core::types::alloy_primitives::{Address, B256};
#[derive(Debug, Deserialize)]
pub struct Config {
pub chain_id: u64,
pub debts: BTreeMap<Address, u64>,
pub escrow_contract: Address,
#[serde_as(as = "DisplayFromStr")]
pub escrow_subgraph: Url,
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ async fn main() -> anyhow::Result<()> {
.into_iter()
.filter_map(|receiver| {
let balance = escrow_accounts.get(&receiver).cloned().unwrap_or(0);
let debt = debts.get(&receiver).cloned().unwrap_or(0);
let debt = u128::max(
debts.get(&receiver).copied().unwrap_or(0),
config.debts.get(&receiver).copied().unwrap_or(0) as u128 * GRT,
);
let next_balance = next_balance(debt);
let adjustment = next_balance.saturating_sub(balance);
if adjustment == 0 {
Expand Down

0 comments on commit 833caec

Please sign in to comment.