Protocol

Repay & withdraw

Repayment is partial or full. Withdrawals are gated on the resulting health factor — you can always pull collateral while you're solvent.

typescript
// Repay 1,000 USDG
await usdg.approve(POOL, 1_000n * 10n ** 6n);
await pool.repay(1_000n * 10n ** 6n);

// Withdraw 5 TSLA back to your wallet
await vault.withdraw(TSLA, 5n * 10n ** 18n);

If you try to withdraw an amount that would drop your health factor below 1.0, the call reverts with InsufficientCollateral(). Repay more first, or withdraw less.