Repay Loans
How Repayment Works
Call repay(amount) on VarlaCore. Stablecoins are transferred from your wallet back to the VarlaPool, reducing your scaled debt. Your health factor improves immediately.
Repayment flow
1. Approve USDC/USDT to VarlaCore (one-time)
2. Call repay(amount) — or repay(type(uint256).max) for full repayment
3. Stablecoins transfer: your wallet → VarlaPool
4. Scaled debt reduced: scaledDebt -= amount / currentBorrowIndex
5. Health factor improves immediately Partial vs Full Repayment
- Partial repayment — pay back any amount. Reduces debt and improves health factor. Remaining debt continues accruing interest.
- Full repayment — pass
type(uint256).maxas the amount. The contract calculates your exact debt (including accrued interest to the current second) and charges exactly that amount. After full repayment, you can withdraw all collateral.
💡 Full repayment tip
Always use
type(uint256).max for full repayment rather than trying to calculate the exact amount yourself. Interest accrues per-second, so your calculation will be slightly off by the time the transaction is mined.
After Repayment
Post-repayment options
After partial repayment:
├── Health factor improved
├── Can withdraw some collateral (if HF allows)
└── Remaining debt continues accruing interest
After full repayment:
├── Debt = 0
├── Health factor = ∞
├── Can withdraw ALL collateral
└── Account remains open for future use ℹ Account persistence
Repaying all debt doesn't close your account. Your collateral remains deposited and you can borrow again anytime. To fully exit, repay all debt then withdraw all collateral.