# Tangent — Agent Skill

> One-file guide for agents and bots interacting with Tangent — Hyperliquid liquidity, on-chain.
> Spot, RFQ, options and structured yield on Elysium — every unit hedged on Hyperliquid.
> Site: https://tangent.it.com · API: https://tangent.it.com/api/* · MCP: https://tangent.it.com/mcp · Docs: https://tangent.it.com/app/docs

## What it is

Tangent is **one USDC pool** on Elysium that quotes several spot markets against USDC (WHYPE / USDC, UBTC / USDC, UETH / USDC, USOL / USDC, PURR / USDC) off **Hyperliquid perp
mark prices** and hedges every unit of exposure it holds with the matching Hyperliquid perp (WHYPE → HYPE-PERP, UBTC → BTC-PERP, UETH → ETH-PERP, USOL → SOL-PERP, PURR → PURR-PERP). The market
list is data-driven — always read `GET /api/markets` (or the `markets` MCP tool) for the current set. On top of that pool:
**RFQ** for size (signed quotes off real book depth), **cash-settled options** written by the pool, **senior / junior
tranches** on tLP, an **on-chain risk policy** (reduce-only when the hedge lags) and a **free TWAP oracle**. LPs earn spread
and premium with (near) zero directional exposure. 20% of every spread (`protocolShareBps`) accrues to the protocol
treasury (`TangentTreasury`).

## Network

| Item | Value |
| --- | --- |
| Chain | Elysium (chainId **99901**), native gas HYPE (18 dec) |
| RPC | https://elysium-mainnet.g.alchemy.com/v2/alch__-l_b9pAKdG_hc26pQlYX |
| Explorer | https://elysium.kinetiq.xyz/explorer |
| Markets live | yes |

## Addresses (chain 99901)

| Contract | Address |
| --- | --- |
| TangentPool (tLP vault + AMM) | `0x63E9820703bA150068C4533e292D1A1745dcaE87` |
| TangentOracle | `0xCF0FA1a6E2cb9210382D1a0e0808Fc1b7A90eC2c` |
| TangentTreasury | `0xf91b8ebd2552fD513fD74B5307804410FfBe7A31` |
| USDC (6 dec, quote asset) | `0xb47c4C8F73F009CC0C0d3f92B388d13E293F0B65` |
| WHYPE — Wrapped HYPE (18 dec, HL perp #159) | `0xbA876237B0F021A6c6D852d6c26E107997cC5E81` |
| UBTC — Unit Bitcoin (8 dec, HL perp #0) | `0xE9C29585EAe4B9a55b02a9605AEa892B40d972E8` |
| UETH — Unit Ethereum (18 dec, HL perp #1) | `0x7A66A75fe41Bc26867C17fe1bc7D1C076EBd4eCd` |
| USOL — Unit Solana (9 dec, HL perp #5) | `0xd78eC40Ac7412069cA0f223413c7E5E1d18f4315` |
| PURR — Purr (18 dec, HL perp #152) | `0x46b131573Ca7c2674b652BbeB7FC16D530396aEC` |
| TangentRFQ (signed quotes for size) | `0x04d2DAf62010eFf08c6850798CbD8996d0060EA5` |
| TangentTranche (tSR / tJR) | `0x32cc5d0CB5213a72604cCb0B5E81d0e2C93cDB38` |
| TangentOptions (ERC-1155 calls / puts) | `0x39ba3973e41c2D7AFb01b5Bf6F83BAe3127d4Fbd` |
| TangentRewards (buy rewards) | `0x8F0B1f412dFAe3Db6Bb8a9413EA18866cD879b67` |

Live copy: `GET https://tangent.it.com/api/health` (`addresses` field).

## Units

* Prices: **E8** — USD per 1 whole token × 1e8 (`midE8`).
* USD amounts: **E6** — USDC base units.
* Token amounts: each token's own decimals (USDC 6, WHYPE 18, UBTC 8, UETH 18, USOL 9, PURR 18, tLP shares 18). Read `decimals` from `/api/markets` — never assume 18.
* bps: 1 bp = 0.01%.
* All bigints are serialised as **decimal strings** in JSON.

## Pricing rules (what you will be quoted)

```
mid        = oracle.getPrice(perpIndex).pxE8           (Hyperliquid mark, posted by the hedger; fail-closed if stale > maxAgeSec)
inv        = tokenBalance - targetInventory             (signed, token units);  invUsd = inv * mid
dir        = +1 if you SELL token to the pool, -1 if you BUY token from the pool
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)

buy  token with USDC : amountOut = usdcIn / (mid * (1 + spread))
sell token for USDC  : amountOut = tokenIn * mid * (1 - spread)
protocolFeeUsdE6     = tradeUsd * spreadBps * protocolShareBps / 1e8
```

Parameters are per market (`/api/markets` → `params`); WHYPE launched with base 8 bps, skew 40 bps, max 150 bps, max inventory $25,000, max trade $5,000.
Exactly one side of every swap must be USDC; the other side selects the market (any listed token: WHYPE, UBTC, UETH, USOL, PURR). Swaps revert `Expired` if `block.timestamp > deadline`,
`Slippage(out, minOut)` if `amountOut < minAmountOut`, `Paused` / `DirectionPaused` / `MarketDisabled` when halted.

## On-chain risk policy (reduce-only mode)

```
struct RiskPolicy { uint128 maxNetDeltaUsdE6; uint16 breachSpreadBps; bool enforce; }   // defaults 10_000e6, 10, true
netDeltaUsd(id) = (tokenBalance + hedgeSize) * mid                                        // inventory(id).netDeltaUsdE6
riskMode() -> (mode, worstNetDeltaUsdE6, hedgeStale); mode 1 = reduce-only when enforce && (hedgeIsStale() || max |netDeltaUsd| > maxNetDeltaUsdE6)
```

In reduce-only mode `quote` / `swapExactIn` / `swapRFQ` / `depositToken` only accept trades that shrink that market's |netDelta|;
others revert `ReduceOnly(netDeltaUsdE6, maxNetDeltaUsdE6)`. Delta-reducing trades then pay `spread + breachSpreadBps` (capped by maxSpread).
`/api/risk` returns `riskMode` and `riskPolicy` (null on a pool without the policy); `/api/quote` returns 409 `{ revert: "ReduceOnly", explanation }`.
Agents: check `riskMode.mode` before sending size; in reduce-only, only trade in the direction that reduces |net delta| or wait for the next hedge report.

## RFQ for size (TangentRFQ)

For amounts above `maxTradeUsdE6` request a firm, signed quote instead of the AMM:

```
POST https://tangent.it.com/api/rfq/quote   body { tokenIn, tokenOut, amountIn (base units, string), taker? (your address) }
200 -> { quote: { taker, tokenIn, tokenOut, amountIn, amountOut, spreadBps, expiry, nonce }, signature, midE8, slippageBps, spreadBps, fairOut, expiresAt, rfqAddress, chainId, poolAddress }
422 -> { error, code }   size > rfqMaxTradeUsdE6, inventory cap, reduce-only, stale oracle
503 -> { error: "RFQ quoter offline" }
GET  https://tangent.it.com/api/rfq/info    -> { available, rfqAddress, quoterAddress, onchain: { rfq, minRfqSpreadBps, rfqMaxTradeUsdE6 }, quoterStatus }
```

Pricing: spread = clamp(max(minRfqSpreadBps, baseSpread/2 + Hyperliquid book slippage for the hedge size + buffer), minRfqSpreadBps, maxSpreadBps)
at the posted mid, no skew. Quotes expire after ~30 s (`quote.expiry`, unix seconds) and carry a one-time nonce.
Fill: `approve(tokenIn → TangentRFQ, amountIn)` then `TangentRFQ.fill(quote, signature)` (or use `rfq_fill_calldata`).
Reverts: `QuoteExpired`, `NonceUsed`, `BadSigner`, `WrongTaker` (RFQ) and `ReduceOnly`, `RfqPriceOutOfBounds(amountOut, minOut, maxOut)`, `InventoryLimit`, `TradeTooLarge` (pool).
The pool bounds the fill to `fairOut * (1 - maxSpread) <= amountOut <= fairOut` at the current oracle mid, so a stale quote fails rather than fills badly.

## Senior / junior tranches (TangentTranche)

Two ERC-20 claims on tLP held by the tranche contract: `tSR` (senior) and `tJR` (junior), 18 decimals. USD values are E6.

```
totalValue = pool.convertToAssets(tLP balance);  seniorValue = min(seniorEntitlement, totalValue);  juniorValue = totalValue - seniorValue
seniorEntitlement accrues at seniorRateBps / year (default 800 = 8%); junior takes the residual and absorbs first losses
junior buffer = juniorValue * 1e4 / totalValue must stay >= minJuniorBps (default 2000) after senior deposits and junior withdrawals -> else JuniorTooThin
depositSenior/depositJunior(assets USDC E6, receiver) -> shares;  withdrawSenior/withdrawJunior(shares E18, receiver) -> USDC (InsufficientLiquidity if no free USDC)
```

`GET /api/tranche` → `{ available, tranche: { seniorToken, juniorToken, seniorRateBps, minJuniorBps, totalValueUsdE6, seniorValueUsdE6, juniorValueUsdE6, seniorSharePriceE18, juniorSharePriceE18, juniorBufferBps, juniorThin } }`.

## TWAP oracle

`TangentOracle.twap(perpIndex, windowSec) -> (pxE8, coveredSec)`: time-weighted average of posted observations (ring buffer, 512 slots) over
`[now - windowSec, now]`, last observation carried forward. Reverts `InsufficientHistory` until the buffer covers at least `windowSec / 2`.
`/api/oracle` prices include `twap1h` / `twap24h` as `{ pxE8, coveredSec, windowSec }` or `null`. Free to read from any contract on Elysium.

## 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

| Endpoint | Purpose |
| --- | --- |
| `GET /api/options/series` | Active 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/book` | Mark 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.

## Buy rewards

Qualifying buys may receive a hedged position; eligible wallets see it in the app after connecting. Agents can read a wallet's own state with
`GET /api/rewards/status?address=` (or the `rewards_status` MCP tool): `status` 0 none · 1 eligible · 2 claimed, `canClaim { ok, reason }`,
the claimed `position` (series, units) and `payoutPreview`. Claiming: `POST /api/rewards/quote { wallet }` → `TangentRewards.claim(quote, signature)`
(the quote's `trader` is the rewards contract; no approval needed). After expiry: `TangentOptions.settle(seriesId)` if needed, then `TangentRewards.exercise()` pays USDC to the wallet.

## REST endpoints (JSON, CORS `*`, no key)

| Endpoint | Returns |
| --- | --- |
| `/api/markets` | markets[] (token, symbol, name, decimals, perpIndex, params, inventory, delta, hedge, oracle mid E8/age/source, HL mark + 24h), paused, protocolShareBps |
| `/api/quote?tokenIn=USDC&tokenOut=WHYPE&amountIn=1000000` | amountOut, midE8, spreadBps, protocolFeeUsdE6, executionPrice (409 + decoded `revert` on TradeTooLarge / ReduceOnly / …). Works for every market, e.g. `tokenOut=UBTC` |
| `/api/pool` | nav {usdcE6, inventoryUsdE6, hedgeEquityUsdE6, totalE6}, sharePriceE18, totalSupply, fees, hedge freshness, roles, treasury |
| `/api/risk` | status ok/degraded/paused, pause flags, oracle age/source, hedge staleness, cap utilisation, warnings[], riskMode, riskPolicy |
| `/api/oracle` | maxAgeSec, maxDeviationBps, per-market posted/native price, deviation vs HL mark, twap1h / twap24h, last PricePosted tx |
| `POST /api/rfq/quote` | signed RFQ quote (see above) |
| `/api/rfq/info` | RFQ contract, quoter, min spread, max trade, quoter reachability |
| `/api/tranche` | senior / junior tranche state |
| `/api/options/series` | active option series + quoter mark / ask / bid per unit, delta, mid, liability & cap |
| `POST /api/options/quote` | `{ seriesId, amountE18, isBuy, trader? }` → signed option quote |
| `/api/options/positions?address=` | option balances, cost basis, mark value, payout previews |
| `/api/options/book` | options liability, cap utilisation, book delta / gamma / vega |
| `/api/rewards/status?address=` | buy-reward status for one wallet (eligibility, canClaim, position, payout preview) |
| `POST /api/rewards/quote` | `{ wallet, isCall? }` → signed reward quote for `TangentRewards.claim` (422 when not eligible) |
| `/api/swaps?blocks=2000` | recent Swap events |
| `/api/health` | rpc + HL reachability, block number, addresses |

Token parameters accept an address or a symbol: `USDC` or any market token (`WHYPE`, `UBTC`, `UETH`, `USOL`, `PURR`).

## MCP (Model Context Protocol)

Streamable HTTP, **stateless**, keyless: `POST https://tangent.it.com/mcp` with
`Content-Type: application/json` and `Accept: application/json, text/event-stream`.

Tools: `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`, `rewards_status`.

Example (initialize → tools/call):

```bash
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":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
curl -s https://tangent.it.com/mcp -H 'content-type: application/json' -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"quote","arguments":{"tokenIn":"USDC","tokenOut":"WHYPE","amountIn":"1000000"}}}'
```

## Calldata helpers (you sign, we never hold keys)

* `swap_calldata { tokenIn, tokenOut, amountIn, quotedOut?, slippageBps?=50, recipient, deadlineMinutes?=10 }`
  → `{ approve: {to,data,value}, swap: {to,data,value}, minAmountOut, deadline }`
  Flow: `quote` → `swap_calldata` with `quotedOut` → send `approve` (if allowance < amountIn) → send `swap`.
* `deposit_calldata { token?=USDC, amount, receiver }` → `{ approve, deposit }` (USDC → `deposit`; any market token → `depositToken` in-kind at mid·(1−baseSpread)).
* `withdraw_calldata { mode?=assets|shares, amount, receiver, owner? }` → `{ withdraw }` (`withdraw(assets)` or `redeem(shares)`), bounded by `maxWithdraw(owner) = min(ownerAssets, freeUsdc)`.
* `rfq_quote { tokenIn, tokenOut, amountIn, taker? }` → the quoter response above (tool error when the quoter is offline or rejects).
* `rfq_fill_calldata { quote, signature }` → `{ approve: {to: tokenIn, …}, fill: {to: TangentRFQ, …}, expiry }`. Send both before `expiry`.
* `tranche` → `/api/tranche`; `tranche_calldata { tranche: senior|junior, action: deposit|withdraw, amount, receiver }` → `{ approve, deposit }` or `{ withdraw }`.
* `options_series` → `/api/options/series`; `options_quote { seriesId, amountE18, isBuy, trader? }` → signed quote; `options_buy_calldata { quote, signature }` → `{ approve, buy }` (or `{ sell }` for isBuy=false); `options_exercise_calldata { seriesId, amountE18? | holder }` → `{ settle?, exercise, payoutUsdE6 }`; `options_book` → `/api/options/book`.
* `rewards_status { address }` → `/api/rewards/status` for that wallet.

Direct ABI (viem human-readable):

```
function quote(address tokenIn, address tokenOut, uint256 amountIn) view returns (uint256 amountOut, uint256 midE8, uint256 spreadBps, uint256 protocolFeeUsdE6)
function swapExactIn(address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, address to, uint256 deadline) returns (uint256 amountOut)
function deposit(uint256 assets, address receiver) returns (uint256 shares)
function depositToken(address token, uint256 amount, address receiver) returns (uint256 shares)
function withdraw(uint256 assets, address receiver, address owner) returns (uint256 shares)
function redeem(uint256 shares, address receiver, address owner) returns (uint256 assets)
function maxWithdraw(address owner) view returns (uint256)
function sharePriceE18() view returns (uint256)
function nav() view returns (uint256 usdcE6, uint256 inventoryUsdE6, int256 hedgeEquityUsdE6, uint256 totalE6)
function riskMode() view returns (uint8 mode, int256 worstNetDeltaUsdE6, bool hedgeStale)
function riskPolicy() view returns ((uint128 maxNetDeltaUsdE6, uint16 breachSpreadBps, bool enforce))
function rfq() view returns (address)
function minRfqSpreadBps() view returns (uint16)
function rfqMaxTradeUsdE6() view returns (uint128)
// TangentRFQ
struct Quote { address taker; address tokenIn; address tokenOut; uint256 amountIn; uint256 amountOut; uint256 spreadBps; uint256 expiry; uint256 nonce; }
function fill(Quote q, bytes sig) returns (uint256 amountOut)
function cancelNonce(uint256 nonce)
function isNonceUsed(address taker, uint256 nonce) view returns (bool)
// TangentTranche
function depositSenior(uint256 assets, address receiver) returns (uint256 shares)
function depositJunior(uint256 assets, address receiver) returns (uint256 shares)
function withdrawSenior(uint256 shares, address receiver) returns (uint256 assets)
function withdrawJunior(uint256 shares, address receiver) returns (uint256 assets)
function previewDepositSenior(uint256 assets) view returns (uint256 shares)   // + previewDepositJunior / previewWithdrawSenior / previewWithdrawJunior
function seniorToken() view returns (address)
function juniorToken() view returns (address)
// TangentOracle
function twap(uint32 perpIndex, uint32 windowSec) view returns (uint256 pxE8, uint256 coveredSec)
// TangentOptions (ERC-1155; 1e18 units = 1 HYPE)
struct OptionQuote { address trader; uint256 seriesId; uint256 amountE18; uint256 premiumUsdE6; bool isBuy; uint256 expiry; uint256 nonce; }
function buy(OptionQuote q, bytes sig)          // approve USDC premium to TangentOptions first
function sell(OptionQuote q, bytes sig)         // burns units, pool pays premiumUsdE6
function settle(uint256 seriesId)               // anyone, after expiry (30-min oracle TWAP)
function exercise(uint256 seriesId, uint256 amountE18)
function activeSeries() view returns (uint256[])
function series(uint256 id) view returns ((uint32 perpIndex, uint64 expiry, uint256 strikeE8, bool isCall, bool settled, uint256 settlePxE8, uint256 openInterestE18, uint256 maxOpenInterestE18))
```

## Rules of thumb for agents

1. Always fetch `/api/risk` before trading: do not trade if `paused` or the market direction is paused, or oracle `error` is set. If `riskMode.mode` is `reduce-only`, only delta-reducing trades will fill.
2. Always pass `quotedOut` so `minAmountOut` is set; 30–100 bps slippage is typical. Quotes move with the HL mark every few seconds.
3. Keep AMM trades under `maxTradeUsdE6` and check `inventoryUtilisationPct` — large one-directional flow widens spread via `skewSpreadBps`. For bigger size use `rfq_quote` and fill before `expiry`.
4. NAV includes hedger-reported HL equity. If `hedge.stale` is true, LP deposits/withdrawals still work but value may be stale.
5. Tranches: senior deposits and junior withdrawals revert `JuniorTooThin` when the junior buffer would drop below `minJuniorBps`; check `/api/tranche` first.
6. Options: quotes last ~20 s; approve exactly `premiumUsdE6` then `buy` before `quote.expiry`. The quoter returns 422 `OI_CAP` / `LIABILITY_CAP` when a series or the pool is full — try a smaller size or another strike. Sell-back needs no approval.
7. Gas is paid in the chain's native currency (HYPE on Elysium).

## Trust model (today)

Owner (multisig intended) sets params/markets and may move ≤ `maxHedgeCapitalBps` (30%) of NAV to the HL margin account.
Operator (hedger hot key) can only post prices and report hedge state. Guardian can only pause.
Nobody can withdraw LP USDC except LPs themselves. Upgrade path: ElysiumCoreWriter atomic hedging + native precompile price reads.
