feat(insurance): add parametric insurance products (#249) - #409
Merged
LaGodxy merged 2 commits intoApr 29, 2026
Conversation
Implement oracle-triggered parametric insurance policies that pay out automatically when oracle data crosses a defined threshold — no manual claims assessment required. Changes: - types.rs: add TriggerComparison, ParametricPolicyStatus, ParametricPolicy, OracleDataPoint - errors.rs: add ParametricPolicyNotFound, ParametricPolicyAlreadyTriggered, ParametricPolicyInactive - lib.rs: add storage fields, events (ParametricPolicyCreated, ParametricPolicyTriggered, OracleDataSubmitted), and messages: create_parametric_policy, submit_oracle_data, cancel_parametric_policy, get_parametric_policy, get_property_parametric_policies, get_holder_parametric_policies, get_oracle_data, get_parametric_policy_count - tests.rs: 14 unit tests covering creation, oracle triggers (GTE/LTE), threshold boundary, wrong metric, unauthorized access, cancellation, and multi-policy scenarios Closes MettaChain#249
|
@Nuel-ship-it 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! 🚀 |
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.
Summary
Implements parametric insurance policies that pay out automatically when oracle data crosses a defined threshold — no manual claims assessment required.
What changed
contracts/insurance/src/types.rsTriggerComparisonenum:GreaterThanOrEqual/LessThanOrEqualParametricPolicyStatusenum:Active/Triggered/Expired/CancelledParametricPolicystruct: holds policyholder, property, metric, threshold, coverage amount, pool, and statusOracleDataPointstruct: records each oracle submissioncontracts/insurance/src/errors.rsParametricPolicyNotFoundParametricPolicyAlreadyTriggeredParametricPolicyInactivecontracts/insurance/src/lib.rsNew storage fields, events, and
#[ink(message)]methods:create_parametric_policysubmit_oracle_datacancel_parametric_policyget_parametric_policyget_property_parametric_policiesget_holder_parametric_policiesget_oracle_dataget_parametric_policy_countNew events:
ParametricPolicyCreated,ParametricPolicyTriggered,OracleDataSubmittedcontracts/insurance/src/tests.rs14 new unit tests covering:
How it works
create_parametric_policywith a metric name (e.g.flood_depth_cm), a threshold (e.g.200), a comparison operator, and a coverage amount. Premium is paid upfront.submit_oracle_datafor that property + metric, the contract evaluates all active parametric policies. Any whose trigger condition is satisfied receive an automatic payout from the backing risk pool — no assessor needed.Closes #249