Skip to content

Instantly share code, notes, and snippets.

@patcito
Created January 26, 2026 10:19
Show Gist options
  • Select an option

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

Select an option

Save patcito/927aa16958312d1124fb45292a483365 to your computer and use it in GitHub Desktop.
# API Fixes for Decimals and Yield Endpoints
## Summary
Two fixes have been deployed to address issues with yield data and USD conversion in the API.
---
## Fix 1: Weekly Yield USD Conversion and Decimals Handling
**Commit:** `80125f5`
### What Changed
1. **Weekly cumulative yield now uses oracle prices for USD conversion**
- Previously: Stored pre-calculated USD values
- Now: Converts to USD dynamically using oracle prices at request time
- **Frontend impact:** More accurate USD values in `CumulativeYieldClaimed` series
2. **New endpoint data: Per-wrapper yield with asset addresses**
- Added `GetWeeklyYieldByWrapper` to fetch yield data per wrapper with correct asset addresses
- Enables accurate pricing by joining with allocation data
3. **Decimals handling priority changed**
- **Priority order now:**
1. On-chain collateral decimals (most accurate)
2. Stored decimals from DB
3. Default to 6 (stablecoins fallback)
- This fixes issues where some tokens (like WETH=18 decimals) were incorrectly calculated using 6 decimals
4. **Auto-correction of stored decimals**
- When a mismatch is detected between stored and on-chain decimals, the DB is automatically updated
- Historical queries skip this update to avoid modifying the DB
### Affected Endpoints
- `/dashboard` - Series data: `CumulativeYieldClaimed`
- Any endpoint returning yield USD values
### Response Format Changes
None - the response format remains the same, but **values will be more accurate**.
---
## Fix 2: Daily Yield Date Scanning Error
**Commit:** `f260e48`
### What Changed
Fixed a PostgreSQL driver error when scanning date fields:
```
cannot scan date (OID 1082) in binary format into *string
```
The `DATE` type is now explicitly cast to `text` in SQL queries.
### Affected Endpoints
- `/yield`
- `/yield_daily`
- Any endpoint returning daily yield data
### Response Format Changes
None - this was a bug fix that was causing endpoints to fail entirely.
---
## Summary for Frontend
| Endpoint | Change | Action Required |
|----------|--------|-----------------|
| `/dashboard` | More accurate USD values in `CumulativeYieldClaimed` | None - values are now correct |
| `/yield` | Fixed 500 error | None - endpoint now works |
| `/yield_daily` | Fixed 500 error | None - endpoint now works |
**No frontend code changes required** - these are backend fixes that improve data accuracy and fix broken endpoints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment