Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Closing YieldVault can burn residual AutoBalancer yield tokens (mainnet WETH↔tauUSDFv), returning less collateral on close

Abierto
#152 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
blockchain
Área
blockchain

Línea de trabajo

Start with closeYieldVault in FlowYieldVaults.cdc:415, then inspect SwapConnectors.cdc:600-609 and the close flow in close_yield_vault.cdc. Trace both FCM and PM strategy cleanup paths using the linked mainnet transactions as evidence. Done means closing a vault preserves or returns residual yield tokens and avoids unintended AutoBalancer burns.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

When closing a YieldVault backed by an FCM (FlowCreditMarket) strategy, residual yield tokens (e.g., tauUSDFv) remain in the AutoBalancer and are burned during cleanup. This occurs because FCM's withdrawal logic only pulls enough from the AutoBalancer to repay the MOET debt — any yield profit beyond that stays in the AutoBalancer and is destroyed when the YieldVault is burned.

Impact

  • Value loss: User loses accrued yield profit (the residual tokens burned)
  • Affected strategies: Primarily FCM-backed strategies (mUSDFStrategy) — non-FCM strategies have minimal risk (see below)

Mainnet Evidence (WETH → tauUSDFv)

Transaction Link
Open https://www.flowscan.io/tx/d726d3ac61a2b72de5644f7ed0c07b3d3715e8770fa02f1493c73a81526c5007
Close https://www.flowscan.io/tx/5fff138475e00daa7ed1580669ddb5d82f4566a136f5ca1dab323699b0d45e8a

From close tx events:

AutoBalancer.Withdrawn amount=0.01911391, balanceAfter=0.00000759
FungibleToken.Burned amount=0.00000759  ← residual tauUSDFv burned
AutoBalancer.ResourceDestroyed

Root Cause

  1. closeYieldVault calls yieldVault.withdraw(amount: getYieldVaultBalance()) (FlowYieldVaults.cdc:415)
  2. For FCM strategies, the Strategy's source is position.createSourceWithOptions(type: collateralType, pullFromTopUpSource: true)
  3. FCM's Position Source determines withdrawal based on debt repayment requirements, not total AutoBalancer balance
  4. Since yield accrued, AutoBalancer holds more value than needed to repay — FCM only pulls what's necessary
  5. Burner.burn(<-yieldVault) triggers Strategy.burnCallback → _cleanupAutoBalancer → residual tokens destroyed
Additional Issue: Inconsistent Quote Logic in SwapSource

There's also an inconsistency in SwapConnectors.SwapSource:

  • minimumAvailable() uses quoteOut to estimate collateral from all yield tokens
  • withdrawAvailable(maxAmount) uses quoteIn when maxAmount == minimumAvail due to < condition
// SwapConnectors.cdc:600-609
var quote = minimumAvail < maxAmount    // ← uses < not <=
    ? self.swapper.quoteOut(...)        // withdraws ALL (when minimumAvail < maxAmount)
    : self.swapper.quoteIn(...)         // calculates needed input (when minimumAvail >= maxAmount)

When closing PM strategies where maxAmount == minimumAvail:

  • Condition minimumAvail < maxAmount is FALSE
  • Uses quoteIn which may return slightly less input due to swap math rounding
  • Tiny dust left in AutoBalancer → burned

Why Non-FCM Strategies Are Less Affected

For PM strategies (syWFLOWvStrategy, tauUSDFvStrategy, FUSDEVStrategy):

  • No FCM debt constraint — on close, maxAmount == minimumAvail
  • SwapSource uses quoteIn(forDesired: maxAmount) which should withdraw nearly all input
  • Residual risk: Tiny dust from swap rounding (not significant yield loss)
  • FCM strategies: Leave entire yield profit because maxAmount < minimumAvail (FCM limits withdrawal to debt repayment)
Strategy Type Residual Risk Amount
FCM strategies (mUSDFStrategy) HIGH Entire yield profit (significant)
PM strategies LOW Swap rounding dust (tiny)

Proposed Fix

1. Fix SwapSource quote consistency (SwapConnectors.cdc)

Change < to <= so that when minimumAvail == maxAmount, it uses quoteOut (consistent with how minimumAvailable() calculated the value):

var quote = minimumAvail <= maxAmount   // ← change < to <=
    ? self.swapper.quoteOut(forProvided: self.source.minimumAvailable(), reverse: false)
    : self.swapper.quoteIn(forDesired: maxAmount, reverse: false)

This ensures PM strategies withdraw ALL yield tokens on close, eliminating dust.

2. Sweep AutoBalancer before burn (FlowYieldVaults.cdc)

Add closeYieldVaultAndSweepAutoBalancer method that:

  1. Withdraws collateral via normal flow
  2. Sweeps any remaining AutoBalancer balance to a caller-provided receiver
  3. Optionally swaps residual yield tokens back to collateral
  4. Then burns the YieldVault

This is a safety net for FCM strategies where minimumAvail > maxAmount due to debt constraints — the SwapSource fix alone doesn't help there.

3. Update close transaction (close_yield_vault.cdc)

Use the new closeYieldVaultAndSweepAutoBalancer method and handle the swept yield tokens (swap to collateral if route exists).

Lenguaje dominante
Cadence
Estrellas
41
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de onflow/FlowYieldVaults

Todos los issues de onflow/FlowYieldVaults

Issues similares

Más issues de Blockchain

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.