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,168 @@
1
+ import { type LpV3GuardDeployment } from './lp-v3-atomic-contract.js';
2
+ import { type LpV3CollectProtocolObservationOptions } from './lp-v3-collect-protocol-observation.js';
3
+ import type { LpV3VerifyOptions } from './lp-v3-plan.js';
4
+ /** NON-AUTHORIZING protocol component. The host supplies a reviewed immutable
5
+ * deployment policy and trusted read client. Default empty policy disables
6
+ * collection. This starts no signer, journal, RPC transport or background work.
7
+ * Account profile, atomic batch, provider enforcement, UserOp gas/finality and
8
+ * durable claims remain exclusively the host's separately verified gates.
9
+ */
10
+ export declare function createLpV3CollectProtocolLibrary(options?: {
11
+ guardDeployments?: readonly LpV3GuardDeployment[];
12
+ }): Readonly<{
13
+ policy: readonly {
14
+ id: "base-weth-usdc-collect-v1";
15
+ chainId: 8453;
16
+ address: string;
17
+ runtimeCodeHash: string;
18
+ configurationHash: `0x${string}`;
19
+ codeVersion: "OttoV3CollectGuard-v1";
20
+ deploymentBlock: string;
21
+ reviewReference: string;
22
+ }[];
23
+ collectProtocolEvidence: (intent: unknown, readOptions: LpV3CollectProtocolObservationOptions) => Promise<{
24
+ chainId: 8453;
25
+ fee: number;
26
+ blockNumber: string;
27
+ blockHash: string;
28
+ account: string;
29
+ factory: "0x33128a8fc17869897dce68ed026d694621f6fdfd";
30
+ blockTimestamp: number;
31
+ manager: "0x03a520b32c04bf3beef7beb72e919cf822ed34f1";
32
+ token0: "0x4200000000000000000000000000000000000006";
33
+ token1: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913";
34
+ usdcImplementation: "0x2ce6311ddae708829bc0784c967b7d77d19fd779";
35
+ factoryCodeHash: `0x${string}`;
36
+ managerCodeHash: `0x${string}`;
37
+ token0CodeHash: `0x${string}`;
38
+ token1CodeHash: `0x${string}`;
39
+ usdcImplementationCodeHash: `0x${string}`;
40
+ pool: string;
41
+ balances: [string, string];
42
+ allowances: [string, string];
43
+ factoryPool: string;
44
+ tick: number;
45
+ observedAt: number;
46
+ managerFactory: "0x33128a8fc17869897dce68ed026d694621f6fdfd";
47
+ usdcPaused: false;
48
+ accountBlacklisted: false;
49
+ managerBlacklisted: false;
50
+ poolFactory: "0x33128a8fc17869897dce68ed026d694621f6fdfd";
51
+ tickSpacing: number;
52
+ sqrtPriceX96: string;
53
+ unlocked: true;
54
+ position: {
55
+ tokenId: string;
56
+ owner: string;
57
+ token0: string;
58
+ token1: string;
59
+ fee: number;
60
+ tickLower: number;
61
+ tickUpper: number;
62
+ liquidity: string;
63
+ tokensOwed: [string, string];
64
+ approved: string;
65
+ };
66
+ managerNativeBalance: string;
67
+ schemaVersion: 3;
68
+ accountCode: string;
69
+ accountCodeHash: string;
70
+ guard: {
71
+ address: string;
72
+ runtimeCodeHash: string;
73
+ configurationHash: string;
74
+ deploymentChainId: 8453;
75
+ ownerApprovalForAll: false;
76
+ guardBlacklisted: false;
77
+ poolBlacklisted: false;
78
+ tokenAllowances: ["0", "0"];
79
+ tokenBalances: [string, string];
80
+ };
81
+ }>;
82
+ prepare: (intent: unknown, observation: unknown, verifyOptions?: LpV3VerifyOptions) => {
83
+ intent: {
84
+ action: "collect";
85
+ tokenId: string;
86
+ amountMax: [string, string];
87
+ amountMin: [string, string];
88
+ protocol: "uniswap-v3";
89
+ chainId: 8453;
90
+ operationId: string;
91
+ account: string;
92
+ recipient: string;
93
+ manager: "0x03a520b32c04bf3beef7beb72e919cf822ed34f1";
94
+ factory: "0x33128a8fc17869897dce68ed026d694621f6fdfd";
95
+ pool: string;
96
+ token0: "0x4200000000000000000000000000000000000006";
97
+ token1: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913";
98
+ fee: 10000 | 100 | 500 | 3000;
99
+ tickLower: number;
100
+ tickUpper: number;
101
+ deadline: number;
102
+ nftApprovalPolicy: "zero-before-and-after";
103
+ guardDeploymentId: "base-weth-usdc-collect-v1";
104
+ schemaVersion: 3;
105
+ };
106
+ intentCommitment: string;
107
+ policyCommitment: string;
108
+ guardDeployment: {
109
+ id: "base-weth-usdc-collect-v1";
110
+ chainId: 8453;
111
+ address: string;
112
+ runtimeCodeHash: string;
113
+ configurationHash: `0x${string}`;
114
+ codeVersion: "OttoV3CollectGuard-v1";
115
+ deploymentBlock: string;
116
+ reviewReference: string;
117
+ };
118
+ calls: [{
119
+ step: "mutation" | "erc20-approve" | "erc20-cleanup" | "nft-approve" | "nft-clear";
120
+ tokenIndex: 0 | 1 | null;
121
+ chainId: 8453;
122
+ from: string;
123
+ to: string;
124
+ value: "0";
125
+ data: string;
126
+ }, {
127
+ step: "mutation" | "erc20-approve" | "erc20-cleanup" | "nft-approve" | "nft-clear";
128
+ tokenIndex: 0 | 1 | null;
129
+ chainId: 8453;
130
+ from: string;
131
+ to: string;
132
+ value: "0";
133
+ data: string;
134
+ }];
135
+ preparedBlock: {
136
+ number: string;
137
+ hash: string;
138
+ };
139
+ preparedObservationCommitment: string;
140
+ planCommitment: string;
141
+ executionAuthorized: false;
142
+ transportVerified: false;
143
+ claimReleased: false;
144
+ retainClaim: true;
145
+ retrySafe: false;
146
+ schemaVersion: 3;
147
+ kind: "lp-v3-collect-protocol";
148
+ };
149
+ validatePrepared: (plan: unknown, independentIntent: unknown, observation: unknown, verifyOptions?: LpV3VerifyOptions) => {
150
+ planCommitment: string;
151
+ intentCommitment: string;
152
+ policyCommitment: string;
153
+ baselineCommitment: string;
154
+ checkedAt: number;
155
+ checkCommitment: string;
156
+ executionAuthorized: false;
157
+ transportVerified: false;
158
+ claimReleased: false;
159
+ retainClaim: true;
160
+ retrySafe: false;
161
+ schemaVersion: 3;
162
+ kind: "lp-v3-collect-protocol-check";
163
+ };
164
+ reconcileCollectProtocol: (input: unknown, verifyOptions?: LpV3VerifyOptions) => import("./lp-v3-collect-protocol-contract.js").LpV3CollectProtocolAccounting;
165
+ }>;
166
+ export { LP_V3_COLLECT_PROTOCOL_NO_AUTHORITY, lpV3CollectProtocolIntentSchema, lpV3CollectProtocolObservationSchema, lpV3CollectProtocolPlanSchema, lpV3CollectProtocolCheckSchema, lpV3CollectProtocolLogSchema, lpV3CollectProtocolBindingSchema, lpV3CollectProtocolEvidenceSchema, lpV3CollectProtocolReconcileInputSchema, } from './lp-v3-collect-protocol-contract.js';
167
+ export type { LpV3CollectProtocolIntent, LpV3CollectProtocolObservation, LpV3CollectProtocolPlan, LpV3CollectProtocolCheck, LpV3CollectProtocolLog, LpV3CollectProtocolBinding, LpV3CollectProtocolEvidence, LpV3CollectProtocolReconcileInput, LpV3CollectProtocolAccounting, } from './lp-v3-collect-protocol-contract.js';
168
+ export type { LpV3CollectProtocolObservationOptions, LpV3CollectProtocolReadClient } from './lp-v3-collect-protocol-observation.js';
@@ -0,0 +1,23 @@
1
+ import { reviewedGuardPolicy } from './lp-v3-atomic-contract.js';
2
+ import { prepareLpV3CollectProtocol, validateLpV3CollectProtocol } from './lp-v3-collect-protocol-plan.js';
3
+ import { reconcileLpV3CollectProtocol } from './lp-v3-collect-protocol-reconcile.js';
4
+ import { collectLpV3CollectProtocolEvidence } from './lp-v3-collect-protocol-observation.js';
5
+ import { lpV3CollectProtocolIntentSchema } from './lp-v3-collect-protocol-contract.js';
6
+ /** NON-AUTHORIZING protocol component. The host supplies a reviewed immutable
7
+ * deployment policy and trusted read client. Default empty policy disables
8
+ * collection. This starts no signer, journal, RPC transport or background work.
9
+ * Account profile, atomic batch, provider enforcement, UserOp gas/finality and
10
+ * durable claims remain exclusively the host's separately verified gates.
11
+ */
12
+ export function createLpV3CollectProtocolLibrary(options = {}) {
13
+ const policy = reviewedGuardPolicy(options.guardDeployments);
14
+ return Object.freeze({
15
+ policy,
16
+ collectProtocolEvidence: (intent, readOptions) => collectLpV3CollectProtocolEvidence(lpV3CollectProtocolIntentSchema.parse(intent), policy, readOptions),
17
+ prepare: (intent, observation, verifyOptions) => prepareLpV3CollectProtocol(intent, observation, policy, verifyOptions),
18
+ validatePrepared: (plan, independentIntent, observation, verifyOptions) => validateLpV3CollectProtocol(plan, independentIntent, observation, policy, verifyOptions),
19
+ reconcileCollectProtocol: (input, verifyOptions) => reconcileLpV3CollectProtocol(input, policy, verifyOptions),
20
+ });
21
+ }
22
+ export { LP_V3_COLLECT_PROTOCOL_NO_AUTHORITY, lpV3CollectProtocolIntentSchema, lpV3CollectProtocolObservationSchema, lpV3CollectProtocolPlanSchema, lpV3CollectProtocolCheckSchema, lpV3CollectProtocolLogSchema, lpV3CollectProtocolBindingSchema, lpV3CollectProtocolEvidenceSchema, lpV3CollectProtocolReconcileInputSchema, } from './lp-v3-collect-protocol-contract.js';
23
+ //# sourceMappingURL=lp-v3-collect-protocol-index.js.map
@@ -0,0 +1,32 @@
1
+ import { type LpV3GuardDeployment } from './lp-v3-atomic-contract.js';
2
+ import { type LpV3CollectProtocolIntent, type LpV3CollectProtocolObservation } from './lp-v3-collect-protocol-contract.js';
3
+ type ReadRequest = {
4
+ method: 'eth_chainId' | 'eth_getBlockByNumber' | 'eth_getCode' | 'eth_getStorageAt' | 'eth_call' | 'eth_getBalance';
5
+ params?: readonly unknown[];
6
+ };
7
+ /** Trusted host dependency. No default HTTP provider or signer is constructed. */
8
+ export interface LpV3CollectProtocolReadClient {
9
+ request(request: ReadRequest): Promise<unknown>;
10
+ }
11
+ export interface LpV3CollectProtocolObservationOptions {
12
+ client: LpV3CollectProtocolReadClient;
13
+ /** Trusted host wall clock in integer Unix seconds; never a block-time substitute. */
14
+ nowSeconds?: () => number;
15
+ /** Fresh mode only. Integer 1..60, default 60. */
16
+ maxBlockAgeSeconds?: number;
17
+ /** Wall-clock and independent monotonic deadline. Integer 1..30, default 30. */
18
+ maxReadDurationSeconds?: number;
19
+ /** Supplied by the host's canonical UserOp reader. This observer makes no finality claim. */
20
+ historicalAnchor?: {
21
+ number: string;
22
+ hash: string;
23
+ timestamp: number;
24
+ };
25
+ }
26
+ /** Collect-scoped protocol observation only. All state reads use one EIP-1898
27
+ * canonical hash, followed by a fresh number mapping and chain check. Historical
28
+ * mode never requests latest state, substitutes block time for the host clock, or
29
+ * claims finality. Actual nonempty account code is recorded, not profile-approved.
30
+ */
31
+ export declare function collectLpV3CollectProtocolEvidence(input: LpV3CollectProtocolIntent, policy: readonly LpV3GuardDeployment[], options: LpV3CollectProtocolObservationOptions): Promise<LpV3CollectProtocolObservation>;
32
+ export {};
@@ -0,0 +1,228 @@
1
+ import { decodeFunctionResult, encodeFunctionData, keccak256, parseAbi } from 'viem';
2
+ import { z } from 'zod';
3
+ import { LP_V3_BASE as B, deepFreeze, lpHash, lpUint } from './lp-v3-contract.js';
4
+ import { lpV3AtomicPositionSchema, lpV3AtomicGuardEvidenceSchema, reviewedGuardPolicy, } from './lp-v3-atomic-contract.js';
5
+ import { lpV3CollectProtocolIntentSchema, lpV3CollectProtocolObservationSchema, } from './lp-v3-collect-protocol-contract.js';
6
+ import { MAX_TICK, MIN_TICK, sqrtPriceAtTick } from './v4-math.js';
7
+ const READ_ABI = parseAbi([
8
+ 'function factory() view returns (address)', 'function WETH9() view returns (address)',
9
+ 'function getPool(address token0,address token1,uint24 fee) view returns (address)',
10
+ 'function feeAmountTickSpacing(uint24 fee) view returns (int24)',
11
+ 'function token0() view returns (address)', 'function token1() view returns (address)',
12
+ 'function fee() view returns (uint24)', 'function tickSpacing() view returns (int24)',
13
+ 'function slot0() view returns (uint160 sqrtPriceX96,int24 tick,uint16 observationIndex,uint16 observationCardinality,uint16 observationCardinalityNext,uint8 feeProtocol,bool unlocked)',
14
+ 'function balanceOf(address owner) view returns (uint256)',
15
+ 'function allowance(address owner,address spender) view returns (uint256)',
16
+ 'function decimals() view returns (uint8)', 'function paused() view returns (bool)',
17
+ 'function isBlacklisted(address account) view returns (bool)',
18
+ 'function ownerOf(uint256 tokenId) view returns (address)',
19
+ 'function positions(uint256 tokenId) view returns (uint96 nonce,address operator,address token0,address token1,uint24 fee,int24 tickLower,int24 tickUpper,uint128 liquidity,uint256 feeGrowthInside0LastX128,uint256 feeGrowthInside1LastX128,uint128 tokensOwed0,uint128 tokensOwed1)',
20
+ 'function configurationHash() view returns (bytes32)', 'function deploymentChainId() view returns (uint256)',
21
+ 'function isApprovedForAll(address owner,address operator) view returns (bool)',
22
+ ]);
23
+ const READ_METHODS = new Set([
24
+ 'eth_chainId', 'eth_getBlockByNumber', 'eth_getCode', 'eth_getStorageAt', 'eth_call', 'eth_getBalance',
25
+ ]);
26
+ const historicalAnchorSchema = z.object({
27
+ number: lpUint(), hash: lpHash, timestamp: z.number().int().positive().safe(),
28
+ }).strict();
29
+ const FAILURE = 'LP_PROTOCOL_REQUIRED_CHAIN_STATE_UNAVAILABLE';
30
+ function requireState(value) { if (!value)
31
+ throw new Error(FAILURE); }
32
+ function hex(value) {
33
+ requireState(typeof value === 'string' && value.length <= 131_074 && /^0x(?:[0-9a-fA-F]{2})*$/.test(value));
34
+ return value.toLowerCase();
35
+ }
36
+ function address(value, zeroAllowed = false) {
37
+ requireState(typeof value === 'string' && /^0x[0-9a-fA-F]{40}$/.test(value)
38
+ && (zeroAllowed || !/^0x0{40}$/.test(value)));
39
+ return value.toLowerCase();
40
+ }
41
+ function quantity(value) {
42
+ requireState(typeof value === 'string' && /^0x(?:0|[1-9a-fA-F][0-9a-fA-F]{0,63})$/.test(value));
43
+ return BigInt(value);
44
+ }
45
+ function uint(value, bits = 256) {
46
+ requireState(typeof value === 'bigint' && value >= 0n && value < 1n << BigInt(bits));
47
+ return value;
48
+ }
49
+ function integer(value, minimum, maximum) {
50
+ requireState(typeof value === 'number' && Number.isSafeInteger(value) && value >= minimum && value <= maximum);
51
+ return value;
52
+ }
53
+ function tuple(value, length) {
54
+ requireState(Array.isArray(value) && value.length === length);
55
+ return value;
56
+ }
57
+ function block(value) {
58
+ requireState(value !== null && typeof value === 'object');
59
+ const raw = value, number = quantity(raw.number), timestamp = quantity(raw.timestamp), hash = hex(raw.hash);
60
+ requireState(hash.length === 66 && !/^0x0{64}$/.test(hash) && timestamp > 0n && timestamp <= BigInt(Number.MAX_SAFE_INTEGER));
61
+ return { number, hash, timestamp: Number(timestamp) };
62
+ }
63
+ /** Collect-scoped protocol observation only. All state reads use one EIP-1898
64
+ * canonical hash, followed by a fresh number mapping and chain check. Historical
65
+ * mode never requests latest state, substitutes block time for the host clock, or
66
+ * claims finality. Actual nonempty account code is recorded, not profile-approved.
67
+ */
68
+ export async function collectLpV3CollectProtocolEvidence(input, policy, options) {
69
+ let stopped = false;
70
+ try {
71
+ // Copy caller intent and startup policy before the first asynchronous boundary.
72
+ const intent = deepFreeze(lpV3CollectProtocolIntentSchema.parse(input));
73
+ const guards = reviewedGuardPolicy(policy), deployment = guards.find(g => g.id === intent.guardDeploymentId);
74
+ requireState(deployment);
75
+ requireState(options?.client && typeof options.client.request === 'function');
76
+ const requestRpc = options.client.request.bind(options.client);
77
+ const now = options.nowSeconds ?? (() => Math.floor(Date.now() / 1000));
78
+ requireState(typeof now === 'function');
79
+ const maxAge = integer(options.maxBlockAgeSeconds ?? 60, 1, 60);
80
+ const maxDuration = integer(options.maxReadDurationSeconds ?? 30, 1, 30);
81
+ const historical = options.historicalAnchor === undefined ? undefined
82
+ : deepFreeze(historicalAnchorSchema.parse(options.historicalAnchor));
83
+ const startedMonotonic = performance.now();
84
+ let lastClock = 0;
85
+ const clock = () => {
86
+ const time = integer(now(), 1, Number.MAX_SAFE_INTEGER);
87
+ requireState(time >= lastClock);
88
+ lastClock = time;
89
+ return time;
90
+ };
91
+ const startedAt = clock();
92
+ const checkTime = () => {
93
+ requireState(!stopped);
94
+ const time = clock();
95
+ requireState(time - startedAt <= maxDuration && performance.now() - startedMonotonic <= maxDuration * 1000);
96
+ return time;
97
+ };
98
+ const rpc = async (request) => {
99
+ checkTime();
100
+ requireState(READ_METHODS.has(request.method));
101
+ let timer;
102
+ try {
103
+ const remaining = Math.max(1, maxDuration * 1000 - (performance.now() - startedMonotonic));
104
+ const result = await Promise.race([
105
+ requestRpc(deepFreeze(request)),
106
+ new Promise((_resolve, reject) => { timer = setTimeout(() => reject(new Error(FAILURE)), remaining); }),
107
+ ]);
108
+ checkTime();
109
+ return result;
110
+ }
111
+ catch {
112
+ stopped = true;
113
+ throw new Error(FAILURE);
114
+ }
115
+ finally {
116
+ if (timer !== undefined)
117
+ clearTimeout(timer);
118
+ }
119
+ };
120
+ const chain = async () => requireState(quantity(await rpc({ method: 'eth_chainId' })) === BigInt(B.chainId));
121
+ await chain();
122
+ const anchor = block(await rpc({
123
+ method: 'eth_getBlockByNumber',
124
+ params: [historical ? '0x' + BigInt(historical.number).toString(16) : 'latest', false],
125
+ }));
126
+ if (historical)
127
+ requireState(anchor.number.toString() === historical.number && anchor.hash === historical.hash && anchor.timestamp === historical.timestamp);
128
+ requireState(anchor.number >= BigInt(deployment.deploymentBlock));
129
+ const fresh = (time) => {
130
+ requireState(anchor.timestamp <= time);
131
+ if (!historical)
132
+ requireState(time - anchor.timestamp <= maxAge);
133
+ };
134
+ fresh(checkTime());
135
+ const reference = Object.freeze({ blockHash: anchor.hash, requireCanonical: true });
136
+ const read = async (target, functionName, args) => {
137
+ const data = encodeFunctionData({ abi: READ_ABI, functionName, args });
138
+ return decodeFunctionResult({ abi: READ_ABI, functionName,
139
+ data: hex(await rpc({ method: 'eth_call', params: [{ to: target, data }, reference] })) });
140
+ };
141
+ const getCode = async (target) => hex(await rpc({ method: 'eth_getCode', params: [target, reference] }));
142
+ const [factoryPoolRaw, factorySpacingRaw, managerFactoryRaw, managerWethRaw, accountCode, implementationStorage] = await Promise.all([
143
+ read(B.factory, 'getPool', [B.token0, B.token1, intent.fee]), read(B.factory, 'feeAmountTickSpacing', [intent.fee]),
144
+ read(B.manager, 'factory'), read(B.manager, 'WETH9'), getCode(intent.account),
145
+ rpc({ method: 'eth_getStorageAt', params: [B.token1, B.usdcImplementationSlot, reference] }),
146
+ ]);
147
+ const factoryPool = address(factoryPoolRaw), managerFactory = address(managerFactoryRaw);
148
+ requireState(factoryPool === intent.pool && managerFactory === B.factory && address(managerWethRaw) === B.token0);
149
+ requireState(accountCode !== '0x');
150
+ const storage = hex(implementationStorage);
151
+ requireState(/^0x0{24}[0-9a-f]{40}$/.test(storage));
152
+ const usdcImplementation = address('0x' + storage.slice(-40));
153
+ requireState(usdcImplementation === B.usdcImplementation);
154
+ const tickSpacing = integer(factorySpacingRaw, 1, 16_383);
155
+ requireState(intent.tickLower < intent.tickUpper && intent.tickLower % tickSpacing === 0 && intent.tickUpper % tickSpacing === 0);
156
+ const [poolFactoryRaw, token0Raw, token1Raw, feeRaw, spacingRaw, rawSlot, balancesRaw, allowancesRaw, paused, accountBlacklisted, managerBlacklisted, decimals, codes, positionRaw, managerNativeRaw] = await Promise.all([
157
+ read(factoryPool, 'factory'), read(factoryPool, 'token0'), read(factoryPool, 'token1'),
158
+ read(factoryPool, 'fee'), read(factoryPool, 'tickSpacing'), read(factoryPool, 'slot0'),
159
+ Promise.all([B.token0, B.token1].map(token => read(token, 'balanceOf', [intent.account]))),
160
+ Promise.all([B.token0, B.token1].map(token => read(token, 'allowance', [intent.account, B.manager]))),
161
+ read(B.token1, 'paused'), read(B.token1, 'isBlacklisted', [intent.account]), read(B.token1, 'isBlacklisted', [B.manager]),
162
+ Promise.all([B.token0, B.token1].map(token => read(token, 'decimals'))),
163
+ Promise.all([B.factory, B.manager, B.token0, B.token1, usdcImplementation, factoryPool].map(getCode)),
164
+ Promise.all([read(B.manager, 'ownerOf', [BigInt(intent.tokenId)]), read(B.manager, 'positions', [BigInt(intent.tokenId)])]),
165
+ rpc({ method: 'eth_getBalance', params: [B.manager, reference] }),
166
+ ]);
167
+ const poolFactory = address(poolFactoryRaw), token0 = address(token0Raw), token1 = address(token1Raw);
168
+ const fee = integer(feeRaw, 0, 999_999);
169
+ requireState(poolFactory === B.factory && token0 === B.token0 && token1 === B.token1 && fee === intent.fee && spacingRaw === tickSpacing);
170
+ requireState(paused === false && accountBlacklisted === false && managerBlacklisted === false);
171
+ requireState(decimals[0] === 18 && decimals[1] === 6);
172
+ const slot = tuple(rawSlot, 7), sqrt = uint(slot[0], 160), tick = integer(slot[1], MIN_TICK, MAX_TICK - 1);
173
+ requireState(slot[6] === true && sqrt >= sqrtPriceAtTick(MIN_TICK) && sqrt < sqrtPriceAtTick(MAX_TICK));
174
+ requireState(sqrt >= sqrtPriceAtTick(tick) && sqrt <= sqrtPriceAtTick(tick + 1));
175
+ const balances = balancesRaw.map(v => uint(v).toString()), allowances = allowancesRaw.map(v => uint(v).toString());
176
+ const data = tuple(positionRaw[1], 12);
177
+ const position = lpV3AtomicPositionSchema.parse({
178
+ tokenId: intent.tokenId, owner: address(positionRaw[0]), approved: address(data[1], true),
179
+ token0: address(data[2]), token1: address(data[3]), fee: integer(data[4], 0, 999_999),
180
+ tickLower: integer(data[5], MIN_TICK, MAX_TICK), tickUpper: integer(data[6], MIN_TICK, MAX_TICK),
181
+ liquidity: uint(data[7], 128).toString(), tokensOwed: [uint(data[10], 128).toString(), uint(data[11], 128).toString()],
182
+ });
183
+ requireState(position.owner === intent.account && position.token0 === token0 && position.token1 === token1
184
+ && position.fee === fee && position.tickLower === intent.tickLower && position.tickUpper === intent.tickUpper);
185
+ const managerNativeBalance = quantity(managerNativeRaw).toString();
186
+ requireState(codes.every(code => code !== '0x'));
187
+ const hashes = codes.slice(0, 5).map(code => keccak256(code));
188
+ const expectedHashes = [B.factoryCodeHash, B.managerCodeHash, B.token0CodeHash, B.token1CodeHash, B.usdcImplementationCodeHash];
189
+ requireState(hashes.every((hash, i) => hash === expectedHashes[i]));
190
+ const guardAddress = deployment.address;
191
+ const [guardCode, configurationHash, deploymentChainId, ownerApprovalForAll, tokenAllowances, tokenBalances, guardBlacklisted, poolBlacklisted] = await Promise.all([
192
+ getCode(guardAddress), read(guardAddress, 'configurationHash'), read(guardAddress, 'deploymentChainId'),
193
+ read(B.manager, 'isApprovedForAll', [intent.account, guardAddress]),
194
+ Promise.all([B.token0, B.token1].map(token => read(token, 'allowance', [guardAddress, B.manager]))),
195
+ Promise.all([B.token0, B.token1].map(token => read(token, 'balanceOf', [guardAddress]))),
196
+ read(B.token1, 'isBlacklisted', [guardAddress]), read(B.token1, 'isBlacklisted', [intent.pool]),
197
+ ]);
198
+ requireState(guardCode !== '0x' && keccak256(guardCode) === deployment.runtimeCodeHash
199
+ && configurationHash === deployment.configurationHash && deploymentChainId === 8453n);
200
+ const guard = lpV3AtomicGuardEvidenceSchema.parse({
201
+ address: guardAddress, runtimeCodeHash: keccak256(guardCode), configurationHash, deploymentChainId: 8453,
202
+ ownerApprovalForAll, tokenAllowances: tokenAllowances.map(v => uint(v).toString()),
203
+ tokenBalances: tokenBalances.map(v => uint(v).toString()), guardBlacklisted, poolBlacklisted,
204
+ });
205
+ const canonicalBlock = block(await rpc({ method: 'eth_getBlockByNumber', params: ['0x' + anchor.number.toString(16), false] }));
206
+ await chain();
207
+ requireState(canonicalBlock.number === anchor.number && canonicalBlock.hash === anchor.hash && canonicalBlock.timestamp === anchor.timestamp);
208
+ const observedAt = checkTime();
209
+ fresh(observedAt);
210
+ return deepFreeze(lpV3CollectProtocolObservationSchema.parse({
211
+ schemaVersion: 3, chainId: B.chainId, blockNumber: anchor.number.toString(), blockHash: anchor.hash,
212
+ blockTimestamp: anchor.timestamp, observedAt, account: intent.account, accountCode, accountCodeHash: keccak256(accountCode),
213
+ balances, allowances, manager: B.manager, managerFactory, factory: B.factory, factoryPool,
214
+ factoryCodeHash: hashes[0], managerCodeHash: hashes[1], token0CodeHash: hashes[2], token1CodeHash: hashes[3],
215
+ usdcImplementation, usdcImplementationCodeHash: hashes[4], usdcPaused: paused, accountBlacklisted, managerBlacklisted,
216
+ pool: factoryPool, poolFactory, token0, token1, fee, tickSpacing, tick, sqrtPriceX96: sqrt.toString(),
217
+ unlocked: slot[6], position, managerNativeBalance, guard,
218
+ }));
219
+ }
220
+ catch {
221
+ // Provider messages and decoding errors may contain credentials or raw payloads.
222
+ throw new Error(FAILURE);
223
+ }
224
+ finally {
225
+ stopped = true;
226
+ }
227
+ }
228
+ //# sourceMappingURL=lp-v3-collect-protocol-observation.js.map
@@ -0,0 +1,11 @@
1
+ import { type LpV3GuardDeployment } from './lp-v3-atomic-contract.js';
2
+ import type { LpV3VerifyOptions } from './lp-v3-plan.js';
3
+ import { type LpV3CollectProtocolPlan, type LpV3CollectProtocolCheck } from './lp-v3-collect-protocol-contract.js';
4
+ export declare class LpV3CollectProtocolError extends Error {
5
+ readonly code: string;
6
+ constructor(code: string);
7
+ }
8
+ export declare function requireProtocol(value: unknown, code: string): asserts value;
9
+ export declare function protocolClock(options?: LpV3VerifyOptions): number;
10
+ export declare function prepareLpV3CollectProtocol(input: unknown, rawObservation: unknown, policy: readonly LpV3GuardDeployment[], options?: LpV3VerifyOptions): LpV3CollectProtocolPlan;
11
+ export declare function validateLpV3CollectProtocol(input: unknown, independentIntent: unknown, rawObservation: unknown, policy: readonly LpV3GuardDeployment[], options?: LpV3VerifyOptions): LpV3CollectProtocolCheck;
@@ -0,0 +1,91 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { canonicalJson, commitment, deepFreeze, LP_V3_BASE as B } from './lp-v3-contract.js';
3
+ import { LP_V3_ATOMIC_NPM_ABI, LP_V3_COLLECT_GUARD_ABI, reviewedGuardPolicy } from './lp-v3-atomic-contract.js';
4
+ import { sqrtPriceAtTick } from './v4-math.js';
5
+ import { LP_V3_COLLECT_PROTOCOL_NO_AUTHORITY as NO_AUTHORITY, lpV3CollectProtocolIntentSchema, lpV3CollectProtocolObservationSchema, lpV3CollectProtocolPlanSchema, lpV3CollectProtocolCheckSchema, } from './lp-v3-collect-protocol-contract.js';
6
+ export class LpV3CollectProtocolError extends Error {
7
+ code;
8
+ constructor(code) {
9
+ super(code);
10
+ this.code = code;
11
+ this.name = 'LpV3CollectProtocolError';
12
+ }
13
+ }
14
+ export function requireProtocol(value, code) {
15
+ if (!value)
16
+ throw new LpV3CollectProtocolError(code);
17
+ }
18
+ const ZERO = '0x0000000000000000000000000000000000000000';
19
+ const same = (a, b) => canonicalJson(a) === canonicalJson(b);
20
+ export function protocolClock(options = {}) {
21
+ const now = (options.now ?? (() => Math.floor(Date.now() / 1000)))();
22
+ requireProtocol(Number.isSafeInteger(now) && now > 0, 'LP_PROTOCOL_INVALID_CLOCK');
23
+ return now;
24
+ }
25
+ /** Collect-only protocol checks. This does not assert EOA or smart-account
26
+ * eligibility; the caller's reviewed UserOp profile owns that independent gate.
27
+ */
28
+ function context(intent, e, policy, now) {
29
+ requireProtocol(e.account === intent.account && intent.recipient === intent.account, 'LP_PROTOCOL_OWNER_MISMATCH');
30
+ requireProtocol(e.observedAt <= now && now - e.observedAt <= 30 && e.blockTimestamp <= e.observedAt
31
+ && now - e.blockTimestamp <= 60, 'LP_PROTOCOL_STALE_OBSERVATION');
32
+ requireProtocol(intent.deadline > now && intent.deadline <= now + 300, 'LP_PROTOCOL_DEADLINE');
33
+ requireProtocol(intent.pool === e.pool && e.factoryPool === intent.pool && intent.fee === e.fee, 'LP_PROTOCOL_POOL_MISMATCH');
34
+ const spacing = { 100: 1, 500: 10, 3000: 60, 10000: 200 }[intent.fee];
35
+ requireProtocol(e.tickSpacing === spacing && intent.tickLower < intent.tickUpper
36
+ && intent.tickLower % spacing === 0 && intent.tickUpper % spacing === 0, 'LP_PROTOCOL_RANGE_MISMATCH');
37
+ const sqrt = BigInt(e.sqrtPriceX96);
38
+ requireProtocol(e.tick >= -887272 && e.tick < 887272 && sqrt >= sqrtPriceAtTick(-887272)
39
+ && sqrt < sqrtPriceAtTick(887272) && sqrt >= sqrtPriceAtTick(e.tick) && sqrt <= sqrtPriceAtTick(e.tick + 1), 'LP_PROTOCOL_POOL_PRICE');
40
+ const p = e.position;
41
+ requireProtocol(intent.tokenId !== '0' && p.tokenId === intent.tokenId && p.owner === intent.account
42
+ && p.token0 === intent.token0 && p.token1 === intent.token1 && p.fee === intent.fee
43
+ && p.tickLower === intent.tickLower && p.tickUpper === intent.tickUpper, 'LP_PROTOCOL_NFT_MISMATCH');
44
+ requireProtocol(p.approved === ZERO && e.allowances.every(v => v === '0'), 'LP_PROTOCOL_EXISTING_APPROVAL');
45
+ requireProtocol(!intent.amountMax.every(v => v === '0') && !intent.amountMin.every(v => v === '0')
46
+ && intent.amountMin.every((v, i) => BigInt(v) <= BigInt(intent.amountMax[i])), 'LP_PROTOCOL_COLLECTION_BOUNDS');
47
+ const deployment = policy.find(d => d.id === intent.guardDeploymentId);
48
+ requireProtocol(deployment, 'LP_PROTOCOL_GUARD_UNAVAILABLE');
49
+ const g = e.guard;
50
+ requireProtocol(g.address === deployment.address && g.runtimeCodeHash === deployment.runtimeCodeHash
51
+ && g.configurationHash === deployment.configurationHash && BigInt(e.blockNumber) >= BigInt(deployment.deploymentBlock), 'LP_PROTOCOL_GUARD_MISMATCH');
52
+ return deployment;
53
+ }
54
+ function calls(intent, deployment) {
55
+ const base = { tokenIndex: null, chainId: 8453, from: intent.account, value: '0' };
56
+ return [
57
+ { ...base, step: 'nft-approve', to: B.manager, data: encodeFunctionData({ abi: LP_V3_ATOMIC_NPM_ABI,
58
+ functionName: 'approve', args: [deployment.address, BigInt(intent.tokenId)] }) },
59
+ { ...base, step: 'mutation', to: deployment.address, data: encodeFunctionData({ abi: LP_V3_COLLECT_GUARD_ABI,
60
+ functionName: 'collect', args: [{ owner: intent.account, pool: intent.pool, tokenId: BigInt(intent.tokenId),
61
+ tickLower: intent.tickLower, tickUpper: intent.tickUpper,
62
+ amount0Max: BigInt(intent.amountMax[0]), amount1Max: BigInt(intent.amountMax[1]),
63
+ amount0Min: BigInt(intent.amountMin[0]), amount1Min: BigInt(intent.amountMin[1]), deadline: BigInt(intent.deadline) }] }) },
64
+ ];
65
+ }
66
+ export function prepareLpV3CollectProtocol(input, rawObservation, policy, options = {}) {
67
+ const intent = lpV3CollectProtocolIntentSchema.parse(input), observation = lpV3CollectProtocolObservationSchema.parse(rawObservation);
68
+ const guards = reviewedGuardPolicy(policy), deployment = context(intent, observation, guards, protocolClock(options));
69
+ const body = { schemaVersion: 3, kind: 'lp-v3-collect-protocol', ...NO_AUTHORITY,
70
+ intent, intentCommitment: commitment(intent), policyCommitment: commitment(guards), guardDeployment: deployment,
71
+ calls: calls(intent, deployment), preparedBlock: { number: observation.blockNumber, hash: observation.blockHash },
72
+ preparedObservationCommitment: commitment(observation) };
73
+ return deepFreeze(lpV3CollectProtocolPlanSchema.parse({ ...body, planCommitment: commitment(body) }));
74
+ }
75
+ export function validateLpV3CollectProtocol(input, independentIntent, rawObservation, policy, options = {}) {
76
+ const plan = lpV3CollectProtocolPlanSchema.parse(input), intent = lpV3CollectProtocolIntentSchema.parse(independentIntent);
77
+ const observation = lpV3CollectProtocolObservationSchema.parse(rawObservation), checkedAt = protocolClock(options);
78
+ const guards = reviewedGuardPolicy(policy), deployment = context(intent, observation, guards, checkedAt);
79
+ requireProtocol(same(plan.intent, intent) && plan.intentCommitment === commitment(intent), 'LP_PROTOCOL_INTENT_MISMATCH');
80
+ requireProtocol(plan.policyCommitment === commitment(guards) && same(plan.guardDeployment, deployment), 'LP_PROTOCOL_POLICY_MISMATCH');
81
+ requireProtocol(same(plan.calls, calls(intent, deployment)), 'LP_PROTOCOL_CALL_MISMATCH');
82
+ const { planCommitment, ...body } = plan;
83
+ requireProtocol(planCommitment === commitment(body), 'LP_PROTOCOL_PLAN_COMMITMENT');
84
+ requireProtocol(BigInt(plan.preparedBlock.number) <= BigInt(observation.blockNumber)
85
+ && (plan.preparedBlock.number !== observation.blockNumber || plan.preparedBlock.hash === observation.blockHash), 'LP_PROTOCOL_PREPARATION_BLOCK');
86
+ const check = { schemaVersion: 3, kind: 'lp-v3-collect-protocol-check', ...NO_AUTHORITY,
87
+ planCommitment, intentCommitment: plan.intentCommitment, policyCommitment: plan.policyCommitment,
88
+ baselineCommitment: commitment(observation), checkedAt };
89
+ return deepFreeze(lpV3CollectProtocolCheckSchema.parse({ ...check, checkCommitment: commitment(check) }));
90
+ }
91
+ //# sourceMappingURL=lp-v3-collect-protocol-plan.js.map
@@ -0,0 +1,9 @@
1
+ import { type LpV3GuardDeployment } from './lp-v3-atomic-contract.js';
2
+ import type { LpV3VerifyOptions } from './lp-v3-plan.js';
3
+ import { type LpV3CollectProtocolAccounting } from './lp-v3-collect-protocol-contract.js';
4
+ /** Protocol accounting only. Raw inputs, including UserOp status and the window,
5
+ * cannot prove transport, finality, account authority or release a durable claim.
6
+ * The host authenticates the entire receipt and derives the COMPLETE operation
7
+ * slice before calling this helper; both supplied boundary indices are exclusive.
8
+ */
9
+ export declare function reconcileLpV3CollectProtocol(input: unknown, policy: readonly LpV3GuardDeployment[], options?: LpV3VerifyOptions): LpV3CollectProtocolAccounting;