How the rebalancer works
The rebalancer loop runs on a configurable interval (default: every 60 seconds) and applies a simple two-rule policy:- If liquid balance exceeds the threshold: deposit the excess into the configured Blend pool.
- If liquid balance falls below the threshold: withdraw from Blend to restore the target level.
Treasury rebalancing is not subject to agent spending limits. Rebalance moves are internal portfolio management between your wallet and your Blend deposit — they are not outbound payments to third parties.
Treasury tools
| Tool | Parameters | What it does |
|---|---|---|
get_treasury_status | — | Shows liquid balance, Blend deposit amount, supply APY, liquidity threshold, rebalance interval, and the last rebalance action |
set_liquidity_threshold | threshold | Sets the minimum liquid balance; excess above this level auto-deposits to Blend |
optimize_treasury | — | Triggers one immediate rebalance cycle without waiting for the next scheduled interval |
blend_check_rates | — | Reads current Blend supply APY for the configured asset (read-only, no transaction, not subject to spending limits) |
Configuration
Control the treasury entirely through environment variables in your MCP config:| Variable | Default | Purpose |
|---|---|---|
TREASURY_ASSET | xlm | Asset to manage in Blend: xlm or usdc |
LIQUIDITY_THRESHOLD | 10 | Minimum liquid balance to maintain in the wallet |
REBALANCE_INTERVAL_SECONDS | 60 | How often the background rebalancer checks and acts |
XLM_FEE_BUFFER | 5 | XLM reserved for transaction fees when TREASURY_ASSET=xlm (never deposited) |
TREASURY_MAX_PER_REBALANCE | (none) | Optional cap on the amount moved per rebalance cycle |
Treasury configuration example
XLM fee buffer
WhenTREASURY_ASSET=xlm, the rebalancer never deposits the entire XLM balance. The XLM_FEE_BUFFER amount (default: 5 XLM) is always kept liquid to cover transaction fees and the Stellar minimum account reserve. Without this buffer, your agent could become unable to submit transactions.
USDC and the Circle trustline
WhenTREASURY_ASSET=usdc, the rebalancer uses your Circle USDC balance. Note that the treasury status output distinguishes between “Circle USDC” (your standard trustline balance) and the USDC deposited in Blend — Circle USDC is not directly usable in Blend positions.
Checking treasury status
Ask your agent to runget_treasury_status at any time for a full snapshot:
- Liquid balance vs. Blend deposited balance
- Current supply APY from Blend
- Your configured liquidity threshold
- The timestamp and details of the last rebalance action
- Any rebalancer errors
Triggering a manual rebalance
The rebalancer runs automatically, but you can trigger an immediate cycle:Wallet
Fund your agent wallet and set up USDC
Spending Policy
Understand what is and isn’t subject to spending limits