Docs

Integration

Everything you need to show a Yoke coin in your own app.

Reading a coin

const c = await yoke.read.curves([token])
// [pair, creator, full, graduated, poolFee, tickLower, tickUpper, pool, vPair, raised, sold]
const [out, spent] = await yoke.read.quoteBuy([token, amountIn])
const pairOut      = await yoke.read.quoteSell([token, tokensIn])

Market cap in raw pair units: (vPair + raised) * SUPPLY / (VT - sold). Progress: sold / 800e24.

The JavaScript engine

This site ships assets/js/engine.js: the contract's maths in BigInt, with the same rounding. It is plain JavaScript, works in the browser and in Node, and has no dependencies.

const E = require('./engine.js')
let c = E.newCurve(5_000n * 10n ** 6n)         // opens at 5,000 USDG
const r = E.buy(c, 1_000n * 10n ** 6n)         // { out, spent, fee, refund, full, state }
c = r.state
E.plan(5_000n * 10n ** 6n)                      // { vPair, raise, grossRaise, endCap, poolPrice, multiple }

It is tested against numbers printed by the real contract on a fork (tests-js/engine.test.mjs), plus 2,000 random trades that check the invariant on three different curves.

Indexing

Everything a front end needs is in the events: Created gives the pair and the virtual reserve, Trade carries the running raised and sold, Graduated gives the pool. After graduation, DexScreener indexes the Uniswap pool by itself.

Mind the public RPCThe chain's public RPC puts a challenge page in front of clients that send many requests, for example a wide eth_getLogs loop or a burst of eth_call. A browser app should read through an indexer or a dedicated RPC rather than scanning logs itself.

Dollar prices

The contract has no dollar price and never needs one. To show dollars, ask DexScreener: https://api.dexscreener.com/latest/dex/tokens/<address> accepts CORS and returns priceUsd per pool, with chain id robinhood. Use the pool with the most liquidity. Treat it as a hint, never as an input to anything on chain.