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
accessTokenstringrequiredBearer token from authenticateListing. Sent as Authorization: Bearer <token>. A bad
or expired token yields a 401 (see Throws).
userAddressstringrequiredThe user’s wallet address. The endpoint takes it as a query parameter alongside the token.
daysnumberrequiredSize of the trailing window in days. The service accepts 1–30.
chainIdnumberoptionalTarget 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— aSymmError(kind: "config") when the resolved chain has no listing backend. Raised byresolveListingServicebefore any request goes out.UNSUPPORTED_CHAIN— aSymmError(kind: "config") when thechainIdis not one the config knows about at all.FETCH_USER_TOTAL_REWARD_FAILED— the request itself failed, including the401on a bad token and the422on adaysoutside 1–30. Any axios failure becomes aSymmApiErrorcarryingstatus,statusText,responseData,urlandmethod; a non-axios throw becomes a plainSymmError(kind: "api").
Related
getUserRewardChart— the same rewards, day by day and per market.getPoolTotalReward— the same window for a whole pool.getUserProfit— the wallet’s LP position and claimable balance in one pool.authenticateListing— where the bearer token comes from.@symmio/trading-react—useUserTotalRewardis the React binding over this read.- Errors — the
SymmError/SymmApiErrorhierarchy these codes belong to.