Integrate
For aggregators, wallets, and developers routing to Spherra. Addresses and a hosted ABI go live at mainnet; until then, everything is in the repo.
Quickstart (viem)
import { createPublicClient, http } from 'viem'
const client = createPublicClient({ transport: http(RPC_URL) })
// quote is a view — no state change, no fee applied in the quote path
const [amountOut, segments] = await client.readContract({
address: POOL, abi: orbitalAbi, functionName: 'quote',
args: [tokenInIndex, tokenOutIndex, amountIn],
})
// swap (write): minAmountOut is your slippage bound; reverts if unmet
// await walletClient.writeContract({ address: POOL, abi: orbitalAbi,
// functionName: 'swap', args: [tokenIn, tokenOut, amountIn, minAmountOut] })
Tokens are addressed by their index in the pool (0-based), not by address, in the swap/quote calls.
Reads (views)
| Function | Returns | Use |
|---|---|---|
quote(tokenIn, tokenOut, amountIn) | (amountOut, segments) | Price a trade; segments = tick crossings |
invariantResidual() | int256 F | Pool health; F ≤ 0 = in band |
tickReserves(tickId) | uint256[] effective | Per-tick effective reserves |
impliedPrice(token) | uint256 (WAD) | Pool's implied price for a token |
quarantineDepth() | uint256 | How many layers are quarantined |
nActive() | uint8 | Active token count |
Writes
| Function | Purpose |
|---|---|
swap(tokenIn, tokenOut, amountIn, minAmountOut) | Trade on the sphere |
addLiquidityAtDepeg(pDepeg, maxAmounts, minShares) | Provide liquidity at a tick |
removeLiquidity(tickId, sharesBurn, minAmounts) | Withdraw |
claim(tickId) | Redeem settled proceeds |
poke() | Advance the implied-price accumulator (permissionless) |
Lifecycle writes (freeze, unfreeze, queueSettle, settle, lift) are covered in Lifecycle & safety.
For aggregators
- Source depth from
quote; notesegmentsgrows with trade size as tick planes are crossed (more gas). - The pool holds up to 30 stables in one venue — one integration surfaces the whole book.
- Events (swaps, liquidity,
TickCrossed, lifecycle) support a subgraph for TVL/volume; a reference schema
ships with the dev docs.
v1 constraints
18-decimal tokens only; no fee-on-transfer/rebasing tokens; feeless (no fee to account for in routing). See Security & risk for the full list.