Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

closeYieldVault can leave residual FCM position due to precision/rounding

Aperta
#178 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
blockchain
Ambito
blockchain

Direzione di ricerca

Start at closeYieldVault and trace how the UFix64 amounts and swap quote are used to repay debt and unwind collateral. Add precision edge-case tests around the UFix64 minimum unit of 0.00000001, using the numerical example as a guide. Done means closeYieldVault either leaves zero or explicitly allowed dust, or reverts without burning the strategy.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

closeYieldVault can succeed while leaving a tiny non-zero FCM position (small residual debt/collateral).

Root cause: close flow relies on UFix64 (8 decimals) plus swap quote rounding, so exact repay amounts are not always representable in one pass.

This is separate from #152.

Why this matters

  • A user expects "close" to mean fully closed.
  • Current behavior can leave a small residual position after close.
  • Residual is usually tiny, but this breaks close invariants and creates inconsistent behavior.

Expected behavior

On close, protocol should either:

  1. Fully unwind debt/collateral to zero (or a defined dust threshold), then burn; or
  2. Revert and keep vault open if full unwind cannot be guaranteed.

Acceptance criteria

  • After closeYieldVault, residual debt/collateral is zero (or <= explicit dust threshold).
  • No successful close that burns strategy while leaving non-zero position above threshold.
  • Precision edge-case tests added around UFix64 minimum unit (0.00000001).

Numerical example (what is happening)

Observed close flow (mainnet investigation):

  • Before close:

    • Collateral: 0.00001000 WETH
    • Debt: 0.02038486 MOET
    • getYieldVaultBalance(): 0.00000996 WETH (less than full collateral)
  • During close:

    • 0.01911391 tauUSDFv swapped to 0.02030333 MOET for repayment
  • After close:

    • Residual debt: 0.00008153 MOET
    • Residual collateral: 0.00000004 WETH

Precision constraint:

  • Price used: 3312.54037990 MOET/WETH
  • Exact collateral needed for residual debt: ~0.00000002461253 WETH
  • UFix64 step is 0.00000001, so exact amount is not representable
    • 0.00000002 underpays
    • 0.00000003 clears debt (with small overpayment)
Lingua principale
Cadence
Stelle
41
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di onflow/FlowYieldVaults

Tutte le issue di onflow/FlowYieldVaults

Issue simili

Altre issue su Blockchain

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.