Smart Contract Overview
Sera Protocol consists of several interconnected smart contracts deployed on Ethereum.Contract Addresses (Sepolia Testnet)
| Contract | Address |
|---|---|
| Market Router | 0x82bfe1b31b6c1c3d201a0256416a18d93331d99e |
| Market Factory | 0xe54648526027e236604f0d91413a6aad3a80c01e |
| Order Canceller | 0x53ad1ffcd7afb1b14c5f18be8f256606efb11b1b |
Architecture
Core Contracts
Market Router
The primary entry point for all trading operations. Users should interact with the Router rather than OrderBooks directly. Key Functions:limitBid/limitAsk- Place limit ordersmarketBid/marketAsk- Execute market ordersclaim- Claim proceeds from filled orders
OrderBook
Each trading pair has its own OrderBook contract that:- Stores all open orders
- Matches incoming orders against the book
- Tracks order fills and claimable amounts
getDepth- Get order depth at a price levelgetOrder- Get order detailsbestPriceIndex- Get best bid/ask pricegetClaimable- Check claimable proceeds
PriceBook
Handles price calculations using the arithmetic price formula:indexToPrice- Convert price index to actual pricepriceToIndex- Convert price to nearest indexmaxPriceIndex- Get maximum supported index
Order Canceller
A utility contract for batch cancelling orders across multiple markets. Address (Sepolia):0x53ad1ffcd7afb1b14c5f18be8f256606efb11b1b
Key Functions:
cancel(params[])- Cancel orders and return tokens to callercancelTo(params[], to)- Cancel orders and send tokens to specified address
nftId field).
View Order Canceler ABI →
Token Flow
Placing a Bid (Buy Order)
Claiming Proceeds
Gas Optimization
Sera is optimized for gas efficiency:| Operation | Typical Gas |
|---|---|
| Limit Order (make only) | ~150,000 |
| Limit Order (take + make) | ~200,000 |
| Market Order | ~120,000 |
| Claim Single Order | ~80,000 |
| Cancel Order | ~60,000 |
Security Considerations
- Always approve only what you need or use permit signatures
- Check the deadline parameter to prevent stale transactions
- Use postOnly for maker orders to avoid unexpected fills
- Set reasonable limitPriceIndex for market orders to prevent sandwich attacks
Next Steps
Router
Explore Router functions
OrderBook
Explore OrderBook functions
PriceBook
Explore PriceBook functions
