Withdraw Assets
How Withdrawal Works
Call withdraw(tokenId, amount) on VarlaCore. The contract simulates your post-withdrawal health factor. If it stays ≥ 1.0 (or you have zero debt), the ERC-1155 positions are transferred back to your wallet.
Withdrawal check
remainingCollateral = currentCollateral - withdrawAmount
newHF = weightedValue(remainingCollateral) / currentDebt
if newHF >= 1.0 OR currentDebt == 0:
✓ Transfer positions back to borrower
else:
✗ Revert — would make position unhealthy Full vs Partial Withdrawal
- Full withdrawal — requires zero outstanding debt. Repay everything first, then withdraw all collateral.
- Partial withdrawal — remove some collateral while maintaining a healthy position. Your health factor must remain ≥ 1.0 after withdrawal.
⚠ Oracle must be fresh
Withdrawals require non-stale oracle data. If the oracle is stale (>15 minutes), withdrawals are blocked until fresh prices arrive.
Best Practices
- Leave a buffer — don't withdraw to exactly HF 1.0. Price movements could immediately trigger liquidation.
- Repay first — if you want to withdraw significant collateral, reduce debt first to maintain a comfortable health factor.
- Check oracle freshness — if the oracle is stale, your withdrawal will revert. Wait for fresh data.