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,87 @@
1
+ /** Pure source-policy relation for native yield plus same-account guarded LP collection. */
2
+ import { getAddress } from 'viem';
3
+ import { z } from 'zod';
4
+ import { freezeHybridValue, hybridYieldCommitment } from './hybrid-yield-markets.js';
5
+ import { policyRulesDigest } from './execution-policy-compatibility.js';
6
+ import { compileNativeYieldEndUserOperationPolicy } from './native-yield-userop-policy.js';
7
+ import { LP_USEROP_ACTIVATION_SCHEMA } from './lp-userop-definition.js';
8
+ import { LP_V3_BASE } from './vendor/lp-v3/lp-v3-contract.js';
9
+ import { LP_V3_ATOMIC_NPM_ABI, LP_V3_COLLECT_GUARD_ABI } from './vendor/lp-v3/lp-v3-atomic-contract.js';
10
+ const digest = z.string().regex(/^[0-9a-f]{64}$/).refine(value => !/^0+$/.test(value));
11
+ import { ACCOUNT_NATIVE_LP_USEROP_COMPILER, SPONSORED_LP_USEROP_POLICY_RELATION_SCHEMA } from './account-userop-policy-definition.js';
12
+ export { ACCOUNT_NATIVE_LP_USEROP_COMPILER, SPONSORED_LP_USEROP_POLICY_RELATION_SCHEMA } from './account-userop-policy-definition.js';
13
+ export class LpUserOpPolicyRefusal extends Error {
14
+ code;
15
+ constructor(code) {
16
+ super(code);
17
+ this.code = code;
18
+ this.name = 'LpUserOpPolicyRefusal';
19
+ }
20
+ }
21
+ function ensure(value, code) { if (!value)
22
+ throw new LpUserOpPolicyRefusal(code); }
23
+ export function lpUserOpActivationCommitment(raw) {
24
+ return hybridYieldCommitment(LP_USEROP_ACTIVATION_SCHEMA.parse(raw));
25
+ }
26
+ /**
27
+ * Provider scope is per call: Base, zero native value, pinned NPM/guard, and only
28
+ * approve(guard, tokenId) or the guard's exact collect selector. The immutable
29
+ * guard enforces the caller/recipient, position, pair and atomic NFT cleanup.
30
+ * The host separately enforces exactly [approve, collect]. This provider rule
31
+ * cannot express batch cardinality/order; allowed subsets/repetitions remain a
32
+ * provider-authority residual, including a standalone approval to the guard.
33
+ * Tuple-parameter enforcement is not claimed. Provider acceptance and denial
34
+ * evidence remain an activation gate, independent of SDK schema parsing.
35
+ */
36
+ export function compileLpCollectEndUserOperationRules(raw) {
37
+ const activation = LP_USEROP_ACTIVATION_SCHEMA.parse(raw);
38
+ const guard = getAddress(activation.guardDeployment.address), manager = getAddress(LP_V3_BASE.manager);
39
+ const approvalAbi = LP_V3_ATOMIC_NPM_ABI.filter(item => item.type === 'function' && item.name === 'approve');
40
+ const collectionAbi = LP_V3_COLLECT_GUARD_ABI.filter(item => item.type === 'function' && item.name === 'collect');
41
+ ensure(approvalAbi.length === 1 && collectionAbi.length === 1 && guard !== manager, 'LP_USEROP_POLICY_ABI_UNAVAILABLE');
42
+ return freezeHybridValue([{
43
+ action: 'accept', operation: 'sendEndUserOperation',
44
+ criteria: [
45
+ { type: 'evmNetwork', networks: ['base'], operator: 'in' },
46
+ { type: 'ethValue', ethValue: '0', operator: '<=' },
47
+ { type: 'evmAddress', addresses: [manager, guard], operator: 'in' },
48
+ { type: 'evmData', abi: [...approvalAbi, ...collectionAbi], conditions: [
49
+ { function: 'approve', params: [{ name: 'to', operator: 'in', values: [guard] }] },
50
+ { function: 'collect' },
51
+ ] },
52
+ ],
53
+ }]);
54
+ }
55
+ export function compileNativeLpCollectEndUserOperationPolicy(nativeActivation, rawLpActivation) {
56
+ const native = compileNativeYieldEndUserOperationPolicy(nativeActivation);
57
+ const lpActivation = LP_USEROP_ACTIVATION_SCHEMA.parse(rawLpActivation);
58
+ ensure(lpActivation.nativeActivationCommitment === native.nativeActivationCommitment, 'LP_USEROP_NATIVE_ACTIVATION_RELATION');
59
+ const lpRules = compileLpCollectEndUserOperationRules(lpActivation), rules = [...native.body.rules, ...lpRules];
60
+ ensure(lpRules.length === 1 && rules.length <= 10, 'LP_USEROP_POLICY_RULE_LIMIT');
61
+ return freezeHybridValue({
62
+ body: { scope: 'project', description: native.body.description, rules },
63
+ compiler: ACCOUNT_NATIVE_LP_USEROP_COMPILER,
64
+ nativeCompiledPolicyDigest: native.compiledFullPolicyDigest,
65
+ nativeActivationCommitment: native.nativeActivationCommitment, nativeRulesDigest: native.nativeRulesDigest,
66
+ lpActivationCommitment: lpUserOpActivationCommitment(lpActivation), lpRulesDigest: policyRulesDigest(lpRules),
67
+ compiledFullPolicyDigest: policyRulesDigest(rules),
68
+ });
69
+ }
70
+ /** Preserve the existing native-only compiler proof; the new relation binds the augmented actual policy. */
71
+ export function assertNativeLpCollectPolicyRelation(nativeActivation, sponsorActivation, lpActivation) {
72
+ const base = compileNativeYieldEndUserOperationPolicy(nativeActivation);
73
+ const compiled = compileNativeLpCollectEndUserOperationPolicy(nativeActivation, lpActivation);
74
+ const relation = SPONSORED_LP_USEROP_POLICY_RELATION_SCHEMA.parse(sponsorActivation.lpUserOpPolicyRelation);
75
+ const native = sponsorActivation.nativeYieldUserOpPolicyRelation;
76
+ ensure(native && native.compiler === base.compiler &&
77
+ native.nativeActivationCommitment === base.nativeActivationCommitment &&
78
+ native.nativeRulesDigest === base.nativeRulesDigest && native.compiledFullPolicyDigest === base.compiledFullPolicyDigest &&
79
+ digest.safeParse(native.relationReviewEvidenceDigest).success, 'LP_USEROP_NATIVE_POLICY_RELATION');
80
+ const { relationReviewEvidenceDigest: _reviewEvidence, ...derived } = relation;
81
+ const { body: _body, ...expected } = compiled;
82
+ ensure(hybridYieldCommitment(derived) === hybridYieldCommitment(expected) &&
83
+ sponsorActivation.policyId === nativeActivation.policyId && sponsorActivation.policyName === nativeActivation.policyName &&
84
+ sponsorActivation.policyRulesDigest === compiled.compiledFullPolicyDigest, 'LP_USEROP_COMPOSITE_POLICY_RELATION');
85
+ return compiled;
86
+ }
87
+ //# sourceMappingURL=account-userop-policy-relation.js.map
@@ -27,6 +27,7 @@
27
27
  import { type Address, type Hex, type PublicClient } from 'viem';
28
28
  import { type SealedWaitOptions } from './chain.js';
29
29
  import type { SentStep } from './sent-step.js';
30
+ import { AdapterRefusal } from './refusal.js';
30
31
  import { type SigningCapability, type VerifiedSwap } from './verify.js';
31
32
  export declare const CDP_CAPABILITIES: readonly SigningCapability[];
32
33
  export declare const CHAIN_ID: 8453;
@@ -40,6 +41,31 @@ export interface CdpEndUser {
40
41
  readonly userId: string;
41
42
  readonly address: Address;
42
43
  }
44
+ export interface DelegatedSubmissionAttempt {
45
+ readonly index: number;
46
+ readonly kind: 'approve_reset' | 'approve' | 'call' | 'allowance_clear';
47
+ readonly userId: string;
48
+ readonly address: Address;
49
+ readonly transaction: Hex;
50
+ readonly network: typeof NETWORK;
51
+ }
52
+ export interface DelegatedSubmissionReceipt {
53
+ readonly transactionHash: Hex;
54
+ readonly status: 'success' | 'reverted';
55
+ readonly blockNumber: string;
56
+ readonly blockHash: Hex;
57
+ readonly gasUsed: string;
58
+ }
59
+ /** Durable observer used by the hosted delegated path. Its prepare call must commit before it resolves. */
60
+ export interface DelegatedSubmissionJournal {
61
+ prepare(attempt: DelegatedSubmissionAttempt): Promise<{
62
+ readonly idempotencyKey: string;
63
+ }>;
64
+ notSubmitted(index: number, idempotencyKey: string): Promise<void>;
65
+ submitted(index: number, idempotencyKey: string, transactionHash: Hex): Promise<void>;
66
+ unknown(index: number, idempotencyKey: string): Promise<void>;
67
+ receipt(index: number, idempotencyKey: string, receipt: DelegatedSubmissionReceipt): Promise<void>;
68
+ }
43
69
  /** The PUBLIC face of a rig: chain reads, delegation read-back, revocation. No submission surface. */
44
70
  export interface CdpRig {
45
71
  readonly pub: PublicClient;
@@ -57,24 +83,33 @@ export interface CdpRig {
57
83
  export interface CdpRawOperations {
58
84
  readonly pub: PublicClient;
59
85
  /** Sign + broadcast an unsigned serialized EIP-1559 transaction under the user's delegation. Returns the tx hash. */
60
- submit(user: CdpEndUser, unsignedTransaction: Hex): Promise<Hex>;
86
+ submit(user: CdpEndUser, unsignedTransaction: Hex, idempotencyKey?: string): Promise<Hex>;
61
87
  revoke(userId: string): Promise<void>;
62
88
  readDelegation(userId: string): Promise<{
63
89
  expiresAt: string;
64
90
  } | undefined>;
65
91
  }
66
- /** True once `rig.revoke(userId)` has been called on this rig, whatever it returned. */
67
- export declare function revocationRequested(rig: CdpRig, userId: string): boolean;
92
+ /**
93
+ * True once revocation was requested on this rig for THIS grant — the one expiring at `expiresAt`.
94
+ * A user with no live grant, or with a different one, is not marked.
95
+ */
96
+ export declare function revocationRequested(rig: CdpRig, userId: string, expiresAt: string): boolean;
68
97
  /**
69
98
  * Why a delegated plan halted — a closed vocabulary the signer sets from STRUCTURED facts only (the CDP
70
99
  * `errorType`, an error's class, the receipt status, its own checks). Message text never selects it, so
71
100
  * upstream text cannot steer the class a consumer reports.
72
101
  */
73
- export type DelegatedHaltCause = 'policy_violation' | 'delegation_not_active' | 'artifact_no_longer_signable' | 'reverted' | 'receipt_not_sealed' | 'upstream_failure';
102
+ export type DelegatedHaltCause = 'policy_violation' | 'delegation_not_active' | 'artifact_no_longer_signable' | 'reverted'
103
+ /** A later step's gas estimate reverted after an earlier step had landed; nothing more was broadcast. */
104
+ | 'would_revert'
105
+ /** The node could not estimate a later step (timeout, rate limit, transport); nothing more was broadcast. */
106
+ | 'estimate_unavailable' | 'receipt_not_sealed' | 'upstream_failure';
74
107
  /**
75
- * A delegated plan halted; `cause` is the structured class above, `allowanceCleared` says whether the
76
- * router allowance is known to be zero again. The message is for the operator; a consumer that must not
77
- * relay upstream text reads `cause` and the two fields only.
108
+ * A delegated plan halted; `cause` is the structured class above. `allowanceCleared` reports only
109
+ * whether the bounded cleanup's live, unpinned allowance read returned zero. It is diagnostic and is
110
+ * never sufficient to release a durable operation claim; finalized-canonical recovery owns that proof.
111
+ * The message is for the operator; a consumer that must not relay upstream text reads `cause` and the
112
+ * two fields only.
78
113
  */
79
114
  export declare class DelegatedPlanHaltedError extends Error {
80
115
  readonly failedStep: number;
@@ -103,19 +138,51 @@ export declare function openCdpRig(credentials: CdpDeveloperCredentials, rpcUrl?
103
138
  * This IS `rig.revoke`: serialized on the rig, lock held through the read-back, fail-closed afterwards.
104
139
  */
105
140
  export declare function revokeDelegationByUserId(rig: CdpRig, userId: string): Promise<void>;
141
+ /**
142
+ * A plan step whose gas estimate REVERTED. The node evaluates nothing of Coinbase's policy — the policy
143
+ * engine answers at submission, not at `eth_estimateGas` — so a reverting estimate is a transaction that
144
+ * would revert on chain, and broadcasting it anyway would spend the user's gas and buy nothing.
145
+ *
146
+ * 🔴 THIS IS WHAT THE STATIC 400,000 FALLBACK USED TO DO (2026-09-03, the first live delegated swap):
147
+ * the estimate reverted, the step went out at 400k, reverted on chain (234k gas burned), and only then
148
+ * did the halt path clear the allowance. 400k was also below every LI.FI swap's real need (~320–580k
149
+ * used, 1.1–1.4M quoted), so even a healthy route would have reverted under it. There is no fallback
150
+ * now: an estimate that reverts is a refusal, by name.
151
+ */
152
+ export declare class DelegatedTransactionWouldRevertError extends AdapterRefusal {
153
+ readonly stepKind: string;
154
+ constructor(stepKind: string, detail: string);
155
+ }
156
+ /**
157
+ * A plan step the node could not estimate AT ALL — a timeout, a rate limit, a dropped connection. Nothing
158
+ * is proven about the transaction, so nothing is broadcast without an estimate; but it is NOT a revert:
159
+ * the caller may retry, and no route is blamed (gate r7, finding 2).
160
+ */
161
+ export declare class DelegatedTransactionEstimateUnavailableError extends AdapterRefusal {
162
+ readonly stepKind: string;
163
+ constructor(stepKind: string, detail: string);
164
+ }
165
+ /** The bounded limit the halt path's `approve(spender, 0)` uses when the node cannot estimate it. */
166
+ export declare const ALLOWANCE_CLEAR_STATIC_GAS = 80000n;
106
167
  export declare class CdpDelegatedSigner {
107
168
  #private;
108
169
  readonly capabilities: readonly SigningCapability[];
109
170
  readonly chainId: 8453;
110
171
  constructor(rig: CdpRig, user: CdpEndUser, options?: {
111
172
  readonly sealedWait?: SealedWaitOptions;
173
+ readonly beforeEachStep?: () => Promise<void>;
174
+ readonly afterBuild?: () => Promise<void>;
175
+ readonly beforeSubmit?: () => void;
176
+ readonly grantExpiresAt?: string;
177
+ readonly submissionJournal?: DelegatedSubmissionJournal;
112
178
  });
113
179
  get address(): Address;
114
180
  get user(): CdpEndUser;
115
181
  /**
116
182
  * `send_evm_transaction`, under delegation: only a plan `assertPlanSignableBy` accepts for THIS user,
117
- * re-checked before every step AND again immediately before each hand-off to CDP (after the nonce /
118
- * fee / gas round trips, so an artifact that expires during preparation is never submitted). The plan
183
+ * re-checked before every step — together with the caller's async `beforeEachStep`, which re-reads the
184
+ * GRANT and its recorded per-swap cap — AND again immediately before each hand-off to CDP (after the
185
+ * nonce / fee / gas round trips, so an artifact that expires during preparation is never submitted). The plan
119
186
  * halts at the first step that does not succeed; after ANY failure a bounded `approve(spender, 0)` is
120
187
  * attempted under the same policy and its real outcome — confirmed by an allowance read-back — is
121
188
  * reported. A failed reset may leave a pre-existing allowance, so step 0 is not exempt.