This app runs inside the BotSurf browser. Don't have it yet? Get the app or extension now!

Collateralized Debt Position Closer

DeFi · All
0 installs · Verified BotGentz app
Launch App
Opens in BotSurf — nothing to install.
CategoryDeFi
PlatformAll
Pricing Free
Installs0
Download BotSurf to use — free
No account needed for free apps. Once BotSurf is open, find this app in Apps from the + menu.

About this app

WHAT IT DOES

Collateralized Debt Position Closer is a DeFi tool that lets you close an existing lending position in one transaction. Instead of manually repaying your debt and then withdrawing your collateral in separate steps, this tool combines both actions into a single atomic operation. It reads your current debt, collateral balance, token prices, and health factor, then calculates the net collateral you will receive after closing the position. You can choose to repay the full debt or a partial amount, and the tool handles approvals, repayment, and withdrawal in a single transaction, saving you gas and execution time.

HOW TO USE

Connect your EVM wallet via the BGWallet bridge. Enter your lending pool address, collateral token, and debt token. Optionally, specify a repayment amount — leave it blank to repay the full debt. Click "Preview Position" to see your current debt, collateral locked, health factor, and the net collateral you will receive after closing. Review the details and ensure you have sufficient funds to repay the debt. Click "Close Position" to sign and broadcast the transaction. The tool will handle debt repayment and collateral withdrawal atomically — if any step fails, the entire transaction reverts, leaving your position unchanged. A transaction hash is provided for tracking.

TECHNICAL MECHANISM

The tool fetches your current debt and collateral balances from the lending pool using the appropriate view functions. It calculates the value of your collateral and debt in USD using the pool's oracle or a fallback price feed. The health factor is computed as (collateral_value * liquidation_threshold) / debt_value. When you execute a close, the tool encodes a multicall or sequential transaction that: (1) approves the debt token if needed, (2) calls the pool's `repay` function to clear the debt, and (3) calls the pool's `withdraw` function to retrieve your collateral. The entire operation is atomic — if any step fails, the transaction reverts and no changes are made to your wallet. The tool also computes the net collateral you will receive after closing, helping you understand the financial outcome before you commit.

WHAT IT CANNOT SEE

This tool cannot guarantee that the position can be closed profitably if collateral prices drop or gas costs spike during execution. The net collateral calculation is based on current prices and may change between the preview and the actual execution. The tool also cannot predict oracle updates, protocol changes, or sudden market movements that could affect your position. Always monitor market conditions and consider the gas cost — closing a position with low net collateral may not be worth the transaction fees. This tool is an aid for closing positions, not a guarantee of profit.

PLEASE NOTE

EVM chains only. This tool relies on the BGWallet connector and will not function on Solana, Tron, Starknet, SUI, TON, Aptos, Bitcoin, Cosmos, or XRP. The user is responsible for ensuring the supplied contract addresses are correct and that the lending protocol supports the specified operations. Always double-check the preview results and ensure you have sufficient funds to repay the debt before signing the transaction.

Similar Apps

Log in to BotGentz

Suggest an App

Tell us what you'd find useful — if we build it, we'll email you the moment it's ready.