Developers

Flywheel engine

The cycle

For each flywheel-enabled coin, one cycle claims fees, spends half on buying the token, burns what it bought, and records the result on the coin's ledger.

flywheel-engine.ts
// For every flywheel coin: claim -> buy 50% -> burn -> log.
const claimable = await getClaimableFees(coin.mint)
if (claimable.lamports < MIN_CLAIM_LAMPORTS) {
  return { ran: false, reason: "below threshold" }
}

// Claim trading fees into the signer (the on-chain fee claimer).
const received = await claimTradingFees(coin, signer)

// Spend 50%, always reserving a buffer for transaction fees.
const spend = Math.floor((received * BUYBACK_BPS) / 10_000) // 5000 = 50%

// Market-buy the token, then send everything bought to the burn.
const bought = await buyToken(coin, spend, signer)
const burnSig = await burnTokens(coin.mint, bought, signer)

await recordBuyback({
  coinMint: coin.mint,
  solAmount: spend,
  tokenAmount: bought,
  burned: true,
  signature: burnSig,
})

Scheduling

The engine is triggered hourly by a Vercel Cron job. The cron endpoint is authenticated with a bearer secret, and a module-level lock prevents overlapping runs.

vercel.json
{
  "crons": [
    { "path": "/api/cron/flywheel", "schedule": "0 * * * *" }
  ]
}

Safety

  • Signer is verified. The engine asserts its signer equals the on-chain fee claimer before it touches any funds, or it aborts.
  • Fails safe.If the signer key is unset, every run is a no-op — funds are never moved.
  • Isolated per coin. One coin failing never blocks the others; slippage is capped on every buy.
Running on $DREAM