Skip to content

Instantly share code, notes, and snippets.

@patcito
Created March 16, 2026 16:07
Show Gist options
  • Select an option

  • Save patcito/c8e2b555c24e077a649ea8cb3054dd58 to your computer and use it in GitHub Desktop.

Select an option

Save patcito/c8e2b555c24e077a649ea8cb3054dd58 to your computer and use it in GitHub Desktop.
ftUSD user activity: USD-based sorting changes
# ftUSD User Activity — USD Sorting Changes
## What changed
The `/ftusd/user/{address}/transactions` endpoint now sorts by **USD value** instead of raw token amounts when using amount-based sorting.
## Sorting
Use the `sort` query parameter:
- `to_amount_desc` / `to_amount_asc` — sort by destination amount in USD
- `from_amount_desc` / `from_amount_asc` — sort by source amount in USD
- `timestamp_desc` / `timestamp_asc` — unchanged (default: `timestamp_desc`)
Previously, sorting by amount compared raw token values across different decimals (e.g., 1 USDC = 1000000 vs 1 FT = 1000000000000000000). Now sorting is done on pre-computed USD values stored in the DB.
## Response format
No breaking changes. The response fields are the same:
```json
{
"to_amount": "1000000",
"to_decimals": 6,
"to_amount_usd": "1",
"from_amount": "1000000",
"from_decimals": 6,
"from_amount_usd": "1"
}
```
`to_amount_usd` and `from_amount_usd` are now sourced from DB-stored values (computed at indexing time) instead of being computed at query time. The values should be identical for existing data.
## Token prices used
- ftUSD / sftUSD: $1.00
- Stablecoin collateral (USDC, USDT, DAI): $1.00
- FT: $0.10
## Example
```
GET /ftusd/user/0x540bCa1D332EA9B8cf46473d97AE73DDD3Cc5fE9/transactions?sort=to_amount_desc&chain_id=146
```
A Claim of 1000 FT ($100) will now sort correctly relative to a Buy of 50 USDC ($50).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment