Skip to content

Feat/dry run preview modal#170

Open
cyberdocs120 wants to merge 3 commits into
Dgetsylver:mainfrom
cyberdocs120:feat/dry-run-preview-modal
Open

Feat/dry run preview modal#170
cyberdocs120 wants to merge 3 commits into
Dgetsylver:mainfrom
cyberdocs120:feat/dry-run-preview-modal

Conversation

@cyberdocs120
Copy link
Copy Markdown

What changed

blend.ts — four new exported helpers that build the xdr.ScVal requests vec for each action type without
assembling a signed XDR:

  • buildOpenRequestsVec (open / add-funds)
  • buildCloseRequestsVec
  • buildIncreaseRequestsVec
  • buildDecreaseRequestsVec

dryRunSubmit was already present and is unchanged.

main.ts — showDryRunModal() calls dryRunSubmit, renders the modal with:

  • Net tokens moved
  • Current HF → projected HF (colour-coded)
  • Estimated fee in XLM
  • Any simulation error

Returns Promise. Wired into openPosition, adjustLeverage, and addFundsToPosition — cancel aborts the
flow before the wallet is ever prompted.

index.html — modal markup reusing the existing .alert-modal-overlay shell.

style.css — .dryrun-table, .dryrun-error, .dryrun-actions styles.

Acceptance checklist

  • Simulation uses soroban-rpc simulateTransaction
  • Modal renders before the signing prompt
  • Clear diff: current state vs post-submit (HF before/after, net tokens, fee)
  • Errors surfaced in modal — no signature required

Closes #17

- Add rate_snapshots table + index to schema.sql
- Cron writes (pool, asset, supply_rate, borrow_rate, util, blnd_eps) snapshot each 15-min tick
- Cron prunes snapshots older than 365 days
- Add GET /rates?pool=&asset=&window= public endpoint
- Expose util + blndEps fields on ReserveRates
- Add fetchEwmaRates() to blend.ts: fetches 30d snapshots from B3 /rates
  endpoint and computes EWMA with 7-day half-life (α ≈ 0.0029 per 15-min tick)
- Add apyMode state (instant | smoothed) and activeRates() helper in main.ts
- Net supply APY and net borrow cost rows use activeRates() — affected by toggle
- Position net APY in renderPosition() also uses activeRates()
- Toggle button (#apy-mode-toggle) in APR section header switches modes
- EWMA results cached per pool+asset; cache cleared on pool/asset switch
- Docs panel (<details id=ewma-docs>) explains EWMA, half-life, and formula
- blend.ts: export buildOpenRequestsVec, buildCloseRequestsVec,
  buildIncreaseRequestsVec, buildDecreaseRequestsVec to build
  submit requests without assembling signed XDR
- main.ts: showDryRunModal() calls dryRunSubmit via soroban-rpc
  simulateTransaction, shows net tokens moved, current→projected HF,
  estimated fee, and any simulation errors; resolves Promise<boolean>
  so actions bail early on cancel
- Wired into openPosition, adjustLeverage, addFundsToPosition —
  modal renders before the wallet signing prompt
- index.html: dry-run modal markup reusing alert-modal shell
- style.css: dryrun-table, dryrun-error, dryrun-actions styles

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

drips-wave Bot commented May 29, 2026

@cyberdocs120 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.

A15: Dry-run preview modal

1 participant