Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
CorePoolsgetUserTotalReward

getUserTotalReward

Fetch the signed-in user’s aggregate LP reward over the last days, across every market they earn in.

import { getUserTotalReward, LISTING_VALUE_DECIMALS } from "@symmio/trading-core"; import { formatUnits } from "@symmio/utils/decimal"; const earned30d = await getUserTotalReward(config, { accessToken: token.accessToken, userAddress: account.address, days: 30, }); formatUnits(earned30d, LISTING_VALUE_DECIMALS).toFixed(2); // "3.20"

One GET /v2/profit/total-reward against the chain’s listing backend, authed with the bearer token from authenticateListing. It is the single-number companion to getUserRewardChart and the per-wallet twin of getPoolTotalReward.

days is capped at 30 by the service (minimum 1); a wider window is rejected with a 422. The endpoint also wants user_address as a query parameter even though the bearer token already identifies the session — both are required.

Earned, not claimable

The figure is built from earned daily snapshots, so claiming does not reduce it: it is what the wallet accrued over the window, not what remains unclaimed. For the claimable balance in one pool, read claimableReward from getUserProfit.

It is also not scoped to a pool — it sums every market the wallet earns in. To break the same window down per pool, sum the matching slice of getUserRewardChart.

Parameters

accessTokenstringrequired

Bearer token from authenticateListing. Sent as Authorization: Bearer <token>. A bad or expired token yields a 401 (see Throws).

userAddressstringrequired

The user’s wallet address. The endpoint takes it as a query parameter alongside the token.

daysnumberrequired

Size of the trailing window in days. The service accepts 1–30.

chainIdnumberoptional

Target chain id. Defaults to the config’s defaultChainId. Selects which chain’s listing backend is used, and is folded into the query key. There is no solverId — listing is resolved at chain level.

Returns

Promise<bigint>

Aggregate reward over the window, 18-decimal fixed point (LISTING_VALUE_DECIMALS). A USD amount — 1e18 is $1. An absent figure comes back as 0n.

Query options

import { getUserTotalRewardQueryOptions } from "@symmio/trading-core"; import { useQuery } from "@tanstack/react-query"; useQuery(getUserTotalRewardQueryOptions(config, { accessToken, userAddress, days: 30 }));

GetUserTotalRewardOptions is the action’s parameters plus a query bag of TanStack overrides. The bearer token is dropped from the key by filterQueryOptions, but userAddress is kept — it is what the figure is actually scoped to, so two wallets never share a cache entry. getUserTotalRewardQueryKey builds the same ["getUserTotalReward", …] key, and GetUserTotalRewardData / GetUserTotalRewardQueryKey / GetUserTotalRewardQueryOptions name the factory’s other halves.

Throws

  • LISTING_NOT_CONFIGURED — a SymmError (kind: "config") when the resolved chain has no listing backend. Raised by resolveListingService before any request goes out.
  • UNSUPPORTED_CHAIN — a SymmError (kind: "config") when the chainId is not one the config knows about at all.
  • FETCH_USER_TOTAL_REWARD_FAILED — the request itself failed, including the 401 on a bad token and the 422 on a days outside 1–30. Any axios failure becomes a SymmApiError carrying status, statusText, responseData, url and method; a non-axios throw becomes a plain SymmError (kind: "api").
Last updated on