Repository navigation
feat: build circuit breaker status indicator on buy form for price im… - #1039
Merged
Chucks1093 merged 4 commits intoSep 28, 2026
Merged
Chucks1093 merged 4 commits into
Chucks1093 merged 4 commits into
Conversation
…pact warnings (accesslayerorg#1034) Show real-time price impact indicator on buy forms (TradeDialog and BuySellKeyFlow), display approaching and breached warning banners when impact reaches threshold, and disable buy submission with circuit breaker warning when threshold breached. Closes accesslayerorg#1034
|
@Unclebaffa 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! 🚀 |
…esslayerorg#1015 holding cap PR After the large dev rebase (20+ PRs merged including holding cap accesslayerorg#1015, batch trade accesslayerorg#1044, cooldown accesslayerorg#1043), several issues were introduced in BuySellKeyFlow and TradeDialog: - TradeDialog.tsx: priceImpactPercent guard was changed to currentSupply <= 0, incorrectly blocking valid impact calculations at supply=0 (new bonding curves). Reverted to < 0 to match calculateTradePriceImpact's own guard. Fixes 4 failing circuit breaker tests. - BuySellKeyFlow.tsx: Unused HoldingCapIndicator import and dead isCapLimitReached/isCapBreached/isCapExceeded useMemo blocks added but never rendered. Removed to fix ESLint no-unused-vars errors. - TradeDialog.tsx: Unused isCapExceeded combined variable removed (isCapLimitReached and isCapBreached used directly). - course.service.ts: holdingCap and maxHoldingCap properties missing from KeyConfig interface despite being accessed via keyConfig?.holdingCap in both BuySellKeyFlow and TradeDialog. Added with correct JSDoc (accesslayerorg#1015). Result: 31/31 circuit breaker tests pass, lint 0 errors, 0 TypeScript errors.
- course.service.ts: Restore WhitelistEntry and Course whitelist properties dropped during merge (accesslayerorg#1031) - BuySellKeyFlow.tsx: Re-integrate HoldingCapIndicator and cap limit/breach checks to satisfy holding cap tests (accesslayerorg#1015) - TradeDialog.tsx: Clean up dataset access, redundant jumps, Number.NaN, nullish coalescing, and ambiguous spacing - TradeDialog.sellPayoutDisplay.test.tsx: Acknowledge high price impact override checkbox on 5-key sell - TradeDialog.mobileBottomSheet.test.tsx: Provide safe supply in mobile trade confirmation test to avoid tripping circuit breaker
5 tasks
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.
Closes #1034
Pull Request: feat: build circuit breaker status indicator on buy form for price impact warnings (#1034)
Target Branch:
devCloses: #1034
Summary
This PR implements a real-time price impact indicator and circuit breaker protection system across the key purchasing interfaces (
TradeDialogmodal andBuySellKeyFlowtab). When traders enter an order amount on a bonding curve, the UI dynamically assesses price impact against the key's configured circuit breaker threshold to protect buyers from predatory front-running and sudden volatility.Key Capabilities & Architectural Additions
Real-Time Price Impact Evaluation:
src/utils/circuitBreaker.utils.tsviaevaluateCircuitBreakerStatusandresolveCircuitBreakerThreshold.circuitBreakerThresholdPercent, falls back tocircuitBreakerThresholdBps / 100, or defaults to15.0%. Proximity warning triggers atDEFAULT_CIRCUIT_BREAKER_PROXIMITY_RATIO = 0.8).Three-Tier Visual State Indicator (
CircuitBreakerStatusIndicator):Hard Protection (Non-Bypassable):
disabled:cursor-not-allowed, changes text to"Circuit Breaker Tripped", and prevents submission even if triggered programmatically.Accessible Tooltip & Responsive Design:
aria-label="Circuit breaker protection info", role, keyboard focusable via Tab/Escape) detailing the automated circuit breaker mechanism.Data Models & Page Propagation:
CourseandKeyConfiginsrc/services/course.service.tsto support optionalcircuitBreakerThresholdPercentandcircuitBreakerThresholdBps.CreatorDetailPage.tsxintoTradeDialog.Changed Files
src/utils/circuitBreaker.utils.tssrc/utils/__tests__/circuitBreaker.utils.test.tssrc/components/common/CircuitBreakerStatusIndicator.tsxsrc/components/common/__tests__/CircuitBreakerStatusIndicator.test.tsxsrc/components/common/TradeDialog.tsxsrc/components/common/__tests__/TradeDialog.circuitBreaker.test.tsxsrc/components/common/BuySellKeyFlow.tsx"Circuit Breaker Tripped", and blocked submit.src/components/common/__tests__/BuySellKeyFlow.circuitBreaker.test.tsxsrc/pages/CreatorDetailPage.tsxcircuitBreakerThresholdPercentandcircuitBreakerThresholdBpstoTradeDialog.src/services/course.service.tsCourseandKeyConfig.src/test/setup.tslocalStoragemock fallback for jsdom test runner environments.Testing
pnpm lint(0 errors, 0 warnings)pnpm build(clean production bundle generated viatsc -b && vite build)pnpm vitest run circuitBreaker TradeDialog.circuitBreaker BuySellKeyFlow.circuitBreaker(31 tests passed across 4 test suites)pnpm vitest run TradeDialog.a11y.test.tsx TradeDialog.test.tsx(17 tests passed)Checklist