Positions
positions.get
Section titled “positions.get”An account’s positions, built from its swaps, newest trade first. HTTP: /positions.
| Param | Description |
|---|---|
account |
Required |
limit |
1 to 1000, default 1000 |
The first time an account is asked about, its positions are built from its newest 1,000 trades. From then on they’re kept current with every trade it makes, whether it’s asked about again or not.
Result:
{ "height": 220122260, "timestamp_millis": 1792093696887, "since_millis": 1790709119408, "columns": ["token", "opened_at_millis", "closed_at_millis", "last_trade_millis", "amount", "cost_usd", "bought", "bought_usd", "sold", "sold_usd", "realized_pnl_usd", "buys", "sells"], "rows": [["ribbit-426.meme-cooking.near", 1791563912000, null, 1792086520230, "600000000000000000000000", 3600, "1000000000000000000000000", 6000, "400000000000000000000000", 4000, 1600, 3, 1]]}since_millis: the oldest trade the positions were built from,nullwhen the account had none. What was bought before it isn’t known, so selling it isn’t counted.- A position is open while
closed_at_millisisnull. An account has at most one open position per token. amount,boughtandsoldare in the token’s smallest units.amountis what’s held now, andcost_usdwhat it cost.realized_pnl_usd: what sells got, minus what the part sold cost, at average cost. For an open position, what it’s worth now is up to you:amountat the token’s price.
How swaps count
Section titled “How swaps count”- A transaction’s trades, one per pool, count as one swap. A token passed from one pool to the next nets to nothing.
- A swap buys what the account got and sells what it gave. wNEAR, USDC, USDt and their bridged forms are what positions are paid in, so they never hold one.
- A buy opens a position in the token, or adds to the open one at a new average entry.
- A sell takes from the open position. The position closes once 1% or less of what was bought is left.
- A sell of more than the position holds is left out, like selling tokens bought before
since_millisor that came in by transfer. - Transfers in and out don’t count.