A decentralized options trading protocol built on top of the 1inch Limit Order Protocol, enabling efficient on-chain options trading with NFT-based position representation.
OpEx combines the power of 1inch's limit order infrastructure with a sophisticated options engine to create a seamless DeFi options trading experience. The protocol uses NFTs to represent option positions that support a dynamic premium pricing using the Heston model.
- 📊 Options Trading: Create and trade call/put options with customizable strike prices and expiration dates
- 🎫 NFT Positions: Each option position is represented as an ERC-721 NFT for easy transferability
- 🔄 1inch Integration: Leverage 1inch's battle-tested limit order protocol for efficient order matching
- 🎨 Frontend Interface: Modern React-based UI for seamless user interaction
The protocol consists of several interconnected components:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Frontend │ │ Backend API │ │ Smart │
│ (Next.js) │◄──►│ (Python) │◄──►│ Contracts │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
┌────────────────────────┼────────────────────────┐
│ │ │
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Option Engine │ │ Option Hook │ │ Option NFT │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└────────────────────────┼────────────────────────┘
│
┌─────────────────┐
│ 1inch Limit │
│ Order Protocol │
└─────────────────┘
- OptionEngine: Core logic for option creation, exercise, and settlement
- OptionHook: Pre/post interaction hooks for the 1inch limit order protocol
- OptionNFT: ERC-721 implementation representing option positions
- LimitOrderProtocol: Custom implementation of 1inch's limit order system
-
Clone the repository
git clone https://github.com/6-5-Inch/main-asla.git cd main-asla -
Install dependencies
Smart Contracts:
cd contracts forge install OpenZeppelin/openzeppelin-contracts forge install 1inch/limit-order-protocol forge install 1inch/solidity-utilsFrontend:
cd frontend npm install # or yarn install
Python Backend:
cd twap python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Environment Setup
Copy the example environment files and fill in your configuration:
cp contracts/.env.example contracts/.env
MAKER_KEY=your_private_key_here
BUYER_KEY=another_private_key_here
UNDERLYING_ADDRESS=0x... # ERC20 token address
QUOTE_ADDRESS=0x... # Quote token address
OPTION_NFT_ADDRESS=0x... # Deployed NFT contract
ENGINE_CONTRACT=0x... # Option engine contract
HOOK_CONTRACT=0x... # Hook contract
LIMIT_ORDER_PROTOCOL=0x...# Limit order protocol-
Start development server
cd frontend npm run dev -
Build for production
npm run build
-
Run TWAP calculations
cd twap python twap.py -
Run option pricing
python option.py
- Connect Wallet: Connect your Web3 wallet to the frontend
- Select Parameters: Choose underlying asset, strike price, expiration, and option type
- Create Order: Submit the option creation transaction
- Browse Options: View available options in the marketplace
- Select Option: Choose an option that matches your trading strategy
- Execute Trade: Purchase the option by matching the limit order
- Exercise: Exercise your option before expiration if profitable
-
Configure network
# Add network configuration to foundry.toml [rpc_endpoints] sepolia = "https://sepolia.base.org"
-
Deploy contracts
forge script script/Interaction.s.sol:InteractScript \ --rpc-url sepolia \ --broadcast \ --verify
- 1inch Network for the excellent limit order protocol
- OpenZeppelin for secure smart contract libraries
- Foundry for the development framework