Skip to content

qwe638853/ExitNow

Repository files navigation

ExitNow is an instant exit layer for Obol Validator Managers (OVMs). It advances liquidity to stakers while enforcing accountability via an on-chain state machine, deadlines, and a bond. ExitNow is built on top of the Ovm

⚠️ IMPORTANT WARNING

This contract has only undergone basic functional testing. DO NOT USE ON MAINNET. It is recommended to use only on testnets and conduct thorough security audits before considering mainnet deployment.

Problem & Motivation

When the network is congested, validator exits can take many days and your principal gets stuck. ExitNow provides immediate liquidity; it doesn’t make protocol exits faster—it simply bridges the liquidity gap caused by the wait.

Overview

ExitNow provides immediate liquidity for Ethereum validators by:

  1. Instant Liquidity: ExitNow advances 99% while withholding a 3.5% bond; net to staker ≈ 95.5%
  2. Bonded Security: A 3.5% bond ensures accountability against slashing or inactivity penalties
  3. EIP-7002 Integration: Uses OVM's withdrawal mechanisms which internally leverage EIP-7002

Deployed address

Ovm address:0xFf15ad0DD7574992eEDa2Bd92cDc3AB34Bb382f1
ExitNow address:0x6110bc76138cA3C9A77b14728e95Df28D54D8D98

All testing was conducted using Foundry.

How It Works

Process Flow

ExitNow Workflow

The diagram above illustrates the complete ExitNow process flow in the normal case where the staker is the OVM Owner and everything operates correctly:

Phase 1: Setup

  1. Staker calls exit_setup(): The staker (who owns the OVM) initiates the exit process by calling the ExitNow contract with validator public keys
  2. Validation checks: ExitNow validates OVM contract, principal stake (≥32 ETH), and contract balance sufficiency
  3. Request ownership: ExitNow calls requestOwnershipHandover() on the OVM to initiate ownership transfer
  4. Complete ownership: Staker calls completeOwnershipHandover() to transfer OVM ownership to ExitNow

Phase 2: Execution

  1. Staker calls exit_execute(): The staker triggers the execution phase with matching validator public keys
  2. Validation: ExitNow verifies public key hash, ownership, and sufficient contract balance
  3. Request withdrawals: ExitNow calls requestWithdrawal() on the OVM with system contract fees
  4. Transfer funds to staker: ExitNow advances 99% of principal value, withholding 3.5% as bond (net to staker ≈ 95.5%)
  5. Set deadline: 60-day withdrawal deadline is established for completion

Phase 3: Settlement

  1. Validator exits: When validators have exited, the contract owner uses withdrawOvm() to trigger fund distribution from the OVM
  2. Fund distribution: The OVM calls distributeFunds() to transfer principal stake back to ExitNow
  3. Automatic settlement: ExitNow's receive() function automatically processes the funds:
    • If full expected amount received: Returns 3.5% bond to staker and transitions to Settled phase
    • If insufficient funds or past deadline: Confiscates bond as penalty

Key Functions

  • exit_setup(): Initiates exit process with validator public keys and validates OVM contract
  • exit_execute(): Executes withdrawal with public key verification and advances 99% to staker (withholding 3.5% bond)
  • withdrawOvm(): Triggers fund distribution from OVM after validator exits (owner only)
  • cancel_ownership_handover(): Cancels exit when ExitNow owns OVM and returns ownership to staker
  • cancel_exit(): Cancels exit when staker still owns OVM and resets state
  • receive(): Handles fund reception and automatic bond settlement based on success/failure

The contract enforces strict state transitions:

  • None: Initial state, no exit process initiated
  • Setup: Exit initiated, ownership handover requested
  • Executed: Withdrawal triggered, funds advanced to staker
  • Settled: Process completed, bond returned or confiscated

OVM Integration

ExitNow is built on top of the Ovm, leveraging the following OVM operations:

  • requestOwnershipHandover(): Initiates ownership transfer process
  • transferOwnership(): Transfers ownership back to staker during cancellation
  • requestWithdrawal(): Triggers validator withdrawals with system contract fees (uses EIP-7002 internally)
  • setPrincipalRecipient(): Sets ExitNow as fund recipient
  • distributeFunds(): Distributes available funds back to ExitNow
  • amountOfPrincipalStake(): Gets current principal stake amount
  • principalThreshold(): Gets withdrawal threshold per validator

Usage

Prerequisites

  • Foundry development framework
  • OVM contract deployed via Obol Network's factory
  • OVM contract with minimum 32 ETH stake
  • Validator public keys for withdrawal
  • Access to Obol Network's distributed validator infrastructure

Installation

git clone <repository-url>
cd ExitNow
forge install

Build

forge build

Test

forge test

Deploy

forge script script/Deploy.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key>

Future Extensibility

The current design targets individual liquidity providers but is architected for future expansion into:

  • Non-custodial marketplace for validator exits
  • Programmable validator exit platform
  • Advanced DeFi integrations

Development

Project Structure

src/
├── ExitNow.sol              # Main contract
├── ovm/
│   ├── ObolValidatorManager.sol
│   └── ObolValidatorManagerFactory.sol
└── interfaces/
    └── IENSReverseRegistrar.sol

test/
├── ExitNow.t.sol            # Main test suite
└── mocks/                   # Mock contracts for testing

Testing

# Run all tests
forge test

# Run with verbosity
forge test -vv

# Run specific test
forge test --match-test testExitSetup

# Generate gas report
forge test --gas-report

Formatting

forge fmt

Security note

This contract is a proof of concept and has known security risks—for example, validator slashing, validator inactivity, and spoofed validator pubkey lists.

For more comprehensive validator verification, consider incorporating the beacon state root and SSZ proofs.

Loom Video Overview

Loom:https://www.loom.com/share/54a08fc4bf1b4322b81c3096f44b7eb1?sid=b82826d1-8422-434f-8a83-1ca91a89fa34

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published