Options liquidity for HYPE.
Provide it, or trade against it.
The options liquidity layer of Elysium. Provide HYPE, KNTQ or USDC and earn the premium. Traders buy and sell calls and puts against your liquidity at any time, settled at the Hyperliquid price.
How the liquidity works
Deposit
HYPE or KNTQ into a calls pool, USDC into a puts pool.
Pool
Your liquidity backs every option the pool sells, one to one.
Option
Traders buy calls and puts and sell them back to the pool.
Premium
90% of every premium is paid to the pool, in USDC.
++++Be the liquidity
Every market has two pools. HYPE or KNTQ fills the calls pool, USDC fills the puts pool. Each option sold locks collateral from its pool one to one, and that pool's liquidity providers earn 90% of the premium in USDC. Deposits join at the Monday roll and can be taken back at once until then. Withdrawals are paid at the end of the epoch. A liquidity provider is never liquidated.
Provide liquidity→
++++Liquidity on both sides of every trade
No order book and no counterparty to find: the pool quotes every strike. HYPE at 62.10, a 7-day 68 call for 0.65 USDC, breakeven 68.65, maximum loss 0.65. Pick an expiry and a strike on the live chain, see premium, breakeven, delta and implied vol, and pay in USDC. You hold the Option NFT, you sell it back to the pool whenever you want, and at expiry an in-the-money option pays out of its own collateral. No margin, no liquidation.
Open the option chain→
++++The premium flows back to the liquidity
90% of every premium goes to the liquidity providers of the pool that wrote the option, 10% to the protocol. The premium stays in the pool for the epoch, funds sell-backs first, then is booked to providers at the roll, in USDC.
Learn more→Three contracts hold the liquidity
Read every line of the liquidity pool
1// SPDX-License-Identifier: MIT2pragma solidity 0.8.28;34import {5 OptionInfo,6 OptionStatus,7 MarketInfo,8 Quote,9 IAsphodelFactory,10 IAsphodelVault,11 IMarkOracle,12 IOptionArt,13 IERC20Min,14 IERC721Receiver15} from "./interfaces/IAsphodel.sol";1617/// @title AsphodelOptions18/// @notice Asphodel's options market: European, cash settled, fully collateralised calls and puts traded against the19/// liquidity pools (AsphodelVault). Every option is an ERC-721 drawn on chain. Every option sold is backed one to one20/// by collateral locked in its pool: one unit of the asset per call, the strike in USDC per put.21///22/// Trades run on an EIP-712 quote signed by the server key (deadline at most 10 seconds, one-time nonce), which carries23/// the spot the premium was priced on. The chain bounds what that key can do: only strikes at or out of the money are24/// sold (a call's strike at or above spot, a put's at or below it, 0.5% tolerance, at most 50% away), on a two25/// significant digit grid, at a minimum notional; an ask is at least a floor in bps of notional, one trade is at most 5%26/// of a side's capital, one strike and expiry at most 20%, a sale cannot take a side above 80% utilisation, a sell-back27/// is capped at what the pool kept for that option and paid only from that epoch's premium, and collateral can only28/// reach an option holder at settlement or go back to the pool.29///30/// Settlement: after expiry anyone relays a signed mark timestamped at or after the expiry and within 10 minutes of it.31/// The signer signs the 30-minute time-weighted average price ending at the expiry. A settlement price far outside the32/// last known mark (the spot of the latest sale, moving at a bounded rate) is refused, and no signature leads to the33/// physical exercise fallback.34/// Calls pay size x (S - K) / S in the asset, puts pay size x (K - S) in USDC. If no price is posted within 24 hours,35/// physical exercise opens for 48 hours (call: pay the strike in USDC, take the asset; put: deliver the asset, take the36/// strike), and after that the collateral returns to the pool. Nothing can be trapped.37contract AsphodelOptions {38 // ------------------------------------------------------------------ rules39 uint256 public constant BPS = 10_000;40 uint16 public constant FEE_BPS = 1_000; // 10% of the premium goes to the protocol41 uint256 public constant MAX_QUOTE_LIFE = 10; // seconds42 uint256 public constant MIN_TO_EXPIRY = 1 hours;43 uint256 public constant SETTLE_WINDOW = 24 hours;44 uint256 public constant PHYSICAL_WINDOW = 48 hours;45 uint256 public constant MIN_PREMIUM = 10_000; // 0.01 USDC46 uint256 public constant MAX_STRIKES = 64; // per side and expiry: bounds the settlement loop47 uint256 public constant OTM_TOLERANCE_BPS = 50; // a strike can sit 0.5% on the in-the-money side of spot48 uint256 public constant MAX_OTM_BPS = 5_000; // a strike is at most 50% away from spot49 /// @notice The last known mark moves toward a sale's signed spot at most this fast, per hour.50 uint256 public constant ANCHOR_RATE_BPS_PER_HOUR = 2_000;51 uint256 public constant SETTLE_BAND_BPS = 5_000; // a settlement price is within 1.5x of the last known mark...52 uint256 public constant SETTLE_BAND_PER_DAY_BPS = 1_000; // ...plus 10% for each day that mark has aged...53 uint256 public constant SETTLE_BAND_MAX_BPS = 20_000; // ...up to 3x54 uint8 internal constant SIDE_BUY = 0;55 uint8 internal constant SIDE_SELL = 1;5657 bytes32 public constant QUOTE_TYPEHASH = keccak256(58 "Quote(uint16 market,bool isCall,uint256 strike,uint256 spot,uint64 expiry,uint256 size,uint256 premium,uint8 side,address trader,uint256 nonce,uint64 deadline)"59 );60 bytes32 public immutable DOMAIN_SEPARATOR;6162 IAsphodelFactory public immutable factory;63 IERC20Min public immutable usdc;64 IOptionArt public immutable art;6566 uint256 public lastId;67 mapping(uint256 => OptionInfo) internal _options;68 mapping(uint256 => bool) public usedNonce;6970 struct Series {71 uint256 openSize;72 uint256 collateral;73 }7475 mapping(bytes32 => Series) internal _series; // per market, side, strike, expiry76 mapping(bytes32 => uint256[]) internal _strikes; // per market, side, expiry77 mapping(bytes32 => uint256) public expiryLocked; // per market, side, expiry78 mapping(uint256 => uint256[]) internal _idsByExpiry; // per market, expiry79 /// @notice Settlement price, 8 decimals, per market and expiry (key = market << 64 | expiry). 0 until settled.80 mapping(uint256 => uint256) public settlementPrice;81 /// @notice True once collateral of a market and expiry with no posted price has gone back to the pools.82 mapping(uint256 => bool) public released;83 /// @notice Last known mark of a market, 8 decimals: the spot of its latest sale, moving at a bounded rate. Frozen by a84 /// pause of new sales. Bounds the settlement price.85 mapping(uint16 => uint256) public lastMark;86 mapping(uint16 => uint64) public lastMarkAt;8788 // ERC-72189 string public constant name = "Asphodel Option";90 string public constant symbol = "ASPHO";91 mapping(uint256 => address) internal _ownerOf;92 mapping(address => uint256) public balanceOf;93 mapping(uint256 => address) public getApproved;94 mapping(address => mapping(address => bool)) public isApprovedForAll;95 mapping(address => uint256[]) internal _held;96 mapping(uint256 => uint256) internal _heldIdx;9798 uint256 private _guard;99100 event Sold(uint256 indexed id, address indexed buyer, uint16 indexed market, bool isCall, uint256 strike, uint64 expiry, uint256 size, uint256 premium, uint256 fee);101 event SoldBack(uint256 indexed id, address indexed seller, uint256 bid);102 event Settled(uint16 indexed market, uint64 indexed expiry, uint256 price);103 event Claimed(uint256 indexed id, address indexed holder, uint256 payout);104 event Exercised(uint256 indexed id, address indexed holder, uint256 paid, uint256 received);105 event ReleasedToPool(uint16 indexed market, uint64 indexed expiry, uint256 callCollateral, uint256 putCollateral);106 event MarkAnchored(uint16 indexed market, uint256 mark);107 event Transfer(address indexed from, address indexed to, uint256 indexed id);108 event Approval(address indexed owner, address indexed spender, uint256 indexed id);109 event ApprovalForAll(address indexed owner, address indexed operator, bool approved);110111 error Reentrancy();112 error BadSide();113 error NotTrader();114 error NotHolder();115 error QuoteExpired();116 error DeadlineTooLong();117 error NonceUsed();118 error BadSignature();119 error WrongSigner();120 error MarketClosed();121 error SalesPaused();122 error BadExpiry();123 error BadSize();124 error BadSpot();125 error StrikeNotOutOfTheMoney();126 error StrikeOffGrid();127 error BelowMinNotional();128 error BidAboveKept();129 error SettlementOutOfBounds();130 error AskBelowFloor();131 error PremiumTooLow();132 error TooManyStrikes();133 error WrongStatus();134 error QuoteMismatch();135 error OptionExpired();136 error NotExpired();137 error TooLate();138 error AlreadySettled();139 error NotSettled();140 error WindowClosed();141 error WindowOpen();142 error AlreadyReleased();143 error TransferFailed();144 error ZeroAddress();145 error NotAuthorized();146 error UnknownId();147 error UnsafeRecipient();148149 modifier nonReentrant() {150 if (_guard == 1) revert Reentrancy();151 _guard = 1;152 _;153 _guard = 0;154 }155156 constructor(IAsphodelFactory factory_, IOptionArt art_) {157 if (address(factory_) == address(0)) revert ZeroAddress();158 factory = factory_;159 usdc = IERC20Min(factory_.usdc());160 art = art_;161 DOMAIN_SEPARATOR = keccak256(162 abi.encode(163 keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),164 keccak256("AsphodelOptions"),165 keccak256("1"),166 block.chainid,167 address(this)168 )169 );170 }171172 // ------------------------------------------------------------------ trading173174 /// @notice Buy an option at a signed ask. Pays the premium in USDC (approve first) and mints the Option NFT.175 function buy(Quote calldata q, bytes calldata sig) external nonReentrant returns (uint256 id) {176 if (q.side != SIDE_BUY) revert BadSide();177 _consume(q, sig);178 if (factory.salesPaused()) revert SalesPaused();179 MarketInfo memory m = factory.marketInfo(q.market);180 if (!m.active) revert MarketClosed();181 IAsphodelVault v = IAsphodelVault(q.isCall ? m.callVault : m.putVault);182 if (q.expiry % 1 days != 0 || q.expiry < block.timestamp + MIN_TO_EXPIRY || q.expiry > v.epochEnd()) {183 revert BadExpiry();184 }185 if (q.size == 0 || q.strike == 0) revert BadSize();186 _checkStrike(q);187188 uint256 notional = _usdcValue(q.size, q.strike, m.unit, true);189 if (notional < factory.minNotional()) revert BelowMinNotional();190 if (q.premium * BPS < notional * factory.floorBps()) revert AskBelowFloor();191 if (q.premium < MIN_PREMIUM) revert PremiumTooLow();192 _anchorMark(q.market, q.spot);193194 uint256 collateral = q.isCall ? q.size : notional;195 _lockCollateral(v, q, collateral);196197 uint256 fee = _collectPremium(v, q.premium);198 id = _issue(q, collateral);199 _emitSold(id, q, fee);200 }201202 function _emitSold(uint256 id, Quote calldata q, uint256 fee) internal {203 emit Sold(id, msg.sender, q.market, q.isCall, q.strike, q.expiry, q.size, q.premium, fee);204 }205206 function _collectPremium(IAsphodelVault v, uint256 premium) internal returns (uint256 fee) {207 fee = (premium * FEE_BPS) / BPS;208 uint256 net = premium - fee;209 _pull(address(usdc), msg.sender, address(v), net);210 if (fee != 0) _pull(address(usdc), msg.sender, factory.feeSink(), fee);211 v.addPremium(net);212 }213214 function _issue(Quote calldata q, uint256 collateral) internal returns (uint256 id) {215 id = ++lastId;216 _options[id] = OptionInfo({217 market: q.market,218 isCall: q.isCall,219 expiry: q.expiry,220 status: OptionStatus.Live,221 strike: q.strike,222 size: q.size,223 collateral: collateral,224 premium: q.premium225 });226 _idsByExpiry[_key(q.market, q.expiry)].push(id);227 _mint(msg.sender, id);228 }229230 /// @notice Sell an option back to the pool at a signed bid, before expiry. Paid only from this epoch's premium.231 function sellBack(uint256 id, Quote calldata q, bytes calldata sig) external nonReentrant {232 if (q.side != SIDE_SELL) revert BadSide();233 if (ownerOf(id) != msg.sender) revert NotHolder();234 OptionInfo storage o = _options[id];235 if (o.status != OptionStatus.Live) revert WrongStatus();236 if (block.timestamp >= o.expiry) revert OptionExpired();237 if (q.market != o.market || q.isCall != o.isCall || q.strike != o.strike || q.expiry != o.expiry || q.size != o.size) {238 revert QuoteMismatch();239 }240 _consume(q, sig);241 // the bid is at most what the pool kept for this option: a round trip can never take from other buyers' premium242 if (q.premium > o.premium - (o.premium * FEE_BPS) / BPS) revert BidAboveKept();243244 o.status = OptionStatus.SoldBack;245 MarketInfo memory m = factory.marketInfo(o.market);246 IAsphodelVault v = IAsphodelVault(o.isCall ? m.callVault : m.putVault);247 _releaseSeries(v, o);248 v.release(o.collateral);249 _burn(id);250 if (q.premium != 0) v.spendPremium(msg.sender, q.premium);251 emit SoldBack(id, msg.sender, q.premium);252 }253254 // ------------------------------------------------------------------ settlement255256 /// @notice Post the signed settlement mark of a market and expiry: closes both sides of that expiry at once.257 /// Anyone can relay it, once, within 24 hours of expiry.258 function settle(uint16 market, uint64 expiry, bytes calldata markData) external nonReentrant {259 if (block.timestamp < expiry) revert NotExpired();260 if (block.timestamp >= expiry + SETTLE_WINDOW) revert TooLate();261 uint256 mk = _key(market, expiry);262 if (settlementPrice[mk] != 0) revert AlreadySettled();263 if (released[mk]) revert AlreadyReleased();264 uint256 price = IMarkOracle(factory.oracle()).settlementPrice(market, expiry, markData);265 _checkSettlementBound(market, price);266 settlementPrice[mk] = price;267 MarketInfo memory m = factory.marketInfo(market);268 _closeSide(m, market, expiry, true, price);269 _closeSide(m, market, expiry, false, price);270 emit Settled(market, expiry, price);271 }272273 /// @notice Pay a settled option to its NFT owner. Anyone can call it; the funds only ever go to the owner.274 function claim(uint256 id) external nonReentrant {275 address holder = ownerOf(id);276 OptionInfo storage o = _options[id];277 if (o.status != OptionStatus.Live) revert WrongStatus();278 uint256 price = settlementPrice[_key(o.market, o.expiry)];279 if (price == 0) revert NotSettled();280 o.status = OptionStatus.Claimed;281 uint256 payout = _payout(o, price);282 _burn(id);283 if (payout != 0) {284 MarketInfo memory m = factory.marketInfo(o.market);285 IAsphodelVault(o.isCall ? m.callVault : m.putVault).pay(holder, payout);286 }287 emit Claimed(id, holder, payout);288 }289290 /// @notice Physical exercise, open only when no price was posted within 24 hours of expiry, for the next 48 hours.291 /// Call: pay the strike in USDC, take the asset. Put: deliver the asset, take the strike. Approve the other leg first.292 function exercise(uint256 id) external nonReentrant {293 if (ownerOf(id) != msg.sender) revert NotHolder();294 OptionInfo storage o = _options[id];295 if (o.status != OptionStatus.Live) revert WrongStatus();296 uint256 mk = _key(o.market, o.expiry);297 if (settlementPrice[mk] != 0 || released[mk]) revert WrongStatus();298 if (block.timestamp < o.expiry + SETTLE_WINDOW) revert WindowClosed();299 if (block.timestamp >= o.expiry + SETTLE_WINDOW + PHYSICAL_WINDOW) revert WindowClosed();300301 MarketInfo memory m = factory.marketInfo(o.market);302 IAsphodelVault v = IAsphodelVault(o.isCall ? m.callVault : m.putVault);303 uint256 altIn;304 if (o.isCall) {305 altIn = _usdcValue(o.size, o.strike, m.unit, true);306 _pull(address(usdc), msg.sender, address(v), altIn);307 } else {308 altIn = o.size;309 _pull(m.asset, msg.sender, address(v), altIn);310 }311 o.status = OptionStatus.Exercised;312 _releaseSeries(v, o);313 v.payPhysical(msg.sender, o.collateral, altIn);314 _burn(id);315 emit Exercised(id, msg.sender, altIn, o.collateral);316 }317318 /// @notice After the physical window, anyone returns the remaining collateral of a market and expiry to the pool.319 function releaseToPool(uint16 market, uint64 expiry) external nonReentrant {320 uint256 mk = _key(market, expiry);321 if (settlementPrice[mk] != 0) revert AlreadySettled();322 if (released[mk]) revert AlreadyReleased();323 if (block.timestamp < expiry + SETTLE_WINDOW + PHYSICAL_WINDOW) revert WindowOpen();324 released[mk] = true;325 MarketInfo memory m = factory.marketInfo(market);326 uint256 c = _closeSide(m, market, expiry, true, 0);327 uint256 p = _closeSide(m, market, expiry, false, 0);328 emit ReleasedToPool(market, expiry, c, p);329 }330331 // ------------------------------------------------------------------ views332333 function getOption(uint256 id) external view returns (OptionInfo memory) {334 return _options[id];335 }336337 function tokensOfOwner(address owner) external view returns (uint256[] memory) {338 return _held[owner];339 }340341 function idsByExpiry(uint16 market, uint64 expiry) external view returns (uint256[] memory) {342 return _idsByExpiry[_key(market, expiry)];343 }344345 function strikesOf(uint16 market, bool isCall, uint64 expiry) external view returns (uint256[] memory) {346 return _strikes[_expiryKey(market, isCall, expiry)];347 }348349 function seriesOf(uint16 market, bool isCall, uint256 strike, uint64 expiry) external view returns (Series memory) {350 return _series[_seriesKey(market, isCall, strike, expiry)];351 }352353 function expiryLockedOf(uint16 market, bool isCall, uint64 expiry) external view returns (uint256) {354 return expiryLocked[_expiryKey(market, isCall, expiry)];355 }356357 /// @notice The payout an option would receive at settlement price `price`.358 function payoutAt(uint256 id, uint256 price) external view returns (uint256) {359 return _payout(_options[id], price);360 }361362 function settlementOf(uint16 market, uint64 expiry) external view returns (uint256) {363 return settlementPrice[_key(market, expiry)];364 }365366 function quoteDigest(Quote calldata q) external view returns (bytes32) {367 return _digest(q);368 }369370 function ownerOf(uint256 id) public view returns (address o) {371 o = _ownerOf[id];372 if (o == address(0)) revert UnknownId();373 }374375 function tokenURI(uint256 id) external view returns (string memory) {376 ownerOf(id);377 OptionInfo memory o = _options[id];378 return art.tokenURI(id, o, factory.marketInfo(o.market).symbol, settlementPrice[_key(o.market, o.expiry)]);379 }380381 function supportsInterface(bytes4 i) external pure returns (bool) {382 return i == 0x01ffc9a7 || i == 0x80ac58cd || i == 0x5b5e139f;383 }384385 function approve(address spender, uint256 id) external {386 address o = ownerOf(id);387 if (msg.sender != o && !isApprovedForAll[o][msg.sender]) revert NotAuthorized();388 getApproved[id] = spender;389 emit Approval(o, spender, id);390 }391392 function setApprovalForAll(address operator, bool approved) external {393 isApprovedForAll[msg.sender][operator] = approved;394 emit ApprovalForAll(msg.sender, operator, approved);395 }396397 function transferFrom(address from, address to, uint256 id) public {398 if (from != ownerOf(id)) revert NotAuthorized();399 if (to == address(0)) revert ZeroAddress();400 if (msg.sender != from && !isApprovedForAll[from][msg.sender] && msg.sender != getApproved[id]) {401 revert NotAuthorized();402 }403 unchecked {404 balanceOf[from]--;405 balanceOf[to]++;406 }407 _ownerOf[id] = to;408 delete getApproved[id];409 _removeHeld(from, id);410 _addHeld(to, id);411 emit Transfer(from, to, id);412 }413414 function safeTransferFrom(address from, address to, uint256 id) external {415 safeTransferFrom(from, to, id, "");416 }417418 function safeTransferFrom(address from, address to, uint256 id, bytes memory data) public {419 transferFrom(from, to, id);420 if (421 to.code.length != 0422 && IERC721Receiver(to).onERC721Received(msg.sender, from, id, data)423 != IERC721Receiver.onERC721Received.selector424 ) revert UnsafeRecipient();425 }426427 // ------------------------------------------------------------------ internal428429 /// @dev Only strikes at or out of the money are sold, on the two significant digit grid, at most 50% from spot.430 function _checkStrike(Quote calldata q) internal pure {431 if (q.spot == 0) revert BadSpot();432 if (!_onGrid(q.strike)) revert StrikeOffGrid();433 uint256 k = q.strike * BPS;434 uint256 s = q.spot;435 bool outOfRange = q.isCall436 ? (k < s * (BPS - OTM_TOLERANCE_BPS) || k > s * (BPS + MAX_OTM_BPS))437 : (k > s * (BPS + OTM_TOLERANCE_BPS) || k < s * (BPS - MAX_OTM_BPS));438 if (outOfRange) revert StrikeNotOutOfTheMoney();439 }440441 /// @dev True when `k` has at most two significant digits: 1-99 x 10^n. Dust cannot open strike slots off this grid.442 function _onGrid(uint256 k) internal pure returns (bool) {443 while (k >= 100) {444 if (k % 10 != 0) return false;445 k /= 10;446 }447 return k != 0;448 }449450 /// @dev The last known mark moves toward a sale's signed spot at a bounded rate, so a stolen key cannot walk it far451 /// in one step and a pause of new sales freezes it.452 function _anchorMark(uint16 market, uint256 spot) internal {453 uint256 last = lastMark[market];454 uint256 next = spot;455 if (last != 0) {456 uint256 maxMove = (last * ANCHOR_RATE_BPS_PER_HOUR * (block.timestamp - lastMarkAt[market])) / (BPS * 1 hours);457 if (maxMove > last / 2) maxMove = last / 2;458 if (next > last + maxMove) next = last + maxMove;459 else if (next < last - maxMove) next = last - maxMove;460 }461 lastMark[market] = next;462 lastMarkAt[market] = uint64(block.timestamp);463 emit MarkAnchored(market, next);464 }465466 /// @dev A settlement price far outside the last known mark is refused. The bound is wide on purpose: an honest extreme467 /// move falls back to physical exercise after 24 hours, nothing is trapped.468 function _checkSettlementBound(uint16 market, uint256 price) internal view {469 uint256 anchor = lastMark[market];470 if (anchor == 0) return; // nothing was ever sold on this market471 uint256 band = SETTLE_BAND_BPS + ((block.timestamp - lastMarkAt[market]) * SETTLE_BAND_PER_DAY_BPS) / 1 days;472 if (band > SETTLE_BAND_MAX_BPS) band = SETTLE_BAND_MAX_BPS;473 if (price * BPS > anchor * (BPS + band) || price * (BPS + band) < anchor * BPS) revert SettlementOutOfBounds();474 }475476 function _lockCollateral(IAsphodelVault v, Quote calldata q, uint256 collateral) internal {477 bytes32 ek = _expiryKey(q.market, q.isCall, q.expiry);478 bytes32 sk = _seriesKey(q.market, q.isCall, q.strike, q.expiry);479 Series storage s = _series[sk];480 if (s.openSize == 0) {481 uint256[] storage list = _strikes[ek];482 if (!_contains(list, q.strike)) {483 if (list.length >= MAX_STRIKES) revert TooManyStrikes();484 list.push(q.strike);485 }486 }487 s.openSize += q.size;488 s.collateral += collateral;489 if (expiryLocked[ek] == 0) v.openExpiry();490 expiryLocked[ek] += collateral;491 v.lock(collateral, s.collateral);492 }493494 function _contains(uint256[] storage list, uint256 strike) internal view returns (bool) {495 uint256 n = list.length;496 for (uint256 i; i < n; ++i) if (list[i] == strike) return true;497 return false;498 }499500 function _releaseSeries(IAsphodelVault v, OptionInfo storage o) internal {501 bytes32 ek = _expiryKey(o.market, o.isCall, o.expiry);502 Series storage s = _series[_seriesKey(o.market, o.isCall, o.strike, o.expiry)];503 s.openSize -= o.size;504 s.collateral -= o.collateral;505 expiryLocked[ek] -= o.collateral;506 if (expiryLocked[ek] == 0) v.closeExpiry();507 }508509 /// @dev Moves one side of a market and expiry out of the lock. With `price` 0 (released) the payout is zero.510 function _closeSide(MarketInfo memory m, uint16 market, uint64 expiry, bool isCall, uint256 price)511 internal512 returns (uint256 lockedAmt)513 {514 bytes32 ek = _expiryKey(market, isCall, expiry);515 lockedAmt = expiryLocked[ek];516 if (lockedAmt == 0) return 0;517 expiryLocked[ek] = 0;518 uint256 payout = price == 0 ? 0 : _sumPayouts(_strikes[ek], market, isCall, expiry, price, m.unit);519 IAsphodelVault(isCall ? m.callVault : m.putVault).settleExpiry(lockedAmt, payout);520 }521522 function _sumPayouts(523 uint256[] storage list,524 uint16 market,525 bool isCall,526 uint64 expiry,527 uint256 price,528 uint256 unit529 ) internal view returns (uint256 total) {530 uint256 n = list.length;531 for (uint256 i; i < n; ++i) {532 uint256 strike = list[i];533 uint256 open = _series[_seriesKey(market, isCall, strike, expiry)].openSize;534 if (open != 0) total += _seriesPayout(isCall, open, strike, price, unit);535 }536 }537538 function _seriesPayout(bool isCall, uint256 size, uint256 strike, uint256 price, uint256 unit)539 internal540 pure541 returns (uint256)542 {543 if (isCall) {544 if (price <= strike) return 0;545 return (size * (price - strike)) / price;546 }547 if (price >= strike) return 0;548 return _usdcValue(size, strike - price, unit, false);549 }550551 function _payout(OptionInfo memory o, uint256 price) internal view returns (uint256) {552 return _seriesPayout(o.isCall, o.size, o.strike, price, factory.marketInfo(o.market).unit);553 }554555 /// @dev USDC (6 decimals) value of `size` asset units at `price` (8 decimals per whole asset).556 function _usdcValue(uint256 size, uint256 price, uint256 unit, bool roundUp) internal pure returns (uint256) {557 uint256 d = unit * 100;558 uint256 n = size * price;559 return roundUp ? (n + d - 1) / d : n / d;560 }561562 function _consume(Quote calldata q, bytes calldata sig) internal {563 if (q.trader != msg.sender) revert NotTrader();564 if (block.timestamp > q.deadline) revert QuoteExpired();565 if (q.deadline > block.timestamp + MAX_QUOTE_LIFE) revert DeadlineTooLong();566 if (usedNonce[q.nonce]) revert NonceUsed();567 usedNonce[q.nonce] = true;568 if (_recover(_digest(q), sig) != factory.signer()) revert WrongSigner();569 }570571 function _digest(Quote calldata q) internal view returns (bytes32) {572 return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, _hashQuote(q)));573 }574575 function _hashQuote(Quote calldata q) internal pure returns (bytes32) {576 return keccak256(abi.encode(QUOTE_TYPEHASH, q));577 }578579 function _recover(bytes32 d, bytes calldata sig) internal pure returns (address recovered) {580 if (sig.length != 65) revert BadSignature();581 bytes32 r = bytes32(sig[0:32]);582 bytes32 s = bytes32(sig[32:64]);583 uint8 v = uint8(sig[64]);584 if (v < 27) v += 27;585 if (v != 27 && v != 28) revert BadSignature();586 if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) revert BadSignature();587 recovered = ecrecover(d, v, r, s);588 if (recovered == address(0)) revert BadSignature();589 }590591 function _key(uint16 market, uint64 expiry) internal pure returns (uint256) {592 return (uint256(market) << 64) | uint256(expiry);593 }594595 function _expiryKey(uint16 market, bool isCall, uint64 expiry) internal pure returns (bytes32) {596 return keccak256(abi.encode(market, isCall, expiry));597 }598599 function _seriesKey(uint16 market, bool isCall, uint256 strike, uint64 expiry) internal pure returns (bytes32) {600 return keccak256(abi.encode(market, isCall, strike, expiry));601 }602603 function _mint(address to, uint256 id) internal {604 unchecked {605 balanceOf[to]++;606 }607 _ownerOf[id] = to;608 _addHeld(to, id);609 emit Transfer(address(0), to, id);610 }611612 function _burn(uint256 id) internal {613 address o = _ownerOf[id];614 unchecked {615 balanceOf[o]--;616 }617 delete _ownerOf[id];618 delete getApproved[id];619 _removeHeld(o, id);620 emit Transfer(o, address(0), id);621 }622623 function _addHeld(address who, uint256 id) internal {624 _heldIdx[id] = _held[who].length;625 _held[who].push(id);626 }627628 function _removeHeld(address who, uint256 id) internal {629 uint256[] storage list = _held[who];630 uint256 i = _heldIdx[id];631 uint256 last = list.length - 1;632 if (i != last) {633 uint256 moved = list[last];634 list[i] = moved;635 _heldIdx[moved] = i;636 }637 list.pop();638 delete _heldIdx[id];639 }640641 function _pull(address token, address from, address to, uint256 amount) internal {642 (bool ok, bytes memory data) =643 token.call(abi.encodeWithSelector(IERC20Min.transferFrom.selector, from, to, amount));644 if (!ok || (data.length != 0 && !abi.decode(data, (bool)))) revert TransferFailed();645 }646}647
Fully collateralised
One unit of the asset per call, the strike in USDC per put, locked in the pool
Read more →Hyperliquid price
Every option settles on a 30-minute average of the Hyperliquid mark, paid in USDC
Read more →Non-custodial
Liquidity moves only by the pool's rules, straight between your wallet and the contract
Read more →




