AI Agent Integration#
AI agents can trade autonomously on Seesaw binary prediction markets using the same SDK surface available to any client.
Overview#
AI agents can autonomously:
- Monitor real-time price feeds from Pyth Network
- Analyze market positions and implied probabilities
- Execute trading strategies based on programmable logic
- Manage positions and claim settlements
Agent tool server (MCP)#
@seesaw/agent-mcp gives an agent tools for the whole trading workflow: discover, inspect terms,
quote, simulate, authorize, submit, reconcile, cancel or recover. It runs as a stdio MCP server
next to the agent, with your own RPC endpoint and, optionally, your own indexer. Read-only mode
needs no key. See Agent tools over MCP for the modes, the tools and
what enforces each limit.
Agent Skill#
The trading skill supplies protocol context. It does not authorize transactions or replace deployment validation.
Skill Installation#
The skill is available as a standalone markdown file that can be loaded into AI agent frameworks:
Raw Skill URL:
https://seesaw.markets/api/docs/downloads/trading-skill
Skill Contents#
The Seesaw Trading Skill provides:
| Section | Description |
|---|---|
| Protocol Overview | Binary prediction market mechanics |
| Market Lifecycle | All states from PENDING to CLOSED |
| Price Fetching | Pyth Hermes SSE streaming integration |
| Order Book Mechanics | YES/NO conversion, tick rounding |
| Trading Instructions | place_order, cancel_order, settle |
| API Endpoints | REST endpoints for market data |
| Trading Strategy Framework | Position analysis, probability estimation |
| Decision Logic | When to buy YES, buy NO, or hold |
| Fee Structure | Capped-linear-decay curve, five-way allocation, eligible rebates |
| Resolution Rules | How markets settle |
| PDA Derivation | Account address computation |
| Risk Management | Position limits, invariants, errors |
Loading the Skill#
Local Skill Runtimes#
Install as a local skill:
(
set -eu
skill_temp=$(mktemp -d)
trap 'rm -rf "$skill_temp"' EXIT
curl --fail --silent --show-error -D "$skill_temp/headers" \
-o "$skill_temp/skill.md" https://seesaw.markets/api/docs/downloads/trading-skill
grep -qi '^content-type: text/markdown' "$skill_temp/headers"
test "$(head -n 1 "$skill_temp/skill.md")" = '---'
grep -q '^skill_name: seesaw-trading' "$skill_temp/skill.md"
mkdir -p ~/.config/agent-skills/seesaw-trading
cp "$skill_temp/skill.md" ~/.config/agent-skills/seesaw-trading/SKILL.md
)
Or reference directly in your agent configuration:
{
"skills": {
"seesaw-trading": {
"url": "https://seesaw.markets/api/docs/downloads/trading-skill"
}
}
}
LangChain / LlamaIndex#
Load as a document:
from urllib.request import urlopen
url = "https://seesaw.markets/api/docs/downloads/trading-skill"
with urlopen(url, timeout=15) as response:
if response.headers.get_content_type() != "text/markdown":
raise ValueError("Expected Markdown")
skill = response.read().decode("utf-8")
if not skill.startswith("---\n") or "skill_name: seesaw-trading" not in skill:
raise ValueError("Unexpected skill document")
print(len(skill))
# Pass the validated text to the framework's document adapter.
Custom Agents#
Fetch and parse the skill directly:
// docs-check: semantic
const skillUrl = 'https://seesaw.markets/api/docs/downloads/trading-skill';
async function loadTradingSkill(): Promise<string> {
const response = await fetch(skillUrl);
if (!response.ok || !response.headers.get('content-type')?.startsWith('text/markdown')) {
throw new Error('Expected a successful Markdown response');
}
const text = await response.text();
if (!text.startsWith('---\n') || !text.includes('skill_name: seesaw-trading')) {
throw new Error('Unexpected skill document');
}
return text;
}
// Add to agent's system prompt or knowledge base
async function main() {
const skill = await loadTradingSkill();
const agent = { addContext: (context: string) => console.log(context.length) };
agent.addContext(skill);
}
void main();
Key Capabilities#
1. Real-Time Price Monitoring#
Agents should connect to Pyth Hermes for streaming prices:
// docs-check: semantic
const PYTH_FEED_IDS = {
'BTC/USD': '0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
'ETH/USD': '0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
'SOL/USD': '0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d',
} as const;
type FeedSymbol = keyof typeof PYTH_FEED_IDS;
function buildPythStreamProxyUrl(feedId: string): string {
const url = new URL('/api/pyth/stream', 'https://api.seesaw.markets');
url.searchParams.set('ids[]', feedId);
return url.toString();
}
const feedSymbol: FeedSymbol = 'SOL/USD';
const feedId = PYTH_FEED_IDS[feedSymbol];
// Browser-native EventSource cannot attach the private Pyth bearer token.
// Use a configured app proxy that injects PYTH_API_KEY server-side and reconnect
// before the 24-hour Pyth stream limit. Do not hard-code indexer REST aliases.
const streamUrl = buildPythStreamProxyUrl(feedId);
console.log(streamUrl);
2. Market Position Analysis#
Compute whether current price favors YES or NO:
// docs-check: semantic
interface MarketPosition {
delta: number; // currentPrice - startPrice
deltaPct: number; // Percentage change
status: 'above' | 'below' | 'at';
isAbove: boolean;
isBelow: boolean;
}
function computeMarketPosition(startPrice: number, currentPrice: number): MarketPosition {
const delta = currentPrice - startPrice;
const deltaPct = delta / startPrice;
const status = deltaPct > 0.0001 ? 'above' : deltaPct < -0.0001 ? 'below' : 'at';
return {
delta,
deltaPct,
status,
isAbove: status === 'above',
isBelow: status === 'below',
};
}
const position = computeMarketPosition(100, 101);
console.log(position.status, position.deltaPct);
3. Trading Signal Generation#
The skill includes a complete decision framework:
// docs-check: semantic
interface TradingSignal {
action: 'buy_yes' | 'buy_no' | 'hold';
confidence: number;
reason: string;
suggestedPrice: number;
suggestedQuantity: number;
}
// See full implementation in the skill file
function analyzeTradeOpportunity(
startPrice: number,
currentPrice: number,
marketBestBid: number,
marketBestAsk: number,
timeRemainingSeconds: number
): TradingSignal;
function analyzeTradeOpportunity(
startPrice: number,
currentPrice: number,
marketBestBid: number,
marketBestAsk: number,
timeRemainingSeconds: number
): TradingSignal {
const priceIsAboveStart = currentPrice > startPrice;
const midPriceBps = Math.floor((marketBestBid + marketBestAsk) / 2);
const enoughTime = timeRemainingSeconds > 60;
if (!enoughTime) {
return {
action: 'hold',
confidence: 0.2,
reason: 'market is close to expiry',
suggestedPrice: midPriceBps,
suggestedQuantity: 0,
};
}
return {
action: priceIsAboveStart ? 'buy_yes' : 'buy_no',
confidence: 0.6,
reason: priceIsAboveStart ? 'current price is above start' : 'current price is below start',
suggestedPrice: midPriceBps,
suggestedQuantity: 1_000_000,
};
}
const signal = analyzeTradeOpportunity(100, 101, 4_900, 5_100, 300);
console.log(signal.action, signal.suggestedPrice);
4. Order Execution#
This example describes order intent. It does not build, sign, or submit a transaction:
// docs-check: semantic
import { OrderType, type OrderIntent } from '@seesaw/core';
// Bullish on price going up: buy the YES outcome. The price is quoted in the
// named outcome's own space (YES price here) and is never complemented.
const order: OrderIntent = { outcome: 'YES', intent: 'BUY', priceBps: 5_100, quantity: 1_000_000n };
const orderType = OrderType.Limit; // match then rest on book
console.log({ ...order, orderType });
Decision Framework#
Explanation context. The tables below describe a simple example decision logic for illustrative purposes. Real trading strategies vary widely. The Seesaw Trading Skill contains a more complete decision framework for AI agents.
When to Trade#
| Condition | Action | Rationale |
|---|---|---|
| Price above start, market underpricing YES | Buy YES | Capture mispricing |
| Price below start, market underpricing NO | Buy NO | Capture mispricing |
| Strong momentum up, time remaining | Buy YES | Momentum play |
| Strong momentum down, time remaining | Buy NO | Momentum play |
| No clear edge | Hold | Preserve capital |
| < 60 seconds remaining | Hold/Exit | Too risky |
Risk Considerations#
Explanation context. These mitigations are design-level guidelines, not enforced constraints. Wire-level validations and on-chain invariants are described in Security.
| Risk | Mitigation |
|---|---|
| Position limits | Max shares per market |
| Time decay | Reduce aggression near end |
| Oracle confidence | Check confidence interval |
| Slippage | Use limit orders |
| Unknown transactions | Reconcile the recorded signature before new signing |
API Integration#
REST Endpoints#
These endpoints supply market observations. For the full surface (positions, trades, fee config, WebSocket subscriptions) see the API Reference.
| Endpoint | Description |
|---|---|
GET /api/v1/markets | List all markets |
GET /api/v1/markets/current | Get active market |
GET /api/v1/markets/{id} | Market details + orderbook |
These are served by Seesaw's hosted indexer (the @seesaw/core API client
wraps them as client.api.markets.list()/current()/get()).
Reading without the indexer#
For a known market identity, derive PDAs and decode finalized account bytes with
@seesaw/core. Market discovery, RPC fetching and validation
of related accounts remain application responsibilities. The SDK does not ship
an automatic place-order account resolver. Use createResilientDataSource for its supported fallback reads.
client.creator.listMarkets(wallet) is an indexer-backed creator listing, not
RPC discovery. Build instructions from verified accounts using
the transaction builders.
Read-only iteration#
Use the read-only example for one validated API response.
The example uses exchangeMarketsResponseSchema. It accepts the exchange markets envelope.
It reports missing markets, missing prices, malformed responses, and transport failures.
It does not infer an oracle price or authorize an order.
Source: packages/core/examples/10-read-only-agent.ts. Generated by node scripts/docs_examples.mjs --write.
import { exchangeMarketsResponseSchema } from '../src/api/exchange.js';
export type ReadOnlyResult =
| { status: 'missing-market' | 'missing-price' | 'malformed' | 'unavailable' }
| { status: 'observed'; market: string; bestBidBps: number; bestAskBps: number };
/** One read. No wallet, signing, timers, or invented oracle prices. */
export async function readOnlyIteration(
fetchMarkets: () => Promise<unknown>
): Promise<ReadOnlyResult> {
let raw: unknown;
try {
raw = await fetchMarkets();
} catch {
return { status: 'unavailable' };
}
const parsed = exchangeMarketsResponseSchema.safeParse(raw);
if (!parsed.success) return { status: 'malformed' };
const market = parsed.data.markets[0];
if (!market) return { status: 'missing-market' };
if (market.bestBid === null || market.bestAsk === null) return { status: 'missing-price' };
return {
status: 'observed',
market: market.marketAddress,
bestBidBps: market.bestBid,
bestAskBps: market.bestAsk,
};
}
Authorized execution#
Use the execution example only after a user approves the reviewed-intent digest.
Use the persistent journal adapter for Node storage.
The host must build and simulate the exact transaction from placeOrderParamsFromReviewedIntent.
The host must supply fresh account, fee, scope, and Clock observations.
An unknown attempt blocks a replacement. A lost response does not authorize another order.
See recovery procedures and the Node tutorial.
Download the integration AGENTS template for an integration project. This template sets application boundaries. It does not replace repository maintainer instructions.
Instruction routes#
Build instructions with the SDK builders. The route table below is generated from the IDL.
<!-- @generated:agent-abi-facts begin (scripts/generate_agent_abi_facts.mjs) --> <!-- prettier-ignore-start -->| Tag | Route | Payload bytes | Accounts |
|---|---|---|---|
0x00 | InitializeConfig | 2 | 15 |
0x01 | UpdateAuthority | 32 | 4 |
0x02 | ClaimAuthority | 0 | 4 |
0x03 | CreateMarket | 30 | 20, 21 |
0x04 | SnapshotEnd | 0 | 7 |
0x05 | ResolveMarket | 0 | 11 |
0x06 | ExpireMarket | 0 | 10 |
0x07 | MintShares | 8 | 14 |
0x08 | DepositFunds | 8 | 12 |
0x09 | WithdrawFunds | 9 | 11–14 |
0x0A | WithdrawShares | 9 | 11 |
0x0B | MergeCompleteSet | 25 | 16–18 |
0x0C | PlaceOrder | 86 | 21–42 |
0x0D | PlaceMultiplePostOnly | ≥ 61 | 21, 22 |
0x0E | SwapWithFreeFunds | 88 | 21–45 |
0x0F | PlaceLimitWithFreeFunds | 88 | 21–45 |
0x10 | BatchPostOnlyWithFreeFunds | ≥ 63 | 21–25 |
0x11 | CancelOrder | 8 | 18 |
0x12 | CancelMultipleOrdersById | variable | 18 |
0x13 | ReduceOrder | 16 | 19 |
0x14 | CancelMultipleOrdersByIdWithFreeFunds | variable | 8–10 |
0x15 | ReduceOrderWithFreeFunds | 17 | 9–11 |
0x16 | ReclaimExpiredOrder | 8 | 19–21 |
0x17 | Redeem | 9 | 13, 14, 16, 17 |
0x18 | ForceClose | 0 | 16 |
0x19 | MarkPositionSettled | 0 | 10, 11 |
0x1A | ClosePosition | 0 | 8, 9 |
0x1B | CloseMarket | 0 | 17–20 |
0x1C | UpdateFeeConfig | 18 | 4 |
0x1D | UpdateTreasuryRecipients | 0 | 12 |
0x1E | SetReferrer | 0 | 7 |
0x1F | ClaimCreatorFees | 0 | 8, 9 |
0x20 | Pause | 0 | 4 |
0x21 | Unpause | 0 | 4 |
0x22 | EnablePostOnlyMode | 0 | 4 |
0x23 | DisablePostOnlyMode | 0 | 4 |
0x24 | UpdateTickSize | 2 | 4 |
0x25 | UpdateMinRestingNotional | 8 | 4 |
0x26 | UpdateMarketCap | 8 | 6 |
0x27 | SetMarketEmergencyStatus | 33 | 6 |
0x28 | ForceCancelMarketOrders | 8 | 20 |
0x29 | SetPauser | 32 | 4 |
0x2A | UpdateOperationalParams | 115 | 4 |
0x2B | EnsureTraderLedgerSpace | 0 or 48 | 7, 8 |
0x2C | EnsureDeepOrderbookSpace | 0 or 48 | 5–8 |
0x2D | TopUpCloserRewards | 0 | 6 |
0x2E | InitSplineSeries | 409 | 8–11 |
0x2F | UpdateSeriesTemplate | 702 | 2, 4 |
0x30 | UpdateSeatQuote | 16, 62, or 126 | 2 |
0x31 | AttachSeat | 8 | 12 |
0x32 | SettleSeat | 0 | 10, 11 |
0x33 | RecoverSeat | 0 | 15 |
0x34 | DepositSeriesVault | 8 | 7, 9 |
0x35 | WithdrawSeriesVault | 8 | 6, 8 |
0x36 | CloseSplineSeries | 0 | 6 |
0x37 | BeginSourceMarket | variable | 12 |
0x38 | OpenSourceMarket | variable | 25 |
0x39 | ExpireExternalMarket | 0 | 9 |
0x3A | ClosePreallocatedChild | 1 | 3 |
0x3B | ReclaimExternalMarketPreallocation | 0 | 11 |
0x3C | TopUpExternalProgressReserve | 0 | 5 |
0x3D | EvacuateIdleSeat | 12 | 19, 20 |
0x3E | ResolveSourceMarket | variable | 11 |
0x3F | HaltSourceMarket | variable | 11 |
0x40 | UpdateSourceClose | variable | 11 |
0x41 | FinalizeSourceMarket | 0 | 9 |
0x42 | CloseSourceAccounts | 0 | 20 |
0x43 | InitializeSourceControl | 1 | 7 |
0x44 | SetSourceProfilePolicy | 128 | 6 |
0x45 | InitializeWitnessRegistry | 69 | 7 |
0x46 | RevokeWitnessSlot | 5 | 5, 6 |
0x47 | SetWitnessMeasurement | 35 | 5 |
0x48 | RegisterAttestedWitness | 497 | 7 |
0x49 | RotateSeatQuoteAuthority | 48 | 2 |
0x4A | ApproveBuilder | 10 | 7 |
0x4B | RevokeBuilder | 0 | 4 |
0x4C | SetCurrencyFreezeException | 1 | 7 |
0x4D | RegisterCurrency | 0 | 7, 8 |
0x4E | InitializeCurrencyReferralTreasury | 1 | 9, 10 |
0x4F | InitializeCurrencyReferrerEarnings | 1 | 9, 10 |
0x50 | ClaimCurrencyReferrerEarnings | 0 | 9 |
0x51 | RollupCurrencyReferralFees | 1 | 11–19 |
0x52 | InitializeCurrencyProtocolTreasury | 1 | 9, 10 |
0x53 | WithdrawCurrencyProtocolTreasury | 9 | 9 |
0x54 | CancelOrderByClientId | 18 | 13–16, 18 |
0x55 | CancelOwnerOrders | 26 | 13–16 |
0x56 | ConfigureStrategy | 523 | 5 |
0x57 | StopStrategy | 1 | 4, 6, 8, 10, 12 |
0x58 | ResumeStrategy | 0 | 4 |
0x59 | CloseStrategy | 0 | 4 |
0x5A | ResetStrategyCapital | 8 | 4 |
0x5B | UpdateSeatTables | 326 | 7, 8 |
0x5C | TopUpSeatCommitment | 8 | 10 |
0x5D | AttachSeatFromSeries | 0 | 12 |
0x5E | UpdateSeriesSubscription | 66 | 5 |
0x5F | TopUpSeriesLamports | 8 | 5 |
0x60 | FlagSeatBelowFloor | 0 | 6, 7 |
0x61 | MakeSeatDormant | 0 | 6, 7 |
0x62 | CloseSeat | 0 | 5 |
0x63 | AssertBalances | 53 | 5, 6 |
0x64 | ReplaceMakerQuotes | 130 | 8 |
0x65 | SetMakerQuoteAuthority | 100 | 6 |
0x66 | InitializeMakerQuoteState | 56 | 7 |
0x67 | CloseMakerQuoteState | 0 | 7, 13, 15, 16, 21, 22, 24, 25 |
0x68 | FundMakerQuoteInventory | 18 | 6, 9–12 |
0x69 | WithdrawMakerQuoteInventory | 10 | 9, 11 |
0x6A | ReclaimExpiredOrders | 129 | 13 |
0x6B | CreateConfidentialMarket | 295 | 10, 11 |
0x6C | RecordConfidentialTerminal | 1 or 48 | 5, 7 |
0x6D | ClaimOwnerPayoutEscrow | 0 | 9 |
0x6E | UpdateSeatParams | 154 | 2 |
0x6F | UpdateSeatProgram | 360 | 7, 8 |
0x70 | OpenConfidentialJob | 143 | 0 |
0x71 | AppendConfidentialJobPage | variable | 0 |
0x72 | SealConfidentialJob | 0 | 0 |
0x73 | CommitConfidentialJob | 0 | 0 |
0x74 | AbortConfidentialJob | 0 | 0 |
0x75 | TopUpConfidentialWorkBudget | variable | 0 |
0x76 | IncreaseConfidentialCap | 8 | 0 |
0x77 | CloseConfidentialMarket | 0 | 0 |
0x78 | FundConfidentialEscrow | 322 | 0 |
0x79 | PrepareConfidentialStep | 359 | 0 |
0x7A | RefundConfidentialObject | 35 | 0 |
0x7B | CreateConfidentialClaims | 609 | 0 |
0x7C | MaterializeConfidentialClaim | 69 | 0 |
0x7D | RefundConfidentialClaim | 35 | 0 |
0x7E | UploadConfidentialCapsule | ≥ 2 | 0 |
0x7F | ReclaimConfidentialCapsuleSlot | 0 | 0 |
0x80 | ActivateConfidentialRfq | ≥ 476 | 0 |
0x81 | SettleConfidentialCell | 78 | 0 |
0x82 | SettleConfidentialPublicCell | ≥ 52 | 0 |
0x83 | ClaimConfidentialRole | 634 | 0 |
0x84 | CloseConfidentialCellByAgreement | 76 | 0 |
0x85 | NovateConfidentialCell | 84 | 0 |
0x86 | AssignConfidentialCell | 68 | 0 |
0x87 | ReassignConfidentialClaim | 67 | 0 |
0x88 | RekeyConfidentialCell | 67 | 0 |
0x89 | PostConfidentialRemainingOrder | 67 | 0 |
0x8A | FillConfidentialOrder | 103 | 0 |
0x8B | RefundConfidentialRemainder | 51 | 0 |
0x8C | SplitConfidentialCountedRun | 51 | 0 |
0x8D | ReplaceConfidentialCellDyadic | 107 | 0 |
0x8E | SplitConfidentialCell | 70 | 0 |
0x8F | RekeyConfidentialSplitRole | 35 | 0 |
0x90 | MergeConfidentialCells | 37 | 0 |
0x91 | CertifyConfidentialClosure | 102 | 0 |
0x92 | ReclaimConfidentialStorage | 0 | 0 |
0x93 | CommitConfidentialOrder | 200 | 0 |
0x94 | CancelConfidentialOrder | 40 | 0 |
0x95 | SealConfidentialEpochCutoff | 40 | 0 |
0x96 | RevealConfidentialOrder | 152 | 0 |
0x97 | ActivateConfidentialStanding | 48 | 0 |
0x98 | FinalizeConfidentialEpoch | 40 | 0 |
0x99 | SubmitConfidentialClearingPage | 128 | 0 |
0x9A | VerifyConfidentialPlan | 72 | 0 |
0x9B | ExecuteConfidentialBatchAtomic | 80 | 0 |
0x9C | CompleteConfidentialBatch | 16 | 0 |
0x9D | CommitConfidentialStanding | 272 | 0 |
0x9E | CancelConfidentialStanding | 8 | 0 |
0x9F | ReleaseConfidentialStanding | 48 | 0 |
0xA0 | AmendConfidentialStanding | 120 | 0 |
0xA1 | LockConfidentialSource | 112 | 0 |
0xA2 | NormalizeConfidentialSource | 72 | 0 |
0xA3 | ReleaseConfidentialSourceLock | 8 | 0 |
0xA4 | CreateShieldedOutcomeMints | 35 | 0 |
0xA5 | MintShieldedPair | 10 | 0 |
0xA6 | MergeShieldedSet | 10 | 0 |
0xA7 | RedeemShieldedTerminal | 11 | 0 |
0xA8 | BridgeConfidentialCellToTokens | 42 | 0 |
0xA9 | BridgeTokensToConfidentialCell | 42 | 0 |
0xAA | OpenConfidentialRoute | 213 | 0 |
0xAB | RefundConfidentialRouteLeg | 2 | 0 |
0xAC | ActivateConfidentialFinancedCell | 177 | 0 |
0xAD | RepayConfidentialFinancing | 41 | 0 |
0xAE | SettleConfidentialFinancedRole | 50 | 0 |
0xAF | ExchangeConfidentialCellPartForTokens | 188 | 0 |
0xB0 | ExchangeTokensForConfidentialCellPart | 188 | 0 |
0xB1 | AdmitContinuousAction | 64 | 0 |
0xB2 | ProcessContinuousAction | 12 | 0 |
0xB3 | FillContinuousStep | 24 | 0 |
0xB4 | TriggerContinuousRecoveryBarrier | 8 | 0 |
0xB5 | PublishSplineOffer | 166 | 0 |
0xB6 | FillSplineOffer | 29 | 0 |
0xB7 | ExpireSplineOffer | 8 | 0 |
0xB8 | GrantSplineDelegate | 90 | 0 |
0xB9 | RevokeSplineDelegate | 8 | 0 |
0xBA | VerifyContinuousTreeParity | 7 | 0 |
0xBB | RebuildContinuousTree | 7 | 0 |
0xBC | DepositConfidentialReservePool | 33 | 0 |
0xBD | WithdrawConfidentialReservePool | 9 | 0 |
0xBE | RefreshReservePoolOffer | 49 | 0 |
Argument offsets, payload variants, account lists, errors, and event tags: skills/seesaw/abi-reference.md, generated from idl/seesaw.json.
Security Considerations#
Agent Wallet Security#
| Recommendation | Description |
|---|---|
| Dedicated wallet | Separate from main holdings |
| Limited funding | Only deposit trading capital |
| Key management | Use secure key storage |
| Transaction limits | Set the per-order bounds of the reviewed intent; program-enforced strategy limits are planned (roadmap phase 5) |
Operational Security#
| Risk | Mitigation |
|---|---|
| Runaway losses | Circuit breakers, position limits |
| API key exposure | Environment variables |
| RPC manipulation | Use an authenticated RPC transport. Check owner, PDA, fields, and commitment. A schema check does not prove chain authenticity |
| Strategy exploitation | Don't expose strategy details |
Monitoring#
Agents should track:
- Current position (YES/NO shares held)
- P&L per market and cumulative
- Order fill rates
- Transaction success rates
- Oracle health status
Referral attribution for bots#
<!-- src: program/src/logic/fee.rs:187 FeeSplit5::TARGET -->The shipped referral allocation is 5% of the taker fee, alongside the protocol,
creator, approved-builder and eligible maker allocations described in fee constants.
Makers receive rebates only after the resting-age gate; unused maker allocation
and rounding dust go to protocol. For referral attribution, supply the taker's
validated ReferralAccount as takerReferralAccount when binding a position.
Orders accept that single optional account after any required creator spline and
before the mandatory recorder pair. An active position-cached binding continues
accruing even when the optional referral account is omitted. With no active
cached or supplied binding, the referral allocation goes to protocol.
pendingReferrer in resolveReferrer and --referrer in the CLI are candidate
inputs; they do not create a lock or override an existing one. Establish a
pending lock with SetReferrer before placing an order that supplies its PDA.
The resolver's legacy eligibleForTriple field reports earnings/shard readiness,
not a three-account wire tail. The CLI still uses that field as a client-side
gate, but appends only takerReferralAccount. Earnings and treasury accounts
belong to the separate lock/rollup/claim instructions, not the order tail.
There is no automatic place-order account resolver: verify the canonical binding, inclusive expiry, and position cache before constructing accounts. Malformed or conflicting supplied bindings can reject the order. See Building transactions and the referral guide below.
<!-- src: program/src/processor/place_order/trailing_layout.rs:40 resolve_deferred_referral_binding --> <!-- src: packages/core/src/instructions.ts:577 placeOrderAccountMetas --> <!-- src: packages/cli/src/commands/order/index.ts:344 referralBindingFromResolution -->// docs-check: semantic
import { address } from '@solana/addresses';
import { resolveReferrer } from '@seesaw/core';
const agentWallet = address(process.env.SEESAW_WALLET_ADDRESS!);
const pendingReferrer = process.env.SEESAW_REFERRER
? address(process.env.SEESAW_REFERRER)
: undefined;
// This offline example has no indexed lock. Production adapters must read
// authoritative referral state and refresh expiry before constructing orders.
const resolution = await resolveReferrer({
wallet: agentWallet,
indexerClient: {
async getReferral() {
return null;
},
},
pendingReferrer,
});
// A pending result is only a candidate: it must be locked before its PDA is supplied.
// The resolver does not construct order accounts or inspect the position cache.
console.log(resolution.source, resolution.address, resolution.isLocked);
See the Referral and creator fees guide for the full precedence rules and wire-level account semantics.
Related Documentation#
- Seesaw Trading Skill - Complete skill file for AI agents
- SDK Guide - TypeScript SDK documentation
- canonical v1 SDK - PDA derivation and account decoding
- Automated Trading - General automation guide
- API Reference - REST and WebSocket APIs
- Referral and creator fees - Fee attribution guide