From 833caecdca772d2e10c3c4778026920d3941eb67 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Tue, 6 Aug 2024 08:59:23 -0400 Subject: [PATCH] feat: configurable debt minimums --- src/config.rs | 1 + src/main.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 25cc841..7e3488c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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, pub escrow_contract: Address, #[serde_as(as = "DisplayFromStr")] pub escrow_subgraph: Url, diff --git a/src/main.rs b/src/main.rs index 698c634..3b9532b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 {