Skip to content

SDK + CLI: getPositions() to fetch all wallet lend positions in one call#508

Draft
its-everdred wants to merge 2 commits into
mainfrom
kevin/sdk-cli-getpositions
Draft

SDK + CLI: getPositions() to fetch all wallet lend positions in one call#508
its-everdred wants to merge 2 commits into
mainfrom
kevin/sdk-cli-getpositions

Conversation

@its-everdred

@its-everdred its-everdred commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Closes #454

Summary

Adds getPositions() to the SDK to fetch all of a wallet's lend positions in one call, replacing the per-market getPosition fan-out that every portfolio consumer had to write by hand. Wires it through the CLI and the demo.

SDK

  • GetPositionsParams (chainId?, provider?, nonZeroOnly?), exported from the public entry.
  • LendProvider.getPositions(walletAddress, params?) — walks the provider's market allowlist and fetches each position with Promise.allSettled, so a single bad-market RPC can't poison the batch (rejected markets are dropped).
  • BaseLendNamespace.fetchPositions — aggregates across configured providers (or one, via provider), flattens, then applies nonZeroOnly.
  • ActionsLendNamespace.getPositions(walletAddress, params?) and WalletLendNamespace.getPositions(params?) (uses wallet.address implicitly).

CLI

  • actions wallet lend positions [--chain <name> | --chain-id <id>] [--non-zero-only] — one wallet.lend.getPositions() call; emits LendMarketPosition[] verbatim (bigints stringified). New lendPositions output sink.

Demo

  • Backend: getLendPositions service + GET /wallet/lend/positions route/controller (optional chainId/nonZeroOnly query).
  • Frontend: actionsApi.getPositions, EarnOperations.getPositions on both wallet operation builders.
  • useLendProvider.ts: both fan-out sites (mount load + post-trade refresh) now call operations.getPositions() once. The single getPosition activity-log entry is now honest (one call, one line).

Testing

  • SDK: provider walk / empty allowlist / missing-address / chain validation / per-market failure isolation; namespace aggregation / provider filter / nonZeroOnly; wallet implicit-address path.
  • CLI: emit shape, --chain + --non-zero-only forwarding, multi-chain rejection, missing-lend/RPC error mapping.
  • Backend: service param-forwarding + bigint serialization + error propagation.
  • All suites green (SDK 673, CLI 267, backend 132, frontend 73); typecheck + lint clean across packages.
  • Manual CLI run against the demo config (Base Sepolia + OP Sepolia): default aggregates both chains; --non-zero-only[]; --chain base-sepolia filters; both-flags rejected with a validation error.

its-everdred and others added 2 commits June 17, 2026 11:28
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Jun 18, 2026

Copy link
Copy Markdown

Deploy Preview for actions-ui failed. Why did it fail? →

Name Link
🔨 Latest commit 92fc418
🔍 Latest deploy log https://app.netlify.com/projects/actions-ui/deploys/6a3337023cd1310008d5bb8e

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.

SDK + CLI: getPositions() to fetch all wallet lend positions in one call

1 participant