getUserRewardChart
Fetch the signed-in user’s daily LP-reward series, grouped by market — the “your performance” side of a pool page’s rewards chart.
import { getUserRewardChart } from "@symmio/trading-core";
const charts = await getUserRewardChart(config, { accessToken: token.accessToken });
const pool = charts.find((entry) => entry.marketAddress.toLowerCase() === address.toLowerCase());One GET /v2/profit/chart/rewards against the chain’s listing backend, authed with the bearer token from authenticateListing. The public, whole-pool twin is getPoolRewardChart.
Not scoped to one pool
The endpoint takes no market: the bearer token alone identifies the caller, and the response covers every market they have rewards in — one UserPoolRewardChart each. A single-pool view filters that response itself:
const mine = charts.find(
(entry) =>
entry.marketAddress.toLowerCase() === pool.contractAddress.toLowerCase() && entry.marketChainId === pool.chainId,
);
const points = mine?.rewards ?? [];Match on both halves of the pair. Two listings on different deposit chains can carry the same address string, so matching on the address alone can pick the wrong series.
One request covers every pool, so a page showing several pools’ “your rewards” should read this once and slice it, not call it per row.
Parameters
accessTokenstringrequiredBearer token from authenticateListing. Sent as Authorization: Bearer <token>. A bad
or expired token yields a 401 (see Throws).
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<UserPoolRewardChart[]>One entry per market the user has rewards in. An empty array means the wallet has earned nothing anywhere yet.
marketAddressstringThe pool’s token contract address — matches ListingMarket.contractAddress.
marketChainIdListingDepositChainIdChain the pool’s token lives on — matches ListingMarket.chainId, not the SDK’s chainId.
rewardsPoolRewardPoint[]The user’s daily rewards in this pool: { timestamp, reward }, with reward an 18-decimal USD bigint and an
absent day collapsed to 0n. Same shape getPoolRewardChart returns.
toUserPoolRewardChart
The mapper this read runs on each group, exported for when you hold a raw response yourself.
import { toUserPoolRewardChart } from "@symmio/trading-core";
toUserPoolRewardChart({
market_address: "0x1234…",
chain_id: 8453,
rewards: [{ timestamp: 1752364800, reward: "1000000000000000000" }],
});
// { marketAddress: "0x1234…", marketChainId: 8453, rewards: [{ timestamp: 1752364800, reward: 1000000000000000000n }] }The wire’s chain_id is surfaced as marketChainId and never as the SDK’s own chainId, so the two cannot be confused downstream.
Query options
import { getUserRewardChartQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(getUserRewardChartQueryOptions(config, { accessToken }));GetUserRewardChartOptions is the action’s parameters plus a query bag of TanStack overrides. The bearer token is dropped from the key by filterQueryOptions — it is a credential, not a cache dimension, so a refreshed token still hits the same cache entry and the token never lands in a devtools-visible key. getUserRewardChartQueryKey builds the same ["getUserRewardChart", …] key, and GetUserRewardChartData / GetUserRewardChartQueryKey / GetUserRewardChartQueryOptions name the factory’s other halves.
Because the token is not in the key, invalidate this query on sign-out. Otherwise the previous wallet’s series stays cached under an identical key and can be served to the next one.
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_REWARD_CHART_FAILED— the request itself failed, including the401on a bad or expired token. Any axios failure becomes aSymmApiErrorcarryingstatus,statusText,responseData,urlandmethod; a non-axios throw becomes a plainSymmError(kind: "api").
Related
getPoolRewardChart— the public, whole-pool series.getUserTotalReward— the trailing-window headline for the same wallet.getUserProfit— the wallet’s LP position and claimable balance in one pool.authenticateListing— where the bearer token comes from.@symmio/trading-react—useUserRewardChartis the React binding over this read.- Errors — the
SymmError/SymmApiErrorhierarchy these codes belong to.