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,211 @@
1
+ /** One manually reviewed LP collection. No signer, durable consent, transport or parallel journal. */
2
+ import { getAddress } from 'viem';
3
+ import { freezeHybridValue, hybridYieldCommitment } from './hybrid-yield-markets.js';
4
+ import { policyRulesDigest } from './execution-policy-compatibility.js';
5
+ import { SPONSORED_ACCOUNT_ACTIVATIONS, SPONSORED_ACTIVATION_SCHEMA, SPONSORED_NATIVE_USEROP_PROFILE_SCHEMA, sponsoredChainTerms, sponsoredDigest } from './execution-sponsored-definition.js';
6
+ import { assertSponsoredAccountProfile, SponsoredAccountProfileError } from './execution-sponsored-account-profile.js';
7
+ import { NATIVE_YIELD_ACCOUNT_ACTIVATIONS } from './native-yield-account-definition.js';
8
+ import { resolveNativeYieldAccountActivation } from './native-yield-account-policy.js';
9
+ import { assertNativeLpCollectPolicyRelation, lpUserOpActivationCommitment } from './account-userop-policy-relation.js';
10
+ import { LP_USEROP_ACTIVATIONS, LP_USEROP_ACTIVATION_SCHEMA, LP_USEROP_INPUT_SCHEMA, LP_USEROP_REVIEW_RECORD_SCHEMA, LP_USEROP_TERMS_SCHEMA, LP_USEROP_RULESET, LP_USEROP_REVIEW_TTL_MS, LP_USEROP_ZERO_ADDRESS } from './lp-userop-definition.js';
11
+ import { commitment as protocolCommitment, LP_V3_BASE } from './vendor/lp-v3/lp-v3-contract.js';
12
+ export class LpUserOpAuthorityRefusal extends Error {
13
+ code;
14
+ constructor(code) {
15
+ super(code);
16
+ this.code = code;
17
+ this.name = 'LpUserOpAuthorityRefusal';
18
+ }
19
+ }
20
+ function ensure(value, code) { if (!value)
21
+ throw new LpUserOpAuthorityRefusal(code); }
22
+ const equal = (left, right) => hybridYieldCommitment(left) === hybridYieldCommitment(right);
23
+ const brand = Symbol('lp-userop-authority');
24
+ const sourceIdentity = ({ nativeActivation, sponsorActivation, lpActivation, chainTerms, profile }) => ({ nativeActivation, sponsorActivation, lpActivation, chainTerms, profile });
25
+ export class LpUserOpAuthorityIssuer {
26
+ sponsor;
27
+ issued = new WeakMap();
28
+ capLocked = new WeakSet();
29
+ nativeActivations;
30
+ sponsorActivations;
31
+ lpActivations;
32
+ constructor(sponsor,
33
+ /** Internal fixtures only; the production constructor reads three empty reviewed source arrays. */
34
+ fixtures) {
35
+ this.sponsor = sponsor;
36
+ this.nativeActivations = fixtures?.nativeActivations ?? NATIVE_YIELD_ACCOUNT_ACTIVATIONS;
37
+ this.sponsorActivations = fixtures?.sponsoredActivations ?? SPONSORED_ACCOUNT_ACTIVATIONS;
38
+ this.lpActivations = fixtures?.lpActivations ?? LP_USEROP_ACTIVATIONS;
39
+ }
40
+ now() {
41
+ const now = this.sponsor.now();
42
+ ensure(Number.isSafeInteger(now) && now > 0, 'LP_USEROP_CLOCK');
43
+ return now;
44
+ }
45
+ sources(input) {
46
+ // Refuse inactive production before touching the runtime, SDK, caps or public RPC.
47
+ ensure(this.nativeActivations.length === 1 && this.sponsorActivations.length === 1 && this.lpActivations.length === 1, 'LP_USEROP_SOURCE_ACTIVATIONS_REQUIRED');
48
+ const nativeActivation = resolveNativeYieldAccountActivation(8453, this.nativeActivations);
49
+ const sponsorActivation = SPONSORED_ACTIVATION_SCHEMA.parse(this.sponsorActivations[0]);
50
+ const lpActivation = LP_USEROP_ACTIVATION_SCHEMA.parse(this.lpActivations[0]);
51
+ ensure(sponsorActivation.mode === 'enabled' && lpActivation.mode === 'enabled' &&
52
+ sponsorActivation.projectId === this.sponsor.projectId &&
53
+ sponsorActivation.approvedAtMs <= this.now() && sponsorActivation.expiresAtMs > this.now() &&
54
+ lpActivation.approvedAtMs <= this.now() && lpActivation.expiresAtMs > this.now(), 'LP_USEROP_ACTIVATION_UNAVAILABLE');
55
+ assertNativeLpCollectPolicyRelation(nativeActivation, sponsorActivation, lpActivation);
56
+ const chainTerms = sponsoredChainTerms(sponsorActivation, 8453);
57
+ const profile = SPONSORED_NATIVE_USEROP_PROFILE_SCHEMA.parse(chainTerms.nativeYieldUserOpProfile);
58
+ ensure(input.account === input.recipient && input.guardDeploymentId === lpActivation.guardDeployment.id &&
59
+ input.amountMax.every((amount, i) => BigInt(amount) <= BigInt(lpActivation.maximumCollectAtomic[i])) &&
60
+ input.amountMax.some(amount => amount !== '0') &&
61
+ input.amountMin.every((amount, i) => BigInt(amount) <= BigInt(input.amountMax[i])) &&
62
+ Number.isSafeInteger(input.deadline * 1000) && input.deadline * 1000 > this.now() &&
63
+ input.deadline * 1000 - this.now() <= lpActivation.maximumDeadlineSeconds * 1000, 'LP_USEROP_INTENT_OUTSIDE_REVIEWED_SCOPE');
64
+ return freezeHybridValue({ nativeActivation, sponsorActivation, lpActivation, chainTerms, profile });
65
+ }
66
+ window(input, facts, prior) {
67
+ const reviewCreatedAtMs = prior?.reviewCreatedAtMs ?? this.now();
68
+ const reviewExpiresAtMs = Math.min(reviewCreatedAtMs + LP_USEROP_REVIEW_TTL_MS, facts.lpActivation.expiresAtMs, facts.sponsorActivation.expiresAtMs, Date.parse(facts.sponsorAuthority.grantExpiresAt), input.deadline * 1000);
69
+ ensure(reviewCreatedAtMs <= this.now() && this.now() < reviewExpiresAtMs &&
70
+ (!prior || prior.reviewExpiresAtMs === reviewExpiresAtMs), 'LP_USEROP_REVIEW_EXPIRED');
71
+ return { reviewCreatedAtMs, reviewExpiresAtMs };
72
+ }
73
+ derivedTerms(input, facts, window) {
74
+ const { sponsorActivation: activation, lpActivation, chainTerms: chain, profile, sponsorAuthority } = facts;
75
+ const intentCommitment = protocolCommitment(input);
76
+ return freezeHybridValue(LP_USEROP_TERMS_SCHEMA.parse({
77
+ version: 1, ruleset: LP_USEROP_RULESET, userId: sponsorAuthority.userId, account: sponsorAuthority.account, chainId: 8453,
78
+ authorityDigest: sponsoredDigest({ domain: 'lp-userop-current-operation-authority-v1', sponsorAuthority,
79
+ lpActivationCommitment: lpUserOpActivationCommitment(lpActivation), intentCommitment, ...window }),
80
+ lpActivationCommitment: lpUserOpActivationCommitment(lpActivation), sponsoredActivationId: activation.id,
81
+ sponsoredActivationDigest: sponsoredDigest(activation), projectId: activation.projectId,
82
+ policyId: activation.policyId, policyRulesDigest: activation.policyRulesDigest,
83
+ providerEnforcementEvidenceDigest: activation.providerEnforcementEvidenceDigest,
84
+ providerEndpoint: 'cdp-end-user-smart-account-send-v1', guardDeployment: lpActivation.guardDeployment,
85
+ finalityPolicy: lpActivation.finalityPolicy,
86
+ delegate: chain.delegate, delegateCodeHash: chain.delegateCodeHash,
87
+ implementation: profile.implementation, implementationCodeHash: profile.implementationCodeHash,
88
+ delegateBatchAbi: profile.delegateBatchAbi, delegateBatchReviewDigest: profile.delegateBatchReviewDigest,
89
+ entryPoint: chain.entryPoint, entryPointCodeHash: chain.entryPointCodeHash,
90
+ entryPointVersion: profile.entryPointVersion, ownerProfile: { kind: 'sole-eoa-owner', nextOwnerIndex: '1',
91
+ ownerCount: '1', ownerAtIndex0: '0x' + '0'.repeat(24) + sponsorAuthority.account.slice(2).toLowerCase(),
92
+ spendPermissionsEnabled: false },
93
+ paymaster: chain.paymaster, paymasterCodeHash: chain.paymasterCodeHash,
94
+ sponsorshipPolicyId: chain.sponsorshipPolicyId, maxGasCostWei: chain.maxGasCostWei,
95
+ maxUserGasCostWei: chain.maxUserGasCostWei, maxTotalGasCostWei: chain.maxTotalGasCostWei,
96
+ maximumCollectAtomic: lpActivation.maximumCollectAtomic, intentCommitment, ...window,
97
+ initialNftApproval: LP_USEROP_ZERO_ADDRESS, finalNftApproval: LP_USEROP_ZERO_ADDRESS,
98
+ execution: 'atomic-nft-approve-guarded-collect', principalDebitAuthorized: false,
99
+ }));
100
+ }
101
+ async facts(accessToken, input) {
102
+ const source = this.sources(input), account = getAddress(input.account);
103
+ // Both possible collection assets are source reviewed. These share a grant fingerprint;
104
+ // neither the legacy perSwapCapUsd nor a quote is represented as an LP notional limit.
105
+ const first = await this.sponsor.authority(accessToken, account, 8453, source.sponsorActivation, getAddress(LP_V3_BASE.token0), 'lp-collect-userop');
106
+ const second = await this.sponsor.authority(accessToken, account, 8453, source.sponsorActivation, getAddress(LP_V3_BASE.token1), 'lp-collect-userop');
107
+ ensure(equal(first, second), 'LP_USEROP_CURRENT_AUTHORITY_CHANGED');
108
+ const facts = { ...source, sponsorAuthority: second };
109
+ const proofTerms = this.derivedTerms(input, facts, this.window(input, facts));
110
+ const client = this.sponsor.client(8453), block = await client.getBlock({ blockTag: 'latest' });
111
+ const timestampMs = Number(block.timestamp) * 1000;
112
+ ensure(block.number !== null && block.hash && Number.isSafeInteger(timestampMs) && timestampMs > 0 &&
113
+ timestampMs <= this.now() + 5000 && this.now() - timestampMs <= 60_000, 'LP_USEROP_ACCOUNT_ANCHOR');
114
+ try {
115
+ await assertSponsoredAccountProfile(client, proofTerms, block.number, block.hash, [
116
+ { address: getAddress(source.lpActivation.guardDeployment.address), codeHash: source.lpActivation.guardDeployment.runtimeCodeHash },
117
+ { address: getAddress(LP_V3_BASE.manager), codeHash: LP_V3_BASE.managerCodeHash },
118
+ { address: getAddress(LP_V3_BASE.token0), codeHash: LP_V3_BASE.token0CodeHash },
119
+ { address: getAddress(LP_V3_BASE.token1), codeHash: LP_V3_BASE.token1CodeHash },
120
+ ]);
121
+ }
122
+ catch (error) {
123
+ if (error instanceof SponsoredAccountProfileError)
124
+ throw new LpUserOpAuthorityRefusal('LP_USEROP_ACCOUNT_' + error.reason);
125
+ throw error;
126
+ }
127
+ const [who, grant, policyReply] = await Promise.all([
128
+ this.sponsor.identity(accessToken, account),
129
+ this.sponsor.cdp.endUser.getDelegationForEndUserAccount({ userId: second.userId, address: account }),
130
+ this.sponsor.cdp.policies.listPolicies({ scope: 'project' }),
131
+ ]);
132
+ const smart = (who.current.evmSmartAccountObjects ?? []).filter(value => getAddress(value.address) === account);
133
+ const policies = (policyReply.policies ?? []).filter(value => value.scope === 'project');
134
+ ensure(who.userId === second.userId && smart.length === 1 && smart[0].ownerAddresses.length === 1 &&
135
+ getAddress(smart[0].ownerAddresses[0]) === account &&
136
+ Date.parse(grant.expiresAt) === Date.parse(second.grantExpiresAt) && Date.parse(grant.expiresAt) > this.now() &&
137
+ policies.length === 1 && policies[0].id === source.sponsorActivation.policyId &&
138
+ policies[0].description === source.sponsorActivation.policyName &&
139
+ policyRulesDigest(policies[0].rules) === source.sponsorActivation.policyRulesDigest, 'LP_USEROP_CURRENT_AUTHORITY_CHANGED');
140
+ await this.sponsor.assertCurrentCap(second);
141
+ ensure(equal(sourceIdentity(this.sources(input)), sourceIdentity(source)), 'LP_USEROP_SOURCE_CHANGED');
142
+ return freezeHybridValue(facts);
143
+ }
144
+ async issue(accessToken, rawInput, previous) {
145
+ const input = freezeHybridValue(LP_USEROP_INPUT_SCHEMA.parse(rawInput));
146
+ const facts = await this.facts(accessToken, input);
147
+ const terms = this.derivedTerms(input, facts, this.window(input, facts, previous?.terms));
148
+ const review = freezeHybridValue(LP_USEROP_REVIEW_RECORD_SCHEMA.parse({ input, terms }));
149
+ ensure(!previous || equal(review, previous), 'LP_USEROP_REVIEW_AUTHORITY_CHANGED');
150
+ const token = Object.freeze({ [brand]: true });
151
+ this.issued.set(token, { facts, review });
152
+ this.assertCurrent(token);
153
+ return token;
154
+ }
155
+ mint(accessToken, rawInput) { return this.issue(accessToken, rawInput); }
156
+ read(authority) {
157
+ const issued = authority && this.issued.get(authority);
158
+ ensure(issued, 'LP_USEROP_OPAQUE_AUTHORITY_REQUIRED');
159
+ return issued;
160
+ }
161
+ async refresh(accessToken, authority) {
162
+ const previous = this.read(authority).review;
163
+ return this.issue(accessToken, previous.input, previous);
164
+ }
165
+ /** Only immutable trusted journal context may enter here; never caller-supplied terms. */
166
+ async restoreFromTrustedReview(accessToken, rawReview) {
167
+ const review = LP_USEROP_REVIEW_RECORD_SCHEMA.parse(rawReview);
168
+ return this.issue(accessToken, review.input, review);
169
+ }
170
+ assertScope(authority) {
171
+ const { facts, review } = this.read(authority);
172
+ this.window(review.input, facts, review.terms);
173
+ ensure(equal(sourceIdentity(this.sources(review.input)), sourceIdentity(facts)), 'LP_USEROP_SOURCE_CHANGED');
174
+ }
175
+ /** Synchronous source/time and Stop check, including inside the caller's shared-journal stamp. */
176
+ assertCurrent(authority) { this.withCurrentCap(authority, () => undefined); }
177
+ /** The existing cap writer lock orders Stop against the synchronous provider POST invocation. */
178
+ withCurrentCap(authority, start) {
179
+ this.assertScope(authority);
180
+ // A provider-start callback may inspect this same authority while its lock is already held.
181
+ if (this.capLocked.has(authority))
182
+ return start();
183
+ return this.sponsor.withCurrentCap(this.read(authority).facts.sponsorAuthority, () => {
184
+ this.assertScope(authority);
185
+ this.capLocked.add(authority);
186
+ try {
187
+ return start();
188
+ }
189
+ finally {
190
+ this.capLocked.delete(authority);
191
+ }
192
+ });
193
+ }
194
+ terms(authority) {
195
+ this.assertCurrent(authority);
196
+ return this.read(authority).review.terms;
197
+ }
198
+ reviewRecord(authority) {
199
+ this.assertCurrent(authority);
200
+ return this.read(authority).review;
201
+ }
202
+ sponsorship(authority) {
203
+ this.assertCurrent(authority);
204
+ return this.read(authority).facts.sponsorAuthority;
205
+ }
206
+ activation(authority) {
207
+ this.assertCurrent(authority);
208
+ return this.read(authority).facts.sponsorActivation;
209
+ }
210
+ }
211
+ //# sourceMappingURL=lp-userop-authority.js.map
@@ -0,0 +1,233 @@
1
+ import { z } from 'zod';
2
+ export declare const LP_USEROP_RULESET: "lp-guarded-collect-userop-v1";
3
+ export declare const LP_USEROP_REVIEW_TTL_MS: number;
4
+ export declare const LP_USEROP_CONFIRMATION: "I reviewed this position collection and sponsored atomic batch";
5
+ export declare const LP_USEROP_ACCOUNT_GAS_CONFIRMATION: "I reviewed this position collection and account-paid atomic batch";
6
+ export declare const LP_USEROP_ZERO_ADDRESS: "0x0000000000000000000000000000000000000000";
7
+ /** These are host collection ceilings. A swap cap is not an LP notional limit. */
8
+ export declare const LP_USEROP_ACTIVATION_SCHEMA: z.ZodObject<{
9
+ version: z.ZodLiteral<1>;
10
+ ruleset: z.ZodLiteral<"lp-guarded-collect-userop-v1">;
11
+ id: z.ZodString;
12
+ mode: z.ZodEnum<{
13
+ enabled: "enabled";
14
+ "recovery-only": "recovery-only";
15
+ }>;
16
+ approvedAtMs: z.ZodNumber;
17
+ expiresAtMs: z.ZodNumber;
18
+ nativeActivationCommitment: z.ZodString;
19
+ guardDeployment: z.ZodObject<{
20
+ id: z.ZodLiteral<"base-weth-usdc-collect-v1">;
21
+ chainId: z.ZodLiteral<8453>;
22
+ address: z.ZodString;
23
+ runtimeCodeHash: z.ZodString;
24
+ configurationHash: z.ZodLiteral<`0x${string}`>;
25
+ codeVersion: z.ZodLiteral<"OttoV3CollectGuard-v1">;
26
+ deploymentBlock: z.ZodString;
27
+ reviewReference: z.ZodString;
28
+ }, z.core.$strict>;
29
+ finalityPolicy: z.ZodObject<{
30
+ schemaVersion: z.ZodLiteral<1>;
31
+ id: z.ZodLiteral<"base-finalized-lp-v1">;
32
+ chainId: z.ZodLiteral<8453>;
33
+ blockTag: z.ZodLiteral<"finalized">;
34
+ reviewReference: z.ZodString;
35
+ minFinalizedConfirmations: z.ZodNumber;
36
+ maxHeadAgeSeconds: z.ZodNumber;
37
+ maxFinalizedLagSeconds: z.ZodNumber;
38
+ maxReadDurationSeconds: z.ZodNumber;
39
+ }, z.core.$strict>;
40
+ capabilities: z.ZodTuple<[z.ZodLiteral<"guarded-collect">], null>;
41
+ maximumCollectAtomic: z.ZodTuple<[z.ZodString, z.ZodString], null>;
42
+ maximumDeadlineSeconds: z.ZodNumber;
43
+ reviewEvidenceDigest: z.ZodString;
44
+ }, z.core.$strict>;
45
+ export type LpUserOpActivation = z.infer<typeof LP_USEROP_ACTIVATION_SCHEMA>;
46
+ /** No environment switch, request field or imported plan can populate this source authority. */
47
+ export declare const LP_USEROP_ACTIVATIONS: readonly LpUserOpActivation[];
48
+ export declare const LP_USEROP_TERMS_SCHEMA: z.ZodObject<{
49
+ version: z.ZodLiteral<1>;
50
+ ruleset: z.ZodLiteral<"lp-guarded-collect-userop-v1">;
51
+ userId: z.ZodString;
52
+ account: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
53
+ chainId: z.ZodLiteral<8453>;
54
+ authorityDigest: z.ZodString;
55
+ lpActivationCommitment: z.ZodString;
56
+ sponsoredActivationId: z.ZodString;
57
+ sponsoredActivationDigest: z.ZodString;
58
+ projectId: z.ZodString;
59
+ policyId: z.ZodString;
60
+ policyRulesDigest: z.ZodString;
61
+ providerEnforcementEvidenceDigest: z.ZodString;
62
+ providerEndpoint: z.ZodLiteral<"cdp-end-user-smart-account-send-v1">;
63
+ guardDeployment: z.ZodObject<{
64
+ id: z.ZodLiteral<"base-weth-usdc-collect-v1">;
65
+ chainId: z.ZodLiteral<8453>;
66
+ address: z.ZodString;
67
+ runtimeCodeHash: z.ZodString;
68
+ configurationHash: z.ZodLiteral<`0x${string}`>;
69
+ codeVersion: z.ZodLiteral<"OttoV3CollectGuard-v1">;
70
+ deploymentBlock: z.ZodString;
71
+ reviewReference: z.ZodString;
72
+ }, z.core.$strict>;
73
+ finalityPolicy: z.ZodObject<{
74
+ schemaVersion: z.ZodLiteral<1>;
75
+ id: z.ZodLiteral<"base-finalized-lp-v1">;
76
+ chainId: z.ZodLiteral<8453>;
77
+ blockTag: z.ZodLiteral<"finalized">;
78
+ reviewReference: z.ZodString;
79
+ minFinalizedConfirmations: z.ZodNumber;
80
+ maxHeadAgeSeconds: z.ZodNumber;
81
+ maxFinalizedLagSeconds: z.ZodNumber;
82
+ maxReadDurationSeconds: z.ZodNumber;
83
+ }, z.core.$strict>;
84
+ delegate: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
85
+ delegateCodeHash: z.ZodString;
86
+ implementation: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
87
+ implementationCodeHash: z.ZodString;
88
+ delegateBatchAbi: z.ZodLiteral<"coinbase-executeBatch-v1">;
89
+ delegateBatchReviewDigest: z.ZodString;
90
+ entryPoint: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
91
+ entryPointCodeHash: z.ZodString;
92
+ entryPointVersion: z.ZodLiteral<"0.6">;
93
+ ownerProfile: z.ZodObject<{
94
+ kind: z.ZodLiteral<"sole-eoa-owner">;
95
+ nextOwnerIndex: z.ZodLiteral<"1">;
96
+ ownerCount: z.ZodLiteral<"1">;
97
+ ownerAtIndex0: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
98
+ spendPermissionsEnabled: z.ZodLiteral<false>;
99
+ }, z.core.$strict>;
100
+ paymaster: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
101
+ paymasterCodeHash: z.ZodString;
102
+ sponsorshipPolicyId: z.ZodString;
103
+ maxGasCostWei: z.ZodString;
104
+ maxUserGasCostWei: z.ZodString;
105
+ maxTotalGasCostWei: z.ZodString;
106
+ maximumCollectAtomic: z.ZodTuple<[z.ZodString, z.ZodString], null>;
107
+ intentCommitment: z.ZodString;
108
+ reviewCreatedAtMs: z.ZodNumber;
109
+ reviewExpiresAtMs: z.ZodNumber;
110
+ initialNftApproval: z.ZodLiteral<"0x0000000000000000000000000000000000000000">;
111
+ finalNftApproval: z.ZodLiteral<"0x0000000000000000000000000000000000000000">;
112
+ execution: z.ZodLiteral<"atomic-nft-approve-guarded-collect">;
113
+ principalDebitAuthorized: z.ZodLiteral<false>;
114
+ }, z.core.$strict>;
115
+ export type LpUserOpTerms = z.infer<typeof LP_USEROP_TERMS_SCHEMA>;
116
+ /** The protocol owner defines this v3 collect intent; older EOA intents remain separate. */
117
+ export declare const LP_USEROP_INPUT_SCHEMA: z.ZodObject<{
118
+ action: z.ZodLiteral<"collect">;
119
+ tokenId: z.ZodString;
120
+ amountMax: z.ZodTuple<[z.ZodString, z.ZodString], null>;
121
+ amountMin: z.ZodTuple<[z.ZodString, z.ZodString], null>;
122
+ protocol: z.ZodLiteral<"uniswap-v3">;
123
+ chainId: z.ZodLiteral<8453>;
124
+ operationId: z.ZodString;
125
+ account: z.ZodString;
126
+ recipient: z.ZodString;
127
+ manager: z.ZodLiteral<"0x03a520b32c04bf3beef7beb72e919cf822ed34f1">;
128
+ factory: z.ZodLiteral<"0x33128a8fc17869897dce68ed026d694621f6fdfd">;
129
+ pool: z.ZodString;
130
+ token0: z.ZodLiteral<"0x4200000000000000000000000000000000000006">;
131
+ token1: z.ZodLiteral<"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913">;
132
+ fee: z.ZodUnion<readonly [z.ZodLiteral<100>, z.ZodLiteral<500>, z.ZodLiteral<3000>, z.ZodLiteral<10000>]>;
133
+ tickLower: z.ZodNumber;
134
+ tickUpper: z.ZodNumber;
135
+ deadline: z.ZodNumber;
136
+ nftApprovalPolicy: z.ZodLiteral<"zero-before-and-after">;
137
+ guardDeploymentId: z.ZodLiteral<"base-weth-usdc-collect-v1">;
138
+ schemaVersion: z.ZodLiteral<3>;
139
+ }, z.core.$strict>;
140
+ export type LpUserOpInput = z.infer<typeof LP_USEROP_INPUT_SCHEMA>;
141
+ export declare const LP_USEROP_REVIEW_RECORD_SCHEMA: z.ZodObject<{
142
+ input: z.ZodObject<{
143
+ action: z.ZodLiteral<"collect">;
144
+ tokenId: z.ZodString;
145
+ amountMax: z.ZodTuple<[z.ZodString, z.ZodString], null>;
146
+ amountMin: z.ZodTuple<[z.ZodString, z.ZodString], null>;
147
+ protocol: z.ZodLiteral<"uniswap-v3">;
148
+ chainId: z.ZodLiteral<8453>;
149
+ operationId: z.ZodString;
150
+ account: z.ZodString;
151
+ recipient: z.ZodString;
152
+ manager: z.ZodLiteral<"0x03a520b32c04bf3beef7beb72e919cf822ed34f1">;
153
+ factory: z.ZodLiteral<"0x33128a8fc17869897dce68ed026d694621f6fdfd">;
154
+ pool: z.ZodString;
155
+ token0: z.ZodLiteral<"0x4200000000000000000000000000000000000006">;
156
+ token1: z.ZodLiteral<"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913">;
157
+ fee: z.ZodUnion<readonly [z.ZodLiteral<100>, z.ZodLiteral<500>, z.ZodLiteral<3000>, z.ZodLiteral<10000>]>;
158
+ tickLower: z.ZodNumber;
159
+ tickUpper: z.ZodNumber;
160
+ deadline: z.ZodNumber;
161
+ nftApprovalPolicy: z.ZodLiteral<"zero-before-and-after">;
162
+ guardDeploymentId: z.ZodLiteral<"base-weth-usdc-collect-v1">;
163
+ schemaVersion: z.ZodLiteral<3>;
164
+ }, z.core.$strict>;
165
+ terms: z.ZodObject<{
166
+ version: z.ZodLiteral<1>;
167
+ ruleset: z.ZodLiteral<"lp-guarded-collect-userop-v1">;
168
+ userId: z.ZodString;
169
+ account: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
170
+ chainId: z.ZodLiteral<8453>;
171
+ authorityDigest: z.ZodString;
172
+ lpActivationCommitment: z.ZodString;
173
+ sponsoredActivationId: z.ZodString;
174
+ sponsoredActivationDigest: z.ZodString;
175
+ projectId: z.ZodString;
176
+ policyId: z.ZodString;
177
+ policyRulesDigest: z.ZodString;
178
+ providerEnforcementEvidenceDigest: z.ZodString;
179
+ providerEndpoint: z.ZodLiteral<"cdp-end-user-smart-account-send-v1">;
180
+ guardDeployment: z.ZodObject<{
181
+ id: z.ZodLiteral<"base-weth-usdc-collect-v1">;
182
+ chainId: z.ZodLiteral<8453>;
183
+ address: z.ZodString;
184
+ runtimeCodeHash: z.ZodString;
185
+ configurationHash: z.ZodLiteral<`0x${string}`>;
186
+ codeVersion: z.ZodLiteral<"OttoV3CollectGuard-v1">;
187
+ deploymentBlock: z.ZodString;
188
+ reviewReference: z.ZodString;
189
+ }, z.core.$strict>;
190
+ finalityPolicy: z.ZodObject<{
191
+ schemaVersion: z.ZodLiteral<1>;
192
+ id: z.ZodLiteral<"base-finalized-lp-v1">;
193
+ chainId: z.ZodLiteral<8453>;
194
+ blockTag: z.ZodLiteral<"finalized">;
195
+ reviewReference: z.ZodString;
196
+ minFinalizedConfirmations: z.ZodNumber;
197
+ maxHeadAgeSeconds: z.ZodNumber;
198
+ maxFinalizedLagSeconds: z.ZodNumber;
199
+ maxReadDurationSeconds: z.ZodNumber;
200
+ }, z.core.$strict>;
201
+ delegate: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
202
+ delegateCodeHash: z.ZodString;
203
+ implementation: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
204
+ implementationCodeHash: z.ZodString;
205
+ delegateBatchAbi: z.ZodLiteral<"coinbase-executeBatch-v1">;
206
+ delegateBatchReviewDigest: z.ZodString;
207
+ entryPoint: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
208
+ entryPointCodeHash: z.ZodString;
209
+ entryPointVersion: z.ZodLiteral<"0.6">;
210
+ ownerProfile: z.ZodObject<{
211
+ kind: z.ZodLiteral<"sole-eoa-owner">;
212
+ nextOwnerIndex: z.ZodLiteral<"1">;
213
+ ownerCount: z.ZodLiteral<"1">;
214
+ ownerAtIndex0: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
215
+ spendPermissionsEnabled: z.ZodLiteral<false>;
216
+ }, z.core.$strict>;
217
+ paymaster: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
218
+ paymasterCodeHash: z.ZodString;
219
+ sponsorshipPolicyId: z.ZodString;
220
+ maxGasCostWei: z.ZodString;
221
+ maxUserGasCostWei: z.ZodString;
222
+ maxTotalGasCostWei: z.ZodString;
223
+ maximumCollectAtomic: z.ZodTuple<[z.ZodString, z.ZodString], null>;
224
+ intentCommitment: z.ZodString;
225
+ reviewCreatedAtMs: z.ZodNumber;
226
+ reviewExpiresAtMs: z.ZodNumber;
227
+ initialNftApproval: z.ZodLiteral<"0x0000000000000000000000000000000000000000">;
228
+ finalNftApproval: z.ZodLiteral<"0x0000000000000000000000000000000000000000">;
229
+ execution: z.ZodLiteral<"atomic-nft-approve-guarded-collect">;
230
+ principalDebitAuthorized: z.ZodLiteral<false>;
231
+ }, z.core.$strict>;
232
+ }, z.core.$strict>;
233
+ export type LpUserOpReviewRecord = z.infer<typeof LP_USEROP_REVIEW_RECORD_SCHEMA>;
@@ -0,0 +1,85 @@
1
+ /** Manual guarded collection for a separately upgraded same-address account. */
2
+ import { getAddress } from 'viem';
3
+ import { z } from 'zod';
4
+ import { lpV3GuardDeploymentSchema } from './vendor/lp-v3/lp-v3-atomic-contract.js';
5
+ import { lpV3FinalityPolicySchema } from './vendor/lp-v3/lp-v3-atomic-read-contract.js';
6
+ import { lpV3CollectProtocolIntentSchema } from './vendor/lp-v3/lp-v3-collect-protocol-contract.js';
7
+ import { SPONSORED_ACCOUNT_PROXY, SPONSORED_ACCOUNT_IMPLEMENTATION, SPONSORED_ACCOUNT_ENTRY_POINT } from './execution-sponsored-account-profile.js';
8
+ export const LP_USEROP_RULESET = 'lp-guarded-collect-userop-v1';
9
+ export const LP_USEROP_REVIEW_TTL_MS = 5 * 60_000;
10
+ export const LP_USEROP_CONFIRMATION = 'I reviewed this position collection and sponsored atomic batch';
11
+ export const LP_USEROP_ACCOUNT_GAS_CONFIRMATION = 'I reviewed this position collection and account-paid atomic batch';
12
+ export const LP_USEROP_ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
13
+ const address = z.string().regex(/^0x[0-9a-fA-F]{40}$/).transform((value, context) => {
14
+ try {
15
+ return getAddress(value);
16
+ }
17
+ catch {
18
+ context.addIssue({ code: 'custom', message: 'Invalid account address' });
19
+ return z.NEVER;
20
+ }
21
+ });
22
+ const hash = z.string().regex(/^0x[0-9a-fA-F]{64}$/).refine(value => !/^0x0{64}$/i.test(value));
23
+ const digest = z.string().regex(/^[0-9a-f]{64}$/).refine(value => !/^0+$/.test(value));
24
+ const commitment = z.string().regex(/^sha256:[0-9a-f]{64}$/);
25
+ const time = z.number().int().positive().safe();
26
+ const uint128 = z.string().regex(/^(0|[1-9][0-9]{0,38})$/)
27
+ .refine(value => /^(0|[1-9][0-9]{0,38})$/.test(value) && BigInt(value) < (1n << 128n));
28
+ const positive = z.string().regex(/^[1-9][0-9]{0,77}$/)
29
+ .refine(value => /^[1-9][0-9]{0,77}$/.test(value) && BigInt(value) < (1n << 256n));
30
+ /** These are host collection ceilings. A swap cap is not an LP notional limit. */
31
+ export const LP_USEROP_ACTIVATION_SCHEMA = z.object({
32
+ version: z.literal(1), ruleset: z.literal(LP_USEROP_RULESET),
33
+ id: z.string().regex(/^[a-zA-Z0-9_-]{8,100}$/), mode: z.enum(['enabled', 'recovery-only']),
34
+ approvedAtMs: time, expiresAtMs: time,
35
+ nativeActivationCommitment: commitment,
36
+ guardDeployment: lpV3GuardDeploymentSchema,
37
+ finalityPolicy: lpV3FinalityPolicySchema,
38
+ capabilities: z.tuple([z.literal('guarded-collect')]),
39
+ maximumCollectAtomic: z.tuple([uint128, uint128]),
40
+ maximumDeadlineSeconds: z.number().int().positive().max(300),
41
+ reviewEvidenceDigest: digest,
42
+ }).strict().refine(value => value.expiresAtMs > value.approvedAtMs &&
43
+ value.expiresAtMs - value.approvedAtMs <= 180 * 24 * 60 * 60_000 &&
44
+ value.maximumCollectAtomic.some(amount => amount !== '0'), 'A current bounded reviewed collection scope is required');
45
+ /** No environment switch, request field or imported plan can populate this source authority. */
46
+ export const LP_USEROP_ACTIVATIONS = Object.freeze([]);
47
+ export const LP_USEROP_TERMS_SCHEMA = z.object({
48
+ version: z.literal(1), ruleset: z.literal(LP_USEROP_RULESET),
49
+ userId: z.string().regex(/^[a-zA-Z0-9-]{1,100}$/), account: address, chainId: z.literal(8453),
50
+ authorityDigest: digest, lpActivationCommitment: commitment,
51
+ sponsoredActivationId: z.string().regex(/^[a-zA-Z0-9_-]{8,100}$/), sponsoredActivationDigest: digest,
52
+ projectId: z.string().uuid(), policyId: z.string().min(1).max(200),
53
+ policyRulesDigest: digest, providerEnforcementEvidenceDigest: digest,
54
+ providerEndpoint: z.literal('cdp-end-user-smart-account-send-v1'),
55
+ guardDeployment: lpV3GuardDeploymentSchema,
56
+ finalityPolicy: lpV3FinalityPolicySchema,
57
+ delegate: address, delegateCodeHash: hash, implementation: address, implementationCodeHash: hash,
58
+ delegateBatchAbi: z.literal('coinbase-executeBatch-v1'), delegateBatchReviewDigest: digest,
59
+ entryPoint: address, entryPointCodeHash: hash, entryPointVersion: z.literal('0.6'),
60
+ ownerProfile: z.object({ kind: z.literal('sole-eoa-owner'), nextOwnerIndex: z.literal('1'), ownerCount: z.literal('1'),
61
+ ownerAtIndex0: z.string().regex(/^0x0{24}[0-9a-fA-F]{40}$/).transform(value => value.toLowerCase()),
62
+ spendPermissionsEnabled: z.literal(false),
63
+ }).strict(),
64
+ paymaster: address, paymasterCodeHash: hash,
65
+ sponsorshipPolicyId: z.string().regex(/^[a-zA-Z0-9_-]{1,128}$/),
66
+ maxGasCostWei: positive, maxUserGasCostWei: positive, maxTotalGasCostWei: positive,
67
+ maximumCollectAtomic: z.tuple([uint128, uint128]),
68
+ intentCommitment: hash,
69
+ reviewCreatedAtMs: time, reviewExpiresAtMs: time,
70
+ initialNftApproval: z.literal(LP_USEROP_ZERO_ADDRESS),
71
+ finalNftApproval: z.literal(LP_USEROP_ZERO_ADDRESS),
72
+ execution: z.literal('atomic-nft-approve-guarded-collect'),
73
+ principalDebitAuthorized: z.literal(false),
74
+ }).strict().refine(value => value.delegate === SPONSORED_ACCOUNT_PROXY &&
75
+ value.implementation === SPONSORED_ACCOUNT_IMPLEMENTATION && value.entryPoint === SPONSORED_ACCOUNT_ENTRY_POINT &&
76
+ value.ownerProfile.ownerAtIndex0 === '0x' + '0'.repeat(24) + value.account.slice(2).toLowerCase() &&
77
+ value.reviewExpiresAtMs > value.reviewCreatedAtMs && value.reviewExpiresAtMs - value.reviewCreatedAtMs <= LP_USEROP_REVIEW_TTL_MS &&
78
+ BigInt(value.maxGasCostWei) <= BigInt(value.maxUserGasCostWei) && BigInt(value.maxUserGasCostWei) <= BigInt(value.maxTotalGasCostWei) &&
79
+ ![value.account, value.paymaster].some(target => target === LP_USEROP_ZERO_ADDRESS), 'LP terms require the reviewed same-address account family and fresh bounded operation review');
80
+ /** The protocol owner defines this v3 collect intent; older EOA intents remain separate. */
81
+ export const LP_USEROP_INPUT_SCHEMA = lpV3CollectProtocolIntentSchema;
82
+ export const LP_USEROP_REVIEW_RECORD_SCHEMA = z.object({
83
+ input: LP_USEROP_INPUT_SCHEMA, terms: LP_USEROP_TERMS_SCHEMA,
84
+ }).strict();
85
+ //# sourceMappingURL=lp-userop-definition.js.map
@@ -0,0 +1,3 @@
1
+ import { type DelegationServices } from './execution-delegation.js';
2
+ import { type LpUserOpBinding } from './lp-userop-registration.js';
3
+ export declare function createHostedLpUserOpBinding(env: NodeJS.ProcessEnv, delegation: DelegationServices): Promise<LpUserOpBinding>;
@@ -0,0 +1,73 @@
1
+ import { LP_USEROP_ACTIVATIONS } from './lp-userop-definition.js';
2
+ import { NATIVE_YIELD_ACCOUNT_ACTIVATIONS } from './native-yield-account-definition.js';
3
+ import { loadDelegationEnv } from './execution-delegation.js';
4
+ import { resolveDelegationCapStorePath } from './execution-delegation-cap-store.js';
5
+ import { SPONSORED_ACCOUNT_ACTIVATIONS, SPONSORED_ACTIVATION_SCHEMA } from './execution-sponsored-definition.js';
6
+ import { createLpUserOpAccountService } from './lp-userop-index.js';
7
+ import { unavailableLpUserOpBinding } from './lp-userop-registration.js';
8
+ import { LP_USEROP_AVAILABILITY_RESULT } from './lp-userop-mcp-definition.js';
9
+ const RPC_ENV = Object.freeze({
10
+ 1: 'OTTO_SPONSORED_RPC_URL_1', 8453: 'BASE_RPC_URL', 42161: 'OTTO_SPONSORED_RPC_URL_42161',
11
+ 10: 'OTTO_SPONSORED_RPC_URL_10', 137: 'OTTO_SPONSORED_RPC_URL_137',
12
+ });
13
+ function privateHttpsUrl(raw) {
14
+ if (!raw)
15
+ throw new Error('missing operator endpoint');
16
+ const url = new URL(raw);
17
+ if (url.protocol !== 'https:' || url.username || url.password || url.hash)
18
+ throw new Error('invalid operator endpoint');
19
+ return url.toString();
20
+ }
21
+ export async function createHostedLpUserOpBinding(env, delegation) {
22
+ // This is not an environment toggle. Adding endpoints cannot authorize a new financial rail.
23
+ if (SPONSORED_ACCOUNT_ACTIVATIONS.length !== 1 || LP_USEROP_ACTIVATIONS.length !== 1 || NATIVE_YIELD_ACCOUNT_ACTIVATIONS.length !== 1)
24
+ return unavailableLpUserOpBinding();
25
+ try {
26
+ const activation = SPONSORED_ACTIVATION_SCHEMA.parse(SPONSORED_ACCOUNT_ACTIVATIONS[0]);
27
+ const loaded = loadDelegationEnv(env);
28
+ if (!loaded || loaded.publicProjectId !== activation.projectId ||
29
+ delegation.publicProjectId !== activation.projectId)
30
+ return unavailableLpUserOpBinding('SPONSOR_ACTIVATION_UNAVAILABLE');
31
+ const operationStorePath = resolveDelegationCapStorePath(env);
32
+ if (!operationStorePath)
33
+ return unavailableLpUserOpBinding('SPONSOR_JOURNAL_UNAVAILABLE');
34
+ const providers = [];
35
+ const urls = new Map();
36
+ for (const terms of activation.chains) {
37
+ try {
38
+ providers.push({ chainId: terms.chainId, sponsorshipPolicyId: terms.sponsorshipPolicyId,
39
+ paymasterUrl: privateHttpsUrl(env['OTTO_SPONSORED_PAYMASTER_URL_' + terms.chainId]) });
40
+ }
41
+ catch { /* Missing send configuration leaves recovery available. */ }
42
+ try {
43
+ urls.set(terms.chainId, privateHttpsUrl(env[RPC_ENV[terms.chainId]]));
44
+ }
45
+ catch { /* Read works without RPC; reconcile keeps the original evidence until this chain returns. */ }
46
+ }
47
+ const [{ CdpClient }, { createPublicClient, http }, chains] = await Promise.all([
48
+ import('@coinbase/cdp-sdk'), import('viem'), import('viem/chains'),
49
+ ]);
50
+ const definitions = { 1: chains.mainnet, 8453: chains.base, 42161: chains.arbitrum,
51
+ 10: chains.optimism, 137: chains.polygon };
52
+ const clients = {};
53
+ for (const terms of activation.chains) {
54
+ if (terms.chainId === 8453 && delegation.pub)
55
+ clients[terms.chainId] = delegation.pub;
56
+ else if (urls.has(terms.chainId))
57
+ clients[terms.chainId] = createPublicClient({
58
+ chain: definitions[terms.chainId], transport: http(urls.get(terms.chainId))
59
+ });
60
+ }
61
+ const service = await createLpUserOpAccountService({
62
+ cdp: new CdpClient(loaded.credentials), capStore: delegation.capStore,
63
+ projectId: activation.projectId, operationStorePath, client: clients[8453], providers: providers.filter(value => value.chainId === 8453), credentials: loaded.credentials,
64
+ });
65
+ return Object.freeze({ ...service, availability: async () => LP_USEROP_AVAILABILITY_RESULT.parse(await service.availability()) });
66
+ }
67
+ catch {
68
+ // Misconfigured sponsorship must not disable existing reads, Stop or recovery on other rails.
69
+ // Errors from providers may contain credentials; expose only a fixed status.
70
+ return unavailableLpUserOpBinding('SPONSOR_RUNTIME_UNAVAILABLE');
71
+ }
72
+ }
73
+ //# sourceMappingURL=lp-userop-hosted.js.map