Skip to main content

Monaco Protocol SDK v0.8.4

Delegated Agents

Delegated agents let an owner wallet authorize a separate signer address to submit orders on the owner’s behalf. The owner retains custody of all funds, collateral movement, and withdrawal rights. The agent can only perform the trading actions permitted by its policy.

How it works

  1. Owner calls upsertDelegatedAgent to register an agent address and define its constraints.
  2. Agent authenticates with its own wallet (normal sdk.auth challenge flow), then calls createDelegatedSession with the owner’s user ID to receive a short-lived, owner-scoped delegated auth session.
  3. Agent signs trading requests with that delegated session. Orders are matched and settled against the owner’s margin accounts; the agent wallet is recorded as the signer.

Owner setup

Agent session

The agent first authenticates with its own wallet, then exchanges for an owner-scoped delegated session using a locally generated session public key:

Placing orders as an agent

Once the delegated session is active, place orders normally. Pass strategyKey to let Monaco auto-resolve or create an isolated margin bucket for that key, so you never need to manage marginAccountId directly:
Each unique strategyKey maps to a dedicated, owner-owned margin account. Omitting strategyKey uses the owner’s default margin account for the trading pair.

List and revoke

Revoking an agent blocks future policy-gated trading for that agent. Existing delegated auth sessions may still authenticate until session expiry, but create, cancel, replace, and close actions fail because Monaco re-checks the active delegation before each mutation. In-flight orders already submitted are unaffected.

UpsertDelegatedAgentRequest shape


strategyKey on order placement

Both placeLimitOrder and placeMarketOrder now accept an optional strategyKey field. Monaco uses this to resolve the owner’s parent margin account and target the isolated bucket for the given (market, strategyKey) pair. This is the recommended way for delegated agents to trade without managing bucket IDs manually — but it is also usable in non-delegated flows for strategy tagging and segregated margin accounting.
strategyKey is also available on batchCreate and batchReplace per-order params.

Migration

No breaking changes. All additions are opt-in:
  • sdk.delegatedAgents is a new module — existing code is unaffected.
  • strategyKey is optional — all existing order placement calls work without change.

Upgrade