Conversation
…dating Credit Line) - CollateralLoan model + migration with partial unique index (one active loan per position) - Origination endpoint with conservative LTV cap, collateral lock, and approval-workflow co-signing - Interest accrual job (simple rate: underlying borrowApy + platform spread) - Liquidation monitor (hourly + circuit-breaker-triggered out-of-cycle) with partial-liquidation executor - Repayment endpoint with proportional collateral unlock - Bad debt recording for underwater liquidations - docs/LENDING.md + openapi.yaml updates - 120 unit tests green
- ProtectionFundBalance, ProtectionFundContribution, CoverageEvent, CoverageClaim models + migration - Revenue-skim contribution wiring (config-driven, off by default) - Coverage-event declaration workflow with dual-review requirement - Automatic per-user claim computation from position history - Pro-rated payout logic with fund-balance awareness - minHoldDurationForCoverage anti-gaming protection - Public status + per-user coverage endpoints - docs/PROTECTION_FUND.md with coverage terms and exclusions - Unit tests for service layer
|
@CHKM001 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.
PR #533 Protocol-Risk Protection Fund / Deposit Insurance
Summary
Adds a platform-funded reserve pool that makes depositors partially or fully whole after a covered protocol-level loss event. Funded by a configurable revenue skim, governed by explicit published coverage terms.
What's Included
Data Model
ProtectionFundBalance— platform-owned treasury tier tracking fund balance per assetProtectionFundContribution— transparent ledger of all fund inflows (revenue skim, manual, treasury transfer)CoverageEvent— admin-declared protocol-loss incident with dual-review workflowCoverageClaim— per-user, per-position claim with automatic computation from position history20260930120000_add_protection_fundwith rollbackService Layer (
src/protectionFund/service.ts)getCoverageTerms()— published coverage terms (covered causes, exclusions, caps)recordContribution()— fund inflow with audit ledger entrydeclareCoverageEvent()— admin declares event, enters PENDING_REVIEWreviewCoverageEvent()— dual-review approval/rejection, triggers claim computationcomputeClaimsForEvent()— automatic per-user claim computation from position historyexecutePayout()— payout via outbox patterngetMyCoverage()— per-user exposure and estimated coveragegetProtectionFundStatus()— public fund status and historical eventsRoutes (
src/routes/protection-fund.ts)/api/v1/protection-fund/status/api/v1/protection-fund/my-coverage/api/v1/protection-fund/events/api/v1/protection-fund/events/:eventId/review/api/v1/protection-fund/contributions/api/v1/protection-fund/claims/:claimId/payoutConfiguration (
src/config/env.ts)PROTECTION_FUND_REVENUE_SKIM_FRACTION(default: 0 = off)PROTECTION_FUND_PER_USER_CAP(default: 10,000 USDC)PROTECTION_FUND_MIN_HOLD_DURATION_MS(default: 7 days)PROTECTION_FUND_DEFAULT_ASSET(default: USDC)Coverage Terms
Covered Events
Excluded Events
Safety Invariants
minHoldDurationMsbefore eligible (anti-gaming)perUserCoverageCapper eventTest Results
tests/unit/protectionFund/service.test.ts— 8 tests covering fund balance, contributions, event declaration, review, claim computation, and queriesDocumentation
docs/PROTECTION_FUND.md— full coverage terms, exclusions, transparency reporting, and API referenceOut of Scope (v1)
Closes #533