Skip to content

feat: dollar tokens Phase 3 foundation (stacked on PR #148)#149

Merged
TuCopFi merged 11 commits into
feat/integrate-usdc-usdm-usat-phase1from
feat/dollars-spend-foundation
Jun 4, 2026
Merged

feat: dollar tokens Phase 3 foundation (stacked on PR #148)#149
TuCopFi merged 11 commits into
feat/integrate-usdc-usdm-usat-phase1from
feat/dollars-spend-foundation

Conversation

@TuCopFi

@TuCopFi TuCopFi commented Jun 4, 2026

Copy link
Copy Markdown
Member

Summary

Foundation layer of Phase 3 of the dollar-tokens initiative. Lands the pure planner, multi-quote hook, Redux slice for in-flight state, orchestrator saga, selectors, and a planner-input hook. No UI integration in this PR; UI bolts on in a follow-up.

Stacked on top of PR #148 (Phase 1 + Phase 2 data layer + cards). Once #148 merges to Development, the base of this PR will become Development.

Spec: `tasks/plans/dollar-tokens-phase3-spend-order.md` (local-only).
Implementation plan: `tasks/plans/dollar-tokens-phase3-foundation-implementation.md` (local-only).

What this PR contains

New module `src/dollarsSpend/`:

  • types.ts - SpendStep, MultiSwapPlan, DollarTokenBalanceSnapshot, SPEND_ORDER (USAT > USDm > USDC > USDT), DOLARES_VIRTUAL_TOKEN_ID
  • planSpend.ts - pure planner walking spend order with dust filter (9 unit tests)
  • slice.ts - Redux state for in-flight multi-swap (plannedSteps, completedSteps, failedAtIndex, lastError) (8 unit tests)
  • useMultiSwapQuote.ts - fetches N Squid quotes in parallel for upfront totals (4 unit tests)
  • saga.ts - executeMultiSwapSaga orchestrator: per-step quote refetch + dispatch swapStart + race(swapSuccess/swapError) on swapId. On step failure halts and emits multiSwapStepFailed; on full success emits multiSwapCompleted. (3 saga tests)
  • selectors.ts - inFlight, hasInFlight, inFlightProgress (5 unit tests)
  • useDollarBalanceSnapshots.ts - builds the planner's input array from the current wallet token state (3 unit tests)
  • index.ts - barrel re-exports

Auxiliary:

  • src/swap/useSwapQuote.ts - extract `fetchSwapQuote` as a named export for re-use (lightweight price-discovery function; the existing hook keeps its full prepareSwapTransactions flow)
  • src/redux/reducersList.ts - register dollarsSpend reducer
  • src/redux/sagas.ts - spawn dollarsSpendSaga
  • src/redux/migrations.ts - migration 247 seeds the new slice
  • src/redux/store.ts - bump persistConfig.version to 247
  • test/RootStateSchema.json + test/schemas.ts - regenerated schema, v247Schema added
  • knip.ts - ignore the dollarsSpend barrel until Phase 3.2 UI consumes it

Verification

  • `yarn build:ts` - pass
  • `yarn lint` - pass
  • `yarn test` - 374 suites pass, 4029 tests pass, 96 snapshots pass, 0 failures
  • `yarn knip --no-gitignore` - dollarsSpend barrel ignored as planned

Known follow-ups for Phase 3.2 (UI integration, separate PR)

  • TokenBottomSheet `collapseDollars` prop to render the virtual Dolares row
  • SwapScreen + GoldBuyEnterAmount + SendEnterAmount route the virtual tokenId through the planner
  • MultiSwapProgressSheet + PartialSuccessSheet UI for in-flight + partial-failure states
  • New i18n keys (`dollarsSpend.*`)
  • Mainnet QA of the full chain
  • One architectural item: the orchestrator saga in this foundation passes `preparedTransactions: []` because the light `fetchSwapQuote` does not build them; Phase 3.2 must either (a) extend fetchSwapQuote to call prepareSwapTransactions per step, or (b) have the UI use the full `useSwapQuote` to prebuild quotes including preparedTransactions for each step and pass them via the action payload. Documented in the spec.

Test plan

  • yarn test passes (verified locally before push)
  • CI passes
  • No regression in single-swap flow (existing swap tests pass and were not modified)
  • Reviewer confirms the saga's race+take predicate matches both shapes of swapSuccess/swapError payload (object with swapId or raw swapId string)

@TuCopFi TuCopFi merged commit d8768fa into feat/integrate-usdc-usdm-usat-phase1 Jun 4, 2026
1 check passed
@TuCopFi TuCopFi deleted the feat/dollars-spend-foundation branch June 12, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant