Prices and safety
Which prices Duos uses, how old each may be, and how the moving average makes oracle manipulation unprofitable.
Duos uses two kinds of price, for two different jobs.
| Price | Used for | Source | Age |
|---|---|---|---|
| Display prices | Duos lists, market caps, the launch page | GeckoTerminal pools on Elysium, and the Pair token pools themselves, cached on the Duos server | Refreshed every 1 to 15 minutes |
| Trade prices | Every swap in a Pair token pool | the Duos price feed, read on Elysium inside the swap | Checked against the block time |
Display prices never settle a trade. Coin pools have no oracle at all: a coin's price is set by its own Uniswap pool.
The oracle check
Every swap in a Pair token pool reads two prices: the asset in USD and HYPE in USD. The hook stops the swap when either one is older than its limit: 24 hours for the price and 10 minutes for the price service's heartbeat, see How a Pair token works.
The moving average
The hook keeps a 30 minute moving average of the oracle price, updated on every swap and every poke(). Each trade uses the worse of the two for the trader:
- a buyer of pSOL pays the higher of the live price and the average
- a seller of pSOL gets the lower of the two
When a price moves and stays, the average catches up within about an hour and both sides trade at the new price. When a price spikes and falls back, the average barely moves, so the spike cannot be bought before and sold after.
The attack this stops
Someone deposits $100k into a Pair token pool, pushes the real asset up 5% on its main markets, and sells into the pool at the new price. Fork tests on Elysium mainnet run this case on the production contracts:
| Case | Result |
|---|---|
| Buy 1 HYPE of pSOL, SOL jumps 5%, sell at once | 0.969 HYPE back, the same as a calm round trip: the sell is priced at the pre-jump average |
| SOL drops 5%, buy at once | 94.99% of the tokens the dropped price would give: the buy is priced at the pre-drop average |
| Buy, SOL rises 5% and holds for 2 hours, sell | Paid the new price minus the two 1.5% fees |
| A calm buy and sell | Over 96.9% back: the two fees and a tick |
A pump that holds for an hour on the asset's main markets costs far more than the 5% it would pay out, and the circulation and hourly limits cap what any one pool can pay.
Display prices
The lists on Pairs and the launch page come from the Duos server and are shared by every visitor. Elysium token lists refresh every 15 minutes from GeckoTerminal; Pair token prices and reserves refresh every minute from the pools.
The same model in production elsewhere
Settling trades at an oracle price while a funded pool takes the other side is how several established protocols work:
| Protocol | What settles at the oracle price | Who takes the other side |
|---|---|---|
| GMX v2 | Swaps and perpetuals, priced by Chainlink Data Streams | The liquidity providers of each market's pool |
| Jupiter Perps | Leveraged positions, priced by Edge and checked against Chainlink and Pyth | JLP pool holders |
| Synthetix | Synths, priced by oracle feeds | SNX stakers, as one shared pool |
On Duos the funded side is each Pair token pool's HYPE reserve, filled by buyers and the 1.5% fee, and topped up by the backstop within set limits. See Reserves and the backstop.