Skip to content

Feat/b2 fee adjusted apy#161

Open
legend-esc wants to merge 3 commits into
Dgetsylver:mainfrom
legend-esc:feat/b2-fee-adjusted-apy
Open

Feat/b2 fee adjusted apy#161
legend-esc wants to merge 3 commits into
Dgetsylver:mainfrom
legend-esc:feat/b2-fee-adjusted-apy

Conversation

@legend-esc
Copy link
Copy Markdown
Contributor

Include annualised XLM fee drag in displayed net APY.

Formula (from doc.md)

fee_drag_%/yr = (rebalances × 2 txs × 0.00001 XLM × xlm_price) / equity_usd × 100
fee_adjusted_net_apy = aprToApy(netApr − fee_drag_%/yr)

Changes

  • main.tsfeeDragPct(): computes annual fee drag as % of equity.
    Uses live XLM reserve price when available, fallback $0.10.
    Applied to prev-net-apr (updatePreview) and pos-net-apr / hero-net-apy (renderPosition).
    Tooltip shows full breakdown: net APR, drag %, rebalances, XLM price.
  • index.html — "Rebalances/yr" number input in settings dropdown.
    Default: 12 (monthly). Persists to localStorage. Updates APY on change.
  • style.css — minimal styles for the new settings row.

Acceptance criteria

  • Default rebalance frequency documented (12/yr = monthly, in code comment)
  • Input persists per user (localStorage key blendlev_rebalances_per_year)
  • APY math matches doc.md formula exactly

Tested

vite build — 0 errors

Closes #29

- fetchPositionEvents() in blend.ts: queries Horizon /accounts/{pool}/operations,
  maps invoke_host_function ops (submit→rebalance, claim→harvest) to PositionEvent
- recordPositionEvent() writes open/rebalance/harvest/close events with HF snapshot
  to localStorage (keyed per asset+pool) at transaction time
- renderPositionTimeline() renders scrollable <details> block: local timestamps,
  UTC on hover, colour-coded icons, network-aware Stellar Expert tx links
- refreshTimelineFromChain() merges on-chain history into local store (fire-and-forget
  from loadAll when a position exists)
- Position History <details> added to position card in index.html
- CSS for .pos-timeline / .pos-event-item with per-kind icon colours

Closes Dgetsylver#27
- irAtUtil(): mirrors exact 3-kink IR formula using live rateConfig params
- renderWorstCase(): projects HF at 30/90/180 days at 99% util (r_three active),
  borrow/supply APR breakdown, and days-to-liquidation at worst-case spread
- Updates on every leverage slider / deposit input change via updatePreview()
- <details> panel collapsed by default in the preview section
- CSS for .worst-case-panel / .wc-* elements

Closes Dgetsylver#41
Formula (from doc.md):
  fee_drag_%/yr = (rebalances × 2_txs × 0.00001_XLM × xlm_price) / equity_usd × 100
  fee_adjusted_net_apy = aprToApy(netApr − fee_drag_%/yr)

- feeDragPct(): computes annualised XLM fee drag as % of equity
  Uses live XLM reserve price when available, fallback $0.10
- Applied to prev-net-apr (updatePreview) and pos-net-apr / hero-net-apy (renderPosition)
- Tooltip shows breakdown: net APR, drag %, rebalances, XLM price
- 'Rebalances/yr' input in settings dropdown (default 12 = monthly)
  Persists to localStorage; updates APY display on change
- Default of 12 documented in code comment

Closes Dgetsylver#29
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@legend-esc 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.

B2: Fee-adjusted APY

1 participant