Build a treasury fund
A treasury fund that rebalances against a public mandate, skips ticks whose data it can't trust, and signs every decision.
The call
Through 2022, DAO treasuries rode their own token down ninety percent.
expectedThe diversification plan sat on the forum the whole way down, never executed.
REBALANCE_DOWNthe agent is the plan executing: it recomputes the target from the candles every tick and trades the gap, with no conviction to override it.
And when a tick's data looks wrong, it signs a SKIP instead of trading on it.
Every treasury has a policy. Sell some on the way up, rebalance on the way down, keep so much in stables. Then the drawdown comes, the policy meets a human with a conviction, and the postmortem says the same thing it always says: we had a plan and we didn't follow it. Through 2022, DAO treasuries holding mostly their own token rode it down by ninety percent with diversification plans sitting on the forum the whole way.
This agent is the plan, executing. The mandate is a public table. Every tick, it recomputes the target from raw candles, trades only when the gap is real, signs the move, and skips the tick when the data itself looks wrong. The one thing it never does is have a conviction.
Build your own in five minutes.
The four files further down are the whole agent. Open the playground, paste them in, change the prompt and thresholds for your case, and deploy. No Solidity to write, no server, no oracle network to run.
What it actually returns
Three ticks from a backtested week: a quiet tick, a sharp drop, and one where the data came back unusable.
Who runs this in production
A fund manager or a DAO treasury. Investors don't take your word that you followed the mandate; the mandate is a public table, and anyone can recompute the target from the same candles and check it against the signed move.
Design decisions
Each item below maps to a specific choice in the workspace. The workspace is the deployable artifact; this section explains why the choices are what they are.
The policy is a public table, on purpose
The model is never asked what the target should be. A vol-regime table sets it, and anyone can recompute that target from the same candles and check it against the signed move. It isn't that the agent can't override the mandate. It's that every move it makes is checkable against a table you can read, which is what an investor actually wants.
Compute the regime from the candles
Hourly candles for the last 24 hours are public; the stdev of log returns, annualized into the familiar 40-100% range, is mechanical; the regime falls out of the calculation. The agent measures vol from the candles it fetched and ignores any vol number stated in the prompt. If the parameter comes from outside, whoever set it controls the fund.
The judgment is whether to trust the tick
A deterministic table has no answer for messy reality: a venue down, a malformed candle series, spot disagreeing with the latest close. That is where the agent's discretion lives. It emits SKIP, signed with the reason, instead of trading on data it doesn't trust. Deterministic policy, plus a judgment about whether reality matches the inputs.
HOLD and SKIP are signed, and the 5pp band stops thrashing
Most ticks are HOLD; the fund's job is to not move when nothing changed. Signing the HOLD (and the SKIP) is the difference between 'deliberately did nothing' and 'failed to run' on the credential page. The 5pp deadband absorbs noise so the fund doesn't rebalance on every one-percent drift; inside the band is HOLD, outside is a trade.
The four-file workspace
This is what the runtime compiles. Copy it into a fresh playground project (or a sibling directory in your CLI workspace), then deploy. Each tab is one file. The agent.rs is the generic adapter; it’s byte-identical across every reference agent.
---
name: Sovereign Fund
id: fund-v1
model: deepseek-chat
---
You are the Sovereign Fund. $100k notional in USDC and ETH. On every
tick: TWO `fetch_url` calls (live spot + recent candles), compute
realized vol and momentum from the candle series, then commit HOLD,
REBALANCE_UP, REBALANCE_DOWN, or SKIP. Do not narrate. The agent
measures vol from the candles it fetched. A vol number stated in the
prompt is ignored.
## Endpoints (exactly two reads)
1. ETH spot:
`https://api.coinbase.com/v2/prices/ETH-USD/spot`
Response shape: `{"data":{"amount":"<price>","base":"ETH","currency":"USD"}}`
2. ETH hourly candles, last 24h:
`https://api.coinbase.com/api/v3/brokerage/market/products/ETH-USD/candles?start=<now-24h>&end=<now>&granularity=ONE_HOUR`
Response: `{"candles":[{"start":"<unix>","low":"<n>","high":"<n>","open":"<n>","close":"<n>","volume":"<n>"}, ...]}`
## Compute from the candle series
- `realized_vol_24h` = stdev of hourly log returns, annualized as
`stdev × sqrt(24 × 365)`.
- `momentum_24h` = (last close − first close) / first close.
## Vol regime to target ETH share
Read top to bottom. The first row whose condition holds sets the
target; stop there. The rows do not overlap by design.
1. `momentum_24h < −10%` → target 30% (a sharp drop overrides the vol
band; get defensive)
2. `realized_vol_24h > 100%` → target 30%
3. `realized_vol_24h > 80%` → target 40%
4. `realized_vol_24h > 60%` → target 50%
5. `realized_vol_24h > 40%` → target 60%
6. `realized_vol_24h ≤ 40%` AND `momentum_24h > 0` → target 70%
7. `realized_vol_24h ≤ 40%` (momentum ≤ 0) → target 60%
## Decision
`current_share` arrives with each tick (default 50% if absent).
First, judge the data. `SKIP` if a fetch failed, the candle series is
short or malformed, or spot and the latest candle close disagree by
more than a few percent. A bad tick is not a reason to trade; sign the
SKIP with the reason and wait for the next one.
Otherwise apply the deadband:
- `HOLD` if `|current_share − target| ≤ 5pp`.
- `REBALANCE_UP` if `target > current_share + 5pp`.
- `REBALANCE_DOWN` if `target < current_share − 5pp`.
## Output rule (absolute)
Your entire response is the verdict block and nothing else. First
character is `H`, `R`, or `S`. No preamble. No procedure narration. No
code fences. Any character outside the block is a discipline failure.
## Output format (strictly one of)
```
HOLD · ETH=$<price> · share=<n>% · target=<n>% · vol=<n>% · mom=<+/-n>%
```
```
REBALANCE_UP · ETH=$<price> · share=<n>% → target=<n>% · vol=<n>% · mom=<+/-n>%
```
```
REBALANCE_DOWN · ETH=$<price> · share=<n>% → target=<n>% · vol=<n>% · mom=<+/-n>%
```
```
SKIP · ETH=$<price or "?"> · <one clause: which read was unusable>
```
You are an agent that nobody pokes. Two fetches, one decision, write
to chain. The `tick-policy` skill carries the vol-regime table and the
5pp deadband.Variations
Three directions you might push this shape in. Same file model, different thresholds or data sources.
- Swap ETH for BTC, or run three assets with per-asset target tables.
- Extend the candle window to 7 days for slower regime detection and fewer trades.
- Blend short and long momentum (weighted 24h plus 7d) to dampen the reaction to single-day moves.
Ship your own.
You have the four files. Drop them into the playground, make it yours, and deploy to a chain where the agent signs every decision it makes. Scripting your deploys instead? Use the CLI.
Open the playground →Related guides
Other guides that share design choices with this one. Worth a read if you’re still deciding which to start from.
See the reference agent end to end (signed credential, recent run grade, the four files inline) at /poa. Try it live at demo-agents.theseus.network/fund.