otto-execute 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -0
  3. package/dist/cdp-signer.d.ts +2 -0
  4. package/dist/cdp-signer.js +3 -0
  5. package/dist/cdp.d.ts +7 -0
  6. package/dist/cdp.js +8 -0
  7. package/dist/chain.d.ts +2 -0
  8. package/dist/chain.js +3 -0
  9. package/dist/cli.d.ts +17 -0
  10. package/dist/cli.js +400 -0
  11. package/dist/delegate.d.ts +117 -0
  12. package/dist/delegate.js +394 -0
  13. package/dist/eoa-signer.d.ts +94 -0
  14. package/dist/eoa-signer.js +289 -0
  15. package/dist/erc20.d.ts +2 -0
  16. package/dist/erc20.js +3 -0
  17. package/dist/index.d.ts +16 -0
  18. package/dist/index.js +19 -0
  19. package/dist/lifi-decode.d.ts +2 -0
  20. package/dist/lifi-decode.js +3 -0
  21. package/dist/mutations.d.ts +55 -0
  22. package/dist/mutations.js +363 -0
  23. package/dist/refusal.d.ts +2 -0
  24. package/dist/refusal.js +3 -0
  25. package/dist/vendor/otto-intel-mcp/VENDORED.json +52 -0
  26. package/dist/vendor/otto-intel-mcp/adapter/cdp-signer.d.ts +133 -0
  27. package/dist/vendor/otto-intel-mcp/adapter/cdp-signer.js +356 -0
  28. package/dist/vendor/otto-intel-mcp/adapter/chain.d.ts +36 -0
  29. package/dist/vendor/otto-intel-mcp/adapter/chain.js +65 -0
  30. package/dist/vendor/otto-intel-mcp/adapter/erc20.d.ts +39 -0
  31. package/dist/vendor/otto-intel-mcp/adapter/erc20.js +17 -0
  32. package/dist/vendor/otto-intel-mcp/adapter/lifi-decode.d.ts +52 -0
  33. package/dist/vendor/otto-intel-mcp/adapter/lifi-decode.js +149 -0
  34. package/dist/vendor/otto-intel-mcp/adapter/refusal.d.ts +21 -0
  35. package/dist/vendor/otto-intel-mcp/adapter/refusal.js +55 -0
  36. package/dist/vendor/otto-intel-mcp/adapter/sent-step.d.ts +15 -0
  37. package/dist/vendor/otto-intel-mcp/adapter/sent-step.js +6 -0
  38. package/dist/vendor/otto-intel-mcp/adapter/verify.d.ts +149 -0
  39. package/dist/vendor/otto-intel-mcp/adapter/verify.js +432 -0
  40. package/dist/vendor/otto-intel-mcp/adapter-cdp-index.d.ts +6 -0
  41. package/dist/vendor/otto-intel-mcp/adapter-cdp-index.js +7 -0
  42. package/dist/vendor/otto-intel-mcp/adapter-index.d.ts +15 -0
  43. package/dist/vendor/otto-intel-mcp/adapter-index.js +15 -0
  44. package/dist/vendor/otto-intel-mcp/artifact-id.d.ts +16 -0
  45. package/dist/vendor/otto-intel-mcp/artifact-id.js +60 -0
  46. package/dist/vendor/otto-intel-mcp/execution-config.d.ts +232 -0
  47. package/dist/vendor/otto-intel-mcp/execution-config.js +443 -0
  48. package/dist/vendor/otto-intel-mcp/execution-delegated-definition.d.ts +165 -0
  49. package/dist/vendor/otto-intel-mcp/execution-delegated-definition.js +116 -0
  50. package/dist/vendor/otto-intel-mcp/execution-delegation-admin-definition.d.ts +208 -0
  51. package/dist/vendor/otto-intel-mcp/execution-delegation-admin-definition.js +170 -0
  52. package/dist/vendor/otto-intel-mcp/execution-delegation-policy.d.ts +257 -0
  53. package/dist/vendor/otto-intel-mcp/execution-delegation-policy.js +279 -0
  54. package/dist/vendor/otto-intel-mcp/execution-errors.d.ts +9 -0
  55. package/dist/vendor/otto-intel-mcp/execution-errors.js +134 -0
  56. package/dist/vendor/otto-intel-mcp/execution-index.d.ts +17 -0
  57. package/dist/vendor/otto-intel-mcp/execution-index.js +16 -0
  58. package/dist/vendor/otto-intel-mcp/execution-intent.d.ts +14 -0
  59. package/dist/vendor/otto-intel-mcp/execution-intent.js +36 -0
  60. package/dist/vendor/otto-intel-mcp/execution-tool-definitions.d.ts +1103 -0
  61. package/dist/vendor/otto-intel-mcp/execution-tool-definitions.js +1051 -0
  62. package/dist/vendor/otto-intel-mcp/execution-types.d.ts +274 -0
  63. package/dist/vendor/otto-intel-mcp/execution-types.js +157 -0
  64. package/dist/verify.d.ts +2 -0
  65. package/dist/verify.js +3 -0
  66. package/dist/x402-table.d.ts +99 -0
  67. package/dist/x402-table.js +221 -0
  68. package/package.json +97 -0
@@ -0,0 +1,232 @@
1
+ import { type Address, type Hex } from 'viem';
2
+ export declare const LIFI_INTEGRATOR: "ottowallet";
3
+ export declare const DEFAULT_LIFI_FEE_BPS: 10;
4
+ export declare const DEFAULT_LIFI_AGGREGATE_FEE_CAP_RATE = "0.0025";
5
+ export declare const DEFAULT_LIFI_FEE_CONFIG_VERSION = "lifi-2026-08-16-10bps-25bps-cap-v2";
6
+ export declare const DEFAULT_OTTO_LIFI_FEE_RECIPIENT: `0x${string}`;
7
+ export declare const DEFAULT_LIFI_PLATFORM_FEE_RECIPIENT: `0x${string}`;
8
+ export declare const LIFI_DIAMOND_ADDRESS: `0x${string}`;
9
+ /**
10
+ * Reviewed LI.FI FeeForwarder deployments, per chain, as a LIST — every address a fee-forwarding leg
11
+ * may call. Newest last. A leg calling any address NOT in its chain's list is refused by name (the
12
+ * drift alarm below), never accepted by shape.
13
+ *
14
+ * Review record (both entries verified against lifinance/contracts `deployments/<chain>.json` and
15
+ * on-chain `eth_getCode`; the v2 rollout is what turned the 2026-08-17 constructors inert until this
16
+ * list existed — caught 2026-08-26 by the Model-B proof kit's first dry run; that kit's runbook,
17
+ * `docs/0826_model_b_proof_runbook.md`, ships with the kit and records the finding):
18
+ * - v1 `0xC18D…75e1` (56/137/8453/42161/43114) · `0x6855…E4eD` (1) — reviewed 2026-08-16/17;
19
+ * still deployed (3110 bytes on Base), no longer emitted by li.quest.
20
+ * - v2.0.0 `0xCE40449B773a3E6E5e769ADb4e567179d4828cbd` on ALL six chains — rolled out
21
+ * 2026-08-21 (lifinance/contracts commit 15039b88 "roll out FeeForwarder v2.0.0 to production
22
+ * (EXSC-737) (#2226)"), `src/Periphery/FeeForwarder.sol` `@custom:version 2.0.0`; 3037 bytes,
23
+ * byte-identical on Base and Arbitrum (CREATE2); same `collectTokenFees` selector; live legs
24
+ * carry unchanged distributions (LI.FI platform + Otto). Reviewed 2026-08-26.
25
+ *
26
+ * Adding a deployment here is a REVIEW, not a config edit: confirm the registry entry, read the
27
+ * bytecode, decode one live leg's distributions, then add — never widen to a pattern.
28
+ */
29
+ export declare const LIFI_FEE_FORWARDER_V1_MAINNET: `0x${string}`;
30
+ export declare const LIFI_FEE_FORWARDER_V1: `0x${string}`;
31
+ export declare const LIFI_FEE_FORWARDER_V2: `0x${string}`;
32
+ export declare const LIFI_FEE_FORWARDERS_BY_CHAIN: Readonly<Record<number, readonly Address[]>>;
33
+ /** The reviewed FeeForwarder list for a chain, or undefined when the chain is outside the reviewed set. */
34
+ export declare function reviewedLiFiFeeForwarders(chainId: number): readonly Address[] | undefined;
35
+ export declare function isReviewedLiFiFeeForwarder(chainId: number, address: Address): boolean;
36
+ /**
37
+ * The drift alarm. When a fee-forwarding leg calls a contract that is not on the reviewed list, the
38
+ * refusal must say so BY ADDRESS and point at where to review it — a silent refusal here is how a
39
+ * shipped rail goes dark for days after an upstream rollout.
40
+ */
41
+ export declare function unreviewedFeeForwarderMessage(chainId: number, callTo: Address, approveTo: Address): string;
42
+ /**
43
+ * The v1 cross-chain bridge route set, ENUMERATED — not "all LI.FI routes" (spec §7.1). The bridge
44
+ * validator is PolymerCCTP-specific, so a route is supported only when both legs are native Circle
45
+ * USDC on a chain that (a) carries a reviewed LI.FI FeeForwarder above and (b) was live-verified on
46
+ * 2026-08-17 to return the reviewed PolymerCCTP facet under `allowBridges=polymerStandard`. All 20
47
+ * ordered pairs of these five chains were probed and returned selector 0x17917a4e.
48
+ *
49
+ * BSC (56) has a reviewed FeeForwarder but is deliberately absent: it carries only Binance-Peg USDC
50
+ * (18 decimals), not native Circle USDC, so CCTP's burn-and-mint same-token guarantee does not hold.
51
+ * A request naming any chain outside this table is refused by name — the route is the named defect.
52
+ */
53
+ export declare const LIFI_CCTP_USDC_BY_CHAIN: Readonly<Record<number, Address>>;
54
+ /** LI.FI bridge tool key pinned in the quote request so the reviewed facet is the only one quoted. */
55
+ export declare const LIFI_POLYMER_BRIDGE_TOOL: "polymerStandard";
56
+ /**
57
+ * True only for an ordered chain pair inside the enumerated set whose tokens are the pinned native
58
+ * USDC on each side. Same-token by construction: CCTP burns USDC on the source and mints canonical
59
+ * USDC on the destination, which is what makes the destination asset assertable from source calldata.
60
+ */
61
+ export declare function isEnumeratedCctpBridgeRoute(fromChainId: number, toChainId: number, fromToken: Address, toToken: Address): boolean;
62
+ /** The only chain Polymarket's CTF exchanges are deployed on; also the EIP-712 domain chain id. */
63
+ export declare const POLYMARKET_CHAIN_ID: 137;
64
+ /** Collateral and conditional-token atomic precision; mirrors the SDK's COLLATERAL_TOKEN_DECIMALS. */
65
+ export declare const POLYMARKET_AMOUNT_DECIMALS: 6;
66
+ /**
67
+ * Otto's registered Polymarket builder code, the bytes32 that lands in the `builder` field INSIDE
68
+ * the signed EIP-712 order (spec §4). Same value the prediction-markets agent already stamps
69
+ * (`services/prediction-markets-agent/src/lib/polymarket-contracts.ts`), live-verified 2026-08-17
70
+ * against `GET https://clob.polymarket.com/fees/builder-fees/<code>`: registered, `enabled: true`,
71
+ * both rates 0 bps.
72
+ */
73
+ export declare const OTTO_PM_BUILDER_CODE: "0x910082696e647acd3f9486c1a6366840c780a26db5b6aa781892ebf69c48508c";
74
+ export declare const PM_BYTES32_ZERO: `0x${string}`;
75
+ /**
76
+ * RULED builder-attribution values: 0 bps maker, 0 bps taker (`docs/0808_model_b_scope_and_verdict.md`
77
+ * §0.3 — "registered and enabled, with both fee rates at 0 bps"; spec §8 records PM as 0/0 today).
78
+ *
79
+ * The *flip* to a non-zero taker rate is an OPEN Founder item (spec §13, waits on the
80
+ * `/builder/trades` volume pull) and is a Polymarket UI settings change, not a code change. So the
81
+ * constructor never guesses a rate: it stamps the ruled value under a config version and refuses
82
+ * with `POLYMARKET_BUILDER_FEE_UNRULED` when the live registry no longer matches it. Bumping this
83
+ * constant plus the config version below is the one place a ruled flip lands.
84
+ */
85
+ export declare const PM_RULED_BUILDER_FEE_BPS: Readonly<{
86
+ maker: number;
87
+ taker: number;
88
+ }>;
89
+ export declare const DEFAULT_PM_BUILDER_FEE_CONFIG_VERSION = "pm-2026-08-17-builder-0bps-0bps-v1";
90
+ export declare const POLYMARKET_TICK_SIZES: readonly ["0.1", "0.01", "0.001", "0.0001"];
91
+ export type PolymarketTickSize = (typeof POLYMARKET_TICK_SIZES)[number];
92
+ export interface PolymarketRounding {
93
+ readonly price: number;
94
+ readonly size: number;
95
+ readonly amount: number;
96
+ }
97
+ /**
98
+ * Decimal precision the SDK rounds price, size, and derived amounts to, per tick size. The SDK's own
99
+ * `ROUNDING_CONFIG` is not reachable from the package root, so it is pinned here and *proved* rather
100
+ * than trusted: the live-captured `polymarket-sdk-created-order-*.json` fixtures are the SDK's real
101
+ * output for a real market, and the amount assertions run against them.
102
+ */
103
+ export declare const POLYMARKET_ROUNDING_BY_TICK_SIZE: Readonly<Record<PolymarketTickSize, PolymarketRounding>>;
104
+ export declare function isPolymarketTickSize(value: string): value is PolymarketTickSize;
105
+ export declare const POLYMARKET_EIP712_DOMAIN_NAME: "Polymarket CTF Exchange";
106
+ export declare const POLYMARKET_EIP712_DOMAIN_VERSION: "2";
107
+ export declare const POLYMARKET_ORDER_PRIMARY_TYPE: "Order";
108
+ /**
109
+ * The CTF Exchange V2 `Order` struct, pinned field-for-field and in order. This is the shape the
110
+ * user's signer hashes and the exchange re-hashes, so `builder` meaning "builder" depends on this
111
+ * array being exactly right — a reordered or retyped field silently changes what every other field
112
+ * commits to. It is asserted against the live-captured SDK payload rather than trusted: the
113
+ * committed fixtures carry a real signature over a real market, and the recovery check in
114
+ * `polymarket-order-assertions.ts` fails if this array is off by one entry.
115
+ *
116
+ * `expiration` and `taker` are deliberately absent: the V2 exchange does not sign them
117
+ * (`@polymarket/clob-client-v2` ctfExchangeV2TypedData.js), which is why the artifact carries
118
+ * `expiration` as an unsigned POST-time field.
119
+ */
120
+ export declare const POLYMARKET_ORDER_V2_EIP712_FIELDS: readonly {
121
+ readonly name: string;
122
+ readonly type: string;
123
+ }[];
124
+ /**
125
+ * Hyperliquid requires the EIP-712 domain `chainId` of an L1 action to be exactly 1337, regardless
126
+ * of which EVM chain the signer's wallet is connected to (`@nktkas/hyperliquid` signing/mod.js:175 —
127
+ * "hyperliquid requires chainId to be 1337"). It is a protocol constant, not a network the artifact
128
+ * executes on, which is why the account profile must declare it and an adapter re-checks it.
129
+ */
130
+ export declare const HYPERLIQUID_L1_SIGNATURE_CHAIN_ID: 1337;
131
+ export declare const HYPERLIQUID_EIP712_DOMAIN_NAME: "Exchange";
132
+ export declare const HYPERLIQUID_EIP712_DOMAIN_VERSION: "1";
133
+ export declare const HYPERLIQUID_AGENT_PRIMARY_TYPE: "Agent";
134
+ /** The L1-action domain has no verifying contract; the venue pins the zero address. */
135
+ export declare const HYPERLIQUID_EIP712_VERIFYING_CONTRACT: "0x0000000000000000000000000000000000000000";
136
+ /** `"a"` on mainnet, `"b"` on testnet (signing/mod.js:186). v1 constructs mainnet actions only. */
137
+ export declare const HYPERLIQUID_MAINNET_AGENT_SOURCE: "a";
138
+ /**
139
+ * The `Agent` struct the user's signer hashes. Pinned field-for-field and in order: the whole action
140
+ * enters the signature only through `connectionId`, so a reordered or retyped field silently changes
141
+ * what the signature commits to. Asserted against the SDK's own types in the live-captured fixture.
142
+ */
143
+ export declare const HYPERLIQUID_AGENT_EIP712_FIELDS: readonly {
144
+ readonly name: string;
145
+ readonly type: string;
146
+ }[];
147
+ /**
148
+ * `connectionId = keccak256(msgpack(action) ++ nonce_u64_be ++ vault_marker[++ vault_address] ++
149
+ * expires_marker[++ expiresAfter_u64_be])` (`signing/mod.js:88-104`). msgpack encodes object keys in
150
+ * INSERTION order, so the key order below is part of the signed bytes, not a formatting choice: an
151
+ * action carrying the same values in a different key order hashes to a different digest and the venue
152
+ * rejects the signature. The orders below are the exact orders the SDK's own valibot normalizer
153
+ * emits, live-proved against the captured SDK action in `hyperliquid-fixture-capture.ts`.
154
+ */
155
+ export declare const HYPERLIQUID_ACTION_KEY_ORDER: readonly string[];
156
+ /** `c` (client order id) is appended only when the order carries one. */
157
+ export declare const HYPERLIQUID_ORDER_KEY_ORDER: readonly string[];
158
+ export declare const HYPERLIQUID_TRIGGER_KEY_ORDER: readonly string[];
159
+ /** Perp price precision ceiling: at most `MAX_DECIMALS - szDecimals` fractional digits. */
160
+ export declare const HYPERLIQUID_PERP_MAX_DECIMALS: 6;
161
+ /** …and at most 5 significant digits, unless the price is an integer (always accepted). */
162
+ export declare const HYPERLIQUID_PRICE_MAX_SIGNIFICANT_DIGITS: 5;
163
+ /**
164
+ * Venue time-in-force values a caller may name. `FrontendMarket` and `LiquidationMarket` exist in the
165
+ * venue schema but are Hyperliquid-UI-internal, so they are not offered. A market fill is expressed
166
+ * as `Ioc` at the caller's OWN aggressive limit price: this constructor never invents a price from a
167
+ * mark read, which is what the trade-execution agent's market path does (`hyperliquid-client.ts:1785`
168
+ * — mark × 1.05) and what would let an artifact signed minutes later fill far from the caller's bound.
169
+ */
170
+ export declare const HYPERLIQUID_TIME_IN_FORCE: readonly ["Gtc", "Ioc", "Alo"];
171
+ export type HyperliquidTimeInForce = (typeof HYPERLIQUID_TIME_IN_FORCE)[number];
172
+ /** `na` for a lone entry; `normalTpsl` binds fixed-size TP/SL legs to the entry (client.ts:1876). */
173
+ export declare const HYPERLIQUID_ORDER_GROUPINGS: readonly ["na", "normalTpsl"];
174
+ export type HyperliquidOrderGrouping = (typeof HYPERLIQUID_ORDER_GROUPINGS)[number];
175
+ /**
176
+ * RULED builder-attribution state (Founder, 2026-08-17; spec §7.2/§12): the Hyperliquid builder field
177
+ * is **spec'd and VALUELESS** until the Step-0 `approveBuilderFee` reversal ships. So the constructed
178
+ * action carries NO `builder` key — an absent key is the only encoding the venue reads as "no builder
179
+ * fee", and inventing an address or a tenths-of-a-bp value here would stamp an unruled fee inside a
180
+ * digest the user signs. The exact `{b, f}` assert lands in a follow-up fold; until then the envelope
181
+ * carries this machine-readable pending marker and the constructor asserts the key's ABSENCE.
182
+ */
183
+ export declare const HL_BUILDER_ATTRIBUTION_STATUS: "pending_step0_builder_fee_approval";
184
+ export declare const DEFAULT_HL_BUILDER_FEE_CONFIG_VERSION = "hl-2026-08-17-builder-unwired-v1";
185
+ export interface HyperliquidPerpAsset {
186
+ readonly name: string;
187
+ /** Index in the live `meta.universe`; the venue's `a` field. Never a value this repo invents. */
188
+ readonly assetId: number;
189
+ readonly szDecimals: number;
190
+ readonly maxLeverage: number;
191
+ readonly isDelisted: boolean;
192
+ }
193
+ export interface DecimalRate {
194
+ readonly decimal: string;
195
+ readonly numerator: bigint;
196
+ readonly denominator: bigint;
197
+ }
198
+ /**
199
+ * Prepare-only custody boundary: this runtime never receives or retains caller wallet keys,
200
+ * signing secrets, or transaction signatures. It may retain an operational LI.FI quote-service
201
+ * credential, which is isolated from caller schemas and execution envelopes.
202
+ */
203
+ export interface ExecutionServiceConfig {
204
+ readonly artifactTtlMs: number;
205
+ /** Quote-service authentication only; never caller wallet/signing material or envelope data. */
206
+ readonly lifiApiKey?: string;
207
+ readonly lifiBaseUrl: string;
208
+ readonly lifiAggregateFeeCap: DecimalRate;
209
+ readonly lifiAllowedFeeRecipients: readonly Address[];
210
+ readonly lifiFee: DecimalRate;
211
+ readonly lifiFeeConfigVersion: string;
212
+ readonly lifiFeeRecipient: Address;
213
+ readonly lifiTimeoutMs: number;
214
+ readonly polymarketClobBaseUrl: string;
215
+ /** The bytes32 stamped into the signed order's `builder` field; never caller-supplied. */
216
+ readonly polymarketBuilderCode: Hex;
217
+ readonly polymarketBuilderFeeConfigVersion: string;
218
+ /** The ruled rates the live builder registry must still match; never used as a fee to charge. */
219
+ readonly polymarketRuledBuilderFeeBps: Readonly<{
220
+ maker: number;
221
+ taker: number;
222
+ }>;
223
+ readonly polymarketTimeoutMs: number;
224
+ readonly hyperliquidApiBaseUrl: string;
225
+ readonly hyperliquidBuilderFeeConfigVersion: string;
226
+ /** The ruled pending state of the builder field; never a fee this constructor may charge. */
227
+ readonly hyperliquidBuilderAttributionStatus: typeof HL_BUILDER_ATTRIBUTION_STATUS;
228
+ readonly hyperliquidTimeoutMs: number;
229
+ }
230
+ export declare function parseDecimalRate(raw: string, name?: string): DecimalRate;
231
+ export declare function loadExecutionServiceConfig(env?: NodeJS.ProcessEnv): ExecutionServiceConfig | undefined;
232
+ export declare function attributedFeeAmount(amount: bigint, rate: DecimalRate): bigint;