Skip to content

ANRGUSC/everlast-protocol

Repository files navigation

EverLast Protocol

Everlasting Options That Never Expire

Trade call and put options on Base with no expiration dates. Powered by a Constant-Log-Utility Market Maker (CLUM) providing pooled liquidity with bounded-loss guarantees.

Live Demo License: MIT Solidity Base


Highlights

  • No Expiration - Options stay open indefinitely, no rolling required
  • Pooled AMM Liquidity - CLUM engine provides continuous two-sided liquidity with bounded loss for LPs
  • Market-Driven Funding - Rates derived from the CLUM's implied probability distribution, not a parametric model
  • ERC-1155 Positions - Semi-fungible position tokens, gas-efficient and tradeable
  • Cross-Strike Efficiency - Arbitrage guard enforces convexity, monotonicity, and put-call parity across strikes
  • Exercise Anytime - American-style, exercise when in-the-money
  • Built on Base - Fast, cheap transactions on Ethereum L2

Try It

Launch App

Connect your wallet to Base Sepolia and get test tokens:


How It Works

flowchart LR
    subgraph Trader
        A[Buys Option]
    end
    subgraph LP [Liquidity Provider]
        B[Deposits USDC into ERC-4626 Vault]
    end

    A -- "premium (USDC)" --> B
    B -- "ERC-1155 position token" --> A
    A -. "continuous funding (mark - payoff)" .-> B
Loading
Action What Happens
Buy Trader pays premium (computed by CLUM), receives ERC-1155 position token
Sell Trader sells position back to CLUM at current market price
Fund Trader deposits USDC to keep position alive (funding accrues continuously)
Exercise Trader exercises ITM option, receives intrinsic value payout from LP pool
Liquidate Anyone can liquidate positions with depleted funding balance

Architecture

flowchart TD
    EM["EvOptionManager<br/>Core Controller"]

    EM --> CLUM["CLUMEngine<br/>Cost Function + State"]
    EM --> LP["LPPool<br/>ERC-4626 Vault"]
    EM --> PT["PositionTokens<br/>ERC-1155"]
    EM --> FD["FundingDeriver<br/>Implied-Dist Rates"]
    EM --> AG["ArbitrageGuard<br/>No-Arb Enforcement"]

    CLUM --> BR["BucketRegistry<br/>Discretized Price Space"]
    FD --> BR

    BR --> CL["Chainlink ETH/USD"]
Loading

Core Contracts (contracts/clum/)

Contract Purpose
CLUMEngine Core AMM: maintains quantity vector, solves sum(pi_i * ln(C - q_i)) = U via bisection. Supports log-normal prior initialization
BucketRegistry Discretized price space (N regular + 2 tail buckets) with oracle-driven recentering
LPPool ERC-4626 vault backing the CLUM with bounded-loss subsidy accounting
PositionTokens ERC-1155 semi-fungible tokens encoding option type and strike
FundingDeriver Derives funding rates from CLUM implied distribution with premium factor
ArbitrageGuard On-chain convexity/monotonicity checks + Merkle-verified off-chain LP bounds
EvOptionManager Trade lifecycle: buy, sell, exercise, funding accrual, liquidation
CLUMMath Gas-optimized fixed-point ln/exp (Solmate-derived)

Off-chain (offchain/)

Module Purpose
clum-verifier.ts Computes C(q) off-chain with higher precision, generates verification payloads for gas-optimized large trades

Legacy Contracts (contracts/)

The original peer-to-peer contracts (OptionManager, PerpetualOptionNFT, FundingOracle, CollateralVault, RiskParams) remain in the repo as reference. The CLUM system replaces this model with pooled AMM liquidity.


CLUM Prior Distribution

The CLUM's pricing depends on a prior probability distribution over the discretized price space. Two initialization modes are available:

Mode Function Description
Uniform initialize(subsidy) Equal probability per bucket (1/n). Simple but produces unrealistically high option prices at launch since extreme price outcomes are weighted equally.
Log-normal initializeWithLogNormalPrior(subsidy, sigma) Probability concentrated near current spot price following a log-normal distribution. Produces economically reasonable initial prices.

Log-Normal Prior

The log-normal prior computes unnormalized weights for each bucket using the PDF evaluated at the bucket midpoint:

w_i = exp(-(ln(mid_i / spot))^2 / (2 * sigma^2)) / mid_i

All weights are normalized on-chain to sum to 1 (WAD). The computation uses the existing CLUMMath.lnWad and CLUMMath.expWad functions with no additional dependencies.

Sigma parameter controls how concentrated the prior is around spot:

Sigma 68% of probability within Typical use
0.3 +/-30% of spot Conservative, tight spread
0.5 +/-50% of spot Default, moderate spread
0.8 +/-80% of spot Wide, accommodates high vol

The deployment script reads the current oracle spot price and centers the bucket grid on it automatically.


Deployed Contracts (Base Sepolia)

CLUM System (Active)

Contract Address
EvOptionManager 0xFD0fFcb0f05ADDDb5209F4041FAC8035E6A422Bc
CLUMEngine 0x9f60e207F7eea86784AAAD9375154936cecf4792
BucketRegistry 0x8ed62D170B8F1dbDFAAEB04ff7d5fc3893573541
LPPool 0xF7430e5073Cd29FafbDe90cB2CB03ba308Ec8E19
FundingDeriver 0xF7c80F55645381a99683b6bC1dDaccB6ADBf1b3C
PositionTokens 0xc125b6Ea79887e0150a6F3eA4B699683E495113B
USDC 0x036CbD53842c5426634e7929541eC2318f3dCF7e
WETH 0x4200000000000000000000000000000000000006
Legacy Peer-to-Peer Contracts (Deprecated)
Contract Address
OptionManager 0x92768885E13B791683Cee58532125c35E943840E
OptionNFT 0xC7831161CB20d1517aD7ad642a6F41727b6AFF55
FundingOracle 0xC46D4e5Ca887a47118Ca5C777972251b39902D77
USDC Vault 0xc6703DEE49Bf14119e63c8fB3Fa0b60212442c7e
WETH Vault 0xf5c6f1843Bf910A00B615c038565B0c1dEaA90cA
RiskParams 0xe24ecE1aD46657D23fcab41e0585FBA5c4E8E61C

For Developers

# Clone and install
git clone https://github.com/ANRGUSC/everlast-protocol.git
cd everlast-protocol && npm install

# Run tests
npx hardhat test

# Run CLUM tests only
npx hardhat test test/CLUM.test.js

# Deploy CLUM contracts to Base Sepolia
#   Reads oracle spot price for grid center, initializes with log-normal prior
#   Requires PRIVATE_KEY and BASE_SEPOLIA_RPC_URL in .env
npx hardhat run scripts/deploy-clum.js --network baseSepolia

# Run frontend locally
cd frontend && npm install && npm run dev

After deploying, update the contract addresses in frontend/src/config/contracts.ts with the output from the deploy script.

Tech Stack

  • Contracts: Solidity 0.8.20, Hardhat, OpenZeppelin, Chainlink
  • Off-chain: TypeScript, ethers.js
  • Frontend: Next.js 14, wagmi, viem, RainbowKit, Tailwind CSS

Security

Warning: This protocol is deployed on testnet only. It has not been audited. Do not use with real funds.


License

MIT License - see LICENSE for details.

About

Everlasting Options Protocol on Base Sepolia Testnet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •