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,357 @@
1
+ import { NATIVE_YIELD_USEROP_ACCOUNT_GAS_CONFIRMATION } from './native-yield-userop-definition.js';
2
+ import { SPONSORED_GAS_REVIEW_INPUT } from './execution-sponsored-definition.js';
3
+ import { accountGasBudgetPublicSchema, accountGasView, accountGasViewMatches, accountGasFailure, AccountGasConfirmationRefusal } from './execution-account-gas-view.js';
4
+ /** Manual native UserOps use the shared sponsored claim, budget, transport and owned recovery rail. */
5
+ import { getAddress } from 'viem';
6
+ import { z } from 'zod';
7
+ import { freezeHybridValue, hybridYieldCommitment } from './hybrid-yield-markets.js';
8
+ import { NATIVE_ACCOUNT_CONSENT_SCHEMA, NATIVE_ACCOUNT_SCOPES } from './native-yield-account-definition.js';
9
+ import { revokeNativeYieldConsent } from './native-yield-consent-store.js';
10
+ import { PREPARE_NATIVE_YIELD_INPUT_SCHEMA, refuseNative } from './native-yield-definition.js';
11
+ import { NATIVE_YIELD_USEROP_CONFIRMATION, NATIVE_YIELD_USEROP_SETTLEMENT_SCHEMA } from './native-yield-userop-definition.js';
12
+ import { assertFreshVerifiedNativeYieldUserOp, assertNativeYieldUserOpEnvelope, nativeYieldUserOpCalls, nativeYieldUserOpRecordedCalls, prepareNativeYieldUserOp, verifyNativeYieldUserOp } from './native-yield-userop.js';
13
+ import { simulateNativeYieldUserOp } from './native-yield-userop-simulation.js';
14
+ import { readNativeYieldUserOpSettlement } from './native-yield-userop-settlement.js';
15
+ import { assertNativeUserOpContext, NATIVE_USEROP_CONTEXT_SCHEMA } from './native-yield-userop-operation.js';
16
+ import { readConfirmedSponsoredReceipt, SponsoredReceiptUnconfirmedError } from './execution-sponsored-receipt.js';
17
+ const token = z.string().min(1).max(16_384);
18
+ const address = z.string().regex(/^0x[0-9a-fA-F]{40}$/);
19
+ const hash = z.string().regex(/^0x[0-9a-fA-F]{64}$/);
20
+ const digest = z.string().regex(/^[0-9a-f]{64}$/);
21
+ const commitment = z.string().regex(/^sha256:[0-9a-f]{64}$/);
22
+ const atomicPattern = /^(0|[1-9][0-9]*)$/;
23
+ const atomic = z.string().max(78).regex(atomicPattern)
24
+ .refine(value => atomicPattern.test(value) && value.length <= 78 && BigInt(value) < 2n ** 256n);
25
+ const positive = atomic.refine(value => atomicPattern.test(value) && value.length <= 78 && BigInt(value) > 0n);
26
+ const time = z.number().int().nonnegative().safe();
27
+ const chain = z.union([z.literal(8453), z.literal(42161)]);
28
+ const operationId = z.string().regex(/^sp_[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
29
+ const consentId = z.string().regex(/^nc_[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
30
+ const publicNativeInput = PREPARE_NATIVE_YIELD_INPUT_SCHEMA.extend({ amount: positive,
31
+ slippage: PREPARE_NATIVE_YIELD_INPUT_SCHEMA.shape.slippage.extend({ minOutput: positive.optional() }).strict(),
32
+ }).strict();
33
+ export const NATIVE_USEROP_ACCOUNT_PREPARE_INPUT = z.object({ accessToken: token, input: publicNativeInput }).strict();
34
+ export const NATIVE_USEROP_ACCOUNT_CONSENT_REVIEW_INPUT = NATIVE_USEROP_ACCOUNT_PREPARE_INPUT;
35
+ export const NATIVE_USEROP_ACCOUNT_CONSENT_CONFIRM_INPUT = NATIVE_USEROP_ACCOUNT_PREPARE_INPUT.extend({
36
+ consentId, consentCommitment: commitment, confirmation: z.literal('I reviewed the native yield scope and limits'),
37
+ }).strict();
38
+ export const NATIVE_USEROP_ACCOUNT_READ_INPUT = z.object({ accessToken: token, operationId }).strict();
39
+ export const NATIVE_USEROP_ACCOUNT_SUBMIT_INPUT = NATIVE_USEROP_ACCOUNT_READ_INPUT.extend({
40
+ envelopeCommitment: commitment, reviewCommitment: digest, confirmation: z.enum([NATIVE_YIELD_USEROP_CONFIRMATION, NATIVE_YIELD_USEROP_ACCOUNT_GAS_CONFIRMATION]),
41
+ }).strict();
42
+ export const NATIVE_USEROP_ACCOUNT_REVOKE_CONSENT_INPUT = z.object({ accessToken: token, account: address }).strict();
43
+ /** Keep the existing consent identity/state/times while removing its internal authority record. */
44
+ export const NATIVE_USEROP_PUBLIC_CONSENT_SCHEMA = NATIVE_ACCOUNT_CONSENT_SCHEMA.omit({ authority: true }).extend({
45
+ account: address, chainId: chain,
46
+ }).strict();
47
+ export const NATIVE_USEROP_PUBLIC_SCOPE_SCHEMA = z.object({ account: address, chainId: chain,
48
+ scopes: z.array(z.enum(NATIVE_ACCOUNT_SCOPES)).length(5),
49
+ marketLimits: z.array(z.object({ marketId: z.string().min(1).max(120), action: z.enum(['deposit', 'withdraw']),
50
+ inputToken: address, maximumInputAtomic: positive }).strict()).min(1).max(12),
51
+ perDepositCapUsd: z.number().int().min(1).max(5000), maximumGasCostWei: positive,
52
+ maximumUserGasCostWei: positive, maximumActivationGasCostWei: positive, expiresAtMs: time,
53
+ requiresSeparateOperationReview: z.literal(true),
54
+ }).strict();
55
+ export const NATIVE_USEROP_ACCOUNT_CONSENT_RESULT = z.object({ schemaVersion: z.literal('1'),
56
+ kind: z.literal('native-yield-userop'), consent: NATIVE_USEROP_PUBLIC_CONSENT_SCHEMA,
57
+ scope: NATIVE_USEROP_PUBLIC_SCOPE_SCHEMA.optional(), requiresSeparateOperationReview: z.literal(true),
58
+ automaticExecutionEnabled: z.literal(false), walletAuthorityChangeIncluded: z.literal(false),
59
+ }).strict().refine(value => value.consent.state !== 'challenge' || !!value.scope, 'A scope challenge must include its human review terms');
60
+ export const NATIVE_USEROP_ACCOUNT_REVOKE_RESULT = z.object({ schemaVersion: z.literal('1'), kind: z.literal('native-yield-userop'),
61
+ account: address, nativeConsentRevoked: z.literal(true), existingOperationRequiresReconciliation: z.literal(true),
62
+ automaticExecutionEnabled: z.literal(false),
63
+ }).strict();
64
+ const publicSettlementBase = { blockNumber: atomic, owner: address, positionBalanceAtBlock: atomic,
65
+ assetBalanceAtBlock: atomic, routerNonceAtBlock: atomic, actualGasCostWei: positive, actualGasUsed: positive, paymaster: address };
66
+ /** Public descriptors keep total numeric validation and contain no checksum transforms. */
67
+ const publicSettlement = z.union([
68
+ NATIVE_YIELD_USEROP_SETTLEMENT_SCHEMA.options[0].extend({ ...publicSettlementBase,
69
+ actualInput: positive, actualOutput: positive, actualOttoFee: atomic, feeToken: address }).strict(),
70
+ NATIVE_YIELD_USEROP_SETTLEMENT_SCHEMA.options[1].extend(publicSettlementBase).strict(),
71
+ ]);
72
+ export const NATIVE_USEROP_ACCOUNT_OPERATION_RESULT = z.object({ schemaVersion: z.literal('1'), kind: z.literal('native-yield-userop'),
73
+ operationId, account: address, chainId: chain, marketId: z.string().min(1).max(120), action: z.enum(['deposit', 'withdraw']),
74
+ state: z.enum(['review', 'active', 'unknown', 'submitted', 'completed', 'failed']), reviewConsumed: z.boolean(),
75
+ envelopeCommitment: commitment, reviewCommitment: digest, validUntilMs: time,
76
+ scopeConsent: z.object({ consentId, consentCommitment: commitment, generation: z.number().int().positive().safe() }).strict(),
77
+ input: z.object({ token: address, amount: positive }).strict(),
78
+ output: z.object({ token: address, minimum: positive }).strict(),
79
+ estimatedOttoFee: z.object({ token: address, amount: atomic }).strict(),
80
+ perDepositCapUsd: z.number().int().min(1).max(5000),
81
+ gas: accountGasBudgetPublicSchema(positive),
82
+ requiresOperationReview: z.boolean(), confirmation: z.enum([NATIVE_YIELD_USEROP_CONFIRMATION, NATIVE_YIELD_USEROP_ACCOUNT_GAS_CONFIRMATION]),
83
+ protocolActionVerified: z.boolean(), userOpHash: hash.optional(), transactionHash: hash.optional(),
84
+ settlement: publicSettlement.optional(), failureCode: z.enum([
85
+ 'SPONSOR_NOT_SUBMITTED', 'SPONSOR_USER_OPERATION_REVERTED', 'SPONSOR_GAS_CAP_EXCEEDED',
86
+ ]).optional(),
87
+ attention: z.literal('The original provider request is unresolved. Read or reconcile this operation; do not submit a replacement.').optional(),
88
+ automaticExecutionEnabled: z.literal(false),
89
+ walletAuthorityChangeIncluded: z.literal(false), retrySafe: z.literal(false),
90
+ }).strict().refine(value => accountGasViewMatches(value) && value.confirmation === (value.gas.payer === 'account' ? NATIVE_YIELD_USEROP_ACCOUNT_GAS_CONFIRMATION : NATIVE_YIELD_USEROP_CONFIRMATION) && value.requiresOperationReview === (value.state === 'review') &&
91
+ value.reviewConsumed === (value.state !== 'review') &&
92
+ value.protocolActionVerified === (value.settlement?.status === 'completed') &&
93
+ (value.state !== 'completed' || value.settlement?.status === 'completed') &&
94
+ (!value.settlement || (value.settlement.status === 'completed' ? value.state === 'completed' : value.state === 'failed')) &&
95
+ (!value.transactionHash || !!value.userOpHash) &&
96
+ (value.gas.payer !== 'sponsor' || !value.gas.activationChainHalted || (value.state === 'submitted' && value.failureCode === 'SPONSOR_GAS_CAP_EXCEEDED')), 'Native UserOp state must agree with its review and settlement proof');
97
+ export function nativeYieldUserOpAccountView(operation) {
98
+ const { context } = operation, { plan, terms } = assertNativeYieldUserOpEnvelope(context.envelope);
99
+ return freezeHybridValue(NATIVE_USEROP_ACCOUNT_OPERATION_RESULT.parse({ schemaVersion: '1', kind: 'native-yield-userop',
100
+ operationId: operation.operationId, account: context.account, chainId: terms.chainId, marketId: plan.marketId, action: plan.action,
101
+ state: operation.state, reviewConsumed: operation.reviewConsumed, envelopeCommitment: context.envelope.commitment,
102
+ reviewCommitment: operation.reviewCommitment, validUntilMs: context.validUntilMs, scopeConsent: context.review.consent,
103
+ input: { token: plan.inputToken, amount: plan.amount }, output: { token: plan.outputToken, minimum: plan.minimumOutput },
104
+ estimatedOttoFee: { token: plan.fee.token, amount: plan.fee.amount },
105
+ perDepositCapUsd: Math.min(context.authority.perSwapCapUsd, context.activation.maxSwapUsdc),
106
+ gas: accountGasView(operation, { maximumCostWei: terms.maxGasCostWei,
107
+ maximumUserCostWei: terms.maxUserGasCostWei, maximumActivationCostWei: terms.maxTotalGasCostWei }),
108
+ requiresOperationReview: operation.state === 'review', confirmation: operation.gasReview?.payer === 'account' ? NATIVE_YIELD_USEROP_ACCOUNT_GAS_CONFIRMATION : NATIVE_YIELD_USEROP_CONFIRMATION,
109
+ protocolActionVerified: operation.settlement?.status === 'completed',
110
+ ...(operation.userOpHash ? { userOpHash: operation.userOpHash } : {}),
111
+ ...(operation.transactionHash ? { transactionHash: operation.transactionHash } : {}),
112
+ ...(operation.settlement ? { settlement: operation.settlement } : {}),
113
+ ...(operation.failureCode ? { failureCode: operation.failureCode } : {}),
114
+ ...(operation.state === 'unknown' && !operation.userOpHash
115
+ ? { attention: 'The original provider request is unresolved. Read or reconcile this operation; do not submit a replacement.' } : {}),
116
+ automaticExecutionEnabled: false, walletAuthorityChangeIncluded: false, retrySafe: false }));
117
+ }
118
+ function equal(left, right) { return hybridYieldCommitment(left) === hybridYieldCommitment(right); }
119
+ function refuse(code) { return refuseNative(code, 'The native UserOp requires its current owner and exact reviewed terms'); }
120
+ export class NativeYieldUserOpAccountService {
121
+ issuer;
122
+ protocols;
123
+ runtime;
124
+ store;
125
+ guards;
126
+ transport;
127
+ gasRuntime;
128
+ constructor(issuer, protocols, runtime, store, guards, transport, gasRuntime) {
129
+ this.issuer = issuer;
130
+ this.protocols = protocols;
131
+ this.runtime = runtime;
132
+ this.store = store;
133
+ this.guards = guards;
134
+ this.transport = transport;
135
+ this.gasRuntime = gasRuntime;
136
+ }
137
+ protocol(chainId) {
138
+ return this.protocols[chainId] ?? refuse('NATIVE_USEROP_CHAIN_UNAVAILABLE');
139
+ }
140
+ async owned(accessToken, id) {
141
+ let userId;
142
+ try {
143
+ userId = (await this.runtime.cdp.endUser.validateAccessToken({ accessToken })).userId;
144
+ }
145
+ catch {
146
+ return refuse('NATIVE_USEROP_SESSION_INVALID');
147
+ }
148
+ if (!/^[a-zA-Z0-9-]{1,100}$/.test(userId))
149
+ return refuse('NATIVE_USEROP_SESSION_INVALID');
150
+ const operation = this.store.read(userId, id), who = await this.runtime.identity(accessToken, operation.context.account);
151
+ if (who.userId !== operation.userId)
152
+ return refuse('NATIVE_USEROP_OWNER_MISMATCH');
153
+ return operation;
154
+ }
155
+ async reviewConsent(raw) {
156
+ const input = NATIVE_USEROP_ACCOUNT_CONSENT_REVIEW_INPUT.parse(raw);
157
+ const { consent, scope } = await this.issuer.reviewConsent(input.accessToken, input.input);
158
+ const { authority, ...publicConsent } = consent;
159
+ return NATIVE_USEROP_ACCOUNT_CONSENT_RESULT.parse({ schemaVersion: '1', kind: 'native-yield-userop',
160
+ consent: { ...publicConsent, account: authority.account, chainId: input.input.accountProfile.chainId }, scope,
161
+ requiresSeparateOperationReview: true, automaticExecutionEnabled: false, walletAuthorityChangeIncluded: false });
162
+ }
163
+ createConsent(raw) { return this.reviewConsent(raw); }
164
+ async confirmConsent(raw) {
165
+ const input = NATIVE_USEROP_ACCOUNT_CONSENT_CONFIRM_INPUT.parse(raw);
166
+ const consent = await this.issuer.confirmConsent(input.accessToken, input.input, { consentId: input.consentId, consentCommitment: input.consentCommitment });
167
+ const { authority, ...publicConsent } = consent;
168
+ return NATIVE_USEROP_ACCOUNT_CONSENT_RESULT.parse({ schemaVersion: '1', kind: 'native-yield-userop',
169
+ consent: { ...publicConsent, account: authority.account, chainId: input.input.accountProfile.chainId },
170
+ requiresSeparateOperationReview: true, automaticExecutionEnabled: false, walletAuthorityChangeIncluded: false });
171
+ }
172
+ async revokeConsent(raw) {
173
+ const input = NATIVE_USEROP_ACCOUNT_REVOKE_CONSENT_INPUT.parse(raw), account = getAddress(input.account);
174
+ const who = await this.runtime.identity(input.accessToken, account);
175
+ revokeNativeYieldConsent(this.store.db, who.userId, account, this.runtime.now());
176
+ return NATIVE_USEROP_ACCOUNT_REVOKE_RESULT.parse({ schemaVersion: '1', kind: 'native-yield-userop', account,
177
+ nativeConsentRevoked: true, existingOperationRequiresReconciliation: true, automaticExecutionEnabled: false });
178
+ }
179
+ async prepare(raw) {
180
+ const input = NATIVE_USEROP_ACCOUNT_PREPARE_INPUT.parse(raw);
181
+ this.store.assertReadyForNewOperations();
182
+ let authority = await this.issuer.mint(input.accessToken, input.input);
183
+ const envelope = await prepareNativeYieldUserOp(this.protocol(input.input.accountProfile.chainId), input.input, this.issuer.terms(authority));
184
+ authority = await this.issuer.refresh(input.accessToken, authority);
185
+ const context = NATIVE_USEROP_CONTEXT_SCHEMA.parse({ kind: 'native-yield-userop', account: envelope.terms.account,
186
+ chainId: envelope.terms.chainId, envelope, review: this.issuer.reviewRecord(authority),
187
+ authority: this.issuer.sponsorship(authority), activation: this.issuer.activation(authority),
188
+ reviewedAtMs: envelope.preparedAtMs, validUntilMs: envelope.validUntilMs });
189
+ const operation = this.store.transaction(() => {
190
+ this.issuer.assertConsent(authority);
191
+ assertNativeUserOpContext(context, true, this.runtime.now());
192
+ return this.store.create(context);
193
+ });
194
+ const guard = await this.guards.acquire('sponsored', operation.operationId, true);
195
+ guard.release();
196
+ if (context.activation.gasPaymentReviewEnabled) {
197
+ try {
198
+ return await this.reviewGas({ accessToken: input.accessToken,
199
+ operationId: operation.operationId, reviewCommitment: operation.reviewCommitment, preference: 'auto' });
200
+ }
201
+ catch (error) {
202
+ return nativeYieldUserOpAccountView(this.store.recordGasReviewFailure(operation.userId, operation.operationId, accountGasFailure(error) ?? 'ACCOUNT_GAS_QUOTE_UNAVAILABLE'));
203
+ }
204
+ }
205
+ return nativeYieldUserOpAccountView(operation);
206
+ }
207
+ async reviewGas(raw) {
208
+ const input = SPONSORED_GAS_REVIEW_INPUT.extend({ operationId: NATIVE_USEROP_ACCOUNT_READ_INPUT.shape.operationId }).parse(raw), owned = await this.owned(input.accessToken, input.operationId);
209
+ const guard = await this.guards.acquire('sponsored', owned.operationId, false);
210
+ try {
211
+ const operation = this.store.read(owned.userId, owned.operationId);
212
+ if (!this.gasRuntime || (operation.state !== 'review' && !(operation.state === 'failed' && !operation.handoffAttempted && operation.failureCode === 'SPONSOR_NOT_SUBMITTED')))
213
+ return refuse('ACCOUNT_GAS_REVIEW_UNAVAILABLE');
214
+ const authority = await this.issuer.restoreFromTrustedReview(input.accessToken, operation.context.review);
215
+ this.assertCurrentReview(operation, authority);
216
+ const gasReview = await this.gasRuntime.review(operation, nativeYieldUserOpRecordedCalls(operation.context.envelope), input.preference);
217
+ return nativeYieldUserOpAccountView(this.store.reviewGas(operation.userId, operation.operationId, input.reviewCommitment, gasReview));
218
+ }
219
+ finally {
220
+ guard.release();
221
+ }
222
+ }
223
+ async read(raw) {
224
+ const input = NATIVE_USEROP_ACCOUNT_READ_INPUT.parse(raw);
225
+ return nativeYieldUserOpAccountView(await this.owned(input.accessToken, input.operationId));
226
+ }
227
+ assertCurrentReview(operation, authority) {
228
+ if (!equal(this.issuer.reviewRecord(authority), operation.context.review) ||
229
+ !equal(this.issuer.terms(authority), operation.context.envelope.terms))
230
+ return refuse('NATIVE_USEROP_REVIEW_CHANGED');
231
+ assertNativeUserOpContext(operation.context, true, this.runtime.now());
232
+ }
233
+ async submit(raw) {
234
+ const input = NATIVE_USEROP_ACCOUNT_SUBMIT_INPUT.parse(raw), owned = await this.owned(input.accessToken, input.operationId);
235
+ if (owned.state !== 'review' || owned.reviewConsumed || input.reviewCommitment !== owned.reviewCommitment ||
236
+ input.envelopeCommitment !== owned.context.envelope.commitment)
237
+ return refuse('NATIVE_USEROP_REVIEW_REQUIRED');
238
+ if (input.confirmation !== (owned.gasReview?.payer === 'account' ? NATIVE_YIELD_USEROP_ACCOUNT_GAS_CONFIRMATION : NATIVE_YIELD_USEROP_CONFIRMATION))
239
+ throw new AccountGasConfirmationRefusal();
240
+ const guard = await this.guards.acquire('sponsored', owned.operationId, false);
241
+ try {
242
+ // Only the authenticated stored row reaches restore; request-provided reviews/terms are rejected by the schema.
243
+ let authority = await this.issuer.restoreFromTrustedReview(input.accessToken, owned.context.review);
244
+ this.assertCurrentReview(owned, authority);
245
+ const protocol = this.protocol(owned.context.envelope.terms.chainId);
246
+ const simulation = await simulateNativeYieldUserOp(protocol, owned.context.envelope, this.issuer.terms(authority));
247
+ authority = await this.issuer.refresh(input.accessToken, authority);
248
+ this.assertCurrentReview(owned, authority);
249
+ const sponsorAuthority = this.issuer.sponsorship(authority);
250
+ this.store.transaction(() => {
251
+ this.store.begin(owned.userId, owned.operationId, input.reviewCommitment, sponsorAuthority);
252
+ this.issuer.assertConsent(authority);
253
+ });
254
+ let handoffProof;
255
+ let unattemptedRecordCommitment;
256
+ try {
257
+ const operation = this.store.read(owned.userId, owned.operationId);
258
+ unattemptedRecordCommitment = hybridYieldCommitment(operation);
259
+ const request = this.transport.prepare({ userId: operation.userId, account: operation.context.account,
260
+ chainId: operation.context.chainId, idempotencyKey: operation.operationId.slice(3) }, nativeYieldUserOpCalls(simulation.verified), operation.gasReview?.payer ?? 'sponsor');
261
+ unattemptedRecordCommitment = hybridYieldCommitment(this.store.prepare(operation.userId, operation.operationId, request));
262
+ let verified;
263
+ let checkedGas;
264
+ const result = await this.transport.send(request, async () => {
265
+ if (operation.context.activation.gasPaymentReviewEnabled && !this.gasRuntime)
266
+ return refuse('ACCOUNT_GAS_REVIEW_UNAVAILABLE');
267
+ checkedGas = await this.gasRuntime?.revalidate(operation, nativeYieldUserOpRecordedCalls(operation.context.envelope));
268
+ // All public-chain and provider-authority awaits finish before the durable attempted stamp.
269
+ verified = await verifyNativeYieldUserOp(protocol, operation.context.envelope, this.issuer.terms(authority));
270
+ authority = await this.issuer.refresh(input.accessToken, authority);
271
+ this.assertCurrentReview(operation, authority);
272
+ assertFreshVerifiedNativeYieldUserOp(verified, this.runtime.now());
273
+ }, start => {
274
+ handoffProof = this.store.attemptedWithProof(operation.userId, operation.operationId);
275
+ return this.store.handoff(operation.userId, operation.operationId, () => {
276
+ // Preserve journal -> caps lock order and the gas-circuit boundary. No await follows the stamp.
277
+ this.issuer.assertConsent(authority);
278
+ this.assertCurrentReview(operation, authority);
279
+ return this.issuer.withCurrentCap(authority, () => {
280
+ this.assertCurrentReview(operation, authority);
281
+ if (!verified || !handoffProof)
282
+ return refuse('NATIVE_USEROP_HANDOFF_UNVERIFIED');
283
+ assertFreshVerifiedNativeYieldUserOp(verified, this.runtime.now());
284
+ return start((gasPolicy) => {
285
+ this.gasRuntime?.assertFresh(operation, nativeYieldUserOpRecordedCalls(operation.context.envelope), checkedGas, gasPolicy);
286
+ this.store.consumeHandoffProof(handoffProof);
287
+ });
288
+ });
289
+ });
290
+ });
291
+ this.store.acknowledged(operation.userId, operation.operationId, result);
292
+ }
293
+ catch (error) {
294
+ const current = this.store.read(owned.userId, owned.operationId);
295
+ if (current.state === 'active' && !current.handoffAttempted && !current.userOpHash && !current.transactionHash &&
296
+ unattemptedRecordCommitment === hybridYieldCommitment(current))
297
+ this.store.failBeforeHandoff(owned.userId, owned.operationId);
298
+ else if (handoffProof) {
299
+ try {
300
+ this.store.failUninvokedHandoff(handoffProof);
301
+ }
302
+ catch { /* Invoked, changed, restarted or uncertain journal state retains the original claim. */ }
303
+ }
304
+ const gasFailure = accountGasFailure(error);
305
+ if (gasFailure)
306
+ this.store.recordGasReviewFailure(owned.userId, owned.operationId, gasFailure);
307
+ return nativeYieldUserOpAccountView(this.store.read(owned.userId, owned.operationId));
308
+ }
309
+ return await this.reconcileOwned(this.store.read(owned.userId, owned.operationId));
310
+ }
311
+ finally {
312
+ guard.release();
313
+ }
314
+ }
315
+ /** Owned recovery deliberately needs neither an active grant, unexpired review nor current sending authority. */
316
+ async reconcile(raw) {
317
+ const input = NATIVE_USEROP_ACCOUNT_READ_INPUT.parse(raw), operation = await this.owned(input.accessToken, input.operationId);
318
+ if (['review', 'completed', 'failed'].includes(operation.state))
319
+ return nativeYieldUserOpAccountView(operation);
320
+ const guard = await this.guards.acquire('sponsored', operation.operationId, false);
321
+ try {
322
+ return await this.reconcileOwned(this.store.read(operation.userId, operation.operationId));
323
+ }
324
+ finally {
325
+ guard.release();
326
+ }
327
+ }
328
+ async reconcileOwned(operation) {
329
+ if (!operation.handoffAttempted)
330
+ return nativeYieldUserOpAccountView(this.store.failBeforeHandoff(operation.userId, operation.operationId));
331
+ if (!operation.userOpHash)
332
+ return nativeYieldUserOpAccountView(operation);
333
+ try {
334
+ const calls = nativeYieldUserOpRecordedCalls(operation.context.envelope);
335
+ const acknowledgement = await this.runtime.readAcknowledgement(operation, calls);
336
+ operation = this.store.acknowledged(operation.userId, operation.operationId, acknowledgement);
337
+ if (!operation.transactionHash)
338
+ return nativeYieldUserOpAccountView(operation);
339
+ const { terms } = operation.context.envelope, client = this.runtime.client(terms.chainId);
340
+ const binding = { userOpHash: operation.userOpHash, transactionHash: operation.transactionHash };
341
+ const receipt = await readConfirmedSponsoredReceipt({ ...binding, chainId: terms.chainId, account: terms.account,
342
+ payer: operation.gasReview?.payer ?? 'sponsor', entryPoint: terms.entryPoint,
343
+ paymaster: operation.gasReview?.payer === 'account' ? '0x0000000000000000000000000000000000000000' : terms.paymaster, maxGasCostWei: BigInt(terms.maxGasCostWei) }, client);
344
+ const settlement = await readNativeYieldUserOpSettlement(operation.context.envelope, binding, client, operation.gasReview?.payer ?? 'sponsor');
345
+ // Reverted batches also need the native zero-allowance/nonce/account proof before claim release.
346
+ if (!settlement.releaseClaim)
347
+ return nativeYieldUserOpAccountView(this.store.read(operation.userId, operation.operationId));
348
+ return nativeYieldUserOpAccountView(this.store.finish(operation.userId, operation.operationId, receipt, settlement));
349
+ }
350
+ catch (error) {
351
+ if (error instanceof SponsoredReceiptUnconfirmedError && error.code === 'SPONSOR_GAS_CAP_EXCEEDED' && error.breachedReceipt)
352
+ return nativeYieldUserOpAccountView(this.store.recordGasCapBreach(operation.userId, operation.operationId, error.breachedReceipt));
353
+ return nativeYieldUserOpAccountView(this.store.read(operation.userId, operation.operationId));
354
+ }
355
+ }
356
+ }
357
+ //# sourceMappingURL=native-yield-userop-account.js.map
@@ -0,0 +1,214 @@
1
+ import { type LpUserOpActivation } from './lp-userop-definition.js';
2
+ import { z } from 'zod';
3
+ import { type SponsoredActivation, type SponsoredAuthority, type SponsoredChainTerms } from './execution-sponsored-definition.js';
4
+ import { SponsoredAccountRuntime } from './execution-sponsored-runtime.js';
5
+ import type { ExecutionJournalDatabase } from './execution-journal-schema.js';
6
+ import { type NativeYieldAccountActivation, type NativeYieldAccountConsent } from './native-yield-account-definition.js';
7
+ import { NativeYieldAccountRuntime } from './native-yield-account-runtime.js';
8
+ import { type NativeYieldUserOpTerms } from './native-yield-userop-definition.js';
9
+ declare const RELATION_SCHEMA: z.ZodObject<{
10
+ nativeActivationCommitment: z.ZodString;
11
+ nativeRulesDigest: z.ZodString;
12
+ compiledFullPolicyDigest: z.ZodString;
13
+ relationReviewEvidenceDigest: z.ZodString;
14
+ compiler: z.ZodLiteral<"legacy-v2-native-enduser-userop-v1">;
15
+ }, z.core.$strict>;
16
+ declare const PROFILE_SCHEMA: z.ZodObject<{
17
+ implementation: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
18
+ implementationCodeHash: z.ZodString;
19
+ delegateBatchAbi: z.ZodLiteral<"coinbase-executeBatch-v1">;
20
+ delegateBatchReviewDigest: z.ZodString;
21
+ entryPointVersion: z.ZodLiteral<"0.6">;
22
+ ownerProfile: z.ZodObject<{
23
+ kind: z.ZodLiteral<"sole-eoa-owner">;
24
+ nextOwnerIndex: z.ZodLiteral<"1">;
25
+ ownerCount: z.ZodLiteral<"1">;
26
+ requireAccountAsOwner: z.ZodLiteral<true>;
27
+ spendPermissionsEnabled: z.ZodLiteral<false>;
28
+ }, z.core.$strict>;
29
+ }, z.core.$strict>;
30
+ /** Source-only additions; neither is accepted from an MCP request. */
31
+ export type NativeYieldUserOpPolicyRelation = z.infer<typeof RELATION_SCHEMA>;
32
+ export type NativeYieldUserOpSourceProfile = z.infer<typeof PROFILE_SCHEMA>;
33
+ export type NativeYieldUserOpSponsoredActivation = SponsoredActivation & {
34
+ nativeYieldUserOpPolicyRelation: NativeYieldUserOpPolicyRelation;
35
+ chains: (SponsoredChainTerms & {
36
+ nativeYieldUserOpProfile?: NativeYieldUserOpSourceProfile;
37
+ })[];
38
+ };
39
+ export { compileNativeYieldEndUserOperationPolicy } from './native-yield-userop-policy.js';
40
+ export declare const NATIVE_YIELD_USEROP_REVIEW_RECORD_SCHEMA: z.ZodObject<{
41
+ input: z.ZodObject<{
42
+ accountProfile: z.ZodObject<{
43
+ kind: z.ZodLiteral<"eoa">;
44
+ address: z.ZodString;
45
+ chainId: z.ZodUnion<readonly [z.ZodLiteral<8453>, z.ZodLiteral<42161>]>;
46
+ }, z.core.$strict>;
47
+ marketId: z.ZodString;
48
+ registryCommitment: z.ZodString;
49
+ action: z.ZodEnum<{
50
+ deposit: "deposit";
51
+ withdraw: "withdraw";
52
+ }>;
53
+ amount: z.ZodString;
54
+ slippage: z.ZodObject<{
55
+ maxBps: z.ZodNumber;
56
+ minOutput: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strict>;
58
+ clientRef: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strict>;
60
+ terms: z.ZodObject<{
61
+ version: z.ZodLiteral<1>;
62
+ ruleset: z.ZodLiteral<"native-yield-userop-v1">;
63
+ userId: z.ZodString;
64
+ account: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
65
+ chainId: z.ZodUnion<readonly [z.ZodLiteral<8453>, z.ZodLiteral<42161>]>;
66
+ authorityDigest: z.ZodString;
67
+ nativeActivationCommitment: z.ZodString;
68
+ sponsoredActivationId: z.ZodString;
69
+ sponsoredActivationDigest: z.ZodString;
70
+ projectId: z.ZodString;
71
+ policyId: z.ZodString;
72
+ policyRulesDigest: z.ZodString;
73
+ providerEnforcementEvidenceDigest: z.ZodString;
74
+ providerEndpoint: z.ZodLiteral<"cdp-end-user-smart-account-send-v1">;
75
+ deployment: z.ZodObject<{
76
+ chainId: z.ZodUnion<readonly [z.ZodLiteral<8453>, z.ZodLiteral<42161>]>;
77
+ address: z.ZodString;
78
+ runtimeCodeHash: z.ZodString;
79
+ version: z.ZodLiteral<"native-yield-router-v1">;
80
+ reviewId: z.ZodString;
81
+ }, z.core.$strict>;
82
+ delegate: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
83
+ delegateCodeHash: z.ZodString;
84
+ implementation: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
85
+ implementationCodeHash: z.ZodString;
86
+ delegateBatchAbi: z.ZodLiteral<"coinbase-executeBatch-v1">;
87
+ delegateBatchReviewDigest: z.ZodString;
88
+ entryPoint: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
89
+ entryPointCodeHash: z.ZodString;
90
+ entryPointVersion: z.ZodLiteral<"0.6">;
91
+ ownerProfile: z.ZodObject<{
92
+ kind: z.ZodLiteral<"sole-eoa-owner">;
93
+ nextOwnerIndex: z.ZodLiteral<"1">;
94
+ ownerCount: z.ZodLiteral<"1">;
95
+ ownerAtIndex0: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
96
+ spendPermissionsEnabled: z.ZodLiteral<false>;
97
+ }, z.core.$strict>;
98
+ paymaster: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
99
+ paymasterCodeHash: z.ZodString;
100
+ sponsorshipPolicyId: z.ZodString;
101
+ maxGasCostWei: z.ZodString;
102
+ maxUserGasCostWei: z.ZodString;
103
+ maxTotalGasCostWei: z.ZodString;
104
+ maximumInputAtomic: z.ZodString;
105
+ intentCommitment: z.ZodString;
106
+ consentCreatedAtMs: z.ZodNumber;
107
+ consentExpiresAtMs: z.ZodNumber;
108
+ initialInputAllowance: z.ZodLiteral<"0">;
109
+ initialProtocolAllowance: z.ZodLiteral<"0">;
110
+ execution: z.ZodLiteral<"atomic-approve-reset-approve-execute">;
111
+ }, z.core.$strict>;
112
+ consent: z.ZodObject<{
113
+ consentId: z.ZodString;
114
+ generation: z.ZodNumber;
115
+ consentCommitment: z.ZodString;
116
+ }, z.core.$strict>;
117
+ }, z.core.$strict>;
118
+ export type NativeYieldUserOpReviewRecord = z.infer<typeof NATIVE_YIELD_USEROP_REVIEW_RECORD_SCHEMA>;
119
+ declare const brand: unique symbol;
120
+ /** The runtime accepts only objects minted by this issuer, never a structural cast or JSON. */
121
+ export interface NativeYieldUserOpAuthority {
122
+ readonly [brand]: true;
123
+ }
124
+ export declare class NativeYieldUserOpAuthorityIssuer {
125
+ private readonly native;
126
+ private readonly sponsor;
127
+ private readonly db;
128
+ private readonly issued;
129
+ private readonly minted;
130
+ private readonly nativeActivations;
131
+ private readonly sponsorActivations;
132
+ private readonly lpActivations;
133
+ constructor(native: NativeYieldAccountRuntime, sponsor: SponsoredAccountRuntime, db: ExecutionJournalDatabase,
134
+ /** Internal source fixtures only. The production constructor uses the two empty reviewed arrays. */
135
+ fixtures?: {
136
+ nativeActivations: readonly NativeYieldAccountActivation[];
137
+ sponsoredActivations: readonly NativeYieldUserOpSponsoredActivation[];
138
+ lpActivations?: readonly LpUserOpActivation[];
139
+ });
140
+ private now;
141
+ private sources;
142
+ private consentAuthority;
143
+ private assertValuation;
144
+ private window;
145
+ private derivedTerms;
146
+ private facts;
147
+ /** Fresh source-scope projection for human consent review, before an operation authority exists. */
148
+ reviewConsent(accessToken: string, rawInput: unknown): Promise<{
149
+ consent: {
150
+ consentId: string;
151
+ authority: {
152
+ userId: string;
153
+ account: string;
154
+ mintKey: string;
155
+ grantExpiresAt: string;
156
+ revokeGeneration: number;
157
+ capRulesetVersion: number;
158
+ perSwapCapUsd: number;
159
+ policyId: string;
160
+ policyName: "OTTO model b swap fence v3";
161
+ policyDigest: string;
162
+ legacyRulesDigest: string;
163
+ nativeRulesDigest: string;
164
+ activationCommitment: string;
165
+ scopeCommitment: string;
166
+ ruleset: "native-yield-account-v1";
167
+ scopes: ("deposit" | "withdraw" | "approve" | "approve-reset" | "revoke")[];
168
+ };
169
+ consentCommitment: string;
170
+ state: "challenge" | "confirmed" | "revoked" | "superseded";
171
+ generation: number;
172
+ createdAtMs: number;
173
+ challengeExpiresAtMs: number;
174
+ confirmedAtMs: number | null;
175
+ };
176
+ scope: {
177
+ account: string;
178
+ chainId: 8453 | 42161;
179
+ scopes: ("deposit" | "withdraw" | "approve" | "approve-reset" | "revoke")[];
180
+ marketLimits: {
181
+ marketId: string;
182
+ action: "deposit" | "withdraw";
183
+ inputToken: `0x${string}`;
184
+ maximumInputAtomic: string;
185
+ }[];
186
+ perDepositCapUsd: number;
187
+ maximumGasCostWei: string;
188
+ maximumUserGasCostWei: string;
189
+ maximumActivationGasCostWei: string;
190
+ expiresAtMs: number;
191
+ requiresSeparateOperationReview: true;
192
+ };
193
+ }>;
194
+ createConsent(accessToken: string, rawInput: unknown): Promise<NativeYieldAccountConsent>;
195
+ confirmConsent(accessToken: string, rawInput: unknown, confirmation: {
196
+ consentId: string;
197
+ consentCommitment: string;
198
+ }): Promise<NativeYieldAccountConsent>;
199
+ private issue;
200
+ mint(accessToken: string, rawInput: unknown): Promise<NativeYieldUserOpAuthority>;
201
+ private read;
202
+ /** Re-read after the shared journal stamp and after transport auth, immediately before POST. */
203
+ refresh(accessToken: string, authority: NativeYieldUserOpAuthority): Promise<NativeYieldUserOpAuthority>;
204
+ /** Internal journal recovery only. Never route raw MCP terms into this method. */
205
+ restoreFromTrustedReview(accessToken: string, rawStoredReview: unknown): Promise<NativeYieldUserOpAuthority>;
206
+ /** Must also run synchronously inside/after the caller's shared-journal stamp; performs no await. */
207
+ assertConsent(authority: NativeYieldUserOpAuthority): void;
208
+ /** Hold the current cap writer lock through the synchronous provider request invocation. */
209
+ withCurrentCap<T>(authority: NativeYieldUserOpAuthority, start: () => T): T;
210
+ terms(authority: NativeYieldUserOpAuthority): NativeYieldUserOpTerms;
211
+ reviewRecord(authority: NativeYieldUserOpAuthority): NativeYieldUserOpReviewRecord;
212
+ sponsorship(authority: NativeYieldUserOpAuthority): SponsoredAuthority;
213
+ activation(authority: NativeYieldUserOpAuthority): NativeYieldUserOpSponsoredActivation;
214
+ }