Skip to content
pk1427Public

About

Confidential Liquidation Liquidity

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

34 Commits

Folders and files

Repository files navigation

Backstop

Backstop is a self-custodial liquidation-liquidity prototype for Ethereum Sepolia. A maker creates reusable, policy-bounded liquidity strategies; Chainlink CRE publishes confidential borrower-bound quotes; and an authorized strategy settles atomically through 1inch Aqua.

The project has two intentionally separate product modes:

  • Live Aave monitoring — reads real Aave V3 Sepolia positions and eligibility data. It is a monitoring surface, not the recorded settlement path.
  • Controlled market — an isolated Sepolia mock lending market using btUSDC / btWETH. This is the complete, onchain, repeatable demo path for CRE quote delivery, Aqua strategy authorization, liquidation, and settlement.

Verified controlled-market flow

Maker / Privy embedded wallet
  │  creates one or more reusable btUSDC → btWETH strategies
  │  (max capital, discount range, expiry)
  ▼
1inch Aqua
  │  stores the maker's strategy-bound virtual btUSDC capacity
  ▼
Controlled borrower becomes liquidatable
  │  mock oracle price → health factor < 1
  ▼
Chainlink CRE workflow
  │  reads borrower state and produces a borrower-bound quote
  ▼
QuoteRegistry
  │  { borrower, discountBps, size, minCollateralOut, expiry, execute }
  ▼
Maker selects the borrower and a compatible strategy
  ▼
LiquidatorExecutor
  │  Aqua pulls quoted btUSDC
  │  controlled pool repays borrower debt and seizes btWETH
  │  Aqua pushes btWETH to the maker
  ▼
Atomic settlement + consumed quote

The execution contract verifies, onchain:

  • strategy hash and immutable policy fields;
  • quote is current, executable, unconsumed, and bound to the selected borrower;
  • quote size does not exceed maxTrade;
  • quote discount is inside the strategy range;
  • quote has not expired;
  • actual collateral received meets minCollateralOut.

Product flow

  1. Open Liquidations and select a liquidatable borrower.
  2. Backstop loads that borrower's CRE quote.
  3. Select one compatible reusable funding strategy.
  4. Review the quote, borrower, and selected strategy.
  5. Execute the controlled liquidation.
  6. Backstop records the transaction in Activity and links to Etherscan.

If no strategy is compatible, create one from the Strategy page using the opportunity's required capital and discount bounds, then return to the same position.

Current Sepolia deployment

Component Address
Aqua registry 0x1111113CCf1426A8E30e2bfF5E005d929bF6a90a
Controlled btWETH 0xB848Fedc37BebaF136e51CfF90Bf73BB0f0dE9e9
Controlled btUSDC 0xFd080b70bAefD6Bb19906c107A7240C4e5C2dcca
Controlled price-aware pool 0x89803CfB464eB76ace81463361a34B86b3E7Bd2A
Controlled oracle 0x7d8ae00643171b904183f3cd32803802de43c32a
CRE QuoteRegistry 0x2d396186e18664c070e7e290891bd96fc92b7842
LiquidationBackstopApp 0x4762fe003b9b0c7cc5a32626391c1fd423399cd9
LiquidatorExecutor 0x3e94e1be34fd374d7a9512008e7ebee82e02a961

The active CRE staging workflow is hello-confidential-staging. Its configuration monitors the two fresh controlled borrowers listed in cre-workflow/my-workflow/config.staging.json.

End-to-end settlement evidence

Position 05 was settled successfully from the Privy maker wallet:

  • 500 btUSDC was pulled and repaid;
  • 0.3500 btWETH was delivered to the maker;
  • the quote was consumed;
  • transaction: 0x779b…3f95.

Position 06 is independently configured for the same flow.

Repository layout

contracts/
  src/
    LiquidationBackstopApp.sol      # Aqua app: validates strategy and CRE quote
    LiquidatorExecutor.sol          # atomic pull → liquidation → push executor
    QuoteRegistry.sol               # CRE-forwarder authenticated borrower quotes
    mocks/                          # controlled btUSDC, btWETH, oracle, lending pool
    adapters/                       # controlled pool and Aave V3 adapters
  script/
    DeployControlledBackstopStack.s.sol
    CreateFreshControlledVideoPositions.s.sol
    FundControlledPrivyMaker.s.sol
    ApproveFreshControlledBorrowers.s.sol

cre-workflow/my-workflow/
  workflow.ts                       # CRE workflow logic
  config.staging.json               # staging workflow configuration

frontend/
  app/overview                      # maker capital and selected strategy summary
  app/strategy                      # reusable strategy creation and selection
  app/opportunities                 # position-first market and quote selection
  app/activity                      # concise settlement history and Etherscan links
  context/BackstopContext.tsx       # wallet, strategy, quote, and execution state

Quick start

Prerequisites

  • Node.js 20+
  • Foundry
  • Chainlink CRE CLI with deployment access
  • Privy application configured for Ethereum Sepolia
  • A Sepolia RPC endpoint

Install

git clone https://github.com/pk1427/Backstop.git
cd Backstop
git submodule update --init --recursive

cd frontend && npm install && cd ..

Environment

Copy the local environment templates and provide your own credentials. Never commit or share private keys, Privy secrets, or CRE secrets.

cp frontend/.env.example frontend/.env.local
# Create contracts/.env and cre-workflow/.env locally.

Key frontend values:

Variable Purpose
NEXT_PUBLIC_PRIVY_APP_ID Privy application ID
NEXT_PUBLIC_PRIVY_AUTH_KEY_ID scoped signer authorization key
NEXT_PUBLIC_PRIVY_POLICY_ID Privy policy ID
NEXT_PUBLIC_RPC_URL Sepolia RPC URL
NEXT_PUBLIC_CONTROLLED_* controlled pool, token, quote registry, app, executor, and borrower addresses

Key contract / workflow values:

Variable Purpose
SEPOLIA_RPC_URL Sepolia RPC URL
SEPOLIA_PRIVATE_KEY_1 test-only controlled-market deployer key
SECRET_API_TOKEN CRE workflow secret identifier/value for staging

Run the frontend

cd frontend
npm run dev

Open http://localhost:3000.

Validate code

cd contracts
forge test --via-ir

cd ../frontend
npx tsc --noEmit

Controlled demo setup

The following commands create fresh, liquidatable controlled borrowers, fund their transaction gas, mint their test collateral, register their debt, and approve collateral seizure by the controlled pool.

cd contracts
set -a; source .env; set +a

forge script script/CreateFreshControlledVideoPositions.s.sol:CreateFreshControlledVideoPositions \
  --rpc-url "$SEPOLIA_RPC_URL" \
  --broadcast -vv

Fund the embedded maker before it creates strategies:

export CONTROLLED_MAKER=<privy_embedded_wallet_address>
forge script script/FundControlledPrivyMaker.s.sol:FundControlledPrivyMaker \
  --rpc-url "$SEPOLIA_RPC_URL" \
  --broadcast -vv

Deploy the CRE staging configuration after updating monitored borrowers:

cd ../cre-workflow
cre workflow deploy ./my-workflow --target staging-settings --env .env
cre execution list hello-confidential-staging

Integration status

Integration Status
Privy embedded wallet Live on Sepolia
1inch Aqua ship, pull, push Live in controlled settlement
Chainlink CRE staging deployment Active; delivers controlled borrower quotes
QuoteRegistry forwarder authentication Live
Atomic controlled settlement Live; confirmed on Sepolia
Aave V3 Sepolia reads Live monitoring via RPC calls
Aave V3 Sepolia liquidation settlement Not the recorded demo path; controlled market is used for reproducible execution

Security and prototype scope

  • The controlled market uses mintable test tokens and an isolated test lending pool. It is for demonstrating the full execution pipeline only.
  • Strategies are immutable once shipped to Aqua. The frontend may retain multiple reusable strategies locally for strategy selection; production persistence/indexing should be added before multi-device use.
  • CRE quotes are borrower-bound. A production upgrade should also bind the CRE attestation directly to a strategy hash if strategy-specific quote authorization is required.
  • This repository is a hackathon prototype and has not been audited. Do not use it with production assets.

License

MIT

About

Confidential Liquidation Liquidity

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages