Skip to content

fix(positions): pass wallet address to getEarnPositions - #297

Open
TuCopFi wants to merge 1 commit into
Developmentfrom
fix/earn-positions-pass-address
Open

fix(positions): pass wallet address to getEarnPositions#297
TuCopFi wants to merge 1 commit into
Developmentfrom
fix/earn-positions-pass-address

Conversation

@TuCopFi

@TuCopFi TuCopFi commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

  • src/positions/saga.ts:106 builds the getEarnPositions URL with networkIds but never sets address, so the backend can only return a generic pool listing with balance=0 and earningItems=[].
  • Today the dedupe loop hides the bug because getPositions (which does pass address) also returns Neeru with real per-user values, and it wins the merge.
  • The moment getPositions stops returning Neeru (e.g. it moves to a purely earn-hosted response, or partialFailure trims it), earn cards would silently drop to 0 balance and no rewards for every user.
  • Also adds a saga-test assertion on the URL so future edits catch a regression.

Verified

Live cross-check against production backend confirms getEarnPositions returns zeroes without address:

GET /hooks-api/getEarnPositions?networkIds=celo-mainnet (no address)
  -> category-0: balance="0", earningItems=[]
GET /hooks-api/getEarnPositions?networkIds=celo-mainnet&address=0x8427e4409b73a31b9d4e0d210677c88877472ece
  -> category-0: balance="10002.656409312776653968", earningItems=[]

Related concern (out of scope for this PR)

A user reported "intereses de todos" appearing immediately after a new deposit. The wallet only renders what the backend returns for /api/earn/neeru/positions?address=X, and that endpoint returns a per-position accruedInterest sourced from the contract. If a fresh deposit shows non-trivial accrued interest at t=0, that is a contract or indexer attribution bug on the backend side. Flagged for backend to investigate; wallet-side change here is defense-in-depth for the separate getEarnPositions gap.

Test plan

  • yarn build:ts (0 errors)
  • yarn test --testPathPattern=positions/saga (18/18 pass, including the new URL assertion)
  • Manual smoke on emulator: Neeru pool card shows correct balance after login

The wallet's getPositions call already scopes results to the caller by
passing 'address' but getEarnPositions did not. Without the address the
backend can only return a generic pool listing with balance=0 and
earningItems=[] for every pool.

Today the dedupe loop in fetchPositions hides the bug because getPositions
returns Neeru entries with real per-user values, and those win the merge.
The moment that contract changes (e.g. Neeru gets moved into a purely
earn-hosted response, or partialFailure trims it from getPositions), the
earn cards would silently show 0 balance and no rewards.

Adds the address, keeps the dedupe order unchanged so behavior is
identical today, and adds a URL assertion in the saga test so future
edits catch a regression.
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