Repository navigation
feat(wallet): put USDY on the recorded cost-basis view - #1271
Conversation
USDY accrues through its price, not its balance, so a portfolio line that never moves reads as "no yield" to people who are in fact earning. The recorded-basis view already expresses this honestly for USTRY; extend it to USDY so the same holding shows its change in value. The earlier attempt shipped a full FIFO lot tracker with its own storage and a YieldDisplay component alongside a simpler recorded-basis module doing the same job. Two sources of truth for one number is the failure mode, so this takes the recorded-basis path and generalises the hardcoded single-asset check instead. Basis is matched by code AND issuer, so a counterfeit token reusing the code cannot inherit someone else's basis. Also reads the stored basis in the state initialiser rather than an effect. Under the previous effect, a client that already had a basis recorded painted "change in value unknown" until the effect committed and re-rendered.
|
@Ugasutun is attempting to deploy a commit to the miracle656's projects Team on Vercel. A member of the Team first needs to authorize it. |
…-basis view Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
|
Merged — thanks, the issuer-pinned matching and the init-time read are both right, and moving off the effect fixes a real first-paint flash. I adjusted one thing before merging. to It now returns the issuer, which is the key already written. Your pairing check is what keeps a counterfeit out, so the issuer alone is still safe as a key. I added a regression test for a USTRY basis stored under the pre-USDY key; switching the return back to the code fails it. Everything else is yours as written. |
Closes #734. Successor to #883, which I am closing as superseded.
What
USDY accrues through its price, not its balance, so a portfolio line that never moves reads as "no yield" to someone who is in fact earning.
mainalready expresses this honestly for USTRY via a manually recorded USDC cost; this puts USDY on the same view.Why this is smaller than #883
The earlier branch carried a full FIFO lot tracker with its own storage and a separate
YieldDisplaycomponent, alongside the simplerlib/costBasis.tsthat landed. Two sources of truth for one number is the failure mode, so this takes the recorded-basis path and generalises the single hardcoded asset check instead of adding a parallel system. No new source files; 19 lines of component change.Basis matches code and issuer, so a counterfeit token reusing the
USDYcode cannot inherit someone else's recorded basis.One bug fixed on the way
The stored basis was read in a
useEffect, so a client that already had a basis recorded painted "change in value unknown" until the effect committed and re-rendered. Moved to the state initialiser. This also blocked the new tests' static render, which is how it was found.Verification
Mirrors the wallet CI job locally:
npx tsc --noEmit— cleannpm run build— succeedednpx jest --coverage— 95 suites, 1,472 tests passedcomponents/__tests__/PortfolioSummaryCostBasis.test.ts: no-basis prompt, recorded change, refusal after the holding changes, USDC excluded, counterfeit issuer excluded, no wallet address,hideAmountsScope
One area: the wallet portfolio line. No swap, privacy or SEP-8 changes, and no markdown. The process documentation from the old stack is not here.