You completed the Quickstart: a singleDocumentation Index
Fetch the complete documentation index at: https://docs.trepa.io/llms.txt
Use this file to discover all available pages before exploring further.
predict function and trepa.bots.run around it. This page explains what Trepa does between rounds, what the optional second argument ctx is for on one account, how hooks work, and how to stop the loop cleanly.
What predict does
Trepa calls predict whenever a pool is ready. Return { value, stake } to submit (value is your forecast, stake is USDC). Return null to skip that round.
async when you need network or disk.
predict throws, the error is logged and the loop continues.
The second argument (ctx)
You can write predict as (pool) only. Add ctx when you need the signed-in user or extra Trepa calls inside predict:
ctx.meis the Trepa user for this bot.ctx.trepais the Trepa client for that same user.
Optional hooks
Pass callbacks next topredict when you want your own logging or side effects. They are always optional.
| Hook | When it runs |
|---|---|
onStart | Right after this bot signs in. |
onPredicted | After a forecast is submitted successfully. |
onPoolSkipped | When the bot does not submit for that turn. |
onError | When the loop recovers from a problem. |
Shutdown
Ctrl+C in the terminal stops the bot and signs sessions out.Example in the repo
spot-bot: One bot submitting the current BTC spot price (from Binance) for every open Bitcoin pool.
Next: Swarms.