Arbitrage is the simplest trading strategy to state: when the same thing has two prices, buy it where it is cheap and sell it where it is dear. If both trades go through, the profit doesn't depend on which way the price moves next. This guide explains the two kinds an agent can run with perps, shows where the profit really comes from, and covers the ways a "riskless" trade loses money.
It assumes the perp guide: the same $1,000 and SPCX at $100. The figures are a teaching model with made-up prices.
1. What arbitrage is
An arbitrage holds two positions, called legs, that cancel each other's exposure to the price. Long 10 SPCX in one place and short 10 SPCX in another is delta-neutral: if SPCX rises $1, one leg makes $10 and the other loses $10. What's left is the reason for the trade: a gap between the two prices, or a payment one leg receives, such as funding.
Every arbitrage answers the same three questions:
- What is the gap? A difference in price, or a payment like funding.
- What does it cost to capture? Fees, slippage, and the margin or capital tied up while you hold.
- What can break the hedge? A leg that doesn't fill, a leg that's liquidated, a gap that widens before it closes.
2. Two prices: cross-venue arbitrage
SPCX's perp trades at $100.00 on one venue and $100.40 on another. You buy on the cheap one and sell on the dear one, at the same moment. You are now long and short the same amount, so price moves cancel, and you've locked in $0.40 a unit.
Locked in, minus costs:
- Fees. Each trade pays the venue a fee. At 2 bp a trade, buying and selling $100 of SPCX costs about $0.04 a unit.
- Slippage. Each venue's book only has so much SPCX near its price. The more you trade, the further down the book you go, and the worse your average price. Slippage grows with size faster than the profit does.
So every gap has a best size: big enough to be worth it, small enough that your own trades don't eat the gap.
How much to trade when SPCX has two prices
SPCX is $100.00 on one venue. Set how much dearer the other is, what each trade costs, and how deep the books are. The curve is your profit at each size.
The profit is the gap times the size, minus fees, which grow in line with the size, minus slippage, which grows with the square of it. The peak is the best size, and past the break-even size you're paying to trade.
3. Funding: cash and carry
The second kind needs no second price, only patience. When a perp's funding is positive, longs pay shorts. So you short the perp and collect funding, and you buy the same amount of SPCX itself (spot) so the price can't hurt you. This is called cash and carry, or a basis trade.
With your $1,000, the trade is two tickets that share it. The perp ticket has the same numbers as in the perp guide:
| Number | Spot leg | Perp leg | What it is |
|---|---|---|---|
| SPCX price | $100 | $100 | Both legs open at the same price. |
| Committed | $833 | $167 of margin | Your $1,000, split so both legs hold the same SPCX. |
| Leverage | 1× | 5× | Spot is never leveraged; you choose the perp's. |
| Notional | $833 | $833 | $167 × 5 on the perp. |
| Position | +8.3 SPCX | −8.3 SPCX | Long on one side, short on the other: they cancel. |
And the ledger, as SPCX moves, before funding:
| SPCX | Spot leg PnL | Perp leg PnL | Together |
|---|---|---|---|
| $110 | +$83 | −$83 | $0 |
| $100 | $0 | $0 | $0 |
| $90 | −$83 | +$83 | $0 |
What's left is funding: every hour, the perp leg collects it on its $833 notional.
The catch is that the legs are in two places. The spot leg's gains sit in your SPCX, while the short leg's losses eat its margin. In a rally the short leg can be liquidated, even though your total is fine, unless you move dollars to it in time. Once it is liquidated, you're simply long SPCX, the bet you set out to avoid.
Collecting funding with your $1,000
Pick what SPCX does over 30 days, the funding rate, and the short leg's leverage. The middle panel splits your PnL into the two legs and the funding.
While both legs stand, price moves cancel and only funding is left. The risk is the short leg's margin: the spot leg's gains can't pay for it unless you move dollars across in time.
4. What can go wrong
5. When to use it, and when not to
6. Parameters
The numbers an arbitrage bot needs before it trades:
| Parameter | What it means |
|---|---|
| Entry threshold | The smallest gap, after costs, worth trading. Below it, do nothing. |
| Size | How much to trade, from the gap, the books' depth and the position cap. |
| Costs | Fees on each venue, expected slippage, and transaction fees. |
| Leg leverage | The margin each perp leg gets, which sets how far the price can move before it's liquidated. |
| Exit rule | When to unwind: the gap closed, funding turned, or a leg needs margin it can't get. |
7. Arbitrage under a mandate
The mandate can hold both kinds: it allows spot
instruments, and a universe that spans several venues, with the account's
value added up across them.
Cross-venue arbitrage on SOL allows the same pair on two venues, both sides:
{
"version": "v0",
"universe": [
{ "instrument": "openbook:spot:SOL-USDC", "max_position": 100 },
{ "instrument": "phoenix:spot:SOL-USDC", "max_position": 100 }
],
"limits": { "max_drawdown_usd": 500 }
}
Both allowances measure the same SOL, held wherever it is, so the cap bounds the SOL the agent has bought and not yet sold, across both venues.
Cash and carry pairs a spot leg with a perp leg on the same asset:
openbook:spot:SOL-USDC long and phoenix:perp:SOL short. The spot
position is the SOL held; the perp position is the short. Setting both caps
equal keeps the agent from holding more on one leg than the other, and the
drawdown limit covers the two legs together, since the account's value adds
them up.
Neither mandate says the legs must match: it bounds what the agent may hold, not how it hedges. A short perp leg left without its spot leg is within both caps, and only the drawdown limit catches what it costs.
8. Check yourself
SPCX is $100.00 on one venue and $100.05 on another, and each trade costs 3 bp. Should you trade the gap?
No. Buying and selling $100 of SPCX costs 3 bp twice, about $0.06 a unit, more than the $0.05 gap, before any slippage.
You're long 10 SPCX spot and short 10 SPCX on the perp. SPCX falls $8. What's your PnL, before funding?
Zero. The spot leg loses $80 and the short gains $80.
In cash and carry, why can a rally hurt you even though the legs cancel?
The short leg's losses come out of its margin on the perp venue, while the spot leg's gains stay in SPCX. If the short leg is liquidated, you're left long SPCX alone, with no hedge.
Who closes an arbitrage gap?
The arbitrageurs. Buying where it's cheap pushes that price up, and selling where it's dear pushes that one down, until the gap is smaller than the cost of trading it.
9. Glossary
Every term this guide uses is in the glossary. In the text, an underlined term shows its definition when you hover it or tap it.