[Smart Contract] Build Parametric Insurance Contract with Oracle Triggers#763
Open
Osifowora wants to merge 1 commit into
Open
Conversation
…gers Implement a fully-featured parametric insurance contract on Soroban that accepts premium deposits, fetches trigger conditions from oracle feeds, and executes instant payouts. - Token-based premium deposits from policyholders via token::Client - Numeric oracle value posting and threshold-based trigger evaluation - Instant payout transfers to insured addresses on successful claim - Capital pool management with underwriter deposits and withdrawals - Solvency enforcement preventing over-leveraged policies - 10 comprehensive tests covering all paths and edge cases Closes StellarDevHub#718
|
@Osifowora is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Osifowora 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
Build an automated parametric insurance contract that pays out automatically based on external data from an oracle feed. This is an MVP-critical feature for Web3 Student Lab's curriculum layer.
Changes
contracts/parametric_insurance/src/lib.rsComplete rewrite with three core capabilities:
Premium deposits —
buy_policy()transfers tokens from buyer → contract viatoken::Client, matching the pattern established inlending.rs.Oracle trigger conditions —
post_oracle_value()accepts numeric values per trigger key (e.g., temperature, rainfall, asset price). Each policy stores atrigger_valueandtrigger_aboveflag;claim()evaluatesoracle_value >= trigger_value(above) ororacle_value <= trigger_value(below).Instant payouts — On successful claim, the payout is tracked as a claimable balance.
withdraw_claim()transfers tokens from the contract to the buyer's address, completing the payout.Capital Pool Management
underwrite()and withdraw excess capital viawithdraw_underwriting(), both protected by solvency checks.buy_policy()rejects iftotal_capital + premium < locked_liability + payout.solvency_ratio_bps()reports pool health in basis points.Testing
10 unit tests covering all paths and edge cases:
buys_policy_and_claims_on_triggerrejects_claim_when_oracle_not_setrejects_claim_when_trigger_not_met_belowclaims_when_trigger_belowrejects_expired_policyprevents_double_claimrejects_policy_that_would_break_solvencyunderwriter_can_withdrawbuyer_can_withdraw_claimsolvency_ratio_worksAcceptance Criteria Met
Technical Details
token::Clientpanic_with_error!with typedInsuranceErrorenumlending.rs,oracle_aggregator.rs, andstate_channel.rsCloses #718