Section 14 of 18

Build
+25 Lynx

Vault: withdraw with Strategy Queue Iteration

What You Are Building

The user-facing withdraw() function. Mirror of deposit() from section 5, but considerably more complex: when the vault's totalIdle doesn't cover the requested withdrawal, the vault walks the withdrawalQueue array and pulls from each strategy in order. Losses incurred while liquidating are accounted to the withdrawer, capped at a maxLoss parameter.

This is the section where the most subtle vault bugs live. Multiple Yearn forks have had withdraw-flow exploits.

Your Code

Solution.sol
Solidity
Loading editor...

Requirements

Write your implementation, then click Run Tests. Tests execute on the server.

Sign up free — keep reading + earn 25 Lynx

Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.

Sign up free to continue

Already have an account? Log in