feat(niffyinsure): rolling claim cap per policy (ledger window) - #246
Merged
Conversation
- Track cumulative paid per (holder, policy) with ledger-bucket rollover - Enforce cap at file_claim; bump accumulator on payout only (no cap re-check) - Admin setters with bounds; ClaimCapUpdated / window update events - Read APIs for cap, window, remaining, raw state; quote_error 49 - Tests: at-cap, two claims to cap, over-cap, in-flight payout, rollover - Gate legacy events schema tests behind legacy-event-schema-tests feature - Fix Claim.asset in tests; remove duplicate contractimpl entrypoints Made-with: Cursor
|
@favourawaku Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Resolve niffyinsure conflicts: combine Cargo features (legacy-event-schema-tests + governance-token), union DataKey instance variants (rolling cap + governance stubs), quarantine legacy events with opt-in feature gate, align claim asset fields and snapshot with setup token, remove duplicate pub mod events in lib.rs. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(niffyinsure): rolling claim cap per policy (ledger-anchored window)
closes #189
Summary
Adds a configurable rolling cap on cumulative paid claim amounts per
(holder, policy_id)within a ledger-sequence window (not wall clock). New filings that would exceed the cap revert with a clear contract error.Behavior
(window_start, cumulative_paid)per policy, reset when the ledger bucket changes.file_claim: After existing validation, requirescumulative_paid + amount ≤ cap(skipped when cap isi128::MAX).process_claim: After a successful payout, addsclaim.amountto the accumulator; does not re-check the cap so in-flight approved claims still pay if the cap is lowered later.set_rolling_claim_capandset_rolling_claim_window_ledgerswith min/max bounds; emitClaimCapUpdatedandRollingClaimWindowLedgersUpdated.get_rolling_claim_cap,get_rolling_claim_window_ledgers,get_rolling_claim_remaining,get_rolling_claim_statefor indexers/UI.validate::Error::RollingClaimCapExceeded(49) andquote_error_messagemapping;AdminErrorvariants for out-of-bounds admin updates.Product note
Cap applies to gross on-chain
claim.amount(same field as payout); deductible/net policy is documented as a future product decision.Tests
tests/rolling_claim_cap.rs: single claim at cap; two claims summing to cap; filing over cap; cap lowered after file still allows payout; window rollover allows another full cap. Window length is chosen so claim rate-limit advances do not roll the cap bucket unintentionally.Other
contractimplfile_claim/vote_on_claim/finalize_claim(panic variants).tests/events.rsgated behind Cargo featurelegacy-event-schema-testsuntil topics match currentcontracteventlayout.Claim.assetfixes in existing tests; Soroban test snapshots updated where regenerated.Checklist
cargo testincontracts/niffyinsurepasses