otto-intel-mcp 0.1.2 → 0.1.4

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 (239) hide show
  1. package/README.md +76 -18
  2. package/dist/account-userop-policy-definition.d.ts +14 -0
  3. package/dist/account-userop-policy-definition.js +12 -0
  4. package/dist/account-userop-policy-relation.d.ts +371 -0
  5. package/dist/account-userop-policy-relation.js +87 -0
  6. package/dist/adapter/cdp-signer.d.ts +76 -9
  7. package/dist/adapter/cdp-signer.js +274 -33
  8. package/dist/adapter/evm-call-failure.d.ts +29 -0
  9. package/dist/adapter/evm-call-failure.js +109 -0
  10. package/dist/adapter/refusal.d.ts +1 -1
  11. package/dist/adapter/refusal.js +13 -0
  12. package/dist/adapter/route-simulator.d.ts +91 -0
  13. package/dist/adapter/route-simulator.js +143 -0
  14. package/dist/adapter-cdp-index.d.ts +1 -1
  15. package/dist/executable-equities.d.ts +55 -0
  16. package/dist/executable-equities.js +116 -0
  17. package/dist/executable-yield-markets.d.ts +261 -0
  18. package/dist/executable-yield-markets.js +154 -0
  19. package/dist/execution-account-gas-quote.d.ts +141 -0
  20. package/dist/execution-account-gas-quote.js +443 -0
  21. package/dist/execution-account-gas-review.d.ts +123 -0
  22. package/dist/execution-account-gas-review.js +104 -0
  23. package/dist/execution-account-gas-runtime.d.ts +33 -0
  24. package/dist/execution-account-gas-runtime.js +131 -0
  25. package/dist/execution-account-gas-view.d.ts +936 -0
  26. package/dist/execution-account-gas-view.js +56 -0
  27. package/dist/execution-config.d.ts +3 -0
  28. package/dist/execution-config.js +4 -0
  29. package/dist/execution-delegated-definition.d.ts +7 -6
  30. package/dist/execution-delegated-definition.js +13 -2
  31. package/dist/execution-delegation-admin-definition.d.ts +127 -5
  32. package/dist/execution-delegation-admin-definition.js +155 -5
  33. package/dist/execution-delegation-admin.d.ts +48 -2
  34. package/dist/execution-delegation-admin.js +422 -12
  35. package/dist/execution-delegation-cap-store.d.ts +386 -0
  36. package/dist/execution-delegation-cap-store.js +1150 -0
  37. package/dist/execution-delegation-exit-definition.d.ts +309 -0
  38. package/dist/execution-delegation-exit-definition.js +204 -0
  39. package/dist/execution-delegation-exit-store.d.ts +114 -0
  40. package/dist/execution-delegation-exit-store.js +671 -0
  41. package/dist/execution-delegation-exit.d.ts +4 -0
  42. package/dist/execution-delegation-exit.js +614 -0
  43. package/dist/execution-delegation-finality.d.ts +22 -0
  44. package/dist/execution-delegation-finality.js +90 -0
  45. package/dist/execution-delegation-operation-store.d.ts +129 -0
  46. package/dist/execution-delegation-operation-store.js +1107 -0
  47. package/dist/execution-delegation-operations-definition.d.ts +282 -0
  48. package/dist/execution-delegation-operations-definition.js +117 -0
  49. package/dist/execution-delegation-operations.d.ts +6 -0
  50. package/dist/execution-delegation-operations.js +282 -0
  51. package/dist/execution-delegation-policy.d.ts +154 -8
  52. package/dist/execution-delegation-policy.js +273 -40
  53. package/dist/execution-delegation.d.ts +51 -0
  54. package/dist/execution-delegation.js +441 -31
  55. package/dist/execution-errors.d.ts +1 -1
  56. package/dist/execution-errors.js +122 -0
  57. package/dist/execution-index.d.ts +7 -2
  58. package/dist/execution-index.js +7 -2
  59. package/dist/execution-journal-schema.d.ts +96 -0
  60. package/dist/execution-journal-schema.js +368 -0
  61. package/dist/execution-journal-tables.d.ts +14 -0
  62. package/dist/execution-journal-tables.js +227 -0
  63. package/dist/execution-policy-compatibility.d.ts +34 -0
  64. package/dist/execution-policy-compatibility.js +76 -0
  65. package/dist/execution-registration.d.ts +54 -2
  66. package/dist/execution-registration.js +151 -5
  67. package/dist/execution-sponsored-account-profile.d.ts +32 -0
  68. package/dist/execution-sponsored-account-profile.js +59 -0
  69. package/dist/execution-sponsored-account.d.ts +1519 -0
  70. package/dist/execution-sponsored-account.js +222 -0
  71. package/dist/execution-sponsored-definition.d.ts +1713 -0
  72. package/dist/execution-sponsored-definition.js +185 -0
  73. package/dist/execution-sponsored-gas-policy.d.ts +27 -0
  74. package/dist/execution-sponsored-gas-policy.js +110 -0
  75. package/dist/execution-sponsored-hosted.d.ts +3 -0
  76. package/dist/execution-sponsored-hosted.js +71 -0
  77. package/dist/execution-sponsored-index.d.ts +1322 -0
  78. package/dist/execution-sponsored-index.js +102 -0
  79. package/dist/execution-sponsored-mcp-definition.d.ts +1662 -0
  80. package/dist/execution-sponsored-mcp-definition.js +94 -0
  81. package/dist/execution-sponsored-receipt.d.ts +47 -0
  82. package/dist/execution-sponsored-receipt.js +74 -0
  83. package/dist/execution-sponsored-registration.d.ts +14 -0
  84. package/dist/execution-sponsored-registration.js +77 -0
  85. package/dist/execution-sponsored-runtime.d.ts +84 -0
  86. package/dist/execution-sponsored-runtime.js +149 -0
  87. package/dist/execution-sponsored-settlement.d.ts +15 -0
  88. package/dist/execution-sponsored-settlement.js +88 -0
  89. package/dist/execution-sponsored-store.d.ts +67 -0
  90. package/dist/execution-sponsored-store.js +517 -0
  91. package/dist/execution-sponsored-transport.d.ts +90 -0
  92. package/dist/execution-sponsored-transport.js +180 -0
  93. package/dist/execution-tool-definitions.d.ts +21 -21
  94. package/dist/execution-tool-definitions.js +0 -7
  95. package/dist/execution-tools.d.ts +53 -1
  96. package/dist/execution-tools.js +171 -13
  97. package/dist/execution-worker-guard.d.ts +28 -0
  98. package/dist/execution-worker-guard.js +124 -0
  99. package/dist/hybrid-yield-index.d.ts +10 -0
  100. package/dist/hybrid-yield-index.js +11 -0
  101. package/dist/hybrid-yield-markets.d.ts +96 -0
  102. package/dist/hybrid-yield-markets.js +124 -0
  103. package/dist/hybrid-yield.d.ts +411 -0
  104. package/dist/hybrid-yield.js +155 -0
  105. package/dist/hyperliquid-order-builder.js +4 -0
  106. package/dist/lifi-execution-client.d.ts +6 -0
  107. package/dist/lifi-execution-client.js +3 -0
  108. package/dist/lp-userop-account.d.ts +461 -0
  109. package/dist/lp-userop-account.js +417 -0
  110. package/dist/lp-userop-authority.d.ts +49 -0
  111. package/dist/lp-userop-authority.js +211 -0
  112. package/dist/lp-userop-definition.d.ts +233 -0
  113. package/dist/lp-userop-definition.js +85 -0
  114. package/dist/lp-userop-hosted.d.ts +3 -0
  115. package/dist/lp-userop-hosted.js +73 -0
  116. package/dist/lp-userop-index.d.ts +1569 -0
  117. package/dist/lp-userop-index.js +112 -0
  118. package/dist/lp-userop-mcp-definition.d.ts +1220 -0
  119. package/dist/lp-userop-mcp-definition.js +46 -0
  120. package/dist/lp-userop-operation.d.ts +1230 -0
  121. package/dist/lp-userop-operation.js +140 -0
  122. package/dist/lp-userop-registration.d.ts +14 -0
  123. package/dist/lp-userop-registration.js +70 -0
  124. package/dist/lp-userop-settlement.d.ts +89 -0
  125. package/dist/lp-userop-settlement.js +184 -0
  126. package/dist/lp-userop.d.ts +643 -0
  127. package/dist/lp-userop.js +343 -0
  128. package/dist/native-yield-account-definition.d.ts +1192 -0
  129. package/dist/native-yield-account-definition.js +232 -0
  130. package/dist/native-yield-account-gas.d.ts +58 -0
  131. package/dist/native-yield-account-gas.js +228 -0
  132. package/dist/native-yield-account-index.d.ts +23 -0
  133. package/dist/native-yield-account-index.js +28 -0
  134. package/dist/native-yield-account-policy.d.ts +168 -0
  135. package/dist/native-yield-account-policy.js +525 -0
  136. package/dist/native-yield-account-rpc.d.ts +8 -0
  137. package/dist/native-yield-account-rpc.js +128 -0
  138. package/dist/native-yield-account-runtime.d.ts +71 -0
  139. package/dist/native-yield-account-runtime.js +125 -0
  140. package/dist/native-yield-account-store.d.ts +40 -0
  141. package/dist/native-yield-account-store.js +307 -0
  142. package/dist/native-yield-account.d.ts +662 -0
  143. package/dist/native-yield-account.js +371 -0
  144. package/dist/native-yield-consent-store.d.ts +20 -0
  145. package/dist/native-yield-consent-store.js +317 -0
  146. package/dist/native-yield-definition.d.ts +288 -0
  147. package/dist/native-yield-definition.js +105 -0
  148. package/dist/native-yield-reader.d.ts +4 -0
  149. package/dist/native-yield-reader.js +137 -0
  150. package/dist/native-yield-settlement.d.ts +48 -0
  151. package/dist/native-yield-settlement.js +167 -0
  152. package/dist/native-yield-simulation.d.ts +18 -0
  153. package/dist/native-yield-simulation.js +45 -0
  154. package/dist/native-yield-userop-account.d.ts +675 -0
  155. package/dist/native-yield-userop-account.js +357 -0
  156. package/dist/native-yield-userop-authority.d.ts +214 -0
  157. package/dist/native-yield-userop-authority.js +296 -0
  158. package/dist/native-yield-userop-definition.d.ts +331 -0
  159. package/dist/native-yield-userop-definition.js +105 -0
  160. package/dist/native-yield-userop-hosted.d.ts +3 -0
  161. package/dist/native-yield-userop-hosted.js +71 -0
  162. package/dist/native-yield-userop-index.d.ts +1522 -0
  163. package/dist/native-yield-userop-index.js +142 -0
  164. package/dist/native-yield-userop-mcp-definition.d.ts +1356 -0
  165. package/dist/native-yield-userop-mcp-definition.js +50 -0
  166. package/dist/native-yield-userop-operation.d.ts +845 -0
  167. package/dist/native-yield-userop-operation.js +127 -0
  168. package/dist/native-yield-userop-policy.d.ts +23 -0
  169. package/dist/native-yield-userop-policy.js +25 -0
  170. package/dist/native-yield-userop-registration.d.ts +17 -0
  171. package/dist/native-yield-userop-registration.js +76 -0
  172. package/dist/native-yield-userop-settlement.d.ts +8 -0
  173. package/dist/native-yield-userop-settlement.js +79 -0
  174. package/dist/native-yield-userop-simulation.d.ts +18 -0
  175. package/dist/native-yield-userop-simulation.js +34 -0
  176. package/dist/native-yield-userop.d.ts +35 -0
  177. package/dist/native-yield-userop.js +156 -0
  178. package/dist/native-yield-verify.d.ts +30 -0
  179. package/dist/native-yield-verify.js +141 -0
  180. package/dist/native-yield.d.ts +17 -0
  181. package/dist/native-yield.js +119 -0
  182. package/dist/stdio-main.js +0 -0
  183. package/dist/stock-buy-definition.d.ts +338 -0
  184. package/dist/stock-buy-definition.js +127 -0
  185. package/dist/stock-buy-oracle.d.ts +8 -0
  186. package/dist/stock-buy-oracle.js +22 -0
  187. package/dist/stock-buy.d.ts +17 -0
  188. package/dist/stock-buy.js +164 -0
  189. package/dist/tool-definitions.d.ts +3 -1
  190. package/dist/tool-definitions.js +55 -2
  191. package/dist/vendor/lp-v3/lp-v3-atomic-contract.d.ts +445 -0
  192. package/dist/vendor/lp-v3/lp-v3-atomic-contract.js +90 -0
  193. package/dist/vendor/lp-v3/lp-v3-atomic-evidence.d.ts +14 -0
  194. package/dist/vendor/lp-v3/lp-v3-atomic-evidence.js +82 -0
  195. package/dist/vendor/lp-v3/lp-v3-atomic-index.d.ts +80 -0
  196. package/dist/vendor/lp-v3/lp-v3-atomic-index.js +19 -0
  197. package/dist/vendor/lp-v3/lp-v3-atomic-plan.d.ts +43 -0
  198. package/dist/vendor/lp-v3/lp-v3-atomic-plan.js +112 -0
  199. package/dist/vendor/lp-v3/lp-v3-atomic-read-contract.d.ts +312 -0
  200. package/dist/vendor/lp-v3/lp-v3-atomic-read-contract.js +41 -0
  201. package/dist/vendor/lp-v3/lp-v3-atomic-read-index.d.ts +3 -0
  202. package/dist/vendor/lp-v3/lp-v3-atomic-read-index.js +3 -0
  203. package/dist/vendor/lp-v3/lp-v3-atomic-read-rpc.d.ts +49 -0
  204. package/dist/vendor/lp-v3/lp-v3-atomic-read-rpc.js +88 -0
  205. package/dist/vendor/lp-v3/lp-v3-atomic-read.d.ts +17 -0
  206. package/dist/vendor/lp-v3/lp-v3-atomic-read.js +232 -0
  207. package/dist/vendor/lp-v3/lp-v3-atomic-settlement.d.ts +105 -0
  208. package/dist/vendor/lp-v3/lp-v3-atomic-settlement.js +162 -0
  209. package/dist/vendor/lp-v3/lp-v3-collect-protocol-contract.d.ts +606 -0
  210. package/dist/vendor/lp-v3/lp-v3-collect-protocol-contract.js +59 -0
  211. package/dist/vendor/lp-v3/lp-v3-collect-protocol-index.d.ts +168 -0
  212. package/dist/vendor/lp-v3/lp-v3-collect-protocol-index.js +23 -0
  213. package/dist/vendor/lp-v3/lp-v3-collect-protocol-observation.d.ts +32 -0
  214. package/dist/vendor/lp-v3/lp-v3-collect-protocol-observation.js +228 -0
  215. package/dist/vendor/lp-v3/lp-v3-collect-protocol-plan.d.ts +11 -0
  216. package/dist/vendor/lp-v3/lp-v3-collect-protocol-plan.js +91 -0
  217. package/dist/vendor/lp-v3/lp-v3-collect-protocol-reconcile.d.ts +9 -0
  218. package/dist/vendor/lp-v3/lp-v3-collect-protocol-reconcile.js +124 -0
  219. package/dist/vendor/lp-v3/lp-v3-contract.d.ts +538 -0
  220. package/dist/vendor/lp-v3/lp-v3-contract.js +137 -0
  221. package/dist/vendor/lp-v3/lp-v3-evidence.d.ts +25 -0
  222. package/dist/vendor/lp-v3/lp-v3-evidence.js +168 -0
  223. package/dist/vendor/lp-v3/lp-v3-plan.d.ts +22 -0
  224. package/dist/vendor/lp-v3/lp-v3-plan.js +135 -0
  225. package/dist/vendor/lp-v3/types.d.ts +131 -0
  226. package/dist/vendor/lp-v3/types.js +6 -0
  227. package/dist/vendor/lp-v3/v4-math.d.ts +18 -0
  228. package/dist/vendor/lp-v3/v4-math.js +90 -0
  229. package/dist/yield-deposit-definition.d.ts +374 -0
  230. package/dist/yield-deposit-definition.js +123 -0
  231. package/dist/yield-deposit.d.ts +16 -0
  232. package/dist/yield-deposit.js +149 -0
  233. package/dist/yield-route-semantics.d.ts +27 -0
  234. package/dist/yield-route-semantics.js +71 -0
  235. package/dist/yield-withdraw-definition.d.ts +357 -0
  236. package/dist/yield-withdraw-definition.js +90 -0
  237. package/dist/yield-withdraw.d.ts +11 -0
  238. package/dist/yield-withdraw.js +122 -0
  239. package/package.json +239 -7
@@ -0,0 +1,180 @@
1
+ import { accountGasFailure } from './execution-account-gas-view.js';
2
+ /** CDP's public REST contract preserves paymasterContext, omitted by the pinned high-level SDK.
3
+ * Server-only transport. Admission, shared claims, consent and receipt finality belong to its caller.
4
+ * A POST is attempted once. Any response loss keeps the original request unresolved.
5
+ */
6
+ import { createHash } from 'node:crypto';
7
+ import { z } from 'zod';
8
+ import { assertSponsoredGasPolicyCurrent, readSponsoredGasPolicy, SponsoredGasPolicyError } from './execution-sponsored-gas-policy.js';
9
+ export const SPONSORED_CDP_NETWORKS = {
10
+ 1: 'ethereum', 8453: 'base', 42161: 'arbitrum', 10: 'optimism', 137: 'polygon',
11
+ };
12
+ const address = z.string().regex(/^0x[0-9a-fA-F]{40}$/);
13
+ const hash = z.string().regex(/^0x[0-9a-fA-F]{64}$/);
14
+ const callSchema = z.object({
15
+ to: address,
16
+ data: z.string().regex(/^0x(?:[0-9a-fA-F]{2})*$/).max(262146),
17
+ value: z.string().regex(/^(0|[1-9][0-9]*)$/).refine(v => BigInt(v) < 2n ** 256n),
18
+ }).strict();
19
+ const callsSchema = z.array(callSchema).min(1).max(8);
20
+ const bindingSchema = z.object({
21
+ userId: z.string().regex(/^[a-zA-Z0-9-]{1,100}$/),
22
+ account: address,
23
+ chainId: z.number().int().refine(v => Object.hasOwn(SPONSORED_CDP_NETWORKS, v)),
24
+ idempotencyKey: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
25
+ }).strict();
26
+ const responseSchema = z.object({
27
+ network: z.string(), userOpHash: hash, calls: callsSchema,
28
+ status: z.enum(['pending', 'signed', 'broadcast', 'complete', 'dropped', 'failed']),
29
+ transactionHash: z.union([hash, z.literal('')]).optional(),
30
+ });
31
+ export class SponsoredTransportError extends Error {
32
+ code;
33
+ constructor(code) {
34
+ super(code === 'SPONSOR_SUBMISSION_UNCERTAIN'
35
+ ? 'The sponsored request may have been submitted. Retain its claim and reconcile the same operation; do not create a replacement.'
36
+ : code === 'SPONSOR_AUTH_UNAVAILABLE' ? 'Sponsorship authentication could not be prepared; no request was sent.'
37
+ : 'The sponsored request or operator configuration is invalid.');
38
+ this.code = code;
39
+ this.name = 'SponsoredTransportError';
40
+ }
41
+ }
42
+ const API_HOST = 'api.cdp.coinbase.com';
43
+ function digest(binding, path, body) {
44
+ return createHash('sha256').update(JSON.stringify([binding.userId, binding.account.toLowerCase(), binding.chainId, binding.idempotencyKey, path, body])).digest('hex');
45
+ }
46
+ function normalizeCalls(calls) {
47
+ return callsSchema.parse(calls).map(call => ({ to: call.to.toLowerCase(), data: call.data.toLowerCase(), value: call.value }));
48
+ }
49
+ function validateProvider(raw) {
50
+ try {
51
+ if (!Object.hasOwn(SPONSORED_CDP_NETWORKS, raw.chainId))
52
+ throw new Error();
53
+ const url = new URL(raw.paymasterUrl);
54
+ if (url.protocol !== 'https:' || url.hostname !== 'api.pimlico.io' || url.port || url.username || url.password || url.hash ||
55
+ url.pathname !== `/v2/${raw.chainId}/rpc` || [...url.searchParams.keys()].length !== 1 || !url.searchParams.get('apikey') ||
56
+ !/^[a-zA-Z0-9_-]{1,128}$/.test(raw.sponsorshipPolicyId))
57
+ throw new Error();
58
+ return Object.freeze({ chainId: raw.chainId, paymasterUrl: url.toString(), sponsorshipPolicyId: raw.sponsorshipPolicyId });
59
+ }
60
+ catch {
61
+ throw new SponsoredTransportError('SPONSOR_CONFIGURATION_INVALID');
62
+ }
63
+ }
64
+ export function createSponsoredCdpTransport(options) {
65
+ const providers = new Map();
66
+ for (const provider of options.providers) {
67
+ if (providers.has(provider.chainId))
68
+ throw new SponsoredTransportError('SPONSOR_CONFIGURATION_INVALID');
69
+ providers.set(provider.chainId, validateProvider(provider));
70
+ }
71
+ const credentials = Object.freeze({ ...options.credentials });
72
+ const requestFetch = options.fetch ?? fetch;
73
+ const now = options.now ?? Date.now;
74
+ const monotonic = options.monotonic;
75
+ const auth = options.auth ?? (async (input) => {
76
+ const sdk = await import('@coinbase/cdp-sdk/auth');
77
+ return sdk.getAuthHeaders(input);
78
+ });
79
+ function prepare(binding, calls, payer = 'sponsor') {
80
+ try {
81
+ bindingSchema.parse(binding);
82
+ const provider = providers.get(binding.chainId);
83
+ if (!provider || (payer !== 'sponsor' && payer !== 'account'))
84
+ throw new Error();
85
+ const path = `/platform/v2/embedded-wallet-api/end-users/${binding.userId}/evm/smart-accounts/${binding.account.toLowerCase()}/send`;
86
+ const body = JSON.stringify({
87
+ network: SPONSORED_CDP_NETWORKS[binding.chainId], calls: normalizeCalls(calls), useCdpPaymaster: false,
88
+ ...(payer === 'sponsor' ? { paymasterAlias: `pimlico:${binding.chainId}`,
89
+ paymasterContext: { sponsorshipPolicyId: provider.sponsorshipPolicyId } } : {}),
90
+ });
91
+ return Object.freeze({ ...binding, account: binding.account.toLowerCase(), path, body,
92
+ digest: digest(binding, path, wireBody(binding.chainId, normalizeCalls(calls), payer)) });
93
+ }
94
+ catch {
95
+ throw new SponsoredTransportError('SPONSOR_REQUEST_INVALID');
96
+ }
97
+ }
98
+ function wireBody(chainId, calls, payer) {
99
+ const provider = providers.get(chainId);
100
+ if (!provider)
101
+ throw new SponsoredTransportError('SPONSOR_REQUEST_INVALID');
102
+ return JSON.stringify({ network: SPONSORED_CDP_NETWORKS[chainId], calls, useCdpPaymaster: false,
103
+ ...(payer === 'sponsor' ? { paymasterUrl: provider.paymasterUrl,
104
+ paymasterContext: { sponsorshipPolicyId: provider.sponsorshipPolicyId } } : {}) });
105
+ }
106
+ function validate(request) {
107
+ try {
108
+ const { userId, account, chainId, idempotencyKey } = request;
109
+ const body = JSON.parse(request.body);
110
+ const calls = normalizeCalls(body.calls);
111
+ const payer = body.paymasterAlias !== undefined || body.paymasterContext !== undefined ? 'sponsor' : 'account';
112
+ const expected = prepare({ userId, account, chainId, idempotencyKey }, calls, payer);
113
+ if (request.path !== expected.path || request.body !== expected.body || request.digest !== expected.digest)
114
+ throw new Error();
115
+ return { calls, payer };
116
+ }
117
+ catch {
118
+ throw new SponsoredTransportError('SPONSOR_REQUEST_INVALID');
119
+ }
120
+ }
121
+ function checkGasPolicy(chainId) {
122
+ const provider = providers.get(chainId);
123
+ if (!provider)
124
+ throw new SponsoredTransportError('SPONSOR_CONFIGURATION_INVALID');
125
+ return readSponsoredGasPolicy(provider, { fetch: requestFetch, now, monotonic });
126
+ }
127
+ return Object.freeze({
128
+ prepare,
129
+ checkGasPolicy,
130
+ /** Readiness/Stop/capability must be checked by the owning service after auth and immediately before POST. */
131
+ async send(request, beforeHandoff, handoff = start => start()) {
132
+ request = Object.freeze({ ...request });
133
+ const { calls: expectedCalls, payer } = validate(request);
134
+ const privateBody = wireBody(request.chainId, expectedCalls, payer);
135
+ let headers;
136
+ try {
137
+ headers = await auth({ ...credentials, requestMethod: 'POST', requestHost: API_HOST,
138
+ requestPath: request.path, requestBody: JSON.parse(privateBody), source: 'otto-sponsored-execution' });
139
+ }
140
+ catch {
141
+ throw new SponsoredTransportError('SPONSOR_AUTH_UNAVAILABLE');
142
+ }
143
+ await beforeHandoff();
144
+ // Read the current cap after asynchronous quote/protocol prechecks, then check its age again at invocation.
145
+ const gasPolicy = payer === 'sponsor' ? await checkGasPolicy(request.chainId) : undefined;
146
+ // No retry, redirect, transport fallback or provider error-body propagation.
147
+ let requestStarted = false;
148
+ try {
149
+ const response = await handoff(onInvoke => {
150
+ if (requestStarted)
151
+ throw new SponsoredTransportError('SPONSOR_SUBMISSION_UNCERTAIN');
152
+ if (gasPolicy)
153
+ assertSponsoredGasPolicyCurrent(gasPolicy, now());
154
+ onInvoke?.(gasPolicy);
155
+ requestStarted = true;
156
+ return requestFetch(`https://${API_HOST}${request.path}`, {
157
+ method: 'POST', redirect: 'error', signal: AbortSignal.timeout(30_000),
158
+ headers: { ...headers, 'Content-Type': 'application/json', 'X-Idempotency-Key': request.idempotencyKey }, body: privateBody,
159
+ });
160
+ });
161
+ if (!response.ok)
162
+ throw new Error();
163
+ const text = await response.text();
164
+ if (text.length > 1_000_000)
165
+ throw new Error();
166
+ const result = responseSchema.parse(JSON.parse(text));
167
+ if (result.network !== SPONSORED_CDP_NETWORKS[request.chainId] || JSON.stringify(normalizeCalls(result.calls)) !== JSON.stringify(expectedCalls))
168
+ throw new Error();
169
+ return Object.freeze({ userOpHash: result.userOpHash, status: result.status,
170
+ ...(result.transactionHash ? { transactionHash: result.transactionHash } : {}) });
171
+ }
172
+ catch (error) {
173
+ if (!requestStarted && (error instanceof SponsoredGasPolicyError || accountGasFailure(error)))
174
+ throw error;
175
+ throw new SponsoredTransportError('SPONSOR_SUBMISSION_UNCERTAIN');
176
+ }
177
+ },
178
+ });
179
+ }
180
+ //# sourceMappingURL=execution-sponsored-transport.js.map
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  export declare const ACCOUNT_PROFILE_SCHEMA: z.ZodObject<{
3
3
  kind: z.ZodEnum<{
4
- safe: "safe";
5
4
  eoa: "eoa";
5
+ safe: "safe";
6
6
  }>;
7
7
  address: z.ZodString;
8
8
  chainId: z.ZodNumber;
@@ -10,8 +10,8 @@ export declare const ACCOUNT_PROFILE_SCHEMA: z.ZodObject<{
10
10
  export declare const PREPARE_SWAP_INPUT_SCHEMA: z.ZodObject<{
11
11
  accountProfile: z.ZodObject<{
12
12
  kind: z.ZodEnum<{
13
- safe: "safe";
14
13
  eoa: "eoa";
14
+ safe: "safe";
15
15
  }>;
16
16
  address: z.ZodString;
17
17
  chainId: z.ZodNumber;
@@ -29,8 +29,8 @@ export declare const PREPARE_SWAP_INPUT_SCHEMA: z.ZodObject<{
29
29
  export declare const PREPARE_BRIDGE_INPUT_SCHEMA: z.ZodObject<{
30
30
  accountProfile: z.ZodObject<{
31
31
  kind: z.ZodEnum<{
32
- safe: "safe";
33
32
  eoa: "eoa";
33
+ safe: "safe";
34
34
  }>;
35
35
  address: z.ZodString;
36
36
  chainId: z.ZodNumber;
@@ -64,8 +64,8 @@ export declare const EXECUTION_ENVELOPE_SCHEMA: z.ZodObject<{
64
64
  intent_digest: z.ZodString;
65
65
  account_binding: z.ZodObject<{
66
66
  kind: z.ZodEnum<{
67
- safe: "safe";
68
67
  eoa: "eoa";
68
+ safe: "safe";
69
69
  }>;
70
70
  address: z.ZodString;
71
71
  chainId: z.ZodNumber;
@@ -88,9 +88,9 @@ export declare const EXECUTION_ENVELOPE_SCHEMA: z.ZodObject<{
88
88
  value: z.ZodString;
89
89
  data: z.ZodString;
90
90
  kind: z.ZodEnum<{
91
- call: "call";
92
- approve_reset: "approve_reset";
93
91
  approve: "approve";
92
+ approve_reset: "approve_reset";
93
+ call: "call";
94
94
  }>;
95
95
  }, z.core.$strict>>;
96
96
  }, z.core.$strict>], "kind">;
@@ -130,8 +130,8 @@ export declare const BRIDGE_EXECUTION_ENVELOPE_SCHEMA: z.ZodObject<{
130
130
  intent_digest: z.ZodString;
131
131
  account_binding: z.ZodObject<{
132
132
  kind: z.ZodEnum<{
133
- safe: "safe";
134
133
  eoa: "eoa";
134
+ safe: "safe";
135
135
  }>;
136
136
  address: z.ZodString;
137
137
  chainId: z.ZodNumber;
@@ -158,9 +158,9 @@ export declare const BRIDGE_EXECUTION_ENVELOPE_SCHEMA: z.ZodObject<{
158
158
  value: z.ZodString;
159
159
  data: z.ZodString;
160
160
  kind: z.ZodEnum<{
161
- call: "call";
162
- approve_reset: "approve_reset";
163
161
  approve: "approve";
162
+ approve_reset: "approve_reset";
163
+ call: "call";
164
164
  }>;
165
165
  }, z.core.$strict>>;
166
166
  }, z.core.$strict>], "kind">;
@@ -195,8 +195,8 @@ export declare const BRIDGE_EXECUTION_ENVELOPE_SCHEMA: z.ZodObject<{
195
195
  export declare const PREPARE_POLYMARKET_ORDER_INPUT_SCHEMA: z.ZodObject<{
196
196
  accountProfile: z.ZodObject<{
197
197
  kind: z.ZodEnum<{
198
- safe: "safe";
199
198
  eoa: "eoa";
199
+ safe: "safe";
200
200
  }>;
201
201
  address: z.ZodString;
202
202
  chainId: z.ZodNumber;
@@ -323,8 +323,8 @@ export declare const POLYMARKET_EXECUTION_ENVELOPE_SCHEMA: z.ZodObject<{
323
323
  intent_digest: z.ZodString;
324
324
  account_binding: z.ZodObject<{
325
325
  kind: z.ZodEnum<{
326
- safe: "safe";
327
326
  eoa: "eoa";
327
+ safe: "safe";
328
328
  }>;
329
329
  address: z.ZodString;
330
330
  chainId: z.ZodNumber;
@@ -580,8 +580,8 @@ export declare const HYPERLIQUID_L1_ACTION_PAYLOAD_SCHEMA: z.ZodObject<{
580
580
  export declare const PREPARE_PERP_ORDER_INPUT_SCHEMA: z.ZodObject<{
581
581
  accountProfile: z.ZodObject<{
582
582
  kind: z.ZodEnum<{
583
- safe: "safe";
584
583
  eoa: "eoa";
584
+ safe: "safe";
585
585
  }>;
586
586
  address: z.ZodString;
587
587
  chainId: z.ZodNumber;
@@ -613,8 +613,8 @@ export declare const HYPERLIQUID_EXECUTION_ENVELOPE_SCHEMA: z.ZodObject<{
613
613
  intent_digest: z.ZodString;
614
614
  account_binding: z.ZodObject<{
615
615
  kind: z.ZodEnum<{
616
- safe: "safe";
617
616
  eoa: "eoa";
617
+ safe: "safe";
618
618
  }>;
619
619
  address: z.ZodString;
620
620
  chainId: z.ZodNumber;
@@ -730,8 +730,8 @@ export declare const EXECUTION_ARTIFACT_SCHEMA: z.ZodUnion<readonly [z.ZodObject
730
730
  intent_digest: z.ZodString;
731
731
  account_binding: z.ZodObject<{
732
732
  kind: z.ZodEnum<{
733
- safe: "safe";
734
733
  eoa: "eoa";
734
+ safe: "safe";
735
735
  }>;
736
736
  address: z.ZodString;
737
737
  chainId: z.ZodNumber;
@@ -754,9 +754,9 @@ export declare const EXECUTION_ARTIFACT_SCHEMA: z.ZodUnion<readonly [z.ZodObject
754
754
  value: z.ZodString;
755
755
  data: z.ZodString;
756
756
  kind: z.ZodEnum<{
757
- call: "call";
758
- approve_reset: "approve_reset";
759
757
  approve: "approve";
758
+ approve_reset: "approve_reset";
759
+ call: "call";
760
760
  }>;
761
761
  }, z.core.$strict>>;
762
762
  }, z.core.$strict>], "kind">;
@@ -795,8 +795,8 @@ export declare const EXECUTION_ARTIFACT_SCHEMA: z.ZodUnion<readonly [z.ZodObject
795
795
  intent_digest: z.ZodString;
796
796
  account_binding: z.ZodObject<{
797
797
  kind: z.ZodEnum<{
798
- safe: "safe";
799
798
  eoa: "eoa";
799
+ safe: "safe";
800
800
  }>;
801
801
  address: z.ZodString;
802
802
  chainId: z.ZodNumber;
@@ -823,9 +823,9 @@ export declare const EXECUTION_ARTIFACT_SCHEMA: z.ZodUnion<readonly [z.ZodObject
823
823
  value: z.ZodString;
824
824
  data: z.ZodString;
825
825
  kind: z.ZodEnum<{
826
- call: "call";
827
- approve_reset: "approve_reset";
828
826
  approve: "approve";
827
+ approve_reset: "approve_reset";
828
+ call: "call";
829
829
  }>;
830
830
  }, z.core.$strict>>;
831
831
  }, z.core.$strict>], "kind">;
@@ -864,8 +864,8 @@ export declare const EXECUTION_ARTIFACT_SCHEMA: z.ZodUnion<readonly [z.ZodObject
864
864
  intent_digest: z.ZodString;
865
865
  account_binding: z.ZodObject<{
866
866
  kind: z.ZodEnum<{
867
- safe: "safe";
868
867
  eoa: "eoa";
868
+ safe: "safe";
869
869
  }>;
870
870
  address: z.ZodString;
871
871
  chainId: z.ZodNumber;
@@ -972,8 +972,8 @@ export declare const EXECUTION_ARTIFACT_SCHEMA: z.ZodUnion<readonly [z.ZodObject
972
972
  intent_digest: z.ZodString;
973
973
  account_binding: z.ZodObject<{
974
974
  kind: z.ZodEnum<{
975
- safe: "safe";
976
975
  eoa: "eoa";
976
+ safe: "safe";
977
977
  }>;
978
978
  address: z.ZodString;
979
979
  chainId: z.ZodNumber;
@@ -1039,13 +1039,6 @@ export const EXECUTION_TOOL_DEFINITIONS = Object.freeze([
1039
1039
  inputSchema: PREPARE_POLYMARKET_ORDER_INPUT_SCHEMA,
1040
1040
  outputSchema: POLYMARKET_EXECUTION_ENVELOPE_SCHEMA,
1041
1041
  }),
1042
- Object.freeze({
1043
- name: 'otto_prepare_perp_order',
1044
- title: 'Prepare an unsigned Hyperliquid perp order L1 action',
1045
- description: "Prepare and verify an unsigned Hyperliquid perpetuals order (limit, with optional reduce-only take-profit and stop-loss triggers bundled as normalTpsl) for the caller-owned Hyperliquid account, returned as the canonical L1 action plus the exact EIP-712 Agent domain, struct, and connectionId recipe the caller's own signer needs. The asset id, size grid, and price grid come from the live perp universe: an unknown or delisted perp, a size finer than the asset's szDecimals, or a price off the venue's 5-significant-digit / (6 - szDecimals) decimal grid is refused by name rather than rounded to a different order. There is no market order — name your own aggressive limit price with 'Ioc'. Otto's builder attribution is spec'd and valueless today, so the action carries no builder field and the envelope says so. The nonce is chosen by the signer, never here; the envelope's valid_until is committed to the artifact digest AND placed inside the signed digest as expiresAfter, so the venue itself rejects a stale action, while the Hyperliquid signer nonce remains the replay boundary and this tool cannot guarantee single execution. This tool never signs or submits, holds no key, and derives no agent wallet.",
1046
- inputSchema: PREPARE_PERP_ORDER_INPUT_SCHEMA,
1047
- outputSchema: HYPERLIQUID_EXECUTION_ENVELOPE_SCHEMA,
1048
- }),
1049
1042
  ]);
1050
1043
  export const EXECUTION_TOOL_DEFINITION_BY_NAME = new Map(EXECUTION_TOOL_DEFINITIONS.map((definition) => [definition.name, definition]));
1051
1044
  //# sourceMappingURL=execution-tool-definitions.js.map
@@ -1,9 +1,16 @@
1
+ import type { LpUserOpBinding } from './lp-userop-registration.js';
2
+ import type { NativeYieldUserOpBinding } from './native-yield-userop-registration.js';
3
+ import type { SponsoredAccountBinding } from './execution-sponsored-registration.js';
1
4
  import { type ExecutionServiceConfig } from './execution-config.js';
2
5
  import { type DelegationServices } from './execution-delegation.js';
6
+ import { type RouteSimulator } from './adapter/route-simulator.js';
7
+ import { type PrepareSwapInput } from './execution-tool-definitions.js';
3
8
  import { type BridgeExecutionEnvelope, type ExecutionEnvelope, type HyperliquidExecutionEnvelope, type PolymarketExecutionEnvelope } from './execution-types.js';
4
9
  import { type HyperliquidInfoClient } from './hyperliquid-info-client.js';
5
10
  import { type UnsignedHyperliquidAction, type UnsignedHyperliquidActionRequest } from './hyperliquid-order-builder.js';
6
- import { type LiFiQuoteClient } from './lifi-execution-client.js';
11
+ import { type LiFiQuote, type LiFiQuoteClient } from './lifi-execution-client.js';
12
+ import type { YieldVaultReader } from './yield-deposit-definition.js';
13
+ import type { EquityOracleReader } from './stock-buy-definition.js';
7
14
  import { type PolymarketClobClient } from './polymarket-clob-client.js';
8
15
  import { type UnsignedPolymarketOrder, type UnsignedPolymarketOrderRequest } from './polymarket-order-builder.js';
9
16
  /** The order-construction seam: request in, unsigned SDK-built order out. */
@@ -37,8 +44,30 @@ export interface ExecutionToolRuntime {
37
44
  * this process prepared (`prepared-artifacts.ts`).
38
45
  */
39
46
  readonly delegation?: DelegationServices;
47
+ readonly sponsoredAccount?: SponsoredAccountBinding;
48
+ readonly nativeYieldUserOp?: NativeYieldUserOpBinding;
49
+ readonly lpUserOp?: LpUserOpBinding;
50
+ /**
51
+ * Proves a quoted swap's calldata executes from the signing account BEFORE it is prepared
52
+ * (`adapter/route-simulator.ts`). Present on a server booted with a Base RPC (the delegated rail's);
53
+ * absent elsewhere, in which case the envelope records `route_simulated:false`.
54
+ */
55
+ readonly routeSimulator?: RouteSimulator;
56
+ /**
57
+ * The one on-chain read `otto_prepare_yield_deposit` needs (the vault's own `previewDeposit`), present
58
+ * on the hosted service over the delegation rig's Base public client; injectable so the parity guard is
59
+ * mutation-provable. Absent → the yield constructor refuses by name, nothing is prepared.
60
+ */
61
+ readonly yieldVaultReader?: YieldVaultReader;
62
+ /**
63
+ * The one on-chain read `otto_prepare_stock_buy` needs (the equity's Chainlink mark), present on the
64
+ * hosted service over the same Base public client; injectable so the parity guard is mutation-provable.
65
+ * Absent → the stock constructor refuses by name, nothing is prepared.
66
+ */
67
+ readonly equityOracleReader?: EquityOracleReader;
40
68
  }
41
69
  export interface ExecutionRuntimeOverrides {
70
+ readonly routeSimulator?: RouteSimulator;
42
71
  readonly quoteClient?: LiFiQuoteClient;
43
72
  readonly clobClient?: PolymarketClobClient;
44
73
  readonly polymarketOrderBuilder?: PolymarketOrderBuilder;
@@ -48,6 +77,11 @@ export interface ExecutionRuntimeOverrides {
48
77
  readonly entropy?: () => Uint8Array;
49
78
  readonly clientOrderIdEntropy?: () => Uint8Array;
50
79
  readonly delegation?: DelegationServices;
80
+ readonly sponsoredAccount?: SponsoredAccountBinding;
81
+ readonly nativeYieldUserOp?: NativeYieldUserOpBinding;
82
+ readonly lpUserOp?: LpUserOpBinding;
83
+ readonly yieldVaultReader?: YieldVaultReader;
84
+ readonly equityOracleReader?: EquityOracleReader;
51
85
  }
52
86
  export declare function createExecutionToolRuntime(config: ExecutionServiceConfig, overrides?: ExecutionRuntimeOverrides): ExecutionToolRuntime;
53
87
  export declare function createExecutionToolRuntimeFromEnv(env?: NodeJS.ProcessEnv): ExecutionToolRuntime | undefined;
@@ -58,7 +92,25 @@ export declare function createExecutionToolRuntimeFromEnv(env?: NodeJS.ProcessEn
58
92
  * the tool.
59
93
  */
60
94
  export declare function createExecutionToolRuntimeWithDelegationFromEnv(env?: NodeJS.ProcessEnv): Promise<ExecutionToolRuntime | undefined>;
95
+ /** How many LI.FI tools the constructor will try before it refuses: the first quote plus two re-quotes. */
96
+ export declare const MAX_ROUTE_ATTEMPTS: 3;
61
97
  export declare function prepareSwap(runtime: ExecutionToolRuntime, rawInput: unknown, signal?: AbortSignal): Promise<ExecutionEnvelope>;
98
+ /**
99
+ * The route-set and fee pre-checks, then ONE LI.FI quote for the parsed swap input. Split from
100
+ * `prepareSwapFromQuote` so a constructor that must read the quote itself (the Yield Copilot deposit:
101
+ * expected shares, the router's floor, the fee lines) quotes exactly once and builds the envelope from
102
+ * that same quote — a second quote could route through a different tool and carry a different floor.
103
+ */
104
+ export declare function quoteSwap(runtime: ExecutionToolRuntime, input: PrepareSwapInput, signal?: AbortSignal): Promise<ExecutableSwapQuote>;
105
+ /** A LI.FI quote as `quoteSwap` returns it: the quote plus the route facts the envelope records. */
106
+ export type ExecutableSwapQuote = LiFiQuote & {
107
+ readonly route: {
108
+ readonly tool: string;
109
+ readonly simulated: boolean;
110
+ };
111
+ };
112
+ /** Decode, assert and commit the envelope for a parsed swap input over the quote `quoteSwap` returned for it. */
113
+ export declare function prepareSwapFromQuote(runtime: ExecutionToolRuntime, input: PrepareSwapInput, quote: LiFiQuote | ExecutableSwapQuote): ExecutionEnvelope;
62
114
  /**
63
115
  * Build the ordered source-chain plan for a cross-chain native-USDC bridge over the enumerated v1
64
116
  * Circle-CCTP route set. Prepare-only: the plan is handed to the caller's own custody to sign.