# Commitry documentation > Commitry lets anyone build or follow AI trading agents on Hyperliquid that can trade but can never withdraw. Every decision is committed onchain before it executes. Source: https://commitry.xyz/docs --- # Overview Commitry lets anyone build or follow AI trading agents on Hyperliquid that can trade but can never withdraw. Every decision is committed onchain before it executes. Commit + registry: a ledger of decisions, each written before it executes. The record lives on Elysium, an Arbitrum Orbit L2 with HYPE as gas (chain id `99801` testnet, `99901` mainnet). This app is configured for **Elysium** (chain id `99901`). ## Three properties - **Trade-only by construction.** An agent trades through a Hyperliquid agent wallet that you approve. Hyperliquid agent wallets can place and cancel orders; they cannot withdraw or transfer funds. Your funds never leave your Hyperliquid account. - **Committed before executed.** For every decision the runtime writes `keccak256(canonicalJson(decision))` to the `IntentLog` contract first. If that commit does not land, the order is not sent. The result is hashed and posted after execution, so the record cannot be edited once the outcome is known. - **Open to build, open to own.** Anyone can register an agent in `AgentRegistry` with a rule or LLM strategy. An agent can route its performance fees to a token on Montra Markets. ## The pieces | Piece | What it does | | --- | --- | | Contracts (Elysium) | `AgentRegistry`, `DelegationRegistry`, `IntentLog`, `FeeRouter`. Non-upgradeable. | | Runtime | Runs one worker per active delegation: market snapshot, strategy decision, risk guard, commit, execute on Hyperliquid, post result. | | Indexer | Ingests Elysium events into Postgres and serves the REST and SSE API this app reads. It recomputes every payload hash. | | Web app | Browse agents and their records, delegate, manage delegations, create agents. | ## Where to go next - Following an agent: [For users](https://commitry.xyz/docs/users) explains delegation, limits, fees and how to revoke. - Building an agent: [For builders](https://commitry.xyz/docs/builders) covers the strategy definition, risk guard and fees. - Checking the record yourself: [How it works](https://commitry.xyz/docs/how-it-works), [Contracts](https://commitry.xyz/docs/contracts) and [API](https://commitry.xyz/docs/api). - Reading this with a model: [/llms.txt](https://commitry.xyz/llms.txt) is the index, [/llms-full.txt](https://commitry.xyz/llms-full.txt) is every page as Markdown. Past results are not a forecast. Token price is not agent performance. --- # How it works Every decision moves through the same four steps. The order is enforced by the contracts and the runtime: nothing executes before it is committed. ```commit-diagram 1. Delegate - you approve a trade-only agent wallet on Hyperliquid and record the delegation on Elysium 2. Commit - the runtime writes the decision hash to IntentLog before any order is sent 3. Execute - the agent wallet places the approved orders on Hyperliquid 4. Record - the result hash is posted; anyone can recompute both hashes ``` ## 1. Delegate You approve a Hyperliquid agent wallet derived for your delegation (named `cm--`, at most 16 characters) and a maximum builder fee. Then you call `DelegationRegistry.delegate(agentId, agentWallet, riskLimitsHash, validUntil)`. The agent's performance fee is snapshotted at this moment. An agent wallet can be bound to exactly one delegation, forever. Your risk limits are hashed (`keccak256` of their canonical JSON) and only the hash goes onchain. The plaintext limits go to the indexer, which accepts them only if they hash to the onchain `riskLimitsHash`. The runtime refuses to trade a delegation whose stored limits do not match that hash. ## 2. Commit Each tick the runtime takes a market and account snapshot, asks the strategy for a proposal and runs the deterministic risk guard over it. The decision payload records all of it: | Field | Meaning | | --- | --- | | `v` | Payload version, `1` | | `delegationId`, `agentId`, `nonce` | Which delegation and which decision | | `ts` | Decision time | | `strategyHash`, `modelId` | The committed strategy and model | | `snapshotHash`, `accountHash` | Hashes of the market snapshot and account state the strategy saw | | `proposal` | Orders, cancels and rationale proposed by the strategy | | `verdict` | Risk guard result: approved, adjusted, rejected (with reason), cancels, breach flags | The runtime then calls `IntentLog.commit(delegationId, nonce, decisionHash)`. A `(delegationId, nonce)` pair can be committed once and never overwritten. `commit` reverts if the delegation has expired or the agent is not `Active`. If the commit fails, the decision is stored as `SKIPPED_NO_COMMIT` and no order is sent. By default no-op decisions are committed too, so a quiet tick is also on the record. ## 3. Execute Approved orders go to Hyperliquid from the agent wallet. Each order carries a deterministic client order id, `bytes16(keccak256(abi.encode(delegationId, nonce, orderIndex)))`, so fills can be matched to the decision without local state. ## 4. Record After execution the runtime builds the result payload (`placeResults`, `cancelResults`, `fills`, `errors`) and calls `IntentLog.postResult(delegationId, nonce, resultHash, outcome, filledNotional)`. A result can only be posted for a committed intent, and only once. Outcomes: `NoOp`, `RiskBlocked`, `Submitted`, `Filled`, `PartiallyFilled`, `Rejected`, `Failed`, `Cancelled`. Periodically the runtime also posts `checkpoint(delegationId, cumRealizedPnl, equity, evidenceHash)`. Performance fees are settled against these checkpoints. ## Verifying a decision 1. Fetch the payloads: `GET /intents/:delegationId/:nonce/payload` on the indexer. 2. Compute `keccak256` over the UTF-8 bytes of the canonical JSON of each payload (`hashCanonical` in `@commitry/core`). 3. Compare with `decisionHash` and `resultHash` from the `IntentCommitted` and `ResultPosted` events, or `IntentLog.getIntent`. The Record tab on every agent page does this in your browser with the Verify action. A match reads "Hash matches". A difference reads "Hash mismatch" and is never hidden. ## What the record does not prove PnL in checkpoints is reported by the runner. `evidenceHash` commits to the Hyperliquid fills behind it so it can be audited, but the chain does not verify it. Fees can never exceed the escrow you deposited, so a wrong report is bounded by that amount. --- # For users You keep your funds in your own Hyperliquid account. Delegating gives an agent a trade-only key and records the terms onchain. ## What an agent can and cannot do | Can | Cannot | | --- | --- | | Place and cancel orders on your Hyperliquid account | Withdraw or transfer your funds | | Open and close positions within your risk limits | Change your withdrawal address | | Commit each decision onchain before it executes | Trade after you revoke access | ## Before you delegate - Read the agent's Record tab. Every decision is listed with its commit and result hashes, and you can verify any of them. - Check its status. Only `Live` agents accept new delegations; `Paused`, `Revoked` and `Degraded` agents cannot open new decisions. - Check the default and maximum limits on the Strategy tab, and the performance fee. ## Delegating, step by step The delegate flow on each agent page has five steps. 1. **Connect wallet and sign in.** You sign a Sign-In with Ethereum message. It is not a transaction and moves nothing. 2. **Limits.** Set your risk limits, starting from the agent's defaults and never above its maximums, and how many days the delegation is valid (90 by default). 3. **Hyperliquid.** You sign two Hyperliquid actions: `approveAgent` for the trade-only agent wallet and `approveBuilderFee` for the platform builder fee. The flow waits until Hyperliquid lists both. 4. **Elysium.** You send `DelegationRegistry.delegate` and, optionally, `FeeRouter.deposit` to prefund performance fees in HYPE. 5. **Record limits.** The plaintext limits go to the indexer, which checks them against the onchain hash so the runtime can enforce them. ## Risk limits Limits are enforced by the deterministic risk guard before every commit. An order that breaks a limit is clipped or rejected, and the reason is part of the committed decision. | Field | Meaning | | --- | --- | | `maxNotionalUsd` | Gross position notional cap across all assets, USD | | `maxOrderNotionalUsd` | Per-order notional cap, USD | | `maxLeverage` | Leverage cap, 1 to 50 | | `allowedAssets` | Assets the agent may trade, at least one | | `maxDailyLossUsd` | Realized plus unrealized loss since 00:00 UTC, USD | | `maxDailyLossPct` | Optional daily loss cap as a percent | | `maxOrdersPerMinute` | Rate limit on approved orders | | `maxPriceDeviationBps` | Max distance of a limit price from mid, default 100 | | `reduceOnlyOnBreach` | After a breach allow only reduce-only orders and cancels, default true | ## Fees and escrow - **Performance fee.** A share of profit above the high-water mark, in basis points, capped at 50.00%. The rate is snapshotted when you delegate; later changes by the operator do not apply to you. - **Escrow.** Fees are paid only from HYPE you deposit into `FeeRouter` for this delegation. Nothing is ever taken from your Hyperliquid account. You can withdraw the unused balance at any time, also while fee settlement is paused; a fee that could not be paid stays owed and is deducted from your next deposit to this delegation. - **Settlement.** The settler calls `settle` at most once per interval and only for a new checkpoint. The fee is `(cumRealizedPnl − highWaterMark) × bps / 10,000` in USD, converted to HYPE at the settler's price. The price must sit inside owner-set bounds and within `maxPriceDeviationBps` of the last charging settlement. One settlement debits at most `maxSettleShareBps` (default 20%) of your balance; the rest is recorded as **owed** and taken from your next deposit. The high-water mark never decreases. - **Owed fees.** If you withdraw before a settlement, the fee is not forgiven: it stays owed and is paid first out of any later deposit to that delegation. Withdrawing after revoke is still free of charge for anything not yet settled against a checkpoint. - **Builder fee.** Orders on Hyperliquid carry a builder fee that you approve in step 3, stated in tenths of a basis point. ## Revoking Revoke has two sides, and the dashboard walks you through both. 1. **Elysium.** `DelegationRegistry.revoke(delegationId)`. New decisions stop: the runtime stops the worker on its next poll and cancels open orders. Results and checkpoints can still be posted, so in-flight orders and final PnL stay on the record. 2. **Hyperliquid.** Overwrite the agent approval by approving a different address under the same agent name (Hyperliquid keeps one address per name), or let it expire. If the runtime finds the approval missing it terminates the delegation onchain with the reason `HL_APPROVAL_MISSING`. Then withdraw any remaining escrow from the dashboard. Until you do, the runner can still post a final checkpoint and the settler can settle a fee against it, as designed. --- # Pause, revoke and resume Permission in Commitry lives in two places: the `DelegationRegistry` on Elysium and the agent approval on Hyperliquid. Stopping an agent means acting on one or both. ## For delegators You have three ways to stop an agent, from lightest to final: **pause**, **update limits**, **revoke**. Pause and revoke are on the dashboard (**Pause trading**, **Revoke**) and on the agent's Delegations tab. ### Pause and resume `DelegationRegistry.pause(delegationId)` is one transaction on Elysium. The delegation moves to `Paused`. While it is paused the runtime cancels the agent's open orders and stops committing new decisions for it. **Pausing does not flatten positions.** Open positions stay on your Hyperliquid account and keep taking price risk until you close them there. Pausing does not revoke the Hyperliquid agent key either. | Pause can | Pause cannot | | --- | --- | | Cancel the agent's resting orders on Hyperliquid, best effort | Close your positions | | Stop the agent committing new decisions | Revoke the Hyperliquid agent key | | Be reversed with `resume(delegationId)` | Be resumed by you if the operator also paused it | | Be followed by a revoke at any time | Change your limits, your fee balance or your high-water mark | #### The two pause bits A delegation holds two independent pause bits, read with `pauseFlags(delegationId)`: | Bit | Value | Set by | | --- | --- | --- | | User | 1 | You, the delegating user | | Operator | 2 | The agent's operator or runner | - Each side can resume only its own bit. You cannot clear the operator's bit, and the operator cannot clear yours. - The delegation trades again only when both bits are clear. Status returns to `Active` when the last bit is cleared. - If only the operator bit is set, the dashboard says: "Paused by the operator. Only the operator can resume it; you can still revoke." - If you are also the agent's operator, the contract treats your call as the user's. - `pauseFlags` is 0 to 3. The indexer returns it on delegation records as `pauseFlags`, next to `status: "Paused"`. A record without the field means no bit is set. - Revoke works from `Paused` and clears the bits. ### Update limits `updateRiskLimits` changes the limits the agent must respect. It is not a stop: the agent can still trade within the new limits. Use pause when you want trading to stop. ### Revoke access A full stop, and permanent. It works from Active and from Paused. Revoke has two steps, each with its own status in the dialog: 1. **Elysium.** `DelegationRegistry.revoke(delegationId)`. New decisions stop. The runtime cancels open orders on a best-effort basis. 2. **Hyperliquid.** Overwrite the agent approval with a throwaway address under the same agent name. This is a signature and costs nothing. Revoking cannot be reversed. If you delegate to the same agent later, that creates a new delegation with a new agent key. The dashboard shows a status line for each delegation, for example "Trade-only access: active on Hyperliquid". If the two sides disagree (active onchain but not approved on Hyperliquid, or the other way round) it shows a warning and a button that completes the missing side. ### What happens to open positions - Neither pause nor revoke closes positions. They stay on your Hyperliquid account and stay yours. Close them on Hyperliquid if you want to. - The runtime cancels open orders on a best-effort basis when a delegation is revoked. Check your open orders on Hyperliquid. - Your fee escrow stays withdrawable at any time, also after revoking and also while fee settlement is paused. ## For operators An operator controls the agent through `AgentRegistry.setStatus`. The Operator panel on the agent page is visible only when your connected wallet is the operator. | Action | From | To | Effect | | --- | --- | --- | --- | | Pause | Active | Paused | New delegations and new decisions stop. Reversible. | | Resume | Paused | Active | The agent accepts delegations again. | | Retire | Active or Paused | Retired | Terminal. All delegations stop. Delegators keep their funds and can withdraw their escrow. | - **Suspended** is set by the protocol owner, not by the operator. Only the owner can lift it, and operators have no button for it. - **Retired** cannot be undone, and no further status change is possible. - **Fee changes** (`setFeeConfig`: up to 5000 bps, a recipient and a recipient kind) apply to new delegations only. Existing delegations keep the fee they accepted. - `transferOperator` hands the agent to another address. It takes effect immediately. ### Pausing a single delegation Separately from the agent status, the Operator panel lists each delegation with its status and pause bits ("paused by user", "paused by operator" or "paused by both"). - **Pause** calls `DelegationRegistry.pause` from your operator wallet and sets the operator bit (2). The runtime cancels that delegation's open orders and stops new decisions. Positions stay open on Hyperliquid. - **Resume** clears only your bit. If the delegator's bit is set, the delegation stays paused until they resume. - **Terminate** calls `terminate(id, reasonHash)`. It ends the delegation for good, from Active or Paused. ## What is not possible - **Pausing without risk.** Pause cancels resting orders and stops new decisions. It does not close positions, so exposure remains until you close it on Hyperliquid. - **Resuming the other side's pause.** Each bit is cleared only by the side that set it. - **Reviving a revoked or terminated delegation.** Both are permanent. Delegate again to start a new one. --- # For builders An agent is a strategy definition, committed by hash in `AgentRegistry`, that the runtime executes for every delegation. You operate it from your own wallet; the platform runner signs its commits. ## Create an agent The [Create](https://commitry.xyz/create) flow has six steps: Basics, Strategy, Limits, Fees, Preview and register, and an optional Montra launch. 1. Write the name and description shown in the registry. 2. Choose a rule or LLM strategy, its parameters and the tick interval. 3. Set the default limits new delegations start from, and the maximum limits a delegator may not exceed. 4. Set the performance fee and where fees go. 5. Preview: the indexer validates the definition (`POST /agents/draft`) and returns `strategyHash`, `modelIdHash` and the normalized strategy. Registering sends `AgentRegistry.registerAgent` with these hashes, the runner address, the fee config and the metadata URI. ## Strategy definition The schema is `StrategyDefinitionSchema` in `@commitry/core` (zod, strict: unknown keys are rejected). | Field | Type | Notes | | --- | --- | --- | | `id` | string | Non-empty identifier | | `kind` | `"llm"` or `"rule"` | | | `systemPrompt` | string, optional | LLM strategies only | | `params` | object | Strategy parameters | | `defaultLimits` | RiskLimits | Limits new delegations start from | | `maxLimits` | RiskLimits, optional | Upper bound a delegator may not exceed | | `tickIntervalSec` | integer, 30 to 86400 | Seconds between decisions | | `modelId` | string, at most 128 chars | `rule:`, `anthropic:` or `openai:`; LLM models must be on the runtime's allowlist | | `decisionTimeoutMs` | integer, at most 60000 | Default 20000 | `systemPrompt` is capped at 16,000 characters and `params` at 8,192 characters of JSON. Each agent has a daily LLM token budget on the runtime; when it is spent, decisions are committed as no-ops until the next UTC day. `strategyHash` is `keccak256(canonicalJson(definition))` after defaults are applied. `modelId` onchain is `keccak256(utf8(modelId))`. The runtime refuses to start a worker unless the stored definition hashes to the onchain `strategyHash`. ```json { "id": "ping-pong", "kind": "rule", "params": { "sizeUsd": 12, "slippageBps": 10 }, "defaultLimits": { "maxNotionalUsd": 200, "maxOrderNotionalUsd": 50, "maxLeverage": 2, "allowedAssets": ["ETH"], "maxDailyLossUsd": 10, "maxOrdersPerMinute": 4, "maxPriceDeviationBps": 100, "reduceOnlyOnBreach": true }, "tickIntervalSec": 60, "modelId": "rule:ping-pong", "decisionTimeoutMs": 20000 } ``` ## Rule or LLM **Rule strategies** are deterministic and built into the runtime: | `modelId` | Behavior | Params (defaults) | | --- | --- | --- | | `rule:noop` | Never trades | none | | `rule:ping-pong` | Alternates a small IOC buy and sell on the first allowed asset, closing an open position first | `sizeUsd` (11), `slippageBps` (10) | | `rule:sma-cross` | Long when the fast SMA is above the slow SMA, flat otherwise, per allowed asset | `fast` (10), `slow` (30), `targetNotionalUsd` (100), `slippageBps` (10) | **LLM strategies** use `anthropic:` or `openai:`. Your `systemPrompt` is followed by a fixed operating contract the runtime appends. Each tick the model can call `getMarketSnapshot`, `getPositions` and `getRiskBudget`, and must finish by calling `proposeOrders` once (at most 20 orders and 50 cancels, with a rationale). The loop is capped at 8 model calls. An empty proposal is a valid decision. The runtime needs the provider's API key; without it the agent cannot start. Either way, the strategy only proposes. The risk guard decides. ## Risk guard rules `DefaultRiskGuard` is pure and deterministic. Orders are checked in proposal order against a worst-case book: current positions plus **every open order on the account** (resting, trigger, and the user's own manual orders) at full size, each side valued at the higher of its order price and the mid. Orders approved earlier in the same proposal join that book, so exposure cannot be stacked across ticks. The first failing rule wins. | # | Reason | Rule | | --- | --- | --- | | 1 | `ASSET_NOT_ALLOWED` | Asset not in `allowedAssets`, or no market metadata | | 2 | `INVALID_PRICE` / `INVALID_SIZE` | Unparseable, non-positive, or rounds to zero under Hyperliquid tick and lot rules | | 3 | `DUPLICATE` | Same asset, side, price, size and reduce-only flag as an earlier order | | 4 | `DAILY_LOSS` / `REDUCE_ONLY_REQUIRED` | After a breach only exposure-reducing orders pass; trigger (TP/SL) orders must always be reduce-only | | 5 | `PRICE_DEVIATION` | Limit price further from mid than `maxPriceDeviationBps` (non-trigger orders) | | 6 | `MIN_ORDER_VALUE` | Price times size below 10 USD | | 7 | `ORDER_NOTIONAL` | Above `maxOrderNotionalUsd`: size is clipped, rejected if the clip falls below the minimum | | 8 | `GROSS_NOTIONAL` | Projected gross above `maxNotionalUsd`: clipped or rejected; reducing orders pass | | 9 | `LEVERAGE` | Projected gross over equity above the lower of `maxLeverage` and the asset's max leverage | | 10 | `RATE_LIMIT` | More approved orders than remain this minute, or more than 20 resting orders for this delegation | Cancels are scoped too: an agent can only cancel orders this delegation placed (matched by client order id or order id in the runtime's records) on its allowed assets. The user's own orders and other agents' orders are never cancelled, also not by the cancel-all on pause or revoke. Sizes are always truncated toward zero. Prices round conservatively: buys down, sells up, so an order is never more aggressive than proposed. ## Metadata `registerAgent` takes a `metadataURI`. The indexer accepts `ipfs://`, `https://` (no private hosts) and inline `data:application/json` URIs, base64 or URL-encoded, up to 256 KiB. The Create flow uses the `data:` option, so nothing is hosted. ```json { "name": "Ping-pong ETH (testnet)", "description": "Reference rule agent.", "modelId": "rule:ping-pong", "strategy": { "id": "ping-pong", "kind": "rule", "...": "full StrategyDefinition" } } ``` `name` and `description` are shown in the registry. `strategy` and `modelId` are published only if they hash to the onchain `strategyHash` and `modelId`; otherwise the strategy is treated as private. Default and maximum limits come from the verified strategy, or from top-level `defaultLimits` and `maxLimits` in the metadata when the strategy is private. Without default limits the agent cannot accept delegations. ## Fees and Montra routes `perfFeeBps` is at most 5000 (50.00%) and applies to delegations created after a change. Fees accrue in `FeeRouter` and anyone can call `forward(agentId)` to push them to the recipient: | `recipientKind` | Value | Route on `forward` | | --- | --- | --- | | `Address` | 0 | Native HYPE transfer to `feeRecipient` | | `MontraToken` | 1 | Native transfer to the agent's `token`, then `token.distribute()` | | `Splitter` | 2 | Native transfer to `feeRecipient` (the splitter is not called) | `forward` is atomic: if the transfer or `distribute()` reverts, the claimable balance is kept. Changing the recipient also redirects fees accrued but not yet forwarded. **Montra launch** is available on Elysium mainnet (chain `99901`) only. The Create flow uploads the token metadata, calls the Montra launch factory with your fee split between your wallet and token holders, then links the token with `AgentRegistry.setToken`. Running an agent does not require a token. ## Operating an agent - `setStatus(agentId, Paused | Retired)` stops new commits for every delegation of the agent. - `updateStrategy` commits a new strategy hash and bumps the version. - `setRunner`, `setFeeConfig`, `setToken` and `transferOperator` are operator-only. --- # Contracts Four contracts on Elysium, all non-upgradeable. Solidity 0.8.28, EVM `cancun`. ## Deployed addresses **Elysium Testnet** (chain id `99801`) | Contract | Address | | --- | --- | | AgentRegistry | [`0x0F7904Ad1bE6D540cDdA56c34880eC303BE0a635`](https://elysium.kinetiq.xyz/testnet-explorer/address/0x0F7904Ad1bE6D540cDdA56c34880eC303BE0a635) | | DelegationRegistry | [`0x1C3C9835E9B26bAF02EfBdEaf975bB999E98da96`](https://elysium.kinetiq.xyz/testnet-explorer/address/0x1C3C9835E9B26bAF02EfBdEaf975bB999E98da96) | | IntentLog | [`0x861B6Bac9eB235E04094971d3c7c2E1B105ad23b`](https://elysium.kinetiq.xyz/testnet-explorer/address/0x861B6Bac9eB235E04094971d3c7c2E1B105ad23b) | | FeeRouter | [`0xbd4E970241A3fBd0A6570568b699969E9683F99d`](https://elysium.kinetiq.xyz/testnet-explorer/address/0xbd4E970241A3fBd0A6570568b699969E9683F99d) | **Elysium** (chain id `99901`) | Contract | Address | | --- | --- | | AgentRegistry | [`0x8b7B9D7a678D3CE093FD493D826bc5A005837167`](https://elysium.kinetiq.xyz/explorer/address/0x8b7B9D7a678D3CE093FD493D826bc5A005837167) | | DelegationRegistry | [`0x2402c5455757500aB1F539a4137646deb8a4C62d`](https://elysium.kinetiq.xyz/explorer/address/0x2402c5455757500aB1F539a4137646deb8a4C62d) | | IntentLog | [`0x068Aa8d6CE438a1bB0B69d9c298e6810b4608283`](https://elysium.kinetiq.xyz/explorer/address/0x068Aa8d6CE438a1bB0B69d9c298e6810b4608283) | | FeeRouter | [`0xEeb9105cE842708B4605E818Ea8ec29aff6ed5F4`](https://elysium.kinetiq.xyz/explorer/address/0xEeb9105cE842708B4605E818Ea8ec29aff6ed5F4) | ## CMTR token | | | | --- | --- | | CMTR | [`0xAeA74a01ec0192975D863119C833F5F5D3D6F472`](https://elysium.kinetiq.xyz/explorer/address/0xAeA74a01ec0192975D863119C833F5F5D3D6F472) | | Launcher (creator, fee recipient) | [`0x489B61BD8Bc6827662420fcA261d046A7ff6aE9A`](https://elysium.kinetiq.xyz/explorer/address/0x489B61BD8Bc6827662420fcA261d046A7ff6aE9A) | | Launch transaction | `0x820a05aa605b8310e9c8588ce61253d3b2ab24ee4b83cc7871b55714933c6048` | | Market | [Montra](https://montramarkets.xyz/token/0xaea74a01ec0192975d863119c833f5f5d3d6f472), HYPE pair, 2% fee | This is the only CMTR. Check the address, not the name: tokens with the same name exist on Montra and are not ours. Plain ERC-20 from Montra's factory: no owner, no mint, no transfer fee. The token has no role in the protocol; delegating, fees and the record work without it, and holding it changes nothing about an agent. ## AgentRegistry Agents: operator, runner key, strategy commitment (`strategyHash`, `modelId`, version), fee config and status. Owned by a Safe that can only suspend agents and manage the runner allowlist; `renounceOwnership` is disabled. | Function | Who | Purpose | | --- | --- | --- | | `registerAgent(p)` | anyone | `p = { runner, strategyHash, modelId, perfFeeBps, feeRecipient, recipientKind, metadataURI }`; returns `agentId` | | `updateStrategy(agentId, strategyHash, modelId, metadataURI)` | operator | New strategy version | | `setFeeConfig(agentId, bps, recipient, kind)` | operator | Fee for new delegations, recipient for future forwards | | `setRunner`, `setToken`, `setStatus`, `transferOperator` | operator | | | `suspend(agentId, suspended)` | owner | Platform suspension; lifting it leaves the agent `Paused` until the operator sets `Active` again | | `setRunnerAllowlist`, `setRunnerAllowlistEnabled` | owner | Runner allowlist | Views: `getAgent`, `isActive`, `isOperator`, `isRunner`, `runnerAndStatus`, `perfFeeBps`, `nextAgentId`. Events: `AgentRegistered`, `StrategyUpdated`, `FeeConfigUpdated`, `RunnerUpdated`, `StatusUpdated`, `TokenSet`, `OperatorTransferred`. ## DelegationRegistry User to agent delegations through a Hyperliquid trade-only agent wallet, with a snapshot of the fee rate and the risk-limits hash. No owner. | Function | Who | Purpose | | --- | --- | --- | | `delegate(agentId, agentWallet, riskLimitsHash, validUntil)` | user | Creates the delegation; id = `keccak256(abi.encode(agentId, user, index))` | | `updateRiskLimits(id, newHash)` | user | New limits hash | | `revoke(id)` | user | Ends the delegation, from Active or Paused | | `pause(id)` | user, or the agent's operator or runner | Sets the caller's pause bit (user 1, operator 2) and moves the status to Paused | | `resume(id)` | same | Clears the caller's own bit; status returns to Active when both bits are clear | | `terminate(id, reasonHash)` | runner or operator | Ends it from the agent side, for example when the Hyperliquid approval is gone | Status values: None 0, Active 1, Revoked 2, Terminated 3, Paused 4. Views: `getDelegation`, `isActive`, `computeId`, `delegationCount`, `walletToDelegation`, `coreOf`, `pauseFlags(id)` (uint8: bit 1 user, bit 2 operator). Events: `Delegated`, `RiskLimitsUpdated`, `Paused(id, by, flags)`, `Resumed(id, by, flags)`, `Revoked`, `Terminated`. ## IntentLog Commit-before-trade decision hashes, results, per-agent and per-delegation stats, and PnL checkpoints. No owner. | Function | Who | Purpose | | --- | --- | --- | | `commit(delegationId, nonce, decisionHash)` | runner | Once per `(delegationId, nonce)`; delegation unexpired, agent `Active` | | `commitBatch(ids, nonces, hashes)` | runner | Batched commits | | `postResult(delegationId, nonce, resultHash, outcome, filledNotional)` | runner | Once, only for a committed intent | | `postResultBatch(...)` | runner | Batched results | | `checkpoint(delegationId, cumRealizedPnl, equity, evidenceHash)` | runner | Periodic PnL checkpoint | Views: `getIntent`, `highestNonce`, `getAgentStats`, `getDelegationStats`, `getCheckpoint`, `getCheckpointCount`, `EPOCH`. Events: `IntentCommitted`, `ResultPosted`, `CheckpointPosted`. A steady-state `commit` costs about 53k gas, a batch of ten about 310k. ## FeeRouter Prepaid, user-capped native HYPE escrow; high-water-mark performance fee settlement; forwarding to the agent's recipient. Owned by a Safe that can set the settler and parameters and pause settlement, but cannot move funds or block withdrawals. | Function | Who | Purpose | | --- | --- | --- | | `deposit(delegationId)` | user, payable | Prefund fees; also the fee cap | | `withdraw(delegationId, amount)` | user | Always available, also while paused | | `settle(delegationId, hypePriceUsd1e6)` | settler | Fee for a new checkpoint, at most once per `minSettleInterval` | | `forward(agentId)` | anyone | Push accrued fees to the recipient | | `pause`, `unpause`, `setSettler`, `setMinSettleInterval`, `setMaxPriceDeviationBps`, `setPriceBounds`, `setReferencePrice`, `setMaxSettleShareBps` | owner | Price bounds must be set before the first settlement; `renounceOwnership` is disabled | Views: `getEscrow` (balance, high-water mark, last settlement, total paid, owed), `claimable`, `previewFee` (gain, fee in USD, owed in HYPE), `lastHypePriceUsd1e6`, `lastPriceAt`, `minHypePriceUsd1e6`, `maxHypePriceUsd1e6`, `maxSettleShareBps`, `paused`. Events: `Deposited`, `Withdrawn`, `Settled`, `OwedPaid`, `Forwarded`, `Paused`, `Unpaused`, `SettlerUpdated`, `PriceBoundsUpdated`, `ReferencePriceUpdated`, `MaxSettleShareBpsUpdated`. ## Invariants - Escrow plus claimable always equals the contract balance. - Per settle, the fee paid is at most the gain times the fee rate, at most the escrow balance, and at most `maxSettleShareBps` of it; the remainder is owed, never forgiven. - The settler's price is always inside the owner's bounds and within `maxPriceDeviationBps` of the anchor; the anchor moves at most once per settlement interval and only when a fee was charged. - The high-water mark never decreases. - A user can always withdraw their full escrow balance. - A decision is committed at most once and never overwritten; a result is posted at most once, only for a committed decision. ## Trust model User funds leave `FeeRouter` only through `withdraw` (to the user) or as fees through `settle` then `forward` (to the agent's recipient). Hyperliquid trading funds never touch these contracts. The runner reports PnL in checkpoints and the settler supplies the HYPE price; both are trusted, and a user's exposure to either is bounded by the escrow they chose to deposit. --- # API The indexer serves a JSON REST API and a Server-Sent Events stream. Every response is validated against the zod schemas in `@commitry/api-types`. Large integers are decimal strings; addresses and hashes are `0x` hex. Base URL for this app: `https://api.commitry.xyz` ## Routes | Method | Path | Auth | Returns | | --- | --- | --- | --- | | `GET` | `/health` | Public | Ingest cursor, chain head and lag | | `GET` | `/agents` | Public | List agents with stats (`AgentSummary`) | | `GET` | `/agents/:id` | Public | One agent with strategy and limits (`AgentDetail`) | | `GET` | `/agents/:id/intents` | Public | Committed decisions, newest first (`IntentRow`) | | `GET` | `/stream/agents/:id` | Public | Server-Sent Events for one agent | | `GET` | `/agents/undefined/delegations` | Public | Delegations to one agent, newest first (`DelegationRow`, with `pauseFlags`) | | `GET` | `/intents/:delegationId/:nonce/payload` | Public | Decision and result payloads with their onchain hashes | | `POST` | `/agents/draft` | Public | Validate a strategy; returns `strategyHash` | | `GET` | `/delegations/:id` | Public | One delegation (`DelegationRow`) | | `POST` | `/delegations/prepare` | Session | Derive the agent wallet and delegation id for `{ agentId }` | | `POST` | `/delegations/:id/limits` | Session | Submit plaintext limits that hash to the onchain value | | `GET` | `/users/:addr/delegations` | Public | Delegations of an address | | `GET` | `/users/:addr/positions` | Public | Hyperliquid account value and positions | | `POST` | `/auth/nonce` | Public | Single-use SIWE nonce | | `POST` | `/auth/verify` | Public | Verify a SIWE signature, start a session | | `POST` | `/auth/logout` | Public | End the session | | `GET` | `/auth/session` | Session | The session's address (`{ address }`) | Lists take `limit` (1 to 100, default 20) and an opaque `cursor`, and return `{ items, nextCursor }`. `GET /agents` also takes `sort` (`recent`, `intents`, `delegations`), `status` (`Active`, `Paused`, `Retired`, `Suspended`) and `operator`. Errors return `{ error, message? }` with a 4xx or 5xx status, for example `not_found`, `invalid_id` or `metadata_unavailable` (503, the agent's default limits are not known yet). ## Stream `GET /stream/agents/:id` is a Server-Sent Events stream for one agent. Event types: | Event | Data | | --- | --- | | `intent` | An `IntentRow` when a decision is committed | | `result` | The updated `IntentRow` when its result is posted | | `fill` | `{ delegationId, coin, px, sz, side, time }` | | `status` | `{ agentId, status }` | Each event has an id. Reconnect with the `Last-Event-ID` header (or `?lastEventId=`) to replay what you missed. A comment ping is sent every 15 seconds. ```bash curl -N https://api.commitry.xyz/stream/agents/1 ``` ## Auth Reading is public. Preparing a delegation and submitting limits need a session: 1. `POST /auth/nonce` returns `{ nonce }` (single use, valid 10 minutes). 2. Sign a Sign-In with Ethereum message containing that nonce. 3. `POST /auth/verify` with `{ message, signature }` sets an httpOnly session cookie (`commitry_session`) and returns `{ address, expiresAt }`. 4. `POST /auth/logout` clears it. Send requests with credentials included. `POST /delegations/:id/limits` accepts limits only from the delegating address, and only if they hash to the onchain `riskLimitsHash`. ## Examples ```bash curl https://api.commitry.xyz/agents?sort=intents&limit=5 curl https://api.commitry.xyz/agents/1/intents?limit=20 curl https://api.commitry.xyz/health ``` `GET /health` returns `{ ok, cursor, chainHead, lag }`: the last block fully ingested, the chain head and the difference in blocks. --- # Agent runtime The runtime runs one worker per active delegation. It is built around ports: the tick pipeline depends only on interfaces, and `RUNTIME_MODE` picks the wiring (`fake`: in-memory, no keys; `live`: Postgres, Elysium and Hyperliquid). ## Ports | Port | Live implementation | Used for | | --- | --- | --- | | `IntentLogPort` | `LiveIntentLog` | `commit`, `postResult`, `checkpoint`, `terminate`; serialized writer per runner key, batching, idempotent retries | | `ChainReaderPort` | `LiveChainReader` | Delegations, agent status, checkpoints, onchain commitments | | `FeeRouterPort` | `LiveFeeRouter` | `previewFee`, `settle`, `forward` with the settler key | | `HlInfoPort` | `LiveHlInfo` | Agent approval, fills, account state, mids, funding | | Executor | `HyperliquidApiExecutor` | Signs orders with the derived agent key; refuses if it differs from the registered agent wallet | | Strategy resolver | `RegistryStrategyResolver` | Rule strategies and LLM providers | ## Tick pipeline Each tick runs these steps in order and stops at the first one that ends the tick: 1. **preflight**: delegation active and unexpired, agent active, stored limits hash to the onchain hash, Hyperliquid approval present, late commits reconciled. 2. **snapshot**: market data and account state. 3. **context**: strategy context with the remaining risk budget. 4. **decide**: the strategy proposes, within `decisionTimeoutMs`. A failure becomes a no-op. 5. **risk**: `DefaultRiskGuard` produces the verdict. 6. **persist**: the decision payload and its hash are stored with the next nonce. 7. **commit**: `IntentLog.commit`. On failure the decision is `SKIPPED_NO_COMMIT` and nothing executes. 8. **execute**: approved orders and cancels go to Hyperliquid. 9. **result**: wait for fills within the result window. 10. **postResult**: hash the result payload and post it. Recovery at boot never re-executes orders. It re-derives every needed write from stored decisions and re-posts pending results. ## Keys - **Runner** (`RUNNER_PRIVATE_KEY`): commits, results, checkpoints and `terminate`. Needs HYPE for gas. - **Settler** (`SETTLER_PRIVATE_KEY`): `settle` and `forward`. Without it settlement is disabled. - **Master seed** (`RUNTIME_MASTER_SEED`): derives every Hyperliquid agent key from `(agentId, user, index, seedVersion)`. Leaking it allows trading, not withdrawing, until users revoke. ## HTTP `GET /healthz` (executor reachability, workers, queue), `GET /metrics` (Prometheus), and `POST /internal/delegations/prepare` for the indexer, protected by a shared secret header. ## Environment | Variable | Default | Notes | | --- | --- | --- | | `RUNTIME_MODE` | `fake` | `fake` or `live` | | `PORT` | `8787` | Use 8788 next to the indexer | | `ELYSIUM_CHAIN_ID` / `ELYSIUM_RPC_URL` | `99801` / public RPC | | | `HL_ENV` | `testnet` | `mainnet` or `testnet` | | `HL_BUILDER_ADDRESS` / `HL_BUILDER_FEE_TENTHS_BP` | none / `10` | Builder fee on every order | | `COMMIT_MODE` | `receipt` | `receipt` waits for the receipt; `submitted` accepts the tx hash | | `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` | none | Needed for LLM agents | --- # Brand Commitry is a precision instrument for trading agents: quiet, exact, verifiable. The full guide, with logo variants, color tokens in both themes, type scale, voice rules and component specs, lives on the [brand page](https://commitry.xyz/brand). ## In short - Warm graphite neutrals and one brass accent. Brass means committed or matched, nothing else. - Instrument Sans for display, Inter for interface text, JetBrains Mono for hashes, addresses and numbers that align. - Sentence case. Plain verbs. State the limit first. Never promise returns. - Signed numbers use the true minus sign: `+1.23%`, `−1.23%`. Zero is `0.00%`. - Hashes truncate as `0x1234…abcd` with copy and explorer actions. Name: Commitry. Ticker: CMTR. Primary tagline: "Every decision, on the record."