Skip to content

Feat/b6 post loop projected rates#176

Open
vicistar-star wants to merge 3 commits into
Dgetsylver:mainfrom
vicistar-star:feat/b6-post-loop-projected-rates
Open

Feat/b6 post loop projected rates#176
vicistar-star wants to merge 3 commits into
Dgetsylver:mainfrom
vicistar-star:feat/b6-post-loop-projected-rates

Conversation

@vicistar-star
Copy link
Copy Markdown

Closes #33. The leverage preview now shows both the current pool APY (pre-loop snapshot) and the projected APY after the user's deposit, making it clear how the position shifts
pool utilization and rates.

Changes:

  • index.html — added "Current pool APY" row above the existing APY row; renamed existing row to "Projected APY after deposit"
  • main.ts updatePreview — computes current APY via projectRates(rs, 0, 0) (zero delta) and projected APY via projectRates(rs, supply - oldSupply, borrow - oldBorrow); tooltip updated
    to explain the distinction

Math verification against src/bin/simulate.rs:

Both use the same 3-kink IR model: utilization → base rate → borrow_apr = base_rate × ir_mod → supply_apr = borrow_apr × util × (1 − bstop_rate). The TS version uses integer
arithmetic matching the on-chain Soroban contract; the Rust version uses floats — both are equivalent.

Acceptance:

  • ✅ Simulation computes new utilization given proposed loop size
  • ✅ UI clearly labels "projected APY after your deposit" vs. current pool APY
  • ✅ Math verified against the Rust simulate binary

- Add rate history storage (B3): recordRateSnapshot / getRateAtWindow
  persist timestamped APY snapshots in localStorage, keyed by pool/asset/field
- Add renderTrendArrow: computes (current-past)/|past| delta, renders ▲/▼
  with percentage and a tooltip showing absolute before/after values + window
- Hook into renderSelectedAsset to record and display arrows on net supply
  APY and net borrow cost rows
- Add .rate-trend CSS (inline, 10px mono, green up / red down)
- Add hist-chart-wrap section in stats-body with 7d/30d/1y window selector
- renderHistoryChart reads B3 localStorage snapshots, renders SVG polyline
  time-series with x/y axis labels and invisible hit-area rects for tooltip
- Pointer tooltip shows exact date + APY value at cursor position
- Window selection persists in _histWin session variable (default 30d)
- Hooked into renderSelectedAsset; window buttons re-render on click
- Add CSS for chart, window buttons, cursor dot, and empty state
- updatePreview now computes two APY values:
  - Current pool APY: projectRates(rs, 0, 0) × leverage — pre-loop snapshot
  - Projected APY after deposit: projectRates(rs, supply-oldSupply, borrow-oldBorrow)
    × leverage — accounts for how the user's supply/borrow shifts utilization
- HTML: added 'Current pool APY' row above 'Projected APY after deposit' row
- Tooltip updated to explain the distinction and show both values
- projectRates math matches Rust simulate binary (same 3-kink IR model)
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@vicistar-star Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

B6: Post-loop projected rates

1 participant