🩹

Testnet arbitrage bot

Status: Completed

Announced: Jan 11

Reward: $2000 + 2 HSC

This bot will run at random times to bring the mark price on Hubble within +-10% of FTX and Binance.

Treat the pool like a uniswap pool: xy = k
where x = usd balance, y = base asset balance in the pool

Let x' and y' denote new pool balances and p denote the target mark price
=> x'/y'= p

From uniswap invariant, xy = x'y'
=> p * (y')^2 = xy
=> y' = sqrt(xy/p)

if (y' < y) Long(y - y')
else if (y' > y) Short(y' - y)

---

E.g.
Say ether is priced at $1k and pool has 1k ether,
so x = 1e6 and y = 1e3, spot price = $1k

We want to get the mark price to $1050,
y' = sqrt(1e6 * 1e3 / 1050) = ~976
=> Long 24 eth