Documentation

Tangent

Hyperliquid liquidity, on-chain. Spot, RFQ, options and structured yield on Elysium — every unit hedged on Hyperliquid.

What is Tangent

Classic constant-product AMMs price from their own reserves, which means LPs sell winners and buy losers (impermanent loss) and pay arbitrageurs to keep the pool in line with the market. Tangent takes the other route: one USDC pool quotes several spot markets against USDC — WHYPE, UBTC, UETH, USOL and PURR today, more as they are listed — at the live Hyperliquid perp mark plus a transparent spread, and the hedger immediately neutralises whatever exposure the pool takes on with the opposite position in that market's perp on Hyperliquid (HYPE, BTC, ETH, SOL, PURR). Elysium gets Hyperliquid's depth and price; LPs earn spread and premium with near-zero directional exposure.

Everything else is built on that one pool and that one hedge:

  • Spot — tight, predictable prices with no pool-ratio slippage and no sandwich surface; the quote depends on the oracle mid and inventory, not on your order touching reserves. LPs deposit USDC (or any market token in-kind), receive tLP shares and keep 80% of every spread; 20% accrues to the protocol treasury (TangentTreasury).
  • RFQ for size — above the AMM per-trade cap the hedger signs firm EIP-712 quotes priced off real Hyperliquid book depth, filled through TangentRFQ under the same on-chain bounds.
  • Options — cash-settled European calls and puts on HYPE (options are HYPE-only for now), written by the pool as ERC-1155 tokens, priced with Black-Scholes and delta-hedged with the rest of the book. No margin, no liquidation; max loss is the premium.
  • Senior / junior tranches — TangentTranche splits tLP into tSR (target rate first) and tJR (residual, first loss), so depositors choose their own risk.
  • On-chain risk policy — the contract, not the bot, caps unhedged net delta and switches to reduce-only when the hedge lags; the options book counts against the same NAV.
  • Free TWAP oracle — TangentOracle keeps a ring buffer of posted Hyperliquid marks and serves twap(perpIndex, windowSec) to any contract on Elysium; it is also the options settlement price.
  • Depth-aware lending (roadmap) — a USDC lending market whose LTV and liquidation capacity follow the Hyperliquid depth the hedger already measures, with liquidations routed through the pool.

Qualifying buys may receive a hedged position; eligible wallets see it in the app after connecting.

Markets are data-driven: each is an on-chain Market struct { token, decimals, perpIndex, baseSpreadBps, skewSpreadBps, maxSpreadBps, maxInventoryUsdE6, maxTradeUsdE6, targetInventory, enabled, buyPaused, sellPaused }. Each market is hedged against its own Hyperliquid perp. Live markets (see Markets or GET /api/markets for the current list and parameters):

MarketTokenDecimalsHyperliquid perp
WHYPE / USDCWrapped HYPE18HYPE-PERP (#159)
UBTC / USDCUnit Bitcoin8BTC-PERP (#0)
UETH / USDCUnit Ethereum18ETH-PERP (#1)
USOL / USDCUnit Solana9SOL-PERP (#5)
PURR / USDCPurr18PURR-PERP (#152)

Token amounts always use the token's own decimals — UBTC has 8 and USOL 9, so never assume 18. The trade page keeps the selected market in the URL (/app/trade?market=UBTC).

How pricing works

All prices are E8 (USD per whole token × 1e8); USD amounts are E6. Let mid be the oracle price for the market's perp index.

inv        = tokenBalance − targetInventory        // signed, token units
invUsd     = inv × mid
dir        = +1 when you SELL token to the pool (inventory rises)
             −1 when you BUY  token from the pool (inventory falls)
invAfter   = invUsd + dir × tradeUsd

revert InventoryLimit  if |invAfter| > maxInventoryUsdE6
revert TradeTooLarge   if tradeUsd  > maxTradeUsdE6

pressure   = clamp(dir × invAfter / maxInventoryUsdE6, 0, 1)
spreadBps  = min(baseSpreadBps + skewSpreadBps × pressure, maxSpreadBps)

Only the side that pushes inventory away from target gets widened; the side that brings it back trades at the base spread. Then:

DirectionFormula
Buy token with USDC (e.g. USDC → UBTC)amountOut = usdcIn / (mid × (1 + spread))
Sell token for USDC (e.g. WHYPE → USDC)amountOut = tokenIn × mid × (1 − spread)

Protocol fee: protocolFeeUsdE6 = tradeUsd × spreadBps × protocolShareBps / 1e8 is book-kept inside the pool as protocolFeesAccrued (excluded from NAV) until anyone calls claimProtocolFees(). The remaining spread stays in NAV for LPs.

Parameters are set per market (the Markets page shows the live values). WHYPE launched with base 8 bps, skew 40 bps, max 150 bps, inventory cap ±$25,000, per-trade cap $5,000. swapExactIn additionally enforces minAmountOut (your slippage) and deadline.

Oracle

TangentOracle routes between two sources per perp index:

  1. Posted — the hedger posts Hyperliquid mark prices (post(perpIndex[], pxE8[], hlTimestampMs[])) every ~15 s or whenever the mark moves more than 5 bps. Stale after maxAgeSec (default 45 s).
  2. Native — optional on-chain source (today the Precompilisium markPx shim; later the Elysium native precompile). Preferred when live and sane.

If both are fresh and disagree by more than maxDeviationBps (default 1%), getPrice reverts PriceDisagreement and the pool fails closed: no quotes, no swaps, until the sources converge. If the posted price is stale and no native source is live, it reverts StalePrice.

Hedging & delta neutrality

The pool holds token inventory in each market whenever traders net-sell to it. The hedger (operator) keeps, per market, a short position in that market's Hyperliquid perp (HYPE-PERP for WHYPE, BTC-PERP for UBTC, ETH-PERP for UETH, SOL-PERP for USOL, PURR-PERP for PURR) equal to the pool's token balance, so the combined book is delta-neutral:

target hedge  = −tokenBalance                       (coin units)
gap           = target − currentHlPosition
if |gap| × mid ≥ HEDGE_MIN_USD  → IOC limit order, slippage-capped (30 bps default)

The hedger runs every 1.5 s and on every Swap event, then calls reportHedge(ids, hedgeSizes, hedgeEquityUsdE6) roughly every 30 s with the HL account value and per-market position sizes. The frontend shows net delta (inventory + hedge, in USD) and the age of the last report. If the report is older than hedgeStaleSec (default 600 s) the pool flags hedgeIsStale() and the UI shows a warning; deposits and withdrawals keep working.

Margin for the hedge is funded by the owner moving USDC out of the pool with moveToHedge (capped at maxHedgeCapitalBps, default 30% of NAV, tracked as hedgeCapitalOutUsdE6). Anyone can return it with returnFromHedge.

On-chain risk policy

Between a trade and the next reportHedge the pool is unhedged by that trade's size. The contract, not the bot, decides how much of that gap is acceptable:

struct RiskPolicy { uint128 maxNetDeltaUsdE6; uint16 breachSpreadBps; bool enforce; }

netDeltaUsd(id) = (tokenBalance + hedgeSize) × mid          // exposed as inventory(id).netDeltaUsdE6
riskMode()      = reduce-only  if enforce && (hedgeIsStale() || max_i |netDeltaUsd(i)| > maxNetDeltaUsdE6)
                = normal       otherwise

In reduce-only mode quote, swapExactIn, swapRFQ and depositToken accept a trade only if it shrinks that market's |net delta| (|netAfter| < |netBefore|); anything else reverts ReduceOnly(netDeltaUsdE6, maxNetDeltaUsdE6). Delta-reducing trades in reduce-only mode pay spread + breachSpreadBps (still capped at maxSpreadBps). Defaults: cap $10,000, breach spread 10 bps, enforced. The owner can change the policy with setRiskPolicy (event RiskPolicySet).

The Trade and Markets pages show the current mode as a badge; /api/risk returns riskMode { mode, worstNetDeltaUsdE6, hedgeStale } and riskPolicy, and /api/quote returns a decoded ReduceOnly with an explanation when a quote is refused. The hedger only executes; the limit lives in the contract.

RFQ for size

The AMM caps each trade at maxTradeUsdE6 and widens with inventory skew because it cannot see Hyperliquid depth. For larger sizes the pool accepts signed quotes through TangentRFQ:

  1. The hedger exposes POST /rfq/quote { tokenIn, tokenOut, amountIn, taker? }. It walks the Hyperliquid l2Book for the hedge size to get VWAP slippage in bps and prices spreadBps = clamp(max(minRfqSpreadBps, baseSpreadBps/2 + slippageBps + buffer), minRfqSpreadBps, maxSpreadBps) at the current posted mid, with the same rounding as the contract. The quote expires after ~30 s and carries a random 256-bit nonce.
  2. It signs an EIP-712 Quote { taker, tokenIn, tokenOut, amountIn, amountOut, spreadBps, expiry, nonce } (domain "Tangent RFQ", version "1") with the key set as TangentRFQ.quoter.
  3. The taker approves tokenIn to TangentRFQ (not the pool) and calls fill(quote, signature). The contract checks expiry (QuoteExpired), taker (WrongTaker), nonce (NonceUsed) and signer (BadSigner), pulls amountIn and calls pool.swapRFQ.
  4. swapRFQ applies no skew but enforces minRfqSpreadBps ≤ spreadBps ≤ maxSpreadBps, tradeUsd ≤ rfqMaxTradeUsdE6 (default $50,000), the inventory cap and the reduce-only rule, and bounds the price at the current oracle mid: fairOut × (1 − maxSpread) ≤ amountOut ≤ fairOut, otherwise RfqPriceOutOfBounds. The taker can never receive more than the stated spread implies.

The web app proxies the quoter at POST /api/rfq/quote and reports its configuration at GET /api/rfq/info. On the Trade page the AMM | RFQ toggle switches to RFQ automatically when the AMM reverts TradeTooLarge; the firm output, spread, book slippage and a countdown to expiry are shown and a fresh quote is requested when fewer than 5 s remain. When TangentRFQ is not deployed on the configured chain the toggle is disabled.

totalAssets = freeUsdc
            + Σ tokenBalance_i × mid_i              // marked inventory
            + max(hedgeEquityUsdE6, 0)              // last reported HL account value
sharePriceE18 = 1e18 × totalAssets / totalSupply    // 1e18 when supply is 0

tLP is an ERC-4626-style share with OpenZeppelin's virtual-offset protection (_decimalsOffset = 12, so 1 USDC ≈ 1e18 shares at genesis). Deposits and withdrawals:

  • deposit(assets) — USDC in, shares = previewDeposit(assets).
  • depositToken(token, amount) — in-kind deposit of any market token (WHYPE, UBTC, UETH, USOL, PURR), valued at mid × (1 − baseSpread) so depositors pay the same half-spread a seller would.
  • withdraw(assets) / redeem(shares) — USDC out, bounded by maxWithdraw(owner) = min(ownerAssets, freeUsdc). If much of NAV sits in inventory or HL margin, you may need to withdraw in pieces while the hedger recycles capital.

The pool page estimates APR from recent Swap events: LP share of spread revenue over the sampled window ÷ NAV × 365 / days. It is a backward-looking approximation and ignores funding paid or earned on the hedge.

Senior / junior tranches

TangentTranche holds tLP on behalf of two ERC-20 claims, tSR (Tangent Senior) and tJR (Tangent Junior), both 18 decimals. All accounting is in USD E6 via pool.convertToAssets(tLP balance):

totalValue        = pool.convertToAssets(pool.balanceOf(tranche))
seniorEntitlement += seniorEntitlement × seniorRateBps × dt / (365 days × 1e4)   // on every state change
seniorValue       = min(seniorEntitlement, totalValue)
juniorValue       = totalValue − seniorValue
sharePrice        = value / supply                                                 // 1e18 when supply is 0
  • Senior gets its target rate first. The entitlement accrues linearly at seniorRateBps (default 800 = 8% APR, max 30%); senior deposits add principal, senior withdrawals subtract pro-rata.
  • Junior takes the rest and absorbs the first losses. If pool NAV falls, junior value shrinks before senior is touched; if NAV outperforms the senior rate, junior keeps the excess.
  • Buffer rule. After any senior deposit or junior withdrawal juniorValue × 1e4 / totalValue must stay ≥ minJuniorBps (default 2000 = 20%), otherwise the call reverts JuniorTooThin(juniorBpsAfter, minJuniorBps).
  • Flows. depositSenior/Junior(assets, receiver) pull USDC, deposit into the pool and mint assets × supply / value shares (floor). withdrawSenior/Junior(shares, receiver) pay shares × value / supply USDC by redeeming tLP; they revert InsufficientLiquidity when the pool has no free USDC — the same bound as maxWithdraw.

The Pool page shows LP (tLP), Senior and Junior tabs with share prices, the senior target APR, the junior buffer versus its minimum and your balances; /api/tranche and the MCP tranche / tranche_calldata tools expose the same data. The tabs are hidden on chains where TangentTranche is not deployed.

TWAP oracle

TangentOracle keeps, per perp index, a ring buffer of up to 512 (timestamp, pxE8) observations appended on every post. Anyone can read a time-weighted average over a configurable window:

twap(perpIndex, windowSec) → (pxE8, coveredSec)

The last observation is carried forward to now; partial coverage is allowed and reported in coveredSec. If the buffer does not reach back at least windowSec / 2 the call reverts InsufficientHistory(perpIndex, windowSec). observationCount(perpIndex) and observation(perpIndex, i) (oldest-first) expose the raw buffer. The Transparency page shows the 1 h and 24 h TWAP next to the spot oracle price (— while history is insufficient), and /api/oracle returns twap1h / twap24h as { pxE8, coveredSec, windowSec } or null. Other Elysium contracts can use this as a free, manipulation-resistant reference price.

Roles & trust assumptions

RoleCanCannot
Owner (Ownable2Step, intended multisig)add markets, set spreads/caps, set roles, set protocol share (≤ 50%), move ≤ 30% NAV to HL margin, pause/unpause, rescue non-pool tokenswithdraw LP USDC, change the pricing formula
Operator (hedger hot key)post oracle prices, report hedge statemove funds, change parameters, pause
Guardianpause the pool or a market directionunpause, move funds, change parameters
Anyoneclaim protocol fees to treasury, return USDC from hedge—

Today the hedge is executed off-chain by the operator and reported back; LPs trust that the HL account equity is reported honestly (verify it on the Hyperliquid explorer — the address is linked on the Transparency page) and that the operator keeps running. Trading fails closed when prices go stale.

Next — once the Elysium ArbOS upgrade ships ElysiumCoreWriter and native precompile reads, the pool can (a) read the Hyperliquid mark directly on-chain, removing the posted-price path, and (b) place the hedge atomically inside swapExactIn, removing the operator from the critical path. The contract interfaces are designed so this is a parameter change plus a new oracle source, not a migration.

Fees & treasury

  • No deposit or withdrawal fees. The only revenue is the spread.
  • protocolShareBps (default 2000 = 20%) of every spread is credited to protocolFeesAccrued inside the pool and excluded from NAV.
  • Anyone may call claimProtocolFees() to send the accrued USDC to TangentTreasury. The treasury address and its USDC balance are shown on the Transparency page and returned by /api/pool.
  • The remaining 80% of every spread stays in the pool for LPs.

Risks

  • Hedge & funding risk — each perp hedge pays or receives funding and carries basis versus its spot token; a fast market can leave a temporary gap between inventory and hedge.
  • Operator dependency — if the hedger stops, prices go stale (trading halts) and NAV relies on the last reported HL equity.
  • Counterparty / venue risk — up to 30% of NAV may be held as margin on Hyperliquid.
  • Liquidity risk — withdrawals are limited to free USDC.
  • Smart-contract risk — parameters are owner-controlled within hard caps; the owner cannot withdraw LP USDC.
  • Oracle risk — Hyperliquid mark manipulation or outages propagate to quotes; the deviation check only protects when two sources are live.

Nothing on this site is financial advice. Do not deposit funds you cannot afford to lose.

Depth-aware lending

The next market Tangent will open is a USDC lending market where collateral limits follow real liquidity rather than a fixed number. Every parameter that normally sits in a governance spreadsheet — loan-to-value, liquidation threshold, borrow caps — is driven by the depth the hedger already measures on the Hyperliquid order book for each collateral asset:

  • Depth feed — the hedger posts a signed depth index to the oracle (USD resting within ±1% / ±2% of mid and the slippage of a reference-size sell), with the same deviation guard and staleness rules as the price feed.
  • Dynamic LTV — the maximum you can borrow against a market token (and later tLP) is a function of that depth and recent volatility. Thin book, lower LTV; thick book, higher LTV. When depth drops below a floor the market switches to repay-only, the same way the pool switches to reduce-only.
  • Liquidations through the pool — liquidators sell seized collateral straight into the Tangent pool or the RFQ channel, and the pool hedges it on Hyperliquid. Liquidation capacity is therefore bounded by real depth, which is exactly what the LTV was sized on.

The lending market ships as soon as the pool has established real, sustained trading volume, because that volume is what proves the depth feed and the liquidation route under live conditions. Watch the Transparency page for volume and the first depth observations.

Options

Tangent writes cash-settled European calls and puts on the HYPE perp price. The pool is the only writer: premiums flow into NAV, the book's liability is deducted from NAV, and payouts are paid from pool USDC. The hedger prices every series with Black-Scholes and delta-hedges the whole book (inventory + options) on Hyperliquid.

Holding an option token means holding a self-adjusting hedged perp position: no margin, no liquidation, no funding to manage. Your maximum loss is the premium you paid.

Series

A series is { perpIndex, expiry, strikeE8, isCall } with id seriesId = uint256(keccak256(abi.encode(perpIndex, expiry, strikeE8, isCall))). Each series is an ERC-1155 token id on TangentOptions; 1e18 units = 1 HYPE of notional. The hedger auto-rolls series for the next 24 h and 7 d expiries (aligned to 08:00 UTC) at strikes mid × {0.9, 0.95, 1.0, 1.05, 1.1}, calls and puts, each capped by maxOpenInterestE18.

Buying and selling

  1. Pick a cell in the strike ladder and enter an amount in HYPE.
  2. The app requests a firm EIP-712 quote (POST /api/options/quote → quoter). Quotes are valid for ~20 s and refresh automatically.
  3. Approve the exact premium in USDC to TangentOptions, then call buy(quote, signature). The premium goes to the pool; you receive the option units.
  4. To close early, request a sell-back quote (isBuy = false) and call sell(quote, signature): units are burned and the pool pays you the quoted USDC.

Pricing: premium = BS(σ) + max(10 bps of notional, gap buffer) with σ = realised vol (1 h candles, 7 d) × 1.25, floored at 50% and capped at 300%. Sell-back = BS − buffer (floor 0).

Settlement and exercise

After expiry anyone calls settle(seriesId): the settlement price is the oracle 30-minute TWAP (at least half the window must be covered, else InsufficientHistory). Holders then call exercise(seriesId, amount) and receive

call: max(settlePx − K, 0) × amount
put:  max(K − settlePx, 0) × amount

in USDC (E8 → E6, floored). Unexercised in-the-money units stay claimable; the pool keeps the liability on its books until they are exercised.

Risk limits

  • Per-series OI cap — openInterest + amount ≤ maxOpenInterestE18, else OpenInterestCap.
  • Pool liability cap — after every buy the options contract checks liabilityUsdE6() ≤ nav × maxOptionsLiabilityBps / 1e4 (default 20% of NAV), else OptionsLiabilityCap. A breached book also puts the AMM in reduce-only mode.
  • Liability = max(intrinsic, mark) where intrinsic is the on-chain payoff at the last oracle price (always enforced) and mark is the hedger's Black-Scholes mark-to-model (used when reported within markMaxAgeSec, default 600 s).

API

EndpointPurpose
GET /api/options/seriesActive series with on-chain state + quoter prices per unit (premiumUsdE6PerUnit mark, askUsdE6PerUnit buy, bidUsdE6PerUnit sell-back), delta / gamma / vega / sigma, oracle mid, liability / cap
POST /api/options/quote{ seriesId, amountE18, isBuy, trader? } → signed quote (503 when the quoter is offline)
GET /api/options/positions?address=ERC-1155 balances across active + recently settled series, cost basis from OptionBought logs, payout previews
GET /api/options/bookMark liability, intrinsic floor, book delta / gamma / vega, cap utilisation

MCP tools: options_series, options_quote, options_buy_calldata, options_exercise_calldata, options_book. The calldata tools are keyless and return { to, data, value } for you to sign.

API, MCP & skill usage

All endpoints are keyless, JSON, CORS *, bigints serialised as strings. Every response carries chainId and ts.

EndpointPurpose
GET /api/marketsevery market (token, symbol, name, decimals, perp), params, inventory, delta, hedge, oracle mid (E8), HL mark & 24h
GET /api/quote?tokenIn=USDC&tokenOut=WHYPE&amountIn=1000000on-chain quote(); tokens by address or symbol (USDC, WHYPE, UBTC, UETH, USOL, PURR)
GET /api/poolNAV breakdown, share price, supply, fees, hedge freshness, roles
GET /api/riskpause flags, oracle age/source, hedge staleness, cap utilisation, warnings
GET /api/oracleoracle params, per-market posted/native prices, deviation vs HL, last post tx
GET /api/swaps?blocks=2000recent Swap events
GET /api/healthRPC + HL reachability, block number, addresses
POST /api/rfq/quoteproxy to the hedger quoter: { tokenIn, tokenOut, amountIn, taker? } → signed quote (503 RFQ quoter offline when unreachable)
GET /api/rfq/infoRFQ contract, quoter address, minRfqSpreadBps, rfqMaxTradeUsdE6, quoter reachability
GET /api/tranchesenior / junior values, rate, buffer, share prices, token addresses (available: false when not deployed)
GET /api/options/seriesactive option series: on-chain state + quoter mark / ask / bid per unit, delta, oracle mid, liability & cap
POST /api/options/quote{ seriesId, amountE18, isBuy, trader? } → signed option quote (503 when the quoter is offline, 422 on caps)
GET /api/options/positions?address=ERC-1155 option balances, cost basis, mark value and payout previews
GET /api/options/bookoptions liability (intrinsic floor, model mark), cap utilisation, book delta / gamma / vega

/api/risk also returns riskMode and riskPolicy; /api/oracle prices carry twap1h / twap24h; /api/pool carries optionsLiabilityUsdE6.

MCP — POST /mcp is a stateless streamable-HTTP Model Context Protocol server exposing markets, quote, pool, risk, oracle, swap_calldata, deposit_calldata, withdraw_calldata, rfq_quote, rfq_fill_calldata, tranche, tranche_calldata, options_series, options_quote, options_buy_calldata, options_exercise_calldata, options_book. The *_calldata tools return { to, data, value } for you to sign; the server never holds keys. Add it to any MCP client with the URL https://tangent.it.com/mcp.

skill.md — GET /skill.md is a single markdown file that explains the market, the rules, every endpoint, the MCP tools and the calldata helpers. Point an agent at it and it can trade or LP safely.

# quote 1 USDC -> WHYPE
curl -s 'https://tangent.it.com/api/quote?tokenIn=USDC&tokenOut=WHYPE&amountIn=1000000'

# quote 0.001 UBTC -> USDC (UBTC has 8 decimals: 0.001 UBTC = 100000 base units)
curl -s 'https://tangent.it.com/api/quote?tokenIn=UBTC&tokenOut=USDC&amountIn=100000'

# MCP: list tools
curl -s https://tangent.it.com/mcp \
  -H 'content-type: application/json' -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'