Skip to main content
Pay down a Borrow loan with a partial repayment, a full close, or a collateral withdrawal. Each operation addresses the loan by loanId.

Prerequisites

Before you begin, ensure that you’ve:

Repay part of a loan

Call repay with the loan’s loanId and the USDC amount. The SDK rejects the request before signing if repayAmount exceeds outstanding debt. Use closeLoan for a full payoff.
TypeScript

Close a loan in full

Call closeLoan to repay all outstanding debt and withdraw all collateral in a single atomic batch. The SDK uses share-based payoff math and may pull more USDC than needed, up to your slippageBps bound, refunding any surplus.
TypeScript
To preview a full close before signing, see Preview Borrow operations.

Withdraw collateral

Call withdrawCollateralRepayIfNeeded to release cirBTC from a loan. The SDK sizes any repayment needed to keep the loan healthy after the withdrawal and pays it from the wallet’s USDC balance in the same atomic batch. If the repayment covers the entire debt, the withdrawal closes the loan.
TypeScript
To preview a collateral withdrawal before signing, see Preview Borrow operations.