Flash-Repay Tool
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
Flash-Repay Tool is a DeFi utility that lets you repay outstanding debt on a lending protocol using a flash loan, then swap a portion of your collateral to cover the loan — all in a single atomic transaction. This is useful when you are near liquidation but lack the liquid funds to repay directly, or when you want to rebalance your position without putting up additional capital. The tool reads your current debt, collateral, and available flash loan pools, then constructs a multi-step transaction that: (1) borrows the debt amount via a flash loan, (2) repays your debt, (3) swaps a designated collateral token for the borrowed amount, and (4) repays the flash loan. If any step fails, the entire transaction reverts, leaving your position unchanged.
HOW TO USE
Connect your EVM wallet via the BGWallet bridge. Enter your lending pool address (e.g., Aave v3, Compound), the debt token address, and the collateral token you want to swap. Provide the flash loan pool address and a swap router (e.g., Uniswap V2/V3) along with the token path for the swap. Enter the amount of debt you wish to repay and your slippage tolerance. Click "Simulate" to preview the required flash loan amount, estimated swap output, and your resulting net position. Review the numbers, then click "Execute Flash-Repay" to sign and broadcast the transaction. The tool will show progress updates and a final transaction hash for tracking.
TECHNICAL MECHANISM
The tool uses a flash loan callback pattern: it calls the flash loan pool's `flashLoan` function, which atomically lends the requested amount. In the callback, the tool repays the debt via the lending pool's `repay` function, then performs a swap through the router to convert collateral into the debt token. The swap output is used to repay the flash loan plus fees. The entire operation is wrapped in a single contract interaction encoded with ethers v5.7.2. The tool simulates the swap using the router's `getAmountsOut` and checks that the expected output is sufficient to cover the flash loan fee (typically 0.05-0.09%). If not, the simulation warns you. The transaction reverts on any error, ensuring atomicity.
WHAT IT CANNOT SEE
This tool cannot guarantee flash loan success if the pool's available liquidity changes between the simulation and execution, or if the swap slippage exceeds the tolerance set. It also cannot predict changes in the debt token's price or collateral valuation that may affect the required swap amount. The simulation is based on current on-chain data and may not reflect real-time mempool conditions. Always monitor your position and adjust slippage according to market volatility.
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 flash loan pool supports the specified debt token.