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
- User.displayCurrency field + migration (defaults to USD) - src/utils/fxConvert.ts with static rate table and graceful degradation - PUT /api/v1/settings endpoint for updating display currency - Portfolio responses gain displayTotalBalance/displayTotalEarnings/displayCurrency - Graceful omission when FX rate unavailable; amountUsd always present - docs/MULTI_CURRENCY.md clarifying display vs tax currency distinction - Unit tests for FX conversion utility
|
@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 #534 Multi-Currency Portfolio Display & Accounting
Summary
Adds user-preferred display currency with additive
displayAmount/displayCurrencyfields on portfolio and goals responses. Strictly presentation layer — all internal accounting stays USD/token-native.What's Included
Data Model
User.displayCurrencyfield (default: "USD") + migration with rollbackFX Utility (
src/utils/fxConvert.ts)convertUsdToCurrency()— returns null when rate unavailable (graceful degradation)withDisplayCurrency()— attaches display fields without replacing canonical USD amountSettings Endpoint (
src/routes/settings.ts)PUT /api/v1/settings— updatedisplayCurrencyUpdated Responses
GET /api/v1/portfolio/:userId— addsdisplayTotalBalance,displayTotalEarnings,displayCurrencyGET /api/v1/goals/:id/progress— addsdisplayTargetAmount,displayCurrentAmount,displayCurrencyAPI Changes
PUT /api/v1/settings
GET /api/v1/portfolio/:userId (response additions)
{ "totalBalance": 10000, "displayTotalBalance": 9200, "displayTotalEarnings": 500, "displayCurrency": "EUR" }Key Design Decisions
amountUsdis never removed or replaced — it stays the source of truthdisplayAmountis omitted;amountUsdalways presentSupported Currencies
USD, EUR, GBP, JPY, CAD, AUD, CHF, CNY, INR, BRL, MXN, SGD, HKD, KRW
Test Results
tests/unit/utils/fxConvert.test.ts— 10 tests covering conversion, rounding, graceful degradation, and field attachmentDocumentation
docs/MULTI_CURRENCY.md— full documentation including display vs tax currency distinctionCloses #534