Function: withdrawFromSpark(uint256 amount)
This function is an admin-only exit path used in Unwind mode to redeem USDT from SparkLend. The caller can withdraw a specific amount or all the available balance if amount == 0.
Inputs
amountControl: N/A.
Constraints: Accepts
0for a full sweep or any value up to the on-contract aToken balance.Impact: Updates
usdtRedeemedand instructs the Spark pool to return liquidity to the vault contract.
Branches and code coverage
Intended branches
Reverts if the contract holds no spUSDT.
Reverts if the amount is greater than the contract's aToken balance (if not 0).
Increments
usdtRedeemedbefore withdrawing from SparkLend.
Negative behavior
Non-admin callers or calls outside Unwind mode revert.
Reentrancy is blocked by
nonReentrant.
Function call analysis
None.