Skip to content

Phase 2: core logic - #109

Merged
MFrancis-dev merged 1 commit into
mainfrom
feat/core-logic
Nov 4, 2026
Merged

MFrancis-dev merged 1 commit into
mainfrom
feat/core-logic

Conversation

@MFrancis-dev

Copy link
Copy Markdown
Owner

Pure, tested domain logic in lib/core (ARCHITECTURE §3–4, ESSENTIALS rules).

What changed

  • money.ts: bigint base-unit conversion/formatting; never floats.
  • cost.ts: cost in bps from the quote's own USD values, rounded up; unknown cost is never treated as free.
  • planMatch.ts: a buy quote must match the on-chain plan (recipient, asset, origin USDC, refunds to the vault, amount ≤ per-run, not dry, has a deposit address).
  • address.ts: checksummed validation — BTC bech32/bech32m + base58check, EVM EIP-55, NEAR accounts — so typos can't send savings to the wrong address.
  • assets.ts: decided target ids (KD-6); schemas.ts: plan form (address typed twice + checksum + on-chain limits), funding quote, session.
  • QuoteSummary now echoes originAsset, refundTo, minAmountOut, timeEstimateS.

Closes #33
Closes #34
Closes #35
Closes #36
Closes #37
Closes #38

Roadmap

  • ROADMAP.md updated: K2.1–K2.6 done, Phase 2 at 100%

Checks

  • 33 tests (pnpm test), pnpm typecheck, pnpm lint

NEAR HACKATHON rules

  • No secrets
  • New libraries @noble/hashes, @scure/base to be listed in the README (K10.3)

- money: bigint base-unit conversion, formatting, scaled decimals
- cost: cost_bps from the quote's USD values (rounded up, null when
  unknown) and checkCost against the plan limit
- planMatch: last off-chain guard before execute_buy (recipient, asset,
  origin, refundTo = vault, amount, dry, paused/plan)
- address: checksummed BTC (bech32/bech32m, base58check), EVM (EIP-55)
  and NEAR account validation
- assets: KD-6 target ids; schemas: plan form, funding quote, session
- 33 tests; adds @noble/hashes and @scure/base
@MFrancis-dev
MFrancis-dev merged commit 2241957 into main Nov 4, 2026
3 checks passed
@MFrancis-dev
MFrancis-dev deleted the feat/core-logic branch November 4, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment