closeYieldVault can leave residual FCM position due to precision/rounding
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- blockchain
- 领域
- blockchain
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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:
- Fully unwind debt/collateral to zero (or a defined dust threshold), then burn; or
- 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)
- Collateral:
-
During close:
0.01911391 tauUSDFvswapped to0.02030333 MOETfor repayment
-
After close:
- Residual debt:
0.00008153 MOET - Residual collateral:
0.00000004 WETH
- Residual debt:
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 representable0.00000002underpays0.00000003clears debt (with small overpayment)
- 主要语言
- Cadence
- 星标
- 41
- 派生
- 0
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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`可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
onflow/FlowYieldVaults#270 ·
查看 onflow/FlowYieldVaults 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
near/near-sdk-rs#1676 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
near/near-cli-rs#714 ·
维护者通常 13 天内回复
-
难度 2/5 1-3 小时 新手友好度 69/100
blinklabs-io/bursa#1211 ·
维护者通常 1 天内回复
-
bug localnet
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
propeller-heads/tycho#1744 ·
维护者通常 2 天内回复