Closing YieldVault can burn residual AutoBalancer yield tokens (mainnet WETH↔tauUSDFv), returning less collateral on close
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- blockchain
- 領域
- blockchain
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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)
From close tx events:
AutoBalancer.Withdrawn amount=0.01911391, balanceAfter=0.00000759
FungibleToken.Burned amount=0.00000759 ← residual tauUSDFv burned
AutoBalancer.ResourceDestroyed
Root Cause
closeYieldVaultcallsyieldVault.withdraw(amount: getYieldVaultBalance())(FlowYieldVaults.cdc:415)- For FCM strategies, the Strategy's source is
position.createSourceWithOptions(type: collateralType, pullFromTopUpSource: true) - FCM's Position Source determines withdrawal based on debt repayment requirements, not total AutoBalancer balance
- Since yield accrued, AutoBalancer holds more value than needed to repay — FCM only pulls what's necessary
Burner.burn(<-yieldVault)triggersStrategy.burnCallback→_cleanupAutoBalancer→ residual tokens destroyed
Additional Issue: Inconsistent Quote Logic in SwapSource
There's also an inconsistency in SwapConnectors.SwapSource:
minimumAvailable()usesquoteOutto estimate collateral from all yield tokenswithdrawAvailable(maxAmount)usesquoteInwhenmaxAmount == minimumAvaildue 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 < maxAmountis FALSE - Uses
quoteInwhich 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:
- Withdraws collateral via normal flow
- Sweeps any remaining AutoBalancer balance to a caller-provided receiver
- Optionally swaps residual yield tokens back to collateral
- 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).
- 主要言語
- Cadence
- スター
- 41
- フォーク
- 0
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
onflow/FlowYieldVaults のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
onflow/FlowYieldVaults#274 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
onflow/FlowYieldVaults#273 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
onflow/FlowYieldVaults#272 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
onflow/FlowYieldVaults#271 ·
-
Move all test files into `./cadence/tests`再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
onflow/FlowYieldVaults#270 ·
onflow/FlowYieldVaults の issue をすべて見る
似ている issue
-
resources: add a regression test confirming admin mint still works after the #16 SAC handoff対応中かも @Daniexie が 1 日前に担当しました。 オープンcontracts good first issue Stellar Wave
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OlaGreat/starbound-realms#137 · コメント 1 件 ·
-
enhancement good first issue module:scaffold trivial
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
soroban-forge-labs/soroban-forge#606 ·
メンテナーはふだん 1 日以内に返信
-
bug difficulty: easy priority: low sdk testing
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
trustflow-protocol/trustflow-sdk#505 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
complexity: medium contracts enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
milepost-labs/milepost#469 ·
メンテナーはふだん 1 日以内に返信