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
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 canary-publish/supply-chain issues in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Actions with empty, address-like, or missing token symbols no longer fall back to "Unknown token". Filter them from the activity list so users only see items with a usable token label.
|
|
||
| return (url: string) => { | ||
| trackEvent("viewTxClicked"); | ||
| window.open(url, "_blank"); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
window.open(url, "_blank") is called on a transaction URL without opener isolation or URL validation. If this URL is attacker-controlled (directly or via compromised upstream metadata), the opened page can retain window.opener access and redirect the original trusted tab.
Impact: This enables reverse-tabnabbing/phishing flow hijack during a wallet-sensitive user journey.
Reviewed by Cursor Security Reviewer for commit 73852cc. 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 canary-publish/supply-chain issues in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Unstake USD previously reflected the full position balance. Scale it from the entered exit amount so partial exits show the correct value.
Tighten the form pane gap and increase spacing within amount and details sections for clearer visual hierarchy.
Proxy to the widget package so `pnpm dev` works from the monorepo root.
Raise pinned toolchain versions to Node 24.19.0, npm 11.19.0, and pnpm 11.19.0 so local and CI tooling stay on current releases.
The legacy price API serializes native tokens with an undefined address key, while local token identity uses an empty one. Fall back to the legacy key so USD amounts format correctly for native tokens.
Introduce a tabbed position-details hub and extract AmountTokenSection so stake and unstake share one amount card instead of drifting apart.
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 canary-publish/supply-chain issues 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 canary-publish/supply-chain issues in
release.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Hide the CTA for empty yield lists only when connected, so disconnected users can still connect instead of seeing no primary action.
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 canary-publish/supply-chain issues in
release.yml). No new reviewers assigned; two reviewers are already requested for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Align classic and dashboard unstake on one shared section with a footer CTA, and select the receive token from the amount accessory like enter/stake instead of a separate dropdown.
Pending actions can require validator selection while the position has nothing to unstake, so rendering the modal inside the unstake section hid it. Render it alongside the whole surface on both classic and dashboard instead.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: Cursor Security Agent did not reach a terminal state within the polling window, and this large earn/borrow refactor exceeds the low-risk approval threshold. No new reviewers assigned; two reviewers are already requested for human review.
Sent by Cursor Approval Agent: Pull Request Router and Approver
Replace technical-kind domain/schema and domain/types folders with concept-owned modules so schemas and rules live with the concept they describe. Record the decision in ADR 0020.
WidgetConfigService exclusively owns one normalization pass and the current value stream so valid Host Configuration updates apply without remounting. Record the decision in ADR 0021 and supersede mount-time Application Runtime Identity for API identity and borrowEnabled.
Keep the wallet runtime alive when comparable wallet fields change after bootstrap; log and ignore those updates so host config can keep syncing. Also remove the unused disableGasCheck host setting.
Match allow, block, and preferred rules with network-sensitive address identity, and commit Earn Selection when Host Configuration updates invalidate the current validators.
Replace the staged Earn state machine with Entry Intent, pure reconciliation, and a non-paginated Earn Catalog per ADR-0022. Drop token pagination, stage-specific retry, and selection facades.
Move validator policy normalization into WidgetConfig so all Earn consumers share the same Map/Set representation. Remove the feature-local adapter while preserving network-specific wildcard identity handling in filterValidators.
Keep window and Vite environment augmentations in one package-owned declaration file. Update the test-only export configuration to track the consolidated entry.
Keep Borrow wallet interpretation with the feature as a pure view projection. Derive it from the shared wallet selector. Remove the unused bridge payload and domain wallet schema. Remove the redundant guard hook and obsolete chain exports.
Move architecture enforcement into the widget package and keep the root hygiene command as a thin Turbo entrypoint. Replace manual interface and export checks with dependency-cruiser, Knip, and ast-grep while removing obsolete fixtures and configs.
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
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 high and medium findings that need human review. No new reviewers assigned; two reviewers are already requested.
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.