refactor: earn flow + remove xstate/store - #551
Conversation
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
Key validators by address and subnet so selection keeps distinct validator options. Scope balance and init token options to the selected dashboard category.
6cf3187 to
5dac944
Compare
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, Cursor Security Agent left an unresolved medium-severity finding, and required checks did not finish on the latest commit (Bugbot cancelled; Security Agent still running). Assigned jdomingos and dnehl for human review.
Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding on
complete.tsx. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Split earn intent and view atoms so route and wallet state changes update the resolved view. Keep dispatch separate from view reads and add wallet resolution handling. Cover dashboard tab selection and patch Effect parent tracking.
Use the native TypeScript 7 compiler across the widget and examples. Keep TypeScript 6 API compatibility for Next.js tooling.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding on
complete.tsx. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Replace legacy context, query, and state-machine integrations with Effect services and atom-backed wallet, API, and workflow state. Split Vitest projects and add AST rules to validate the new architecture.
16d2bb4 to
67eb76f
Compare
Publish each feature through at most state/ui/components entries and keep internals private, so vertical feature boundaries are enforced by tooling. Move borrow intent into atoms, shared UI out of widget-shell, and route matchers into owning features; tighten the domain rev-dep rule and add a public-api conformance test.
Move workflows, resources, routing, and mount sequencing into Effect Atom runtimes. Add generation-scoped borrow configuration and lazy connector setup for stable startup.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has unresolved findings (medium tabnabbing and high remote-script execution in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has unresolved findings (medium tabnabbing and high remote-script execution in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has unresolved findings (medium tabnabbing and high remote-script execution in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Restore detected browser language when a new widget omits an explicit language. Serialize browser files and await async unmounts so tests respect the single-instance lifecycle.
Use balance data only to enrich canonical token amounts instead of expanding the yield catalog. Preserve valid automatic selections and fall back to a positive-balance token before the first token.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has unresolved findings (medium tabnabbing and high remote-script execution in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Move Classic journey phase routes, pages, and flow scopes behind one feature-owned route factory. Keep app-owned mount paths and wallet guards while preserving distinct activity presentations.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has unresolved findings (medium tabnabbing and high remote-script execution in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Restore classic transaction metadata to the stable public shape. Add explicit Borrow provider capabilities and route each family through its matching callback. Preserve typed wallet failures through transaction workflow projections.
Model account snapshots, market positions, and risk projections as distinct domain concepts. Keep pool and isolated collateral behavior explicit. Reset stale forms when markets disappear or change capability. Retain disabled-market positions and surface uncertain risk without blocking execution.
Enforce mount-time runtime identity and preserve one-shot Earn initialization. Keep activity, position, disconnect, and renderer flows aligned with their owners. Record the audit findings and add regression coverage for each resolved case.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has unresolved findings (medium tabnabbing and high remote-script execution in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Keep runtime providers and feature atoms aligned with production composition. Move test substitution into test-owned registries and Effect layers. Expose the canonical yield summary family directly.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has an unresolved high-severity remote-script finding in
release.yml. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Consolidate selection state, resources, and projections behind one entry point. Expose provider-enriched yields so the facade no longer relies on unsafe casts.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has an unresolved high-severity remote-script finding in
release.yml. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
| background="transparent" | ||
| data-rk="borrow-steps-transaction-link" | ||
| onClick={() => | ||
| window.open(submission.link ?? "", "_blank") |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
submission.link from transaction metadata is opened with window.open(..., "_blank") without opener isolation (noopener,noreferrer) and without URL allowlisting. If upstream link data is malicious or compromised, the new tab can perform reverse-tabnabbing (window.opener) and redirect the trusted original tab.
Impact: Users can be navigated from a trusted widget flow to attacker-controlled phishing content after clicking a transaction link.
Reviewed by Cursor Security Reviewer for commit e4062a9. Configure here.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has unresolved findings (medium tabnabbing and high remote-script execution in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent still has unresolved findings (medium tabnabbing and high remote-script execution in release.yml). jdomingos and dnehl are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Router and Approver




Note
High Risk
Large new DeFi borrow path with wallet signing, transaction submission, and LTV validation touches money-moving flows; earn routing/state refactor could regress staking if mis-wired.
Overview
Adds a feature-flagged borrow experience in the dashboard (form → review → steps → complete, plus borrow position management), backed by a new
borrowmodule: Effect Schema domain models, OpenAPI-generatedBorrowApiclient, and@effect/atom-reactatoms for markets/positions, form state, action execution (sign/submit/confirm), and post-tx cache refresh.Earn flow cleanup: drops
EarnPageStateUsageBoundaryProvider/@xstate/store, removescommon/get-token-balances.tsandgetInitialTokenfrom stake types, and tightens validator handling via a compositeValidator.key(address + optional subnet) used in select-validator and position balance keys.Tooling/config: OpenAPI generator gains
BorrowApi(fullhttpclient+ spec prep), optional CLI spec selection,VITE_BORROW_API_URL/VITE_FORCE_BORROW, and rootpnpm.patchedDependenciesremoved; adds skeleton line/circle loaders for borrow UI loading states.Reviewed by Cursor Bugbot for commit 6cf3187. Configure here.