Loophole

Loophole is an agent that monitors your position health and saves you from getting rekt

Repo
Loophole banner

About

Loophole

Unwind recursive Aave leverage positions before liquidation.

Loophole is an AI agent that monitors your Aave position health, simulates flash-loan-powered unwinds, and executes them atomically — all through a Telegram bot.

The Problem

DeFi users create recursive leverage positions (deposit stETH -> borrow WETH -> deposit again -> repeat). When prices drop, these positions face liquidation with a ~5% penalty. Unwinding manually requires multiple transactions and capital you might not have.

The Solution

Loophole uses Aave V3 flash loans to atomically unwind your entire looped position in a single transaction:

Flash loan the debt asset

Repay all debt loops (iteratively, auto-detects loop count) Pull aTokens from user, withdraw collateral Swap via Uniswap v4 (unlock/callback pattern) Repay flash loan + premium Return remainder as USDC An AI agent (powered by Gemini) monitors your position, simulates outcomes, and recommends when to unwind — all accessible via Telegram.

How it's made

Loophole has two packages: a Solidity contract and a TypeScript agent.

Contract (Loophole.sol) — Deployed on Base at 0x0d0AAC9595152fA9c2Ad80fcc86d4B9bf35F5f99. Takes an Aave V3 flash loan, iteratively repays user debt and withdraws collateral, swaps via Uniswap v4 using the unlock/callback pattern with flash accounting (settle + take), and returns USDC to the user. All in one atomic transaction. Protected by ReentrancyGuard, custom errors, and slippage checks. Fork-tested against real Aave V3 state.

Agent — Built with ADK-TS (Gemini 2.5 Flash) and grammY for Telegram. Six tools: get_position fetches Aave V3 data, get_price pulls from Stork oracle, simulate_unwind estimates output and fees, estimate_liquidation stress-tests under price drops, optimize_unwind generates a risk report, and execute_unwind builds unsigned transaction calldata with EIP-681 QR codes so the user can scan and sign from their mobile wallet.

Uniswap v4 — The contract implements IUnlockCallback. Swaps go through PoolManager using unlock() → unlockCallback() → settle() + take(). No direct swap() calls.

Stork (Arc) — Agent uses the Stork REST API for real-time price feeds to calculate health factor, liquidation distance, and unwind economics. USDC settlement.

Stack — Foundry, viem, ADK-TS agent framework, Base chain.

From the public ETHGlobal showcase page. Votes, swipes and the judge score are hackfeed's own.

AI judge

Not judged yet. A free model reads this page, compares it with similar projects and this event's winners, then scores it and says what would make it win.

Still being built?

DormantLast push 301 days ago

Swipe stats

0upvotes
0skips
0saves

Discussion 0

No comments yet. Ask the team something, or say what you'd use it for.

Posting as a guest. Plain text, 1,000 characters max.

Already built nearby

Closest projects by meaning and shared words. Similar isn't the same as copied: read them.

Freeboard Finance

For Aave borrowers: a basket that shifts into your debt asset as health factor falls, and pays you.

Xtreamly looped leverage Agent

AI-powered looped leverage—5x APY, zero liquidation. Smarter, faster, safer yield on Aave.