From 4f3b751126a5a4422fccc68296a6475f76d8f256 Mon Sep 17 00:00:00 2001 From: mikewheeleer Date: Tue, 30 Jun 2026 02:14:05 +0530 Subject: [PATCH] feat: add cumulative dispute fee accumulator entrypoints (#733) --- contracts/predictify-hybrid/src/lib.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/contracts/predictify-hybrid/src/lib.rs b/contracts/predictify-hybrid/src/lib.rs index 0ded06ce..21bd9a20 100644 --- a/contracts/predictify-hybrid/src/lib.rs +++ b/contracts/predictify-hybrid/src/lib.rs @@ -7379,6 +7379,29 @@ impl PredictifyHybrid { pub fn get_snapshot_envelope(env: Env) -> Result { reporting::ReportingManager::get_snapshot_envelope(&env) } + + /// Accumulate dispute fees. Called after each dispute resolution to add + /// `fee_amount` to the running cumulative total. Returns the new total. + pub fn accumulate_dispute_fee(env: Env, caller: Address, fee_amount: i128) -> i128 { + caller.require_auth(); + if fee_amount < 0 { + panic_with_error!(env, Error::InvalidInput); + } + let key = Symbol::new(&env, "cum_disp_fee"); + let current: i128 = env.storage().instance().get(&key).unwrap_or(0i128); + let new_total = current.checked_add(fee_amount) + .unwrap_or_else(|| panic_with_error!(env, Error::Overflow)); + env.storage().instance().set(&key, &new_total); + new_total + } + + /// Get the cumulative dispute fee total accumulated so far. + pub fn get_cumulative_dispute_fee(env: Env) -> i128 { + env.storage() + .instance() + .get(&Symbol::new(&env, "cum_disp_fee")) + .unwrap_or(0i128) + } } // ===== TESTS =====