Delegate trading with strategy limits#
A strategy lets a delegated key, such as a bot or an agent, trade from your
trader-ledger seat while the program enforces limits you set. This how-to creates
a strategy, hands it to a delegate, and stops it. The routes are
ConfigureStrategy (0x56), StopStrategy (0x57), ResumeStrategy (0x58),
CloseStrategy (0x59) and ResetStrategyCapital (0x5A); see spec/IX.md
§61.5.
1. Write the limits#
Create a JSON file. Amounts are decimal strings of atoms of the settlement token or of shares.
{
"delegate": "<delegate public key>",
"expiresAt": "1767225600",
"allowedActions": ["place", "cancel", "reduce", "merge"],
"allowedMarkets": ["<market address>"],
"allowedMints": ["<settlement mint>"],
"maxOrderQuoteAtoms": "50000000",
"capitalBudgetAtoms": "500000000",
"maxPositionShares": "1000000000",
"maxFeeBps": 200,
"maxSlippageBps": 300,
"maxCoveredOrderTtlSeconds": 900,
"withdrawDestinations": []
}
| Field | Enforced limit |
|---|---|
delegate | The key that may act; omit it for an owner-only strategy |
expiresAt | Inclusive Unix-seconds expiry |
allowedActions | Any of place, cancel, reduce, merge, withdrawQuote |
allowedMarkets | Up to 8 markets |
allowedMints | Up to 4 settlement mints |
maxOrderQuoteAtoms | Quote committed by one order |
capitalBudgetAtoms | Total quote the strategy may commit before the owner resets it |
maxPositionShares | Position ceiling a buy may reach |
maxFeeBps | Highest taker fee a fill may charge |
maxSlippageBps | Furthest an order limit may be from the reference price |
maxCoveredOrderTtlSeconds | Longest lease of a resting order (60 to 3,600 seconds) |
withdrawDestinations | Up to 2 token accounts a delegate may withdraw quote to, beside yours |
2. Create the strategy#
seesaw strategy configure --id 1 --limits-file limits.json
--id is your own strategy number (0 to 65534). Running configure again on the
same ID replaces the limits and the delegate. A delegate cannot act in the slot of
the latest configure; it can from the next slot.
3. Let the delegate trade#
The delegate signs ordinary placements, cancellations, reductions and merges that
name the strategy account. The program rejects any action outside the limits with
a strategy error (0xD001 to 0xD010, see
error codes).
Inspect the strategy with seesaw strategy show and its events with
seesaw strategy history.
4. Stop, resume, reset and close#
seesaw strategy stop --id 1 --markets '["<market>"]'stops the strategy. In each market you pass, it advances the seat-wide strategy epoch and retires the covered orders of every strategy on that seat. Covered orders in other markets stay eligible until their lease expires.seesaw strategy resume --id 1enables execution again.seesaw strategy reset-capital --id 1 --used-capital 0sets used capital and starts a new capital epoch.seesaw strategy close --id 1closes the account and returns its rent to you.
Expired covered orders can be reclaimed by anyone; when that happens under a live strategy, the program restores its capital for the matching capital epoch.