feat(refund_ratio_helper): ticker fallbacks, DB precision rows, CSV export, rate limit - #591
Merged
godamongstmen897 merged 1 commit intoSep 28, 2026
Conversation
…xport, rate limit - Goldii-locks#469: resolve asset ticker keys against a known-asset registry and apply DEFAULT_REFUND_ASSET_CONFIG (7 decimals) to missing/malformed/unknown tickers - Goldii-locks#470: formatRefundRowForDb renders amount/refund/remaining as fixed-precision TEXT columns and verifies each round-trips to its raw bigint value - Goldii-locks#472: buildRefundCsvBlock / writeRefundCsvFile export formatted rows as CSV - Goldii-locks#471: refundRatioRateLimit middleware returns 429 with Retry-After and a logged warning once REFUND_RATIO_RATE_MAX is exceeded per window Closes Goldii-locks#469, closes Goldii-locks#470, closes Goldii-locks#471, closes Goldii-locks#472 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@nevysonzim124 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
Adds four features to
refund_ratio_helper, the dispute refund percentage splitter.resolveRefundAssetTicker/getRefundAssetFormatConfiglook up a registry of known assets (XLM, USDC, EURC, USDT). If a ticker is missing, malformed (not 1–12 alphanumeric characters), or unregistered,DEFAULT_REFUND_ASSET_CONFIG(7 decimals) is used. An unknown ticker that is well formed keeps its upper-cased name so rows can still be traced to it. Prototype keys likeconstructornever resolve.formatRefundRowForDb({ amount, ratio, ticker })computes the refund and the remaining share. It writes each amount as a TEXT column with exactlydecimalsfractional digits, plus the exact raw integer values. Before returning the row, it parses every formatted value back and checks it matches the raw value.REFUND_DB_COLUMN_SCHEMASdeclares the column formats.buildRefundCsvBlockproduces a header line plus one line per row, escaped with the existingescapeCSVField.writeRefundCsvFilewrites that block to disk, creating directories as needed. An empty table is refused.refundRatioRateLimitmiddleware follows the existing per-path limiter pattern. Limits are set byREFUND_RATIO_RATE_MAX(default 20) andREFUND_RATIO_RATE_WINDOW_MS(default 60000). Over the limit, it returns 429 with aRetry-Afterheader and logs a warning.The existing
applyRefundRatio/ validation behavior is unchanged. The only other change: the internalfailurehelpers now return the narrowerValidationFailuretype.Tests
__tests__/refund_ratio_helper_formatting.test.ts:__tests__/refund-ratio-rate-limit.test.ts:npm test: 131 suites, 2854 tests, all passing.tsc -p tsconfig.build.json --noEmitis clean.Closes #469
Closes #470
Closes #471
Closes #472
🤖 Generated with Claude Code