@oakagentkit/core 0.2.0 → 0.2.2

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 (380) hide show
  1. package/build/dist/api/addresses.d.ts +93 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.js +1 -1
  4. package/build/dist/api/history.js +1 -1
  5. package/build/dist/api/identity-link.js +1 -1
  6. package/build/dist/api/metadata.js +1 -1
  7. package/build/dist/api/modules/beefy/boosts.js +1 -1
  8. package/build/dist/api/modules/beefy/clm.js +1 -1
  9. package/build/dist/api/modules/beefy/guard.js +1 -1
  10. package/build/dist/api/modules/beefy/index.js +1 -1
  11. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  12. package/build/dist/api/modules/beefy/management.js +1 -1
  13. package/build/dist/api/modules/beefy/vaults.js +1 -1
  14. package/build/dist/api/modules/clanker/extensions.js +1 -1
  15. package/build/dist/api/modules/clanker/index.js +1 -1
  16. package/build/dist/api/modules/clanker/manage.js +1 -1
  17. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  18. package/build/dist/api/modules/clanker/protocol.js +1 -1
  19. package/build/dist/api/modules/clanker/state.js +1 -1
  20. package/build/dist/api/modules/erc8004/common.js +1 -1
  21. package/build/dist/api/modules/erc8004/domain.js +1 -1
  22. package/build/dist/api/modules/erc8004/index.js +1 -1
  23. package/build/dist/api/modules/erc8004/management.js +1 -1
  24. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  25. package/build/dist/api/modules/erc8004/services.js +1 -1
  26. package/build/dist/api/modules/erc8004/validation.js +1 -1
  27. package/build/dist/api/modules/grove/index.js +1 -1
  28. package/build/dist/api/modules/heyresearch/backoff.d.ts +6 -0
  29. package/build/dist/api/modules/heyresearch/backoff.js +1 -0
  30. package/build/dist/api/modules/heyresearch/builder-feed.d.ts +62 -0
  31. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -0
  32. package/build/dist/api/modules/heyresearch/index.d.ts +3 -0
  33. package/build/dist/api/modules/heyresearch/index.js +1 -1
  34. package/build/dist/api/modules/heyresearch/proof-reads.d.ts +7 -0
  35. package/build/dist/api/modules/heyresearch/proof-reads.js +1 -0
  36. package/build/dist/api/modules/heyresearch/public-reads.d.ts +1 -0
  37. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  38. package/build/dist/api/modules/heyresearch/scan.d.ts +31 -0
  39. package/build/dist/api/modules/heyresearch/scan.js +1 -0
  40. package/build/dist/api/modules/heyresearch/status-labels.d.ts +5 -0
  41. package/build/dist/api/modules/heyresearch/status-labels.js +1 -0
  42. package/build/dist/api/modules/heyresearch/token-facts.d.ts +123 -0
  43. package/build/dist/api/modules/heyresearch/token-facts.js +1 -0
  44. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  45. package/build/dist/api/modules/hoodag/index.js +1 -1
  46. package/build/dist/api/modules/hoodag/management.js +1 -1
  47. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  48. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  49. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  50. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  51. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  52. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  53. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  54. package/build/dist/api/modules/hoodlock/index.js +1 -1
  55. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  56. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  57. package/build/dist/api/modules/hoodlock/public.js +1 -1
  58. package/build/dist/api/modules/hookr/actions.d.ts +1 -1
  59. package/build/dist/api/modules/hookr/actions.js +1 -1
  60. package/build/dist/api/modules/hookr/addons.js +1 -1
  61. package/build/dist/api/modules/hookr/agent-gate.d.ts +63 -0
  62. package/build/dist/api/modules/hookr/agent-gate.js +1 -0
  63. package/build/dist/api/modules/hookr/contracts.js +1 -1
  64. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  65. package/build/dist/api/modules/hookr/discovery.js +1 -1
  66. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  67. package/build/dist/api/modules/hookr/index.d.ts +1 -0
  68. package/build/dist/api/modules/hookr/index.js +1 -1
  69. package/build/dist/api/modules/hookr/launch-options.d.ts +119 -0
  70. package/build/dist/api/modules/hookr/launch-options.js +1 -0
  71. package/build/dist/api/modules/hookr/launch-profile.d.ts +5 -0
  72. package/build/dist/api/modules/hookr/launch-profile.js +1 -0
  73. package/build/dist/api/modules/hookr/launch-receipt.d.ts +144 -0
  74. package/build/dist/api/modules/hookr/launch-receipt.js +1 -0
  75. package/build/dist/api/modules/hookr/launch.d.ts +58 -0
  76. package/build/dist/api/modules/hookr/launch.js +1 -0
  77. package/build/dist/api/modules/hookr/liquidity.d.ts +48 -0
  78. package/build/dist/api/modules/hookr/liquidity.js +1 -0
  79. package/build/dist/api/modules/hookr/lp-positions.d.ts +2 -0
  80. package/build/dist/api/modules/hookr/lp-positions.js +1 -0
  81. package/build/dist/api/modules/hookr/lp-reads.d.ts +52 -0
  82. package/build/dist/api/modules/hookr/lp-reads.js +1 -0
  83. package/build/dist/api/modules/hookr/lp-receipt.d.ts +136 -0
  84. package/build/dist/api/modules/hookr/lp-receipt.js +1 -0
  85. package/build/dist/api/modules/hookr/lp-state.d.ts +33 -0
  86. package/build/dist/api/modules/hookr/lp-state.js +1 -0
  87. package/build/dist/api/modules/hookr/pins.d.ts +43 -0
  88. package/build/dist/api/modules/hookr/pins.js +1 -0
  89. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  90. package/build/dist/api/modules/hookr/read-utils.d.ts +59 -0
  91. package/build/dist/api/modules/hookr/read-utils.js +1 -0
  92. package/build/dist/api/modules/hookr/relay.js +1 -1
  93. package/build/dist/api/modules/hookr/revenue.js +1 -1
  94. package/build/dist/api/modules/kyberswap/index.js +1 -1
  95. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  96. package/build/dist/api/modules/lighter/index.js +1 -1
  97. package/build/dist/api/modules/longbow/administration.js +1 -1
  98. package/build/dist/api/modules/longbow/analytics.js +1 -1
  99. package/build/dist/api/modules/longbow/fixed.js +1 -1
  100. package/build/dist/api/modules/longbow/index.js +1 -1
  101. package/build/dist/api/modules/longbow/nft.js +1 -1
  102. package/build/dist/api/modules/longbow/rebates.js +1 -1
  103. package/build/dist/api/modules/longbow/staking.js +1 -1
  104. package/build/dist/api/modules/meridian/index.js +1 -1
  105. package/build/dist/api/modules/meridian/markets.js +1 -1
  106. package/build/dist/api/modules/meridian/rfq.js +1 -1
  107. package/build/dist/api/modules/merkl/discovery.js +1 -1
  108. package/build/dist/api/modules/merkl/index.js +1 -1
  109. package/build/dist/api/modules/merkl/manage.js +1 -1
  110. package/build/dist/api/modules/merkl/protocol.js +1 -1
  111. package/build/dist/api/modules/morpho/allocator.js +1 -1
  112. package/build/dist/api/modules/morpho/bundles.js +1 -1
  113. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  114. package/build/dist/api/modules/morpho/index.js +1 -1
  115. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  116. package/build/dist/api/modules/morpho/midnight.js +1 -1
  117. package/build/dist/api/modules/morpho/protocol.js +1 -1
  118. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  119. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  120. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  121. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  122. package/build/dist/api/modules/netnet/card-read.js +1 -1
  123. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  124. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  125. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  126. package/build/dist/api/modules/netnet/financial.js +1 -1
  127. package/build/dist/api/modules/netnet/index.js +1 -1
  128. package/build/dist/api/modules/netnet/staking.js +1 -1
  129. package/build/dist/api/modules/orbio/index.js +1 -1
  130. package/build/dist/api/modules/pons/claim.js +1 -1
  131. package/build/dist/api/modules/pons/index.js +1 -1
  132. package/build/dist/api/modules/pons/launch-status.js +1 -1
  133. package/build/dist/api/modules/pons/prices.js +1 -1
  134. package/build/dist/api/modules/pons/reads.js +1 -1
  135. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  136. package/build/dist/api/modules/pons/trade.js +1 -1
  137. package/build/dist/api/modules/poolstrade/index.js +1 -1
  138. package/build/dist/api/modules/priors/coverage.js +1 -1
  139. package/build/dist/api/modules/priors/discovery.js +1 -1
  140. package/build/dist/api/modules/priors/features.js +1 -1
  141. package/build/dist/api/modules/priors/index.js +1 -1
  142. package/build/dist/api/modules/priors/integration.js +1 -1
  143. package/build/dist/api/modules/priors/market.js +1 -1
  144. package/build/dist/api/modules/priors/pt.js +1 -1
  145. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  146. package/build/dist/api/modules/priors/starter-line.js +1 -1
  147. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  148. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  149. package/build/dist/api/modules/relay/discovery.js +1 -1
  150. package/build/dist/api/modules/relay/inbound.js +1 -1
  151. package/build/dist/api/modules/relay/index.js +1 -1
  152. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  153. package/build/dist/api/modules/relay/reads.js +1 -1
  154. package/build/dist/api/modules/spark/actions.js +1 -1
  155. package/build/dist/api/modules/spark/details.js +1 -1
  156. package/build/dist/api/modules/spark/index.js +1 -1
  157. package/build/dist/api/modules/spark/management.js +1 -1
  158. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  159. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  160. package/build/dist/api/modules/steakhouse/index.js +1 -1
  161. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  162. package/build/dist/api/modules/steakhouse/management.js +1 -1
  163. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  164. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  165. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  166. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  167. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  168. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  169. package/build/dist/api/modules/tickerspring/index.js +1 -1
  170. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  171. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  172. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  173. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  174. package/build/dist/api/modules/tickerspring/research.js +1 -1
  175. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  176. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  177. package/build/dist/api/modules/uniswap/auction.js +1 -1
  178. package/build/dist/api/modules/uniswap/batch.js +1 -1
  179. package/build/dist/api/modules/uniswap/common.js +1 -1
  180. package/build/dist/api/modules/uniswap/fees.js +1 -1
  181. package/build/dist/api/modules/uniswap/index.js +1 -1
  182. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  183. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  184. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  185. package/build/dist/api/modules/uniswap/pools.js +1 -1
  186. package/build/dist/api/modules/uniswap/position.js +1 -1
  187. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  188. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  189. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  190. package/build/dist/api/modules/uniswap/trade.js +1 -1
  191. package/build/dist/api/modules/uniswap/v2.js +1 -1
  192. package/build/dist/api/modules/uniswap/v3.js +1 -1
  193. package/build/dist/api/modules/uniswap/v4.js +1 -1
  194. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  195. package/build/dist/api/modules/velora/claims.js +1 -1
  196. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  197. package/build/dist/api/modules/velora/index.js +1 -1
  198. package/build/dist/api/modules/wormhole/index.d.ts +5 -0
  199. package/build/dist/api/modules/wormhole/index.js +1 -0
  200. package/build/dist/api/modules/wormhole/license.d.ts +2 -0
  201. package/build/dist/api/modules/wormhole/license.js +1 -0
  202. package/build/dist/api/modules/wormhole/quotetext.d.ts +36 -0
  203. package/build/dist/api/modules/wormhole/quotetext.js +1 -0
  204. package/build/dist/api/modules/wormhole/scan-text.d.ts +40 -0
  205. package/build/dist/api/modules/wormhole/scan-text.js +1 -0
  206. package/build/dist/api/modules/wormhole/token-check.d.ts +54 -0
  207. package/build/dist/api/modules/wormhole/token-check.js +1 -0
  208. package/build/dist/api/positions.js +1 -1
  209. package/build/dist/api/pricenote.js +1 -1
  210. package/build/dist/api/prices.js +1 -1
  211. package/build/dist/api/pricing.js +1 -1
  212. package/build/dist/api/rpc.js +1 -1
  213. package/build/dist/api/send.js +1 -1
  214. package/build/dist/api/signing-registry.js +1 -1
  215. package/build/dist/api/signing.js +1 -1
  216. package/build/dist/api/simulate.js +1 -1
  217. package/build/dist/api/swap.js +1 -1
  218. package/build/dist/api/tokens.d.ts +4 -0
  219. package/build/dist/api/tokens.js +1 -1
  220. package/build/dist/api/tool-policy.js +1 -1
  221. package/build/dist/api/types.d.ts +7 -0
  222. package/build/dist/chunks/{QHHZDXRG.js → 2FSX7MMR.js} +1 -1
  223. package/build/dist/chunks/{RTBOMWCB.js → 2LM7U4S7.js} +1 -1
  224. package/build/dist/chunks/{XKRWJCYE.js → 2MSQ6JII.js} +1 -1
  225. package/build/dist/chunks/{T6MTTMLQ.js → 2UU5TBBB.js} +1 -1
  226. package/build/dist/chunks/{OW7GOYKA.js → 2W46IRX6.js} +1 -1
  227. package/build/dist/chunks/{6LLOTPH2.js → 3EFV4FQF.js} +1 -1
  228. package/build/dist/chunks/{64AF7ECA.js → 3NDVXEBR.js} +1 -1
  229. package/build/dist/chunks/3SC5UI35.js +1 -0
  230. package/build/dist/chunks/{TCS3ICNE.js → 3WBDHUV2.js} +1 -1
  231. package/build/dist/chunks/{UPPYXY74.js → 4AKIXLXH.js} +1 -1
  232. package/build/dist/chunks/{RRSODRGT.js → 4GAWMCQC.js} +1 -1
  233. package/build/dist/chunks/{ZGXNTWYG.js → 4GHVIBL5.js} +1 -1
  234. package/build/dist/chunks/{NHCRJC5X.js → 4KQZTPMS.js} +1 -1
  235. package/build/dist/chunks/{N77ANGBT.js → 4X2JOQ2L.js} +1 -1
  236. package/build/dist/chunks/{ZPM2MFXZ.js → 52DHGSG4.js} +1 -1
  237. package/build/dist/chunks/{ITV52TIE.js → 57HAXNQV.js} +1 -1
  238. package/build/dist/chunks/5IIR3GIN.js +1 -0
  239. package/build/dist/chunks/{CAU44UWP.js → 5O5ZE3ZV.js} +1 -1
  240. package/build/dist/chunks/5OEHZJ6X.js +1 -0
  241. package/build/dist/chunks/{CBA776XQ.js → 5VHH5PW3.js} +1 -1
  242. package/build/dist/chunks/{O5SU2I3G.js → 66VBACC2.js} +1 -1
  243. package/build/dist/chunks/{6HV5BR7P.js → 6AWTAE4Q.js} +1 -1
  244. package/build/dist/chunks/{JRVTSGAT.js → 6UPPUHCL.js} +1 -1
  245. package/build/dist/chunks/{3ACEWCKZ.js → 6ZYLNB2B.js} +1 -1
  246. package/build/dist/chunks/7XLEYOZH.js +1 -0
  247. package/build/dist/chunks/{QCD33HMD.js → AAGDMH54.js} +1 -1
  248. package/build/dist/chunks/ACN2BFMA.js +1 -0
  249. package/build/dist/chunks/{L24EOVLT.js → AJP5LDM2.js} +1 -1
  250. package/build/dist/chunks/{F2YH72GF.js → ALK6NKFP.js} +1 -1
  251. package/build/dist/chunks/{EC5W3UZD.js → AMICUXS6.js} +1 -1
  252. package/build/dist/chunks/{5FTSKYQH.js → BX7XQANB.js} +1 -1
  253. package/build/dist/chunks/{QNPEKNWM.js → CEIPDEXZ.js} +1 -1
  254. package/build/dist/chunks/{HFQS5344.js → CQCVFRQ5.js} +1 -1
  255. package/build/dist/chunks/{OJLMF5AR.js → CUNQ5RG5.js} +1 -1
  256. package/build/dist/chunks/{IWALIX7Q.js → CXLEQCP3.js} +1 -1
  257. package/build/dist/chunks/{VJ3W2V3B.js → CY75R4FK.js} +1 -1
  258. package/build/dist/chunks/{65QFM4JU.js → DCTUYDWF.js} +1 -1
  259. package/build/dist/chunks/DHOBTJRD.js +1 -0
  260. package/build/dist/chunks/{NO57NGRV.js → DRWWPBOQ.js} +1 -1
  261. package/build/dist/chunks/{7B5UH2VS.js → DZGEQBO7.js} +1 -1
  262. package/build/dist/chunks/{RFJCG4NA.js → E7R3J4H7.js} +1 -1
  263. package/build/dist/chunks/{7T4BYFD4.js → EGUMOD3A.js} +1 -1
  264. package/build/dist/chunks/ELZNT5Q3.js +1 -0
  265. package/build/dist/chunks/EPZ7SWKM.js +1 -0
  266. package/build/dist/chunks/{WDGPCPQJ.js → EXRKBBX2.js} +1 -1
  267. package/build/dist/chunks/{U3FMCX3L.js → FBSUTF3B.js} +1 -1
  268. package/build/dist/chunks/FUXT7GRK.js +1 -0
  269. package/build/dist/chunks/G6HCV67X.js +1 -0
  270. package/build/dist/chunks/{HNMOB76J.js → GGUEKSR4.js} +1 -1
  271. package/build/dist/chunks/{GZ5TW3WB.js → GIV5JMTE.js} +1 -1
  272. package/build/dist/chunks/{ZYR5LSVB.js → GJY3P6OG.js} +1 -1
  273. package/build/dist/chunks/HOEQVPY7.js +1 -0
  274. package/build/dist/chunks/{R7D256HG.js → IBXYIN7Q.js} +1 -1
  275. package/build/dist/chunks/{SXX52Y27.js → IUE6RASI.js} +1 -1
  276. package/build/dist/chunks/J2XAEVKC.js +1 -0
  277. package/build/dist/chunks/{AYM5L6L7.js → J3GFCBZZ.js} +1 -1
  278. package/build/dist/chunks/JNZZLA2A.js +1 -0
  279. package/build/dist/chunks/JPOYTTTW.js +1 -0
  280. package/build/dist/chunks/{4IPW5WZ4.js → JST5JGAP.js} +1 -1
  281. package/build/dist/chunks/{ZCGVBK5K.js → JVI26KQO.js} +1 -1
  282. package/build/dist/chunks/JWCOXLYA.js +1 -0
  283. package/build/dist/chunks/{G7UKNO2I.js → KHJFXJBU.js} +1 -1
  284. package/build/dist/chunks/{HQVC6X3T.js → KSZMMNXK.js} +1 -1
  285. package/build/dist/chunks/{JC4SYMBV.js → L3ZM77SJ.js} +1 -1
  286. package/build/dist/chunks/{QRUC7EFE.js → L62M7LOB.js} +1 -1
  287. package/build/dist/chunks/{5VXNQFYJ.js → L7YBCMZU.js} +1 -1
  288. package/build/dist/chunks/{H6ED3RHF.js → LMVB3B6T.js} +1 -1
  289. package/build/dist/chunks/{UIIJWIR6.js → LQGPMOD2.js} +1 -1
  290. package/build/dist/chunks/{BXN3MDS4.js → LQUDJCAR.js} +1 -1
  291. package/build/dist/chunks/LT5P6PZW.js +1 -0
  292. package/build/dist/chunks/M7U3A4EH.js +3 -0
  293. package/build/dist/chunks/MFNP4KOK.js +1 -0
  294. package/build/dist/chunks/MKQVS3IO.js +1 -0
  295. package/build/dist/chunks/{7US6PD56.js → MLPWQTBS.js} +1 -1
  296. package/build/dist/chunks/{5XFXH2JT.js → NATG6YA6.js} +1 -1
  297. package/build/dist/chunks/{O47JXRXN.js → NAYRD43N.js} +1 -1
  298. package/build/dist/chunks/NMYGNJIJ.js +1 -0
  299. package/build/dist/chunks/NRBIXV7V.js +1 -0
  300. package/build/dist/chunks/{D6VP3N27.js → NSOEDRBU.js} +1 -1
  301. package/build/dist/chunks/{HL2MLC3O.js → NU4K3TEZ.js} +1 -1
  302. package/build/dist/chunks/NWSPC3NH.js +1 -0
  303. package/build/dist/chunks/{SDICP7BT.js → OE3CLZHR.js} +1 -1
  304. package/build/dist/chunks/{2NA6JLEC.js → OQVZVR2S.js} +1 -1
  305. package/build/dist/chunks/{D3OWLDVB.js → OVK4EEOD.js} +1 -1
  306. package/build/dist/chunks/{Q2VMH2LB.js → PARWLWXW.js} +1 -1
  307. package/build/dist/chunks/{DHXVYHT4.js → PTAWEHKB.js} +1 -1
  308. package/build/dist/chunks/{KQFDLDHL.js → PWBL4WKB.js} +1 -1
  309. package/build/dist/chunks/{55NX776C.js → PZHR4ITH.js} +1 -1
  310. package/build/dist/chunks/{ANQ43XJA.js → Q356HHCL.js} +1 -1
  311. package/build/dist/chunks/{OG5HRQU4.js → QRDDKA4I.js} +1 -1
  312. package/build/dist/chunks/{YR3QJVJQ.js → QXNPPCOU.js} +1 -1
  313. package/build/dist/chunks/{6NR7SVRO.js → QYYFRAWY.js} +1 -1
  314. package/build/dist/chunks/{7BTELNNI.js → R53P2K3C.js} +1 -1
  315. package/build/dist/chunks/{5HW6JKME.js → R7FXNZRM.js} +1 -1
  316. package/build/dist/chunks/{CCEWSOBT.js → R7QPJQP6.js} +1 -1
  317. package/build/dist/chunks/{SLSPWXR6.js → R7SXC74O.js} +1 -1
  318. package/build/dist/chunks/{IHGVCPVA.js → RAKUK5VR.js} +1 -1
  319. package/build/dist/chunks/{7LDAJ6BM.js → S3HNPTXA.js} +1 -1
  320. package/build/dist/chunks/SI6GCOAS.js +1 -0
  321. package/build/dist/chunks/{WIDTTGSH.js → SJPM5ST4.js} +1 -1
  322. package/build/dist/chunks/{GHDDVBPK.js → SJPYXNOK.js} +1 -1
  323. package/build/dist/chunks/{VY3P34PY.js → SKQGLGES.js} +1 -1
  324. package/build/dist/chunks/{ZT67OMLW.js → SOYQOE5P.js} +1 -1
  325. package/build/dist/chunks/{BFVLBENV.js → SQZRVIVF.js} +1 -1
  326. package/build/dist/chunks/{N6RL3SUZ.js → SSTROLQM.js} +1 -1
  327. package/build/dist/chunks/{IUXOUKQN.js → SXAIXD56.js} +1 -1
  328. package/build/dist/chunks/{TNRDCBGO.js → SXX3VTBP.js} +1 -1
  329. package/build/dist/chunks/{UXG67LH3.js → TCPPYBGQ.js} +1 -1
  330. package/build/dist/chunks/TFVWAYHY.js +1 -0
  331. package/build/dist/chunks/{67TJOOBI.js → TLJPVYRJ.js} +1 -1
  332. package/build/dist/chunks/{HRG2VVPY.js → TMGWXDCZ.js} +1 -1
  333. package/build/dist/chunks/{NMFVXBTL.js → TNSKEHPC.js} +1 -1
  334. package/build/dist/chunks/{C2FEXLMA.js → TQL7UDFL.js} +1 -1
  335. package/build/dist/chunks/{SQH7A4O3.js → TWCSCRFS.js} +1 -1
  336. package/build/dist/chunks/{2EDXKJ3B.js → TWSTOFN3.js} +1 -1
  337. package/build/dist/chunks/{JREVERSC.js → U3F6DDML.js} +1 -1
  338. package/build/dist/chunks/{6PU2CMQZ.js → UFS2RVEZ.js} +1 -1
  339. package/build/dist/chunks/{Y2IWPNEW.js → UNZRE3YU.js} +1 -1
  340. package/build/dist/chunks/{K463HFGC.js → USSOVTD5.js} +1 -1
  341. package/build/dist/chunks/V2OOOV6B.js +1 -0
  342. package/build/dist/chunks/{WQZLYX64.js → V5LTA42G.js} +1 -1
  343. package/build/dist/chunks/{TAI63P6E.js → VC2RCYQE.js} +1 -1
  344. package/build/dist/chunks/{2SNQWKHA.js → VFSRRDLY.js} +1 -1
  345. package/build/dist/chunks/{XW7RH7YY.js → VVEUJ36E.js} +1 -1
  346. package/build/dist/chunks/{5EHQM6DM.js → WQ6H62DM.js} +1 -1
  347. package/build/dist/chunks/{FSPNOVKB.js → WQQJ7UPJ.js} +1 -1
  348. package/build/dist/chunks/{F3TJCOVV.js → WTSMPDT5.js} +1 -1
  349. package/build/dist/chunks/{BYXBS45D.js → WVXW6VL3.js} +1 -1
  350. package/build/dist/chunks/WWFOYZT2.js +1 -0
  351. package/build/dist/chunks/WWNAGOCD.js +1 -0
  352. package/build/dist/chunks/X2NJSQUY.js +203 -0
  353. package/build/dist/chunks/{PJ65ZOQ7.js → XMA25DXR.js} +1 -1
  354. package/build/dist/chunks/{C3ZZSGSP.js → XQUPZ3GU.js} +1 -1
  355. package/build/dist/chunks/XQXLFF7Y.js +1 -0
  356. package/build/dist/chunks/XV2HQKND.js +1 -0
  357. package/build/dist/chunks/{QZM7CWZW.js → XVFLT275.js} +1 -1
  358. package/build/dist/chunks/{BV3AHLH5.js → XWEFKXKA.js} +1 -1
  359. package/build/dist/chunks/{QZTUMSQY.js → Y2KH6DCE.js} +1 -1
  360. package/build/dist/chunks/{GSI5COTD.js → YA5WWDEW.js} +1 -1
  361. package/build/dist/chunks/YHB55C5T.js +1 -0
  362. package/build/dist/chunks/YQUKU2LS.js +1 -0
  363. package/build/dist/chunks/{A25P24G2.js → YZSTP2E6.js} +1 -1
  364. package/build/dist/chunks/{T3NPRRTY.js → Z7RL4NGX.js} +1 -1
  365. package/build/dist/chunks/{LI7FYINH.js → ZT47KN7A.js} +1 -1
  366. package/build/dist/chunks/{QQWF6A4P.js → ZUG6MG46.js} +1 -1
  367. package/package.json +2 -2
  368. package/build/dist/chunks/46ZA2R5L.js +0 -1
  369. package/build/dist/chunks/6SCCW74G.js +0 -1
  370. package/build/dist/chunks/74BPMUAG.js +0 -1
  371. package/build/dist/chunks/7Z5IM2QZ.js +0 -1
  372. package/build/dist/chunks/DLIOZCEG.js +0 -1
  373. package/build/dist/chunks/EYYUWFUR.js +0 -1
  374. package/build/dist/chunks/G4PDM3MX.js +0 -1
  375. package/build/dist/chunks/JRO6WTK4.js +0 -1
  376. package/build/dist/chunks/NBRMUFJP.js +0 -1
  377. package/build/dist/chunks/NIOBE2LK.js +0 -1
  378. package/build/dist/chunks/OJMYESQU.js +0 -1
  379. package/build/dist/chunks/UMK564HS.js +0 -1
  380. package/build/dist/chunks/XPFVT2EA.js +0 -1
@@ -1 +1 @@
1
- import{a as D}from"./RETS2ZEK.js";import{a as d}from"./XPFVT2EA.js";import{a as c}from"./5YS5V2LK.js";import{concat as B,encodeAbiParameters as k,getAddress as v,isAddress as F,keccak256 as g,parseAbiParameters as O,recoverAddress as q,toHex as N}from"viem";import{privateKeyToAccount as U}from"viem/accounts";var T="OakPriceNote",l="1",w=300,E="0x0000000000000000000000000000000000000000",W=g(N("PriceNote(address wallet,uint256 oakPerEthE18,uint64 timestamp,bytes32 nonce)")),L=g(N("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")),M=(1n<<64n)-1n,P=(1n<<256n)-1n,z=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,G=0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;function X(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{130}$/.test(e))return!1;let n=BigInt(`0x${e.slice(2,66)}`),t=BigInt(`0x${e.slice(66,130)}`),i=Number.parseInt(e.slice(130,132),16);return!(i!==27&&i!==28||n<=0n||n>=z||t<=0n||t>G)}function m(e,n){if(typeof e!="string"||!F(e,{strict:!1}))throw new c(`Invalid ${n} address.`);return v(e)}function p(e,n){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new c(`Invalid ${n}.`);t=BigInt(e)}else t=D(e);if(t<0n||t>P)throw new c(`${n} exceeds uint256 bounds.`);return t}function h(e,n){let t=p(e,n);if(t>M)throw new c(`${n} exceeds uint64 bounds.`);return t}function Y(e,n){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new c(`${n} must be a 32-byte hex string.`);return e}function j(e){if(typeof e=="bigint"){if(e<=0n||e>P)throw new c("Private key must be a positive scalar.");return`0x${e.toString(16).padStart(64,"0")}`}if(typeof e=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(e))return`0x${e.slice(2).padStart(64,"0")}`;throw new c("Invalid private key format.")}function K(e){let n=p(e.chainId,"chainId"),t=m(e.verifyingContract,"verifyingContract");return g(k(O("bytes32, bytes32, bytes32, uint256, address"),[L,g(N(e.name)),g(N(e.version)),n,t]))}function ae(e,n=d,t=l){return{name:T,version:t,chainId:Number(p(n,"chainId")),verifyingContract:m(e,"consumer")}}function J(e,n=d,t=l){return K({name:T,version:t,chainId:n,verifyingContract:e})}function Q(e){let n=m(e.wallet,"wallet"),t=p(e.oakPerEthE18,"oakPerEthE18"),i=h(e.timestamp,"timestamp"),r=Y(e.nonce,"nonce");return g(k(O("bytes32, address, uint256, uint64, bytes32"),[W,n,t,i,r]))}function C(e,n,t=d,i=l){let r=J(n,t,i),o=Q(e);return g(B(["0x1901",r,o]))}async function ce(e,n,t,i=d,r=l){let o=C(e,n,i,r);return typeof t=="object"&&t!==null&&"sign"in t?t.sign({hash:o}):U(j(t)).sign({hash:o})}async function Z(e,n,t,i=d,r=l){if(!X(n))return E;try{let o=C(e,t,i,r),x=await q({hash:o,signature:n});return v(x)}catch{return E}}function ee(e,n){let t=p(e,"oakPerEthE18"),i=p(n,"spotOakPerEthE18");if(i<=0n||t<=0n)return!1;if(t>P/2n||i>P/3n)throw new c("Guard arithmetic overflow.");let r=t*2n;return r>=i&&r<=i*3n}function te(e,n,t,i){if("signature"in e&&"consumer"in e&&"note"in e&&!("average"in e))return e;if("note"in e&&"signature"in e&&"consumer"in e){let a=e,f=n??{};return{...f,note:a.note,signature:a.signature,consumer:f.consumer??a.consumer,expiresAt:f.expiresAt??a.expiresAt}}return{...i??{},note:e,signature:n,consumer:t}}async function fe(e,n,t,i){let r=te(e,n,t,i),{note:o,signature:x,consumer:S}=r,a=h(o.timestamp,"timestamp"),f=p(o.oakPerEthE18,"oakPerEthE18"),y=(a+BigInt(w)).toString(),s=(b,V,H)=>({valid:!1,ok:!1,...H?{signer:H}:{},oakPerEthE18:f.toString(),expiresAt:y,reason:b,error:V}),I=r.wallet??r.boundWallet;if(I===void 0)return s("wrong_wallet","Bound wallet context is required to verify a price note.");if(m(o.wallet,"wallet")!==m(I,"boundWallet"))return s("wrong_wallet","Price note wallet does not match the bound wallet.");if(r.now===void 0)return s("expired","Current time (now) is required to verify price note expiry.");let A=h(r.now,"now");if(a>A)return s("not_yet_valid","Price note timestamp is in the future.");if(A-a>BigInt(w))return s("expired","Price note has expired.");if(r.expiresAt!==void 0){let b=h(r.expiresAt,"expiresAt");if(b!==a+BigInt(w)||A>b)return s("expired","Price note has expired.")}let R=r.chainId??d,$=r.version??l,u=await Z(o,x,S,R,$);if(u===E)return s("bad_signature","Price note signature could not be recovered.");if(r.signer===void 0)return s("bad_signature","Expected oracle signer is required to verify a price note.",u);let _=m(r.signer,"signer");return _===E||u!==_?s("bad_signature","Price note signer does not match the oracle signer.",u):r.spotOakPerEthE18===void 0?s("outside_guard","Spot OAK/ETH price is required to verify the price note guard band.",u):ee(f,r.spotOakPerEthE18)?{valid:!0,ok:!0,signer:u,oakPerEthE18:f.toString(),expiresAt:y}:s("outside_guard","Price note is outside the 50% spot guard band.",u)}export{T as a,l as b,w as c,E as d,W as e,K as f,ae as g,J as h,Q as i,C as j,ce as k,Z as l,ee as m,fe as n};
1
+ import{a as D}from"./RETS2ZEK.js";import{a as d}from"./G6HCV67X.js";import{a as c}from"./5YS5V2LK.js";import{concat as B,encodeAbiParameters as k,getAddress as v,isAddress as F,keccak256 as g,parseAbiParameters as O,recoverAddress as q,toHex as N}from"viem";import{privateKeyToAccount as U}from"viem/accounts";var T="OakPriceNote",l="1",w=300,E="0x0000000000000000000000000000000000000000",W=g(N("PriceNote(address wallet,uint256 oakPerEthE18,uint64 timestamp,bytes32 nonce)")),L=g(N("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")),M=(1n<<64n)-1n,P=(1n<<256n)-1n,z=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,G=0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;function X(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{130}$/.test(e))return!1;let n=BigInt(`0x${e.slice(2,66)}`),t=BigInt(`0x${e.slice(66,130)}`),i=Number.parseInt(e.slice(130,132),16);return!(i!==27&&i!==28||n<=0n||n>=z||t<=0n||t>G)}function m(e,n){if(typeof e!="string"||!F(e,{strict:!1}))throw new c(`Invalid ${n} address.`);return v(e)}function p(e,n){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new c(`Invalid ${n}.`);t=BigInt(e)}else t=D(e);if(t<0n||t>P)throw new c(`${n} exceeds uint256 bounds.`);return t}function h(e,n){let t=p(e,n);if(t>M)throw new c(`${n} exceeds uint64 bounds.`);return t}function Y(e,n){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new c(`${n} must be a 32-byte hex string.`);return e}function j(e){if(typeof e=="bigint"){if(e<=0n||e>P)throw new c("Private key must be a positive scalar.");return`0x${e.toString(16).padStart(64,"0")}`}if(typeof e=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(e))return`0x${e.slice(2).padStart(64,"0")}`;throw new c("Invalid private key format.")}function K(e){let n=p(e.chainId,"chainId"),t=m(e.verifyingContract,"verifyingContract");return g(k(O("bytes32, bytes32, bytes32, uint256, address"),[L,g(N(e.name)),g(N(e.version)),n,t]))}function ae(e,n=d,t=l){return{name:T,version:t,chainId:Number(p(n,"chainId")),verifyingContract:m(e,"consumer")}}function J(e,n=d,t=l){return K({name:T,version:t,chainId:n,verifyingContract:e})}function Q(e){let n=m(e.wallet,"wallet"),t=p(e.oakPerEthE18,"oakPerEthE18"),i=h(e.timestamp,"timestamp"),r=Y(e.nonce,"nonce");return g(k(O("bytes32, address, uint256, uint64, bytes32"),[W,n,t,i,r]))}function C(e,n,t=d,i=l){let r=J(n,t,i),o=Q(e);return g(B(["0x1901",r,o]))}async function ce(e,n,t,i=d,r=l){let o=C(e,n,i,r);return typeof t=="object"&&t!==null&&"sign"in t?t.sign({hash:o}):U(j(t)).sign({hash:o})}async function Z(e,n,t,i=d,r=l){if(!X(n))return E;try{let o=C(e,t,i,r),x=await q({hash:o,signature:n});return v(x)}catch{return E}}function ee(e,n){let t=p(e,"oakPerEthE18"),i=p(n,"spotOakPerEthE18");if(i<=0n||t<=0n)return!1;if(t>P/2n||i>P/3n)throw new c("Guard arithmetic overflow.");let r=t*2n;return r>=i&&r<=i*3n}function te(e,n,t,i){if("signature"in e&&"consumer"in e&&"note"in e&&!("average"in e))return e;if("note"in e&&"signature"in e&&"consumer"in e){let a=e,f=n??{};return{...f,note:a.note,signature:a.signature,consumer:f.consumer??a.consumer,expiresAt:f.expiresAt??a.expiresAt}}return{...i??{},note:e,signature:n,consumer:t}}async function fe(e,n,t,i){let r=te(e,n,t,i),{note:o,signature:x,consumer:S}=r,a=h(o.timestamp,"timestamp"),f=p(o.oakPerEthE18,"oakPerEthE18"),y=(a+BigInt(w)).toString(),s=(b,V,H)=>({valid:!1,ok:!1,...H?{signer:H}:{},oakPerEthE18:f.toString(),expiresAt:y,reason:b,error:V}),I=r.wallet??r.boundWallet;if(I===void 0)return s("wrong_wallet","Bound wallet context is required to verify a price note.");if(m(o.wallet,"wallet")!==m(I,"boundWallet"))return s("wrong_wallet","Price note wallet does not match the bound wallet.");if(r.now===void 0)return s("expired","Current time (now) is required to verify price note expiry.");let A=h(r.now,"now");if(a>A)return s("not_yet_valid","Price note timestamp is in the future.");if(A-a>BigInt(w))return s("expired","Price note has expired.");if(r.expiresAt!==void 0){let b=h(r.expiresAt,"expiresAt");if(b!==a+BigInt(w)||A>b)return s("expired","Price note has expired.")}let R=r.chainId??d,$=r.version??l,u=await Z(o,x,S,R,$);if(u===E)return s("bad_signature","Price note signature could not be recovered.");if(r.signer===void 0)return s("bad_signature","Expected oracle signer is required to verify a price note.",u);let _=m(r.signer,"signer");return _===E||u!==_?s("bad_signature","Price note signer does not match the oracle signer.",u):r.spotOakPerEthE18===void 0?s("outside_guard","Spot OAK/ETH price is required to verify the price note guard band.",u):ee(f,r.spotOakPerEthE18)?{valid:!0,ok:!0,signer:u,oakPerEthE18:f.toString(),expiresAt:y}:s("outside_guard","Price note is outside the 50% spot guard band.",u)}export{T as a,l as b,w as c,E as d,W as e,K as f,ae as g,J as h,Q as i,C as j,ce as k,Z as l,ee as m,fe as n};
@@ -1 +1 @@
1
- import{d as P,e as E,f,h as M,j as b,k as V,l as T,m as q,n as j,o as g,p as S,q as x,t as F,w as U,z as $}from"./2EDXKJ3B.js";import{c as m}from"./X5V2Z2NM.js";import{a as _}from"./6IM6A5VA.js";import{c as R,g as v}from"./73N3TOJL.js";import{a as i}from"./5YS5V2LK.js";import{a as I}from"./JXOEJPJ4.js";import{encodeFunctionData as N,keccak256 as G,toBytes as L}from"viem";var D=`0x${"00".repeat(32)}`,ae=d=>{let A=(e,t,s)=>({name:e,inputSchema:t,execute:async(r,a)=>{try{return _(a),j(d,r.chainId),await s(r,a)}catch(u){throw new i(d.plainError(u))}}}),C={transactionHash:{...E,description:"After local submission, repeat the same arguments with the mined hash to verify calldata, event and registry state."}},w=(e,t,s)=>d.clientFor(M(d).chainId).readContract({address:e,abi:m,functionName:t,args:s}),p=async(e,t)=>{try{return await w(e,"getValidationStatus",[t])}catch{return}},H=(e,t)=>({requestHash:e,validator:t[0],agentId:t[1].toString(),response:t[2],responseHash:t[3],tag:I(t[4]),lastUpdate:t[5].toString(),possiblyUnanswered:t[2]===0&&t[3]===D&&t[4]===""}),W=A("erc8004_validation_request",{type:"object",additionalProperties:!1,required:["agentId","validator","requestURI"],description:"Ask a validator (re-execution staker, zkML verifier, TEE oracle, judge) to check an agent's work (Validation Registry validationRequest). Owner or approved operator only.",properties:{agentId:P,validator:{...R,description:"The validator contract or wallet that will respond."},requestURI:{type:"string",description:"HTTPS/IPFS URI of the data the validator needs (inputs and outputs)."},requestHash:{...f,description:"keccak256 commitment to the request payload; provide this or requestContent."},requestContent:{type:"string",description:"The exact request payload text; Oak commits its keccak256 as requestHash."},...C}},async(e,t)=>{let{address:s}=b(d),r=T(e.agentId),a=q(e.validator,"validator");if(V(a))throw new i("Provide a real validator address.");let u=x(e.requestURI,"requestURI");if(e.requestHash===void 0==(e.requestContent===void 0))throw new i("Provide exactly one of requestHash or requestContent.");let l=e.requestHash!==void 0?g(e.requestHash,"requestHash"):G(L(S(e.requestContent,"requestContent",1e6,!1)));return $(d,t,e,{to:s,data:N({abi:m,functionName:"validationRequest",args:[a,r,u,l]}),description:`Request validation of ERC-8004 agent ${r} by ${a}.`,summary:`Asks ${a} to validate agent ${r}'s work: request ${l}, data at ${I(u)}. The request is public and permanent. Only the named validator can respond. Repeat with transactionHash to verify.`,authority:async()=>{if(await F(d,r,t,"request validation"),await p(s,l))throw new i("A validation request with that requestHash already exists; use a different payload commitment.")},verify:async h=>{let c=U(h,s,m,"ValidationRequest"),o=await p(s,l);if(!o||!v(String(c.validatorAddress),a)||c.agentId!==r||c.requestHash!==l||o[1]!==r||!v(o[0],a))throw new i("The registry event or stored request does not match.");return{...H(l,o),confirmed:!0}}})}),Z=A("erc8004_validation_response",{type:"object",additionalProperties:!1,required:["requestHash","response"],description:"As the named validator, record a validation result from 0 (failed) to 100 (passed) for a request. May be called again to update.",properties:{requestHash:f,response:{type:"integer",minimum:0,maximum:100},responseURI:{type:"string",description:"Optional HTTPS/IPFS evidence or audit URI."},responseHash:{...f,description:"Optional commitment to the evidence content."},tag:{type:"string",description:"Optional category, e.g. soft-finality / hard-finality."},...C}},async(e,t)=>{let{address:s}=b(d),r=g(e.requestHash,"requestHash"),a=e.response;if(typeof a!="number"||!Number.isInteger(a)||a<0||a>100)throw new i("response must be an integer from 0 to 100.");let u=e.responseURI===void 0?"":x(e.responseURI,"responseURI"),l=e.responseHash===void 0?D:g(e.responseHash,"responseHash"),h=S(e.tag,"tag",128);return $(d,t,e,{to:s,data:N({abi:m,functionName:"validationResponse",args:[r,a,u,l,h]}),description:`Respond ${a}/100 to validation request ${r}.`,summary:`Records validation result ${a}/100${h?` (tag ${I(h)})`:""} for request ${r} as this wallet. It is public; a later response replaces the stored result but the event history stays. Repeat with transactionHash to verify.`,authority:async()=>{let c=await p(s,r);if(!c)throw new i("No validation request has that requestHash.");if(!v(c[0],t))throw new i("Only the validator named in the request can respond to it.")},verify:async c=>{let o=U(c,s,m,"ValidationResponse"),n=await p(s,r);if(!n||o.requestHash!==r||o.response!==a||!v(String(o.validatorAddress),t)||n[2]!==a)throw new i("The registry event or stored result does not match.");return{...H(r,n),confirmed:!0}}})}),z=A("erc8004_validation",{type:"object",additionalProperties:!1,description:"Read-only validation lookups. Provide exactly one of requestHash (one request), agentId (its requests and average) or validator (requests addressed to it).",properties:{requestHash:f,agentId:P,validator:R,validators:{type:"array",maxItems:50,items:R,description:"With agentId: average only these validators."},tag:{type:"string",description:"With agentId: average only this tag."},limit:{type:"integer",minimum:1,maximum:100,default:25}}},async e=>{let{address:t}=b(d),s=["requestHash","agentId","validator"].filter(n=>e[n]!==void 0);if(s.length!==1)throw new i("Provide exactly one of requestHash, agentId or validator.");let r=typeof e.limit=="number"?Math.min(Math.max(1,Math.trunc(e.limit)),100):25,a=async n=>{let y=n.slice(-r).reverse(),B=await Promise.all(y.map(async k=>{let O=await p(t,k);return O?H(k,O):{requestHash:k,unavailable:!0}}));return{requestsTotal:n.length,requests:B,truncated:n.length>y.length,newestFirst:!0}};if(s[0]==="requestHash"){let n=g(e.requestHash,"requestHash"),y=await p(t,n);if(!y)throw new i("No validation request has that requestHash.");return{registry:t,...H(n,y)}}if(s[0]==="validator")return{registry:t,validator:q(e.validator,"validator"),...await a(await w(t,"getValidatorRequests",[q(e.validator,"validator")]))};let u=T(e.agentId),l=Array.isArray(e.validators)?e.validators.map(n=>q(n,"validator")):[],h=S(e.tag,"tag",128),[c,o]=await Promise.all([w(t,"getAgentValidations",[u]),w(t,"getSummary",[u,l,h])]);return{registry:t,agentId:u.toString(),answeredCount:o[0].toString(),averageResponse:o[0]===0n?null:o[1],...await a(c),note:"The average counts only answered requests and includes whatever validators were asked; judge a result by who the validator is."}});return{tools:[W,Z,z]}};export{ae as a};
1
+ import{d as P,e as E,f,h as M,j as b,k as V,l as T,m as q,n as j,o as g,p as S,q as x,t as F,w as U,z as $}from"./TWSTOFN3.js";import{c as m}from"./X5V2Z2NM.js";import{a as _}from"./6IM6A5VA.js";import{c as R,g as v}from"./73N3TOJL.js";import{a as i}from"./5YS5V2LK.js";import{a as I}from"./JXOEJPJ4.js";import{encodeFunctionData as N,keccak256 as G,toBytes as L}from"viem";var D=`0x${"00".repeat(32)}`,ae=d=>{let A=(e,t,s)=>({name:e,inputSchema:t,execute:async(r,a)=>{try{return _(a),j(d,r.chainId),await s(r,a)}catch(u){throw new i(d.plainError(u))}}}),C={transactionHash:{...E,description:"After local submission, repeat the same arguments with the mined hash to verify calldata, event and registry state."}},w=(e,t,s)=>d.clientFor(M(d).chainId).readContract({address:e,abi:m,functionName:t,args:s}),p=async(e,t)=>{try{return await w(e,"getValidationStatus",[t])}catch{return}},H=(e,t)=>({requestHash:e,validator:t[0],agentId:t[1].toString(),response:t[2],responseHash:t[3],tag:I(t[4]),lastUpdate:t[5].toString(),possiblyUnanswered:t[2]===0&&t[3]===D&&t[4]===""}),W=A("erc8004_validation_request",{type:"object",additionalProperties:!1,required:["agentId","validator","requestURI"],description:"Ask a validator (re-execution staker, zkML verifier, TEE oracle, judge) to check an agent's work (Validation Registry validationRequest). Owner or approved operator only.",properties:{agentId:P,validator:{...R,description:"The validator contract or wallet that will respond."},requestURI:{type:"string",description:"HTTPS/IPFS URI of the data the validator needs (inputs and outputs)."},requestHash:{...f,description:"keccak256 commitment to the request payload; provide this or requestContent."},requestContent:{type:"string",description:"The exact request payload text; Oak commits its keccak256 as requestHash."},...C}},async(e,t)=>{let{address:s}=b(d),r=T(e.agentId),a=q(e.validator,"validator");if(V(a))throw new i("Provide a real validator address.");let u=x(e.requestURI,"requestURI");if(e.requestHash===void 0==(e.requestContent===void 0))throw new i("Provide exactly one of requestHash or requestContent.");let l=e.requestHash!==void 0?g(e.requestHash,"requestHash"):G(L(S(e.requestContent,"requestContent",1e6,!1)));return $(d,t,e,{to:s,data:N({abi:m,functionName:"validationRequest",args:[a,r,u,l]}),description:`Request validation of ERC-8004 agent ${r} by ${a}.`,summary:`Asks ${a} to validate agent ${r}'s work: request ${l}, data at ${I(u)}. The request is public and permanent. Only the named validator can respond. Repeat with transactionHash to verify.`,authority:async()=>{if(await F(d,r,t,"request validation"),await p(s,l))throw new i("A validation request with that requestHash already exists; use a different payload commitment.")},verify:async h=>{let c=U(h,s,m,"ValidationRequest"),o=await p(s,l);if(!o||!v(String(c.validatorAddress),a)||c.agentId!==r||c.requestHash!==l||o[1]!==r||!v(o[0],a))throw new i("The registry event or stored request does not match.");return{...H(l,o),confirmed:!0}}})}),Z=A("erc8004_validation_response",{type:"object",additionalProperties:!1,required:["requestHash","response"],description:"As the named validator, record a validation result from 0 (failed) to 100 (passed) for a request. May be called again to update.",properties:{requestHash:f,response:{type:"integer",minimum:0,maximum:100},responseURI:{type:"string",description:"Optional HTTPS/IPFS evidence or audit URI."},responseHash:{...f,description:"Optional commitment to the evidence content."},tag:{type:"string",description:"Optional category, e.g. soft-finality / hard-finality."},...C}},async(e,t)=>{let{address:s}=b(d),r=g(e.requestHash,"requestHash"),a=e.response;if(typeof a!="number"||!Number.isInteger(a)||a<0||a>100)throw new i("response must be an integer from 0 to 100.");let u=e.responseURI===void 0?"":x(e.responseURI,"responseURI"),l=e.responseHash===void 0?D:g(e.responseHash,"responseHash"),h=S(e.tag,"tag",128);return $(d,t,e,{to:s,data:N({abi:m,functionName:"validationResponse",args:[r,a,u,l,h]}),description:`Respond ${a}/100 to validation request ${r}.`,summary:`Records validation result ${a}/100${h?` (tag ${I(h)})`:""} for request ${r} as this wallet. It is public; a later response replaces the stored result but the event history stays. Repeat with transactionHash to verify.`,authority:async()=>{let c=await p(s,r);if(!c)throw new i("No validation request has that requestHash.");if(!v(c[0],t))throw new i("Only the validator named in the request can respond to it.")},verify:async c=>{let o=U(c,s,m,"ValidationResponse"),n=await p(s,r);if(!n||o.requestHash!==r||o.response!==a||!v(String(o.validatorAddress),t)||n[2]!==a)throw new i("The registry event or stored result does not match.");return{...H(r,n),confirmed:!0}}})}),z=A("erc8004_validation",{type:"object",additionalProperties:!1,description:"Read-only validation lookups. Provide exactly one of requestHash (one request), agentId (its requests and average) or validator (requests addressed to it).",properties:{requestHash:f,agentId:P,validator:R,validators:{type:"array",maxItems:50,items:R,description:"With agentId: average only these validators."},tag:{type:"string",description:"With agentId: average only this tag."},limit:{type:"integer",minimum:1,maximum:100,default:25}}},async e=>{let{address:t}=b(d),s=["requestHash","agentId","validator"].filter(n=>e[n]!==void 0);if(s.length!==1)throw new i("Provide exactly one of requestHash, agentId or validator.");let r=typeof e.limit=="number"?Math.min(Math.max(1,Math.trunc(e.limit)),100):25,a=async n=>{let y=n.slice(-r).reverse(),B=await Promise.all(y.map(async k=>{let O=await p(t,k);return O?H(k,O):{requestHash:k,unavailable:!0}}));return{requestsTotal:n.length,requests:B,truncated:n.length>y.length,newestFirst:!0}};if(s[0]==="requestHash"){let n=g(e.requestHash,"requestHash"),y=await p(t,n);if(!y)throw new i("No validation request has that requestHash.");return{registry:t,...H(n,y)}}if(s[0]==="validator")return{registry:t,validator:q(e.validator,"validator"),...await a(await w(t,"getValidatorRequests",[q(e.validator,"validator")]))};let u=T(e.agentId),l=Array.isArray(e.validators)?e.validators.map(n=>q(n,"validator")):[],h=S(e.tag,"tag",128),[c,o]=await Promise.all([w(t,"getAgentValidations",[u]),w(t,"getSummary",[u,l,h])]);return{registry:t,agentId:u.toString(),answeredCount:o[0].toString(),averageResponse:o[0]===0n?null:o[1],...await a(c),note:"The average counts only answered requests and includes whatever validators were asked; judge a result by who the validator is."}});return{tools:[W,Z,z]}};export{ae as a};
@@ -1 +1 @@
1
- import{d as S,e as G,f as M,h as U,i as x,l as T,m as C,n as L,o as B,p as I,q as j,w as D,z as _}from"./2EDXKJ3B.js";import{a as O,b as h}from"./X5V2Z2NM.js";import{a as N}from"./6IM6A5VA.js";import{c as F,g as A}from"./73N3TOJL.js";import{a as p}from"./5YS5V2LK.js";import{a as $}from"./JXOEJPJ4.js";import{encodeFunctionData as q}from"viem";var z=10n**38n,W=`0x${"00".repeat(32)}`;function E(s,g){let k=s<0n,l=(k?-s:s).toString().padStart(g+1,"0"),P=l.slice(0,l.length-g),v=g?l.slice(l.length-g).replace(/0+$/,""):"";return`${k?"-":""}${P}${v?`.${v}`:""}`}var ie=s=>{let g=(e,a,i)=>({name:e,inputSchema:a,execute:async(t,n)=>{try{return N(n),L(s,t.chainId),await i(t,n)}catch(r){throw new p(s.plainError(r))}}}),k={transactionHash:{...G,description:"After local submission, repeat the same arguments with the mined hash to verify calldata, event and registry state."}},l=(e,a,i)=>s.clientFor(U(s).chainId).readContract({address:e,abi:h,functionName:a,args:i});async function P(e){let{chainId:a,registry:i}=U(s),t=await s.clientFor(a).readContract({address:i,abi:O,functionName:"ownerOf",args:[e]});return N(t),t}let v=e=>{if(typeof e!="string"||!/^[1-9][0-9]{0,18}$/.test(e)||BigInt(e)>=2n**64n)throw new p("Provide feedbackIndex as a decimal integer string of at least 1 (indexes are 1-based).");return BigInt(e)},X=g("erc8004_give_feedback",{type:"object",additionalProperties:!1,required:["agentId","value"],description:"Post public, permanent-by-hash feedback about an agent (ERC-8004 Reputation Registry giveFeedback). You cannot rate an agent you own or operate.",properties:{agentId:S,value:{type:"string",pattern:"^-?[0-9]+$",description:'Signed integer in fixed point, e.g. "87" with valueDecimals 0 is 87; "9977" with valueDecimals 2 is 99.77.'},valueDecimals:{type:"integer",minimum:0,maximum:18,default:0},tag1:{type:"string",description:"Optional filter tag such as starred, uptime, successRate, responseTime."},tag2:{type:"string"},endpoint:{type:"string",description:"Optional endpoint the feedback is about."},feedbackURI:{type:"string",description:"Optional HTTPS/IPFS URI of an off-chain feedback file."},feedbackHash:{...M,description:"keccak256 of the feedbackURI content; optional for IPFS, recommended for HTTPS."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId);if(typeof e.value!="string"||!/^-?[0-9]+$/.test(e.value))throw new p("Provide value as a signed integer string.");let n=BigInt(e.value);if(n>z||n<-z)throw new p("The feedback value is out of range (\xB11e38).");let r=e.valueDecimals===void 0?0:e.valueDecimals;if(typeof r!="number"||!Number.isInteger(r)||r<0||r>18)throw new p("valueDecimals must be an integer from 0 to 18.");let o=I(e.tag1,"tag1",128),b=I(e.tag2,"tag2",128),u=e.endpoint===void 0?"":I(e.endpoint,"endpoint",2048),f=e.feedbackURI===void 0?"":j(e.feedbackURI,"feedbackURI"),w=e.feedbackHash===void 0?W:B(e.feedbackHash,"feedbackHash"),R=q({abi:h,functionName:"giveFeedback",args:[t,n,r,o,b,u,f,w]});return _(s,a,e,{to:i,data:R,description:`Give feedback ${e.value}e-${r} to ERC-8004 agent ${t}.`,summary:`Publishes feedback ${E(n,r)} about agent ${t}${o?` (tag ${$(o)})`:""} from this wallet. Feedback is public and attributable to this wallet; it can be revoked later but never erased. Repeat with transactionHash to read back the feedback index.`,authority:async()=>{await P(t);let{registry:m,chainId:d}=U(s);if(await s.clientFor(d).readContract({address:m,abi:O,functionName:"isAuthorizedOrOwner",args:[a,t]})===!0)throw new p("The registry refuses feedback from the owner or an approved operator of the same agent.")},verify:async m=>{let d=D(m,i,h,"NewFeedback"),c=d.feedbackIndex,H=await l(i,"readFeedback",[t,a,c]);if(d.agentId!==t||!A(String(d.clientAddress),a)||d.value!==n||H[0]!==n||H[4])throw new p("The registry event or stored feedback does not match.");return{agentId:t.toString(),feedbackIndex:c.toString(),value:E(n,r),confirmed:!0}}})}),Y=g("erc8004_revoke_feedback",{type:"object",additionalProperties:!1,required:["agentId","feedbackIndex"],properties:{agentId:S,feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"1-based index from erc8004_give_feedback or erc8004_reputation."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId),n=v(e.feedbackIndex);return _(s,a,e,{to:i,data:q({abi:h,functionName:"revokeFeedback",args:[t,n]}),description:`Revoke feedback #${n} on ERC-8004 agent ${t}.`,summary:`Marks your feedback #${n} about agent ${t} as revoked. The original entry stays on-chain, flagged revoked. Repeat with transactionHash to verify.`,authority:async()=>{let r=await l(i,"getLastIndex",[t,a]);if(n>r)throw new p(`This wallet has given only ${r} feedback entries on agent ${t}.`);if((await l(i,"readFeedback",[t,a,n]))[4])throw new p("That feedback is already revoked.")},verify:async r=>{let o=D(r,i,h,"FeedbackRevoked"),b=await l(i,"readFeedback",[t,a,n]);if(o.agentId!==t||o.feedbackIndex!==n||!A(String(o.clientAddress),a)||!b[4])throw new p("The registry event or stored feedback does not show a revocation.");return{agentId:t.toString(),feedbackIndex:n.toString(),revoked:!0}}})}),Z=g("erc8004_append_response",{type:"object",additionalProperties:!1,required:["agentId","clientAddress","feedbackIndex","responseURI"],description:"Append a public response to a feedback entry (the agent showing a refund, or anyone tagging spam).",properties:{agentId:S,clientAddress:{...F,description:"The wallet that gave the feedback."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$"},responseURI:{type:"string",description:"HTTPS or IPFS URI of the response file."},responseHash:{...M,description:"keccak256 of the response content; optional for IPFS."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId),n=C(e.clientAddress,"clientAddress"),r=v(e.feedbackIndex),o=j(e.responseURI,"responseURI"),b=e.responseHash===void 0?W:B(e.responseHash,"responseHash");return _(s,a,e,{to:i,data:q({abi:h,functionName:"appendResponse",args:[t,n,r,o,b]}),description:`Append a response to feedback #${r} by ${n} on ERC-8004 agent ${t}.`,summary:`Publishes a response (${$(o)}) under feedback #${r} that ${n} gave agent ${t}, attributed to this wallet. Responses are append-only. Repeat with transactionHash to verify.`,authority:async()=>{let u=await l(i,"getLastIndex",[t,n]);if(r>u)throw new p(`${n} has given only ${u} feedback entries on agent ${t}.`)},verify:async u=>{let f=D(u,i,h,"ResponseAppended");if(f.agentId!==t||f.feedbackIndex!==r||!A(String(f.clientAddress),n)||!A(String(f.responder),a)||f.responseURI!==o)throw new p("The registry event does not match the response.");return{agentId:t.toString(),clientAddress:n,feedbackIndex:r.toString(),responder:a,confirmed:!0}}})}),J=g("erc8004_reputation",{type:"object",additionalProperties:!1,required:["agentId"],description:"Read-only: an agent's feedback summary and entries. Pass the reviewers you trust in clients; without it the summary counts every wallet, which anyone can spam.",properties:{agentId:S,clients:{type:"array",maxItems:200,items:F,description:"Reviewer wallets to count (recommended)."},tag1:{type:"string"},tag2:{type:"string"},includeRevoked:{type:"boolean",default:!1},limit:{type:"integer",minimum:1,maximum:200,default:50},clientAddress:{...F,description:"With feedbackIndex: also count responses to that one entry."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$"}}},async e=>{let{address:a}=x(s),i=T(e.agentId);await P(i);let t=I(e.tag1,"tag1",128),n=I(e.tag2,"tag2",128),r=typeof e.limit=="number"?Math.min(Math.max(1,Math.trunc(e.limit)),200):50,o=Array.isArray(e.clients)?e.clients.map(d=>C(d,"client")):void 0;if(o&&o.length>200)throw new p("Provide at most 200 reviewer wallets.");let b=o??await l(a,"getClients",[i]),u=b.slice(0,200),f={count:"0",value:"0",valueDecimals:0},w=[],R=0;if(u.length){let[d,c]=await Promise.all([l(a,"getSummary",[i,u,t,n]),l(a,"readAllFeedback",[i,u,t,n,e.includeRevoked===!0])]);f={count:d[0].toString(),value:E(d[1],d[2]),valueDecimals:d[2]},R=c[0].length,w=c[0].slice(0,r).map((H,y)=>({clientAddress:H,feedbackIndex:c[1][y].toString(),value:E(c[2][y],c[3][y]),valueDecimals:c[3][y],tag1:$(c[4][y]),tag2:$(c[5][y]),revoked:c[6][y]}))}let m;if(e.clientAddress!==void 0){let d=C(e.clientAddress,"clientAddress"),c=e.feedbackIndex===void 0?0n:v(e.feedbackIndex);m=(await l(a,"getResponseCount",[i,d,c,[]])).toString()}return{agentId:i.toString(),registry:a,clientsTotal:b.length,clientsUsed:u.length,filteredByClients:o!==void 0,summary:f,feedback:w,feedbackTotal:R,truncated:R>w.length||b.length>u.length,...m===void 0?{}:{responseCount:m},note:o?"Summary counts only the reviewers you named.":"Unfiltered: every reviewer wallet counts, and anyone can post feedback for free, so a high score is not evidence. Name trusted reviewers in clients for a meaningful score."}});return{tools:[X,Y,Z,J]}};export{E as a,ie as b};
1
+ import{d as S,e as G,f as M,h as U,i as x,l as T,m as C,n as L,o as B,p as I,q as j,w as D,z as _}from"./TWSTOFN3.js";import{a as O,b as h}from"./X5V2Z2NM.js";import{a as N}from"./6IM6A5VA.js";import{c as F,g as A}from"./73N3TOJL.js";import{a as p}from"./5YS5V2LK.js";import{a as $}from"./JXOEJPJ4.js";import{encodeFunctionData as q}from"viem";var z=10n**38n,W=`0x${"00".repeat(32)}`;function E(s,g){let k=s<0n,l=(k?-s:s).toString().padStart(g+1,"0"),P=l.slice(0,l.length-g),v=g?l.slice(l.length-g).replace(/0+$/,""):"";return`${k?"-":""}${P}${v?`.${v}`:""}`}var ie=s=>{let g=(e,a,i)=>({name:e,inputSchema:a,execute:async(t,n)=>{try{return N(n),L(s,t.chainId),await i(t,n)}catch(r){throw new p(s.plainError(r))}}}),k={transactionHash:{...G,description:"After local submission, repeat the same arguments with the mined hash to verify calldata, event and registry state."}},l=(e,a,i)=>s.clientFor(U(s).chainId).readContract({address:e,abi:h,functionName:a,args:i});async function P(e){let{chainId:a,registry:i}=U(s),t=await s.clientFor(a).readContract({address:i,abi:O,functionName:"ownerOf",args:[e]});return N(t),t}let v=e=>{if(typeof e!="string"||!/^[1-9][0-9]{0,18}$/.test(e)||BigInt(e)>=2n**64n)throw new p("Provide feedbackIndex as a decimal integer string of at least 1 (indexes are 1-based).");return BigInt(e)},X=g("erc8004_give_feedback",{type:"object",additionalProperties:!1,required:["agentId","value"],description:"Post public, permanent-by-hash feedback about an agent (ERC-8004 Reputation Registry giveFeedback). You cannot rate an agent you own or operate.",properties:{agentId:S,value:{type:"string",pattern:"^-?[0-9]+$",description:'Signed integer in fixed point, e.g. "87" with valueDecimals 0 is 87; "9977" with valueDecimals 2 is 99.77.'},valueDecimals:{type:"integer",minimum:0,maximum:18,default:0},tag1:{type:"string",description:"Optional filter tag such as starred, uptime, successRate, responseTime."},tag2:{type:"string"},endpoint:{type:"string",description:"Optional endpoint the feedback is about."},feedbackURI:{type:"string",description:"Optional HTTPS/IPFS URI of an off-chain feedback file."},feedbackHash:{...M,description:"keccak256 of the feedbackURI content; optional for IPFS, recommended for HTTPS."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId);if(typeof e.value!="string"||!/^-?[0-9]+$/.test(e.value))throw new p("Provide value as a signed integer string.");let n=BigInt(e.value);if(n>z||n<-z)throw new p("The feedback value is out of range (\xB11e38).");let r=e.valueDecimals===void 0?0:e.valueDecimals;if(typeof r!="number"||!Number.isInteger(r)||r<0||r>18)throw new p("valueDecimals must be an integer from 0 to 18.");let o=I(e.tag1,"tag1",128),b=I(e.tag2,"tag2",128),u=e.endpoint===void 0?"":I(e.endpoint,"endpoint",2048),f=e.feedbackURI===void 0?"":j(e.feedbackURI,"feedbackURI"),w=e.feedbackHash===void 0?W:B(e.feedbackHash,"feedbackHash"),R=q({abi:h,functionName:"giveFeedback",args:[t,n,r,o,b,u,f,w]});return _(s,a,e,{to:i,data:R,description:`Give feedback ${e.value}e-${r} to ERC-8004 agent ${t}.`,summary:`Publishes feedback ${E(n,r)} about agent ${t}${o?` (tag ${$(o)})`:""} from this wallet. Feedback is public and attributable to this wallet; it can be revoked later but never erased. Repeat with transactionHash to read back the feedback index.`,authority:async()=>{await P(t);let{registry:m,chainId:d}=U(s);if(await s.clientFor(d).readContract({address:m,abi:O,functionName:"isAuthorizedOrOwner",args:[a,t]})===!0)throw new p("The registry refuses feedback from the owner or an approved operator of the same agent.")},verify:async m=>{let d=D(m,i,h,"NewFeedback"),c=d.feedbackIndex,H=await l(i,"readFeedback",[t,a,c]);if(d.agentId!==t||!A(String(d.clientAddress),a)||d.value!==n||H[0]!==n||H[4])throw new p("The registry event or stored feedback does not match.");return{agentId:t.toString(),feedbackIndex:c.toString(),value:E(n,r),confirmed:!0}}})}),Y=g("erc8004_revoke_feedback",{type:"object",additionalProperties:!1,required:["agentId","feedbackIndex"],properties:{agentId:S,feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"1-based index from erc8004_give_feedback or erc8004_reputation."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId),n=v(e.feedbackIndex);return _(s,a,e,{to:i,data:q({abi:h,functionName:"revokeFeedback",args:[t,n]}),description:`Revoke feedback #${n} on ERC-8004 agent ${t}.`,summary:`Marks your feedback #${n} about agent ${t} as revoked. The original entry stays on-chain, flagged revoked. Repeat with transactionHash to verify.`,authority:async()=>{let r=await l(i,"getLastIndex",[t,a]);if(n>r)throw new p(`This wallet has given only ${r} feedback entries on agent ${t}.`);if((await l(i,"readFeedback",[t,a,n]))[4])throw new p("That feedback is already revoked.")},verify:async r=>{let o=D(r,i,h,"FeedbackRevoked"),b=await l(i,"readFeedback",[t,a,n]);if(o.agentId!==t||o.feedbackIndex!==n||!A(String(o.clientAddress),a)||!b[4])throw new p("The registry event or stored feedback does not show a revocation.");return{agentId:t.toString(),feedbackIndex:n.toString(),revoked:!0}}})}),Z=g("erc8004_append_response",{type:"object",additionalProperties:!1,required:["agentId","clientAddress","feedbackIndex","responseURI"],description:"Append a public response to a feedback entry (the agent showing a refund, or anyone tagging spam).",properties:{agentId:S,clientAddress:{...F,description:"The wallet that gave the feedback."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$"},responseURI:{type:"string",description:"HTTPS or IPFS URI of the response file."},responseHash:{...M,description:"keccak256 of the response content; optional for IPFS."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId),n=C(e.clientAddress,"clientAddress"),r=v(e.feedbackIndex),o=j(e.responseURI,"responseURI"),b=e.responseHash===void 0?W:B(e.responseHash,"responseHash");return _(s,a,e,{to:i,data:q({abi:h,functionName:"appendResponse",args:[t,n,r,o,b]}),description:`Append a response to feedback #${r} by ${n} on ERC-8004 agent ${t}.`,summary:`Publishes a response (${$(o)}) under feedback #${r} that ${n} gave agent ${t}, attributed to this wallet. Responses are append-only. Repeat with transactionHash to verify.`,authority:async()=>{let u=await l(i,"getLastIndex",[t,n]);if(r>u)throw new p(`${n} has given only ${u} feedback entries on agent ${t}.`)},verify:async u=>{let f=D(u,i,h,"ResponseAppended");if(f.agentId!==t||f.feedbackIndex!==r||!A(String(f.clientAddress),n)||!A(String(f.responder),a)||f.responseURI!==o)throw new p("The registry event does not match the response.");return{agentId:t.toString(),clientAddress:n,feedbackIndex:r.toString(),responder:a,confirmed:!0}}})}),J=g("erc8004_reputation",{type:"object",additionalProperties:!1,required:["agentId"],description:"Read-only: an agent's feedback summary and entries. Pass the reviewers you trust in clients; without it the summary counts every wallet, which anyone can spam.",properties:{agentId:S,clients:{type:"array",maxItems:200,items:F,description:"Reviewer wallets to count (recommended)."},tag1:{type:"string"},tag2:{type:"string"},includeRevoked:{type:"boolean",default:!1},limit:{type:"integer",minimum:1,maximum:200,default:50},clientAddress:{...F,description:"With feedbackIndex: also count responses to that one entry."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$"}}},async e=>{let{address:a}=x(s),i=T(e.agentId);await P(i);let t=I(e.tag1,"tag1",128),n=I(e.tag2,"tag2",128),r=typeof e.limit=="number"?Math.min(Math.max(1,Math.trunc(e.limit)),200):50,o=Array.isArray(e.clients)?e.clients.map(d=>C(d,"client")):void 0;if(o&&o.length>200)throw new p("Provide at most 200 reviewer wallets.");let b=o??await l(a,"getClients",[i]),u=b.slice(0,200),f={count:"0",value:"0",valueDecimals:0},w=[],R=0;if(u.length){let[d,c]=await Promise.all([l(a,"getSummary",[i,u,t,n]),l(a,"readAllFeedback",[i,u,t,n,e.includeRevoked===!0])]);f={count:d[0].toString(),value:E(d[1],d[2]),valueDecimals:d[2]},R=c[0].length,w=c[0].slice(0,r).map((H,y)=>({clientAddress:H,feedbackIndex:c[1][y].toString(),value:E(c[2][y],c[3][y]),valueDecimals:c[3][y],tag1:$(c[4][y]),tag2:$(c[5][y]),revoked:c[6][y]}))}let m;if(e.clientAddress!==void 0){let d=C(e.clientAddress,"clientAddress"),c=e.feedbackIndex===void 0?0n:v(e.feedbackIndex);m=(await l(a,"getResponseCount",[i,d,c,[]])).toString()}return{agentId:i.toString(),registry:a,clientsTotal:b.length,clientsUsed:u.length,filteredByClients:o!==void 0,summary:f,feedback:w,feedbackTotal:R,truncated:R>w.length||b.length>u.length,...m===void 0?{}:{responseCount:m},note:o?"Summary counts only the reviewers you named.":"Unfiltered: every reviewer wallet counts, and anyone can post feedback for free, so a high score is not evidence. Name trusted reviewers in clients for a meaningful score."}});return{tools:[X,Y,Z,J]}};export{E as a,ie as b};
@@ -1 +1 @@
1
- import{d as n,f as a,g as s,h as l,i as u}from"./EC5W3UZD.js";import{c as e}from"./46ZA2R5L.js";var m="In-kind exits are a separate unsupported flow.";function b(t,i){return n(t,i,e)}function V(t,i,o,r,x,p){return a(t,i,o,r,x,p,e)}function A(t,i,o){return s(t,i,o,e,m)}function P(t){return l(t,e.symbol)}function S(t,i,o,r){u(t,i,o,r,e)}export{b as a,V as b,A as c,P as d,S as e};
1
+ import{d as n,f as a,g as s,h as l,i as u}from"./AMICUXS6.js";import{c as e}from"./JPOYTTTW.js";var m="In-kind exits are a separate unsupported flow.";function b(t,i){return n(t,i,e)}function V(t,i,o,r,x,p){return a(t,i,o,r,x,p,e)}function A(t,i,o){return s(t,i,o,e,m)}function P(t){return l(t,e.symbol)}function S(t,i,o,r){u(t,i,o,r,e)}export{b as a,V as b,A as c,P as d,S as e};
@@ -1 +1 @@
1
- import{a as M}from"./NCQFWPAW.js";import{a as v}from"./65QFM4JU.js";import{K as A}from"./JC4SYMBV.js";import{c as k}from"./46ZA2R5L.js";import{a as $}from"./6IM6A5VA.js";import{a as x}from"./UWOFA6GV.js";import{d as F,g as U,i as _}from"./73N3TOJL.js";import{a as N}from"./XPFVT2EA.js";import{a as n}from"./5YS5V2LK.js";import{encodeFunctionData as H,erc20Abi as P,getAddress as y,zeroAddress as q}from"viem";var B={genesis:y("0x575b7B7c97Ef3E21C82DAeB427899d583e1E913f"),bond:y("0xff32a969A0c567129eECD926D04657728E1980C1"),inverse:y("0x92166e94Eea5B7799b761653881692f881dFC4C9"),treasury:y("0x04822Ea321A0DEE6F40656172F29312104855d66"),pteam:y("0x650F58079dAa17ee28928c2F92d22291d038B2B0"),rwa:y("0x99B6eE6eDe47d9a8a9bfd03F728a99B789df1961"),premium:y("0x346e1a31171A0f7aC73909010b5435768d3B5462"),tax:y("0x086C58400b8708Ef993f256E12e752dcF0AC918e")},j=y("0x59F95461E68e0c77605299791E1449f175165B54"),D={genesis:["purchase","finalize","refund","claim"],bond:["deposit","redeem"],inverse:["swap"],treasury:["rebalanceToMorpho","rebalanceFromMorpho","mintNet","spendUsdg"],pteam:["exercise"],rwa:["redeem","depositInventory","pokeHwm","setDiscount","setInventoryMax","setHalt","setMenu","skim"],premium:["execute"],tax:["convert"]},G={genesis:["wired","finalized","finalizeTime","saleStart","saleDeadline","raisedRaw","totalRaised","registryLength"],bond:["wired","enabled","startTime","marketCount"],inverse:["active","price","capacityRemaining","spreadBps"],treasury:["wired","rfv","backingPerToken","liquidUsdg","morphoAssets","polRfv","morphoCapBps","morphoVault","canonicalPair"],pteam:["wired","holder","vestedFraction","exercisableNow","exercised","strikeWad","capBps","circulatingSupply","excludedFromFloat"],rwa:["manager","halted","inventory","inventoryMax","owedNet","bHwm","deskDiscountBps","VEST","MAX_DISCOUNT_BPS","INVENTORY_HARD_CAP","menu","routerSource","sleeve"],premium:["active","clipSize","lastExecuteAt","premiumThresholdWad","router","pairContract"],tax:["wired","pendingNet","teamBps","treasuryBps","teamWallet","router","pairContract"]},T=b=>JSON.parse(JSON.stringify(b,(S,I)=>typeof I=="bigint"?I.toString():I));function h(b){return _(b,"Provide a checksummed address.",F)}var ne=b=>{async function S(t){if(typeof t!="string"||!Object.hasOwn(B,t))throw new n("Choose a published NetNet financial product.");let c=t,e=B[c],d=M[c],m=b.clientFor(N);if(await m.getChainId()!==N)throw new n("NetNet requires chain 4663.");let a=await m.getBlock(),s=(g,E=[])=>m.readContract({address:e,abi:d,functionName:g,args:E,blockNumber:a.number}),[i,o,p,f]=await Promise.all([s("net"),s("usdg"),m.readContract({address:v.address,abi:P,functionName:"decimals",blockNumber:a.number}),m.readContract({address:k.address,abi:P,functionName:"decimals",blockNumber:a.number})]);if(h(i)!==v.address||h(o)!==k.address||p!==v.decimals||f!==k.decimals)throw new n("NetNet financial token pins or decimals do not match the deployment.");return{product:c,contract:e,abi:d,rpc:m,block:a,read:s}}let I=(t,c,e,d)=>({name:t,inputSchema:{type:"object",properties:c,required:e,additionalProperties:!1},execute:async(m,a)=>{try{if($(a),Object.keys(m).some(s=>!Object.hasOwn(c,s)))throw new n("Unsupported NetNet financial argument.");return await d(m,a)}catch(s){throw new n(b.plainError(s))}}}),C={type:"string",enum:Object.keys(B)};return{tools:[I("netnet_financial_status",{product:C,offset:{type:"integer",minimum:0},limit:{type:"integer",minimum:1,maximum:50}},["product"],async(t,c)=>{let e=await S(t.product),d=G[e.product],m=t.offset??0,a=t.limit??20;if(!Number.isSafeInteger(m)||Number(m)<0||!Number.isSafeInteger(a)||Number(a)<1||Number(a)>50)throw new n("Use a nonnegative offset and limit 1..50.");let s=await Promise.all(d.map(async o=>{try{return[o,{value:T(await e.read(o))}]}catch(p){return[o,{unavailable:b.plainError(p)}]}})),i={};if(e.product==="genesis")for(let o of["purchasedRaw","purchasedNetOf","claimedNet","claimableNetOf"])i[o]=T(await e.read(o,[c]));if(e.product==="bond"||e.product==="rwa"){i.pending=T(await e.read("pendingFor",[c]));let o=await e.read("noteCount",[c]);if(typeof o!="bigint"||o<0n)throw new n("Invalid NetNet note count.");let p=o<BigInt(Number(m)+Number(a))?o:BigInt(Number(m)+Number(a));i.noteCount=o.toString(),i.notes=await Promise.all(Array.from({length:Math.max(0,Number(p-BigInt(Number(m))))},async(f,g)=>({id:String(Number(m)+g),note:T(await e.read(e.product==="bond"?"notes":"noteAt",[c,BigInt(Number(m)+g)]))}))),i.nextOffset=p<o?p.toString():null,e.product==="bond"&&(i.markets=await Promise.all([0n,1n].map(async f=>{try{return{id:f.toString(),quoteToken:h(await e.read("quoteToken",[f])),priceWad:String(await e.read("bondPrice",[f]))}}catch(g){return{id:f.toString(),unavailable:b.plainError(g)}}})))}return e.product==="treasury"&&(i.isMinter=await e.read("isMinter",[c]),i.isSpender=await e.read("isSpender",[c])),{chainId:N,contract:e.contract,product:e.product,blockNumber:String(e.block.number),tokens:[v,k],metrics:Object.fromEntries(s),wallet:i,units:"Raw token amounts use each token\u2019s decimals. Prices, NAV, reserve values and capacityRemaining use 18-decimal USDG WAD. Note timestamps are Unix seconds.",operations:D[e.product],caveat:"An unavailable metric is not zero. Formulaic eligibility, oracle liveness, caps and vesting are checked by the action preview. RWA entry/router calldata and initial deployment wiring remain unsupported."}}),I("netnet_financial_action",{product:C,operation:{type:"string",enum:[...new Set(Object.values(D).flat())]},amount:x(),minAmountOut:x(),maxPriceWad:x(),maxPayment:x(),marketId:{type:"integer",enum:[0,1]},recipient:{type:"string"},halted:{type:"boolean"},token:{type:"string"},noteIds:{type:"array",maxItems:50,items:x()},menu:{type:"array",maxItems:32,items:{type:"object"}}},["product","operation"],async(t,c)=>{let e=await S(t.product),d=t.operation;if(typeof d!="string"||!D[e.product].includes(d))throw new n("This operation is not supported by the selected financial product.");let m=new Set(["product","operation"]),a=[],s,i=0n,o="",p=(...r)=>r.forEach(u=>m.add(u)),f=()=>(p("amount"),A(t.amount)),g=()=>(p("minAmountOut"),A(t.minAmountOut));if(e.product==="genesis"){if(d==="purchase"&&(i=f(),s=k,a=[i],o="Founding subscription; NET is claimable only after successful finalization and vesting. A failed sale requires refund."),d==="claim"&&await e.read("claimableNetOf",[c])===0n)throw new n("No vested founding NET is claimable by this wallet.")}else if(e.product==="bond")if(d==="deposit"){if(p("marketId","maxPriceWad"),t.marketId!==0&&t.marketId!==1)throw new n("Bond marketId must be 0 (USDG) or 1 (canonical LP).");let r=BigInt(t.marketId);if(h(await e.read("quoteToken",[r]))!==(r===0n?k.address:j))throw new n("Bond quote token is not the pinned USDG or canonical LP.");i=f(),s=r===0n?k:{address:j,decimals:18,symbol:"NET/USDG LP",chainId:N};let l=A(t.maxPriceWad),w=await e.read("bondPrice",[r]);if(typeof w!="bigint"||w===0n||w>l)throw new n("Bond price exceeds maxPriceWad or is invalid.");a=[r,i,l,c],o="Payment is exchanged for a non-transferable NET note with two-day linear vesting. Redeem vested NET with the same product; payment cannot be withdrawn."}else a=[c];else if(e.product==="inverse"){if(i=f(),s=v,a=[i,g()],o="Purchased NET is burned permanently; USDG pays directly to this wallet. Capacity is denominated in USDG WAD, not raw USDG.",await e.read("active")!==!0)throw new n("NetNet buyback is inactive: oracle, finalization or capacity is unavailable.")}else if(e.product==="pteam"){if(h(await e.read("holder"))!==y(c))throw new n("This wallet is not the immutable pTEAM holder.");let r=f();if(p("maxPayment"),r>await e.read("exercisableNow"))throw new n("The NET exercise amount exceeds the vested cap.");let u=await e.read("strikeWad");if(i=(r*u/10n**BigInt(v.decimals)+10n**12n-1n)/10n**12n,i===0n||i>A(t.maxPayment))throw new n("The exercise payment exceeds maxPayment or rounds to zero.");s=k,a=[r],o=`Exercise pays ${i} USDG base units into treasury reserves and mints ${r} NET base units to the immutable holder. No withdrawal or exercise reversal exists.`}else if(e.product==="treasury"){let r=f();if(d==="mintNet"||d==="spendUsdg"){p("recipient");let u=h(t.recipient);if(await e.read(d==="mintNet"?"isMinter":"isSpender",[c])!==!0)throw new n("This wallet lacks the fixed NetNet treasury minter/spender role.");a=[u,r],o=`Protocol treasury operation sends ${r} base units to ${u}; it does not deposit into this wallet\u2019s savings.`}else a=[r],o="Permissionless protocol reserve rebalance; assets remain owned by the NetNet treasury. The deployed fraction is constrained by the immutable cap."}else if(e.product==="rwa"){if(["depositInventory","setDiscount","setInventoryMax","setHalt","setMenu"].includes(d)&&h(await e.read("manager"))!==y(c))throw new n("This wallet lacks the immutable RWA manager role.");if(d==="redeem")if(p("noteIds"),t.noteIds===void 0)a=[c];else{if(!Array.isArray(t.noteIds)||!t.noteIds.length||t.noteIds.length>50)throw new n("Provide 1..50 unique note IDs.");let u=t.noteIds.map(w=>A(w,!0));if(new Set(u.map(String)).size!==u.length)throw new n("Note IDs must be unique.");let l=await e.read("noteCount",[c]);if(u.some(w=>w>=l))throw new n("RWA note ID is out of range.");a=[c,u]}else if(d==="setHalt"){if(p("halted"),typeof t.halted!="boolean")throw new n("Provide halted as a boolean.");a=[t.halted]}else if(d==="setMenu"){if(p("menu"),!Array.isArray(t.menu)||!t.menu.length||t.menu.length>32)throw new n("Provide 1..32 explicit RWA menu entries.");let u=t.menu.map(l=>{if(!l||typeof l!="object"||Array.isArray(l)||Object.keys(l).some(z=>!["token","feed","targetWeightBps","active"].includes(z)))throw new n("Invalid RWA menu fields.");let w=l;if(typeof w.active!="boolean")throw new n("RWA active must be boolean.");return{token:h(w.token),feed:h(w.feed),targetWeightBps:A(w.targetWeightBps,!0),active:w.active}});if(new Set(u.map(l=>l.token)).size!==u.length||u.reduce((l,w)=>l+w.targetWeightBps,0n)!==10000n||u.some(l=>l.active&&(l.token===q||l.feed===q)))throw new n("RWA menu tokens must be unique, weights sum to 10000, active feeds/tokens nonzero.");a=[u],o=`Replace the complete RWA equity menu: ${JSON.stringify(T(u))}.`}else if(d==="skim")p("token"),a=[h(t.token)],o=`Sweep eligible stray assets to sleeve ${h(await e.read("sleeve"))}, not to this wallet.`;else if(d!=="pokeHwm"){let u=f();if(a=[u],d==="depositInventory"&&(s=v,i=u,o="Inventory funding is one-way. The manager cannot withdraw these NET; they are committed to bond obligations."),d==="setDiscount"&&u>await e.read("MAX_DISCOUNT_BPS")||d==="setInventoryMax"&&u>await e.read("INVENTORY_HARD_CAP"))throw new n("RWA setting exceeds its immutable maximum.")}}else e.product==="premium"?(a=[g()],o="Permissionless mint-and-sell keeper operation; all sale proceeds go to NetNet treasury. The caller receives no reward."):(a=[f(),g()],o="Convert NET already owned by the tax collector. Proceeds split to treasury and team; the caller receives no reward and supplies no NET.");if(Object.keys(t).some(r=>!m.has(r)))throw new n("Unexpected fields for this NetNet operation.");if(s&&await e.rpc.readContract({address:s.address,abi:P,functionName:"balanceOf",args:[c],blockNumber:e.block.number})<i)throw new n(`Top up ${s.symbol}: needs ${i} base units.`);let E=`NetNet ${e.product}.${d}, contract ${e.contract}, chain ${N}, values ${JSON.stringify(T(a))}. ${s?`Approve exactly ${i} ${s.symbol} base units (${s.address}, decimals ${s.decimals}). `:""}${o}`,O=[...s?[b.approval(s.address,e.contract,i.toString(),N)]:[],b.unsignedTx({to:e.contract,data:H({abi:e.abi,functionName:d,args:a}),value:"0",chainId:N,description:E})],R=await b.preview(O,c),W=0n;for(let r of R.changes){if(!/^-?\d+$/.test(r.amount))throw new n("Invalid NetNet preview amount.");if(BigInt(r.amount)<0n&&(W-=BigInt(r.amount)),BigInt(r.amount)<0n&&(!s||r.token.chainId!==N||!U(r.token.address,s.address)||r.token.decimals!==s.decimals||-BigInt(r.amount)>i))throw new n("NetNet preview spends outside the exact input budget.")}if(W>i)throw new n("NetNet preview exceeds the aggregate input budget.");return{txs:O,preview:R,summary:E}})]}};export{B as a,j as b,ne as c};
1
+ import{a as M}from"./NCQFWPAW.js";import{a as v}from"./DCTUYDWF.js";import{K as A}from"./L3ZM77SJ.js";import{c as k}from"./JPOYTTTW.js";import{a as $}from"./6IM6A5VA.js";import{a as x}from"./UWOFA6GV.js";import{d as F,g as U,i as _}from"./73N3TOJL.js";import{a as N}from"./G6HCV67X.js";import{a as n}from"./5YS5V2LK.js";import{encodeFunctionData as H,erc20Abi as P,getAddress as y,zeroAddress as q}from"viem";var B={genesis:y("0x575b7B7c97Ef3E21C82DAeB427899d583e1E913f"),bond:y("0xff32a969A0c567129eECD926D04657728E1980C1"),inverse:y("0x92166e94Eea5B7799b761653881692f881dFC4C9"),treasury:y("0x04822Ea321A0DEE6F40656172F29312104855d66"),pteam:y("0x650F58079dAa17ee28928c2F92d22291d038B2B0"),rwa:y("0x99B6eE6eDe47d9a8a9bfd03F728a99B789df1961"),premium:y("0x346e1a31171A0f7aC73909010b5435768d3B5462"),tax:y("0x086C58400b8708Ef993f256E12e752dcF0AC918e")},j=y("0x59F95461E68e0c77605299791E1449f175165B54"),D={genesis:["purchase","finalize","refund","claim"],bond:["deposit","redeem"],inverse:["swap"],treasury:["rebalanceToMorpho","rebalanceFromMorpho","mintNet","spendUsdg"],pteam:["exercise"],rwa:["redeem","depositInventory","pokeHwm","setDiscount","setInventoryMax","setHalt","setMenu","skim"],premium:["execute"],tax:["convert"]},G={genesis:["wired","finalized","finalizeTime","saleStart","saleDeadline","raisedRaw","totalRaised","registryLength"],bond:["wired","enabled","startTime","marketCount"],inverse:["active","price","capacityRemaining","spreadBps"],treasury:["wired","rfv","backingPerToken","liquidUsdg","morphoAssets","polRfv","morphoCapBps","morphoVault","canonicalPair"],pteam:["wired","holder","vestedFraction","exercisableNow","exercised","strikeWad","capBps","circulatingSupply","excludedFromFloat"],rwa:["manager","halted","inventory","inventoryMax","owedNet","bHwm","deskDiscountBps","VEST","MAX_DISCOUNT_BPS","INVENTORY_HARD_CAP","menu","routerSource","sleeve"],premium:["active","clipSize","lastExecuteAt","premiumThresholdWad","router","pairContract"],tax:["wired","pendingNet","teamBps","treasuryBps","teamWallet","router","pairContract"]},T=b=>JSON.parse(JSON.stringify(b,(S,I)=>typeof I=="bigint"?I.toString():I));function h(b){return _(b,"Provide a checksummed address.",F)}var ne=b=>{async function S(t){if(typeof t!="string"||!Object.hasOwn(B,t))throw new n("Choose a published NetNet financial product.");let c=t,e=B[c],d=M[c],m=b.clientFor(N);if(await m.getChainId()!==N)throw new n("NetNet requires chain 4663.");let a=await m.getBlock(),s=(g,E=[])=>m.readContract({address:e,abi:d,functionName:g,args:E,blockNumber:a.number}),[i,o,p,f]=await Promise.all([s("net"),s("usdg"),m.readContract({address:v.address,abi:P,functionName:"decimals",blockNumber:a.number}),m.readContract({address:k.address,abi:P,functionName:"decimals",blockNumber:a.number})]);if(h(i)!==v.address||h(o)!==k.address||p!==v.decimals||f!==k.decimals)throw new n("NetNet financial token pins or decimals do not match the deployment.");return{product:c,contract:e,abi:d,rpc:m,block:a,read:s}}let I=(t,c,e,d)=>({name:t,inputSchema:{type:"object",properties:c,required:e,additionalProperties:!1},execute:async(m,a)=>{try{if($(a),Object.keys(m).some(s=>!Object.hasOwn(c,s)))throw new n("Unsupported NetNet financial argument.");return await d(m,a)}catch(s){throw new n(b.plainError(s))}}}),C={type:"string",enum:Object.keys(B)};return{tools:[I("netnet_financial_status",{product:C,offset:{type:"integer",minimum:0},limit:{type:"integer",minimum:1,maximum:50}},["product"],async(t,c)=>{let e=await S(t.product),d=G[e.product],m=t.offset??0,a=t.limit??20;if(!Number.isSafeInteger(m)||Number(m)<0||!Number.isSafeInteger(a)||Number(a)<1||Number(a)>50)throw new n("Use a nonnegative offset and limit 1..50.");let s=await Promise.all(d.map(async o=>{try{return[o,{value:T(await e.read(o))}]}catch(p){return[o,{unavailable:b.plainError(p)}]}})),i={};if(e.product==="genesis")for(let o of["purchasedRaw","purchasedNetOf","claimedNet","claimableNetOf"])i[o]=T(await e.read(o,[c]));if(e.product==="bond"||e.product==="rwa"){i.pending=T(await e.read("pendingFor",[c]));let o=await e.read("noteCount",[c]);if(typeof o!="bigint"||o<0n)throw new n("Invalid NetNet note count.");let p=o<BigInt(Number(m)+Number(a))?o:BigInt(Number(m)+Number(a));i.noteCount=o.toString(),i.notes=await Promise.all(Array.from({length:Math.max(0,Number(p-BigInt(Number(m))))},async(f,g)=>({id:String(Number(m)+g),note:T(await e.read(e.product==="bond"?"notes":"noteAt",[c,BigInt(Number(m)+g)]))}))),i.nextOffset=p<o?p.toString():null,e.product==="bond"&&(i.markets=await Promise.all([0n,1n].map(async f=>{try{return{id:f.toString(),quoteToken:h(await e.read("quoteToken",[f])),priceWad:String(await e.read("bondPrice",[f]))}}catch(g){return{id:f.toString(),unavailable:b.plainError(g)}}})))}return e.product==="treasury"&&(i.isMinter=await e.read("isMinter",[c]),i.isSpender=await e.read("isSpender",[c])),{chainId:N,contract:e.contract,product:e.product,blockNumber:String(e.block.number),tokens:[v,k],metrics:Object.fromEntries(s),wallet:i,units:"Raw token amounts use each token\u2019s decimals. Prices, NAV, reserve values and capacityRemaining use 18-decimal USDG WAD. Note timestamps are Unix seconds.",operations:D[e.product],caveat:"An unavailable metric is not zero. Formulaic eligibility, oracle liveness, caps and vesting are checked by the action preview. RWA entry/router calldata and initial deployment wiring remain unsupported."}}),I("netnet_financial_action",{product:C,operation:{type:"string",enum:[...new Set(Object.values(D).flat())]},amount:x(),minAmountOut:x(),maxPriceWad:x(),maxPayment:x(),marketId:{type:"integer",enum:[0,1]},recipient:{type:"string"},halted:{type:"boolean"},token:{type:"string"},noteIds:{type:"array",maxItems:50,items:x()},menu:{type:"array",maxItems:32,items:{type:"object"}}},["product","operation"],async(t,c)=>{let e=await S(t.product),d=t.operation;if(typeof d!="string"||!D[e.product].includes(d))throw new n("This operation is not supported by the selected financial product.");let m=new Set(["product","operation"]),a=[],s,i=0n,o="",p=(...r)=>r.forEach(u=>m.add(u)),f=()=>(p("amount"),A(t.amount)),g=()=>(p("minAmountOut"),A(t.minAmountOut));if(e.product==="genesis"){if(d==="purchase"&&(i=f(),s=k,a=[i],o="Founding subscription; NET is claimable only after successful finalization and vesting. A failed sale requires refund."),d==="claim"&&await e.read("claimableNetOf",[c])===0n)throw new n("No vested founding NET is claimable by this wallet.")}else if(e.product==="bond")if(d==="deposit"){if(p("marketId","maxPriceWad"),t.marketId!==0&&t.marketId!==1)throw new n("Bond marketId must be 0 (USDG) or 1 (canonical LP).");let r=BigInt(t.marketId);if(h(await e.read("quoteToken",[r]))!==(r===0n?k.address:j))throw new n("Bond quote token is not the pinned USDG or canonical LP.");i=f(),s=r===0n?k:{address:j,decimals:18,symbol:"NET/USDG LP",chainId:N};let l=A(t.maxPriceWad),w=await e.read("bondPrice",[r]);if(typeof w!="bigint"||w===0n||w>l)throw new n("Bond price exceeds maxPriceWad or is invalid.");a=[r,i,l,c],o="Payment is exchanged for a non-transferable NET note with two-day linear vesting. Redeem vested NET with the same product; payment cannot be withdrawn."}else a=[c];else if(e.product==="inverse"){if(i=f(),s=v,a=[i,g()],o="Purchased NET is burned permanently; USDG pays directly to this wallet. Capacity is denominated in USDG WAD, not raw USDG.",await e.read("active")!==!0)throw new n("NetNet buyback is inactive: oracle, finalization or capacity is unavailable.")}else if(e.product==="pteam"){if(h(await e.read("holder"))!==y(c))throw new n("This wallet is not the immutable pTEAM holder.");let r=f();if(p("maxPayment"),r>await e.read("exercisableNow"))throw new n("The NET exercise amount exceeds the vested cap.");let u=await e.read("strikeWad");if(i=(r*u/10n**BigInt(v.decimals)+10n**12n-1n)/10n**12n,i===0n||i>A(t.maxPayment))throw new n("The exercise payment exceeds maxPayment or rounds to zero.");s=k,a=[r],o=`Exercise pays ${i} USDG base units into treasury reserves and mints ${r} NET base units to the immutable holder. No withdrawal or exercise reversal exists.`}else if(e.product==="treasury"){let r=f();if(d==="mintNet"||d==="spendUsdg"){p("recipient");let u=h(t.recipient);if(await e.read(d==="mintNet"?"isMinter":"isSpender",[c])!==!0)throw new n("This wallet lacks the fixed NetNet treasury minter/spender role.");a=[u,r],o=`Protocol treasury operation sends ${r} base units to ${u}; it does not deposit into this wallet\u2019s savings.`}else a=[r],o="Permissionless protocol reserve rebalance; assets remain owned by the NetNet treasury. The deployed fraction is constrained by the immutable cap."}else if(e.product==="rwa"){if(["depositInventory","setDiscount","setInventoryMax","setHalt","setMenu"].includes(d)&&h(await e.read("manager"))!==y(c))throw new n("This wallet lacks the immutable RWA manager role.");if(d==="redeem")if(p("noteIds"),t.noteIds===void 0)a=[c];else{if(!Array.isArray(t.noteIds)||!t.noteIds.length||t.noteIds.length>50)throw new n("Provide 1..50 unique note IDs.");let u=t.noteIds.map(w=>A(w,!0));if(new Set(u.map(String)).size!==u.length)throw new n("Note IDs must be unique.");let l=await e.read("noteCount",[c]);if(u.some(w=>w>=l))throw new n("RWA note ID is out of range.");a=[c,u]}else if(d==="setHalt"){if(p("halted"),typeof t.halted!="boolean")throw new n("Provide halted as a boolean.");a=[t.halted]}else if(d==="setMenu"){if(p("menu"),!Array.isArray(t.menu)||!t.menu.length||t.menu.length>32)throw new n("Provide 1..32 explicit RWA menu entries.");let u=t.menu.map(l=>{if(!l||typeof l!="object"||Array.isArray(l)||Object.keys(l).some(z=>!["token","feed","targetWeightBps","active"].includes(z)))throw new n("Invalid RWA menu fields.");let w=l;if(typeof w.active!="boolean")throw new n("RWA active must be boolean.");return{token:h(w.token),feed:h(w.feed),targetWeightBps:A(w.targetWeightBps,!0),active:w.active}});if(new Set(u.map(l=>l.token)).size!==u.length||u.reduce((l,w)=>l+w.targetWeightBps,0n)!==10000n||u.some(l=>l.active&&(l.token===q||l.feed===q)))throw new n("RWA menu tokens must be unique, weights sum to 10000, active feeds/tokens nonzero.");a=[u],o=`Replace the complete RWA equity menu: ${JSON.stringify(T(u))}.`}else if(d==="skim")p("token"),a=[h(t.token)],o=`Sweep eligible stray assets to sleeve ${h(await e.read("sleeve"))}, not to this wallet.`;else if(d!=="pokeHwm"){let u=f();if(a=[u],d==="depositInventory"&&(s=v,i=u,o="Inventory funding is one-way. The manager cannot withdraw these NET; they are committed to bond obligations."),d==="setDiscount"&&u>await e.read("MAX_DISCOUNT_BPS")||d==="setInventoryMax"&&u>await e.read("INVENTORY_HARD_CAP"))throw new n("RWA setting exceeds its immutable maximum.")}}else e.product==="premium"?(a=[g()],o="Permissionless mint-and-sell keeper operation; all sale proceeds go to NetNet treasury. The caller receives no reward."):(a=[f(),g()],o="Convert NET already owned by the tax collector. Proceeds split to treasury and team; the caller receives no reward and supplies no NET.");if(Object.keys(t).some(r=>!m.has(r)))throw new n("Unexpected fields for this NetNet operation.");if(s&&await e.rpc.readContract({address:s.address,abi:P,functionName:"balanceOf",args:[c],blockNumber:e.block.number})<i)throw new n(`Top up ${s.symbol}: needs ${i} base units.`);let E=`NetNet ${e.product}.${d}, contract ${e.contract}, chain ${N}, values ${JSON.stringify(T(a))}. ${s?`Approve exactly ${i} ${s.symbol} base units (${s.address}, decimals ${s.decimals}). `:""}${o}`,O=[...s?[b.approval(s.address,e.contract,i.toString(),N)]:[],b.unsignedTx({to:e.contract,data:H({abi:e.abi,functionName:d,args:a}),value:"0",chainId:N,description:E})],R=await b.preview(O,c),W=0n;for(let r of R.changes){if(!/^-?\d+$/.test(r.amount))throw new n("Invalid NetNet preview amount.");if(BigInt(r.amount)<0n&&(W-=BigInt(r.amount)),BigInt(r.amount)<0n&&(!s||r.token.chainId!==N||!U(r.token.address,s.address)||r.token.decimals!==s.decimals||-BigInt(r.amount)>i))throw new n("NetNet preview spends outside the exact input budget.")}if(W>i)throw new n("NetNet preview exceeds the aggregate input budget.");return{txs:O,preview:R,summary:E}})]}};export{B as a,j as b,ne as c};
@@ -1 +1 @@
1
- import{c as Re,d as je,e as qe,f as be,i as Le,j as ze}from"./3ACEWCKZ.js";import{i as ue}from"./NBRMUFJP.js";import{b as Ie,o as Ce}from"./CAU44UWP.js";import{a as de}from"./VJ3W2V3B.js";import{a as $,b as Oe}from"./6IM6A5VA.js";import{a as L}from"./UWOFA6GV.js";import{a as D}from"./RETS2ZEK.js";import{a as f,d as Xe,i as ee,j as Be}from"./XPFVT2EA.js";import{a as o,b as He,d as oe}from"./5YS5V2LK.js";import{encodeAbiParameters as A,encodeFunctionData as re,erc20Abi as We,getAddress as y,isAddress as An,keccak256 as xn,pad as Sn,parseAbi as Ae,parseAbiParameters as j,toEventSelector as In,toHex as Ge}from"viem";var Cn=y(ee[4663].uniswap.v4_pool_manager.address),T=y(ee[4663].uniswap.v4_position_manager.address),fe=y(ee[4663].uniswap.v4_state_view.address),_e=y(ee[4663].uniswap.permit2.address),at=y(ee[4663].ponsTrade.universal_router.address),se=y(ee[4663].uniswap.WETH.address),_=y(Be),g="0x0000000000000000000000000000000000000000",De=8388608,Ee=-887272,Pe=887272,pn=(1n<<48n)-1n,ne=(1n<<128n)-1n,qn=(1n<<160n)-1n,pe=1n<<96n,Ze=1800n,Ln="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ke=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:g,currency1:_,fee:500,tickSpacing:10,hooks:g},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:g,currency1:_,fee:460,tickSpacing:9,hooks:g},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:g,currency1:_,fee:100,tickSpacing:1,hooks:g},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:_,fee:200,tickSpacing:4,hooks:g},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:g,currency1:_,fee:87,tickSpacing:1,hooks:g},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Ne=y("0x987e330f00b79864a07fe81dfac344d0078abcc0"),fn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",Tn={currency0:g,currency1:_,fee:De,tickSpacing:1,hooks:Ne},$n=new Set([...Ke.map(e=>e.key.hooks.toLowerCase()),Ne.toLowerCase()]),Mn=j("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),_n=j("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),En=j("address currency0, address currency1"),Un=j("address currency, address recipient"),ge=j("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Dn=j("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Te=j("address currency0, address currency1, address recipient"),le=j("bytes actions, bytes[] params"),H=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Kn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),Ye=j("address currency"),Qe=1e6,me=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Nn=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Fn=In("Transfer(address,address,uint256)");function ve(e){if(typeof e!="string"||!An(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===g||n===de.toLowerCase()?g:y(e)}function R(e){let n=e.toLowerCase();return n===g||n===de.toLowerCase()}function ye(e){let n=ve(e.currency0),i=ve(e.currency1);$(e.hooks);let r=y(e.hooks);return xn(A(Mn,[n,i,e.fee,e.tickSpacing,r]))}function mn(e){return((typeof e=="number"?e:e.fee)&De)!==0}function Je(e,n){return mn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:"Pool uses dynamic fee flag 0x800000; stored lpFee=0 does not mean swaps are free. The hook determines the swap fee; a past observation is not a current quote."}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:`Static LP fee ${n} pips.`}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=ve(e.currency0),r=ve(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");$(e.hooks);let c=y(e.hooks),s=mn(e.fee);if(!s&&e.fee>Qe)throw new o(`PoolKey static fee ${e.fee} exceeds the v4 maximum of ${Qe} pips (100%).`);if(s&&e.fee!==De)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===g)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!$n.has(c.toLowerCase()))throw new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ye(t);if(c===Ne&&d.toLowerCase()!==fn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function Vn(e){if(!Number.isInteger(e)||e<=0||e>Pe)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Ee/e)*e,i=Math.trunc(Pe/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function Hn(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Ee||n>Pe)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Ee}, ${Pe}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function en(e,n,i,r,c=f){if($(e),$(n),R(e))throw new o("Native ETH does not use Permit2 approval.");let s=D(i);if(s<=0n||s>qn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=D(String(r));if(t<=0n||t>pn)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:Nn,functionName:"approve",args:[e,n,s,Number(t)]});return Oe({to:_e,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function nn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function Xn(e){let n=(e&0xffn)!==0n,i=nn(e>>8n&0xffffffn),r=nn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function tn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function on(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+pe-1n)/pe:t/pe}function yn(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:tn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:tn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:on(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:on(n,i,e.liquidity,e.roundUp)}}function Bn(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/pe/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*pe/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function $e(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function rn(e,n=f){if(R(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=y(e);return i.toLowerCase()===_.toLowerCase()?{address:_,symbol:"USDG",decimals:Xe,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function V(e,n,i=f){if(R(n))return rn(n,i);let r=y(n);if(r.toLowerCase()===_.toLowerCase()||r.toLowerCase()===se.toLowerCase())return rn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:We,functionName:"symbol"}),e.readContract({address:r,abi:We,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:ze(c,r),decimals:Number(s),chainId:i}}function W(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return D(e)}function sn(e,n,i,r){let c=e===void 0?D(Ce(n.toString(),i)):W(e,r);if(c<=1n||c>ne)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function wn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Me(e,n,i){let r=await wn(e,i);if(n==null)return r+1800n;let c=D(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Ue(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??g),currency1:String(r.currency1??_),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??g)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??g)}:void 0;if(c){if(R(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let b=ke(c,i);return{poolId:ye(b),poolKey:b}}let s=(i??Ln).toLowerCase();if(s===fn)return{poolId:s,poolKey:ke(Tn,s)};let t=Ke.find(b=>b.poolId.toLowerCase()===s);if(t){if(R(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:T,abi:H,functionName:"poolKeys",args:[d]}),[p,l,m,u,k]=a;if(p.toLowerCase()===g&&l.toLowerCase()===g&&Number(u)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let w=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(u),hooks:k},s);return{poolId:s,poolKey:w}}async function he(e,n,i){try{let[r,c]=await e.readContract({address:T,abi:H,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Ue(e,i)).poolId.toLowerCase()!==ye(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=Xn(BigInt(c));return{poolKey:s,poolId:ye(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}async function an(e,n,i={}){$(n);let r=y(n),c=e.clientFor(f),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(D(String(d)).toString());try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:T.toLowerCase(),topics:[Fn,null,Sn(r)],fromBlock:Ge(p),toBlock:Ge(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let u of m){if(!Array.isArray(u.topics)||u.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(u.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(u.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:T,abi:H,functionName:"ownerOf",args:[a]})}catch(P){if(He(P,3))continue;throw P}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:u,poolId:k,tickLower:w,tickUpper:b}=await he(c,a,{}),S=await c.readContract({address:fe,abi:me,functionName:"getSlot0",args:[k]}),I=BigInt(S[0]),{amount0:h,amount1:x}=yn({liquidity:m,tickLower:w,tickUpper:b,sqrtPriceX96:I}),[v,E]=await Promise.all([V(c,u.currency0,f),V(c,u.currency1,f)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:f,assets:[{token:v,amount:h.toString()},{token:E,amount:x.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${v.symbol}/${E.symbol}, liquidity=${m.toString()}, ticks=[${w},${b}], poolId=${k})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var On={type:"object",properties:{version:{type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"},tickLower:{type:"number"},tickUpper:{type:"number"},fullRange:{type:"boolean"},liquidity:L("Position liquidity in base units."),amount0Max:L("Maximum currency0 base units to spend."),amount1Max:L("Maximum currency1 base units to spend."),recipient:{type:"string"},deadline:L(),permit2Expiration:{type:"string"},hookData:{type:"string"},tokenId:L("Existing v4 position NFT to increase (keeps its tick range). Omit to mint a new position."),initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units (native ETH is 18 decimals). Needs the full poolKey. Creates the pool then mints the first position in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},Rn={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{type:"string",enum:["v4"]},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{type:"string"},fee:{type:"number",description:"Static LP fee in pips (3000 = 0.30%), at most 1000000."},tickSpacing:{type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 ETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},jn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),poolId:{type:"string"},poolKey:{type:"object"},amount0Min:L(),amount1Min:L(),recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},zn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:"Positive base-unit liquidity amount, or all for a full burn."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:Ie},fullExit:{type:"boolean"},burn:{type:"boolean"},amount0Min:L(),amount1Min:L(),poolId:{type:"string"},poolKey:{type:"object"},recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},Wn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenIds:{type:"array",items:L()},includeZero:{type:"boolean"}}};function cn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function dn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return je(BigInt(e.sqrtPriceX96))}return Re(e.initialPrice,n,i)}async function Gn(e,n,i){let r;try{r=await e.readContract({address:T,abi:H,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(y(r)!==y(i))throw new o(`Wallet ${y(i)} is not the owner of Uniswap v4 position #${n} (owned by ${y(r)}).`)}async function un(e,n){let i=ye(n).toLowerCase(),r=new Map;for(let s of Ke)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:fe,abi:me,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:fe,abi:me,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function ln(e,n,i,r,c,s){return e.unsignedTx({to:Cn.toLowerCase(),data:re({abi:Kn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:f,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${be(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var Zn=e=>({tools:[{name:"uniswap_add",inputSchema:On,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:D(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0)throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");let l=e.clientFor(f);p&&cn(t);let m,u,k,w;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await Gn(l,a,d),{poolId:m,poolKey:u,tickLower:k,tickUpper:w}=await he(l,a,t)}else{({poolId:m,poolKey:u}=await Ue(l,t));let q=Vn(u.tickSpacing);k=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),w=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),Hn(k,w,u.tickSpacing)}let[b,S]=await Promise.all([V(l,u.currency0,f),V(l,u.currency1,f)]),I=W(t.amount0Max??t.amount0Desired,"amount0Max"),h=W(t.amount1Max??t.amount1Desired,"amount1Max");if(I<=0n&&h<=0n||I>ne||h>ne)throw new o("Provide positive amount0Max/amount1Max within uint128.");let x=await l.readContract({address:fe,abi:me,functionName:"getSlot0",args:[m]}),v=BigInt(x[0]),E=Number(x[3]),P;if(p){if(v>0n)throw new o(`Pool ${m} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=dn(t,b.decimals,S.decimals),F=Le(q,await un(l,u),t.acceptPriceDeviation===!0,b.decimals,S.decimals);P={sqrtPriceX96:q,note:F},v=q}else if(v<=0n)throw new o(`Pool ${m} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let C=t.liquidity!==void 0?W(t.liquidity,"liquidity"):Bn({amount0:I,amount1:h,tickLower:k,tickUpper:w,sqrtPriceX96:v});if(C<=0n||C>ne)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:U,amount1:X}=yn({liquidity:C,tickLower:k,tickUpper:w,sqrtPriceX96:v,roundUp:!0});if(U>I||X>h)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let G=t.recipient!==void 0?String(t.recipient):d;if($(G),y(G)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let Z=await wn(l),te=await Me(l,t.deadline,Z.toString()),ae=te<Z+Ze?te:Z+Ze,Y=t.permit2Expiration===void 0?ae:D(String(t.permit2Expiration));if(Y<=Z||Y>ae||Y>pn)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let M=typeof t.hookData=="string"?t.hookData:"0x",K=(q,F)=>{let z=P?[ln(e,u,m,P.sqrtPriceX96,b,S)]:[];if(!R(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),q.toString(),f)),z.push(en(ce,T.toLowerCase(),q.toString(),Y.toString(),f))}if(!R(u.currency1)&&F>0n){let ce=u.currency1.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),F.toString(),f)),z.push(en(ce,T.toLowerCase(),F.toString(),Y.toString(),f))}let O={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Se=A(_n,[O,k,w,C,q,F,G.toLowerCase(),M]),gn=A(En,[O.currency0,O.currency1]),Ve=A(Un,[g,G.toLowerCase()]),kn=A(ge,[a??0n,C,q,F,M]),hn=a===void 0?A(le,["0x020d14",[Se,gn,Ve]]):A(le,["0x00121214",[kn,A(Ye,[O.currency0]),A(Ye,[O.currency1]),Ve]]),Pn=re({abi:H,functionName:"modifyLiquidities",args:[hn,te]}),vn=R(u.currency0)?q.toString():"0";return z.push(e.unsignedTx({to:T.toLowerCase(),data:Pn,value:vn,chainId:f,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${m} (liquidity +${C}).`:`Mint Uniswap v4 position on pool ${m} (ticks [${k}, ${w}], liquidity ${C}).`})),z},Q=K(U,X),J=await e.preview(Q,d),B=(q,F)=>{let z=R(F)?de:F.toLowerCase();return-q.changes.filter(O=>O.token.address.toLowerCase()===z).reduce((O,Se)=>O+BigInt(Se.amount),0n)},N=B(J,u.currency0),ie=B(J,u.currency1);if(N<0n||ie<0n||N>U||ie>X||N===0n&&ie===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Fe=a===void 0?K(N,ie):Q,we=a!==void 0||N===U&&ie===X?J:await e.preview(Fe,d);if(B(we,u.currency0)!==N||B(we,u.currency1)!==ie)throw new o("V4 mint spend changed. Refresh the liquidity preview.");let bn=$e(we.changes,e.formatAmount),xe=Je(u,E);return{txs:Fe,preview:we,poolId:m,poolKey:u,tickLower:k,tickUpper:w,liquidity:C.toString(),amount0Max:{token:b,amount:I.toString()},amount1Max:{token:S,amount:h.toString()},dynamicFee:xe.dynamicFee,swapsAreFree:xe.swapsAreFree,action:a!==void 0?"increase":P?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:be(P.sqrtPriceX96,b.decimals,S.decimals),initialTick:qe(P.sqrtPriceX96),priceCheck:P.note}:{},summary:`${a!==void 0?`Increase Uniswap v4 position #${a}`:P?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${C} L, ticks [${k}, ${w}]) on pool ${m}. Preview deltas: ${bn.join(", ")||"none"}. ${xe.feeNote}${P?` ${P.note}`:""}`}}},{name:"uniswap_collect",inputSchema:jn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),u=t.amount0Min!==void 0?W(t.amount0Min,"amount0Min"):0n,k=t.amount1Min!==void 0?W(t.amount1Min,"amount1Min"):0n;if(u>ne||k>ne)throw new o("amount0Min and amount1Min must fit in uint128.");let w=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:b,poolId:S}=await he(p,a,t),[I,h]=await Promise.all([V(p,b.currency0,f),V(p,b.currency1,f)]),x=A(ge,[a,0n,u,k,w]),v=A(Te,[b.currency0.toLowerCase(),b.currency1.toLowerCase(),l.toLowerCase()]),E=A(le,["0x0111",[x,v]]),P=re({abi:H,functionName:"modifyLiquidities",args:[E,m]}),C=[e.unsignedTx({to:T.toLowerCase(),data:P,value:"0",chainId:f,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],U=await e.preview(C,d),X=$e(U.changes,e.formatAmount);return{txs:C,preview:U,tokenId:a.toString(),poolId:S,recipient:l,currencies:[I,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${X.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:zn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),{poolKey:u,poolId:k}=await he(p,a,t),[w,b]=await Promise.all([V(p,u.currency0,f),V(p,u.currency1,f)]),S=t.slippageBps??Ie;if(typeof S!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Ce("0",S);let I=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let x=t.liquidity===void 0||t.liquidity==="all"?void 0:W(t.liquidity,"liquidity");if(x!==void 0&&(x<0n||x===0n&&!h||x>ne))throw new o("Provide positive liquidity within uint128 for v4 removal.");let v;try{v=BigInt(await p.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}))}catch(M){throw new o(`Could not read v4 position liquidity. ${oe(M)}`)}if(v<0n||v===0n&&!h||x!==void 0&&x>v)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&x!==void 0&&x!==v)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let E=h?"0x0311":"0x0111",P=(M,K,Q)=>{let J=h?A(Dn,[a,M,K,I]):A(ge,[a,x,M,K,I]),B=A(Te,[u.currency0,u.currency1,Q]);return e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,[E,[J,B]]),m]}),value:"0",chainId:f,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${E}).`})},C=0n,U=0n;if(v>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let M=e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,["0x0111",[A(ge,[a,0n,0n,0n,I]),A(Te,[u.currency0,u.currency1,T])]]),m]}),value:"0",chainId:f,description:"Simulation only: separate fees from removal principal."}),K=await e.preview([M,P(2n,2n,d)],d),Q=J=>K.changes.reduce((B,N)=>N.token.chainId===f&&N.token.address.toLowerCase()===J.address.toLowerCase()?B+BigInt(N.amount):B,0n);if(C=Q(w),U=Q(b),C<0n||U<0n)throw new o("Removal simulation did not return the expected currencies.")}let X=(M,K)=>{if(M!==void 0&&W(M,K)!==0n)throw new o(`${K} must be zero for an empty position burn.`);return 0n},G=v===0n?X(t.amount0Min,"amount0Min"):sn(t.amount0Min,C,S,"amount0Min"),Z=v===0n?X(t.amount1Min,"amount1Min"):sn(t.amount1Min,U,S,"amount1Min"),te=[P(G,Z,l)],ae=await e.preview(te,d),Y=$e(ae.changes,e.formatAmount);return{txs:te,preview:ae,action:E,tokenId:a.toString(),poolId:k,amount0Min:{token:w,amount:G.toString()},amount1Min:{token:b,amount:Z.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${E})${h?`; burns position #${a} at ${T}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:Wn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=await an(e,d,{tokenIds:a,includeZero:p});return{version:"v4",positions:l,summary:`Found ${l.length} active Uniswap v4 position(s) for ${d}.`}}},{name:"uniswap_create_pool",inputSchema:Rn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');cn(t);let a=e.clientFor(f),{poolId:p,poolKey:l}=await Ue(a,t),[m,u]=await Promise.all([V(a,l.currency0,f),V(a,l.currency1,f)]),k=await a.readContract({address:fe,abi:me,functionName:"getSlot0",args:[p]});if(BigInt(k[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let w=dn(t,m.decimals,u.decimals),b=Le(w,await un(a,l),t.acceptPriceDeviation===!0,m.decimals,u.decimals),S=be(w,m.decimals,u.decimals),I=[ln(e,l,p,w,m,u)],h=await e.preview(I,d),x=Je(l,l.fee);return{txs:I,preview:h,poolId:p,poolKey:l,sqrtPriceX96:w.toString(),initialPrice:S,initialTick:qe(w),priceCheck:b,action:"createPool",summary:`${I[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${x.feeNote} ${b}`}}}],positions:t=>an(e,t)}),ct=Zn;export{Cn as a,T as b,fe as c,_e as d,at as e,se as f,_ as g,g as h,De as i,Ee as j,Pe as k,Ln as l,Ke as m,Ne as n,fn as o,Tn as p,$n as q,R as r,ye as s,mn as t,Je as u,ke as v,Vn as w,Hn as x,en as y,Xn as z,yn as A,Bn as B,$e as C,rn as D,V as E,he as F,an as G,On as H,Rn as I,jn as J,zn as K,Wn as L,un as M,Zn as N,ct as O};
1
+ import{c as Re,d as je,e as qe,f as be,i as Le,j as ze}from"./6ZYLNB2B.js";import{i as ue}from"./FUXT7GRK.js";import{b as Ie,o as Ce}from"./5O5ZE3ZV.js";import{a as de}from"./CY75R4FK.js";import{a as $,b as Oe}from"./6IM6A5VA.js";import{a as L}from"./UWOFA6GV.js";import{a as D}from"./RETS2ZEK.js";import{a as f,d as Xe,i as ee,j as Be}from"./G6HCV67X.js";import{a as o,b as He,d as oe}from"./5YS5V2LK.js";import{encodeAbiParameters as A,encodeFunctionData as re,erc20Abi as We,getAddress as y,isAddress as An,keccak256 as xn,pad as Sn,parseAbi as Ae,parseAbiParameters as j,toEventSelector as In,toHex as Ge}from"viem";var Cn=y(ee[4663].uniswap.v4_pool_manager.address),T=y(ee[4663].uniswap.v4_position_manager.address),fe=y(ee[4663].uniswap.v4_state_view.address),_e=y(ee[4663].uniswap.permit2.address),at=y(ee[4663].ponsTrade.universal_router.address),se=y(ee[4663].uniswap.WETH.address),_=y(Be),g="0x0000000000000000000000000000000000000000",De=8388608,Ee=-887272,Pe=887272,pn=(1n<<48n)-1n,ne=(1n<<128n)-1n,qn=(1n<<160n)-1n,pe=1n<<96n,Ze=1800n,Ln="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ke=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:g,currency1:_,fee:500,tickSpacing:10,hooks:g},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:g,currency1:_,fee:460,tickSpacing:9,hooks:g},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:g,currency1:_,fee:100,tickSpacing:1,hooks:g},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:_,fee:200,tickSpacing:4,hooks:g},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:g,currency1:_,fee:87,tickSpacing:1,hooks:g},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Ne=y("0x987e330f00b79864a07fe81dfac344d0078abcc0"),fn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",Tn={currency0:g,currency1:_,fee:De,tickSpacing:1,hooks:Ne},$n=new Set([...Ke.map(e=>e.key.hooks.toLowerCase()),Ne.toLowerCase()]),Mn=j("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),_n=j("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),En=j("address currency0, address currency1"),Un=j("address currency, address recipient"),ge=j("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Dn=j("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Te=j("address currency0, address currency1, address recipient"),le=j("bytes actions, bytes[] params"),H=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Kn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),Ye=j("address currency"),Qe=1e6,me=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Nn=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Fn=In("Transfer(address,address,uint256)");function ve(e){if(typeof e!="string"||!An(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===g||n===de.toLowerCase()?g:y(e)}function R(e){let n=e.toLowerCase();return n===g||n===de.toLowerCase()}function ye(e){let n=ve(e.currency0),i=ve(e.currency1);$(e.hooks);let r=y(e.hooks);return xn(A(Mn,[n,i,e.fee,e.tickSpacing,r]))}function mn(e){return((typeof e=="number"?e:e.fee)&De)!==0}function Je(e,n){return mn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:"Pool uses dynamic fee flag 0x800000; stored lpFee=0 does not mean swaps are free. The hook determines the swap fee; a past observation is not a current quote."}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:`Static LP fee ${n} pips.`}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=ve(e.currency0),r=ve(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");$(e.hooks);let c=y(e.hooks),s=mn(e.fee);if(!s&&e.fee>Qe)throw new o(`PoolKey static fee ${e.fee} exceeds the v4 maximum of ${Qe} pips (100%).`);if(s&&e.fee!==De)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===g)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!$n.has(c.toLowerCase()))throw new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ye(t);if(c===Ne&&d.toLowerCase()!==fn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function Vn(e){if(!Number.isInteger(e)||e<=0||e>Pe)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Ee/e)*e,i=Math.trunc(Pe/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function Hn(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Ee||n>Pe)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Ee}, ${Pe}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function en(e,n,i,r,c=f){if($(e),$(n),R(e))throw new o("Native ETH does not use Permit2 approval.");let s=D(i);if(s<=0n||s>qn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=D(String(r));if(t<=0n||t>pn)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:Nn,functionName:"approve",args:[e,n,s,Number(t)]});return Oe({to:_e,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function nn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function Xn(e){let n=(e&0xffn)!==0n,i=nn(e>>8n&0xffffffn),r=nn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function tn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function on(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+pe-1n)/pe:t/pe}function yn(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:tn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:tn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:on(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:on(n,i,e.liquidity,e.roundUp)}}function Bn(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/pe/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*pe/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function $e(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function rn(e,n=f){if(R(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=y(e);return i.toLowerCase()===_.toLowerCase()?{address:_,symbol:"USDG",decimals:Xe,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function V(e,n,i=f){if(R(n))return rn(n,i);let r=y(n);if(r.toLowerCase()===_.toLowerCase()||r.toLowerCase()===se.toLowerCase())return rn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:We,functionName:"symbol"}),e.readContract({address:r,abi:We,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:ze(c,r),decimals:Number(s),chainId:i}}function W(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return D(e)}function sn(e,n,i,r){let c=e===void 0?D(Ce(n.toString(),i)):W(e,r);if(c<=1n||c>ne)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function wn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Me(e,n,i){let r=await wn(e,i);if(n==null)return r+1800n;let c=D(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Ue(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??g),currency1:String(r.currency1??_),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??g)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??g)}:void 0;if(c){if(R(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let b=ke(c,i);return{poolId:ye(b),poolKey:b}}let s=(i??Ln).toLowerCase();if(s===fn)return{poolId:s,poolKey:ke(Tn,s)};let t=Ke.find(b=>b.poolId.toLowerCase()===s);if(t){if(R(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:T,abi:H,functionName:"poolKeys",args:[d]}),[p,l,m,u,k]=a;if(p.toLowerCase()===g&&l.toLowerCase()===g&&Number(u)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let w=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(u),hooks:k},s);return{poolId:s,poolKey:w}}async function he(e,n,i){try{let[r,c]=await e.readContract({address:T,abi:H,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Ue(e,i)).poolId.toLowerCase()!==ye(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=Xn(BigInt(c));return{poolKey:s,poolId:ye(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}async function an(e,n,i={}){$(n);let r=y(n),c=e.clientFor(f),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(D(String(d)).toString());try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:T.toLowerCase(),topics:[Fn,null,Sn(r)],fromBlock:Ge(p),toBlock:Ge(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let u of m){if(!Array.isArray(u.topics)||u.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(u.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(u.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:T,abi:H,functionName:"ownerOf",args:[a]})}catch(P){if(He(P,3))continue;throw P}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:u,poolId:k,tickLower:w,tickUpper:b}=await he(c,a,{}),S=await c.readContract({address:fe,abi:me,functionName:"getSlot0",args:[k]}),I=BigInt(S[0]),{amount0:h,amount1:x}=yn({liquidity:m,tickLower:w,tickUpper:b,sqrtPriceX96:I}),[v,E]=await Promise.all([V(c,u.currency0,f),V(c,u.currency1,f)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:f,assets:[{token:v,amount:h.toString()},{token:E,amount:x.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${v.symbol}/${E.symbol}, liquidity=${m.toString()}, ticks=[${w},${b}], poolId=${k})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var On={type:"object",properties:{version:{type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"},tickLower:{type:"number"},tickUpper:{type:"number"},fullRange:{type:"boolean"},liquidity:L("Position liquidity in base units."),amount0Max:L("Maximum currency0 base units to spend."),amount1Max:L("Maximum currency1 base units to spend."),recipient:{type:"string"},deadline:L(),permit2Expiration:{type:"string"},hookData:{type:"string"},tokenId:L("Existing v4 position NFT to increase (keeps its tick range). Omit to mint a new position."),initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units (native ETH is 18 decimals). Needs the full poolKey. Creates the pool then mints the first position in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},Rn={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{type:"string",enum:["v4"]},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{type:"string"},fee:{type:"number",description:"Static LP fee in pips (3000 = 0.30%), at most 1000000."},tickSpacing:{type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 ETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},jn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),poolId:{type:"string"},poolKey:{type:"object"},amount0Min:L(),amount1Min:L(),recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},zn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:"Positive base-unit liquidity amount, or all for a full burn."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:Ie},fullExit:{type:"boolean"},burn:{type:"boolean"},amount0Min:L(),amount1Min:L(),poolId:{type:"string"},poolKey:{type:"object"},recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},Wn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenIds:{type:"array",items:L()},includeZero:{type:"boolean"}}};function cn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function dn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return je(BigInt(e.sqrtPriceX96))}return Re(e.initialPrice,n,i)}async function Gn(e,n,i){let r;try{r=await e.readContract({address:T,abi:H,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(y(r)!==y(i))throw new o(`Wallet ${y(i)} is not the owner of Uniswap v4 position #${n} (owned by ${y(r)}).`)}async function un(e,n){let i=ye(n).toLowerCase(),r=new Map;for(let s of Ke)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:fe,abi:me,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:fe,abi:me,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function ln(e,n,i,r,c,s){return e.unsignedTx({to:Cn.toLowerCase(),data:re({abi:Kn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:f,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${be(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var Zn=e=>({tools:[{name:"uniswap_add",inputSchema:On,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:D(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0)throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");let l=e.clientFor(f);p&&cn(t);let m,u,k,w;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await Gn(l,a,d),{poolId:m,poolKey:u,tickLower:k,tickUpper:w}=await he(l,a,t)}else{({poolId:m,poolKey:u}=await Ue(l,t));let q=Vn(u.tickSpacing);k=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),w=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),Hn(k,w,u.tickSpacing)}let[b,S]=await Promise.all([V(l,u.currency0,f),V(l,u.currency1,f)]),I=W(t.amount0Max??t.amount0Desired,"amount0Max"),h=W(t.amount1Max??t.amount1Desired,"amount1Max");if(I<=0n&&h<=0n||I>ne||h>ne)throw new o("Provide positive amount0Max/amount1Max within uint128.");let x=await l.readContract({address:fe,abi:me,functionName:"getSlot0",args:[m]}),v=BigInt(x[0]),E=Number(x[3]),P;if(p){if(v>0n)throw new o(`Pool ${m} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=dn(t,b.decimals,S.decimals),F=Le(q,await un(l,u),t.acceptPriceDeviation===!0,b.decimals,S.decimals);P={sqrtPriceX96:q,note:F},v=q}else if(v<=0n)throw new o(`Pool ${m} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let C=t.liquidity!==void 0?W(t.liquidity,"liquidity"):Bn({amount0:I,amount1:h,tickLower:k,tickUpper:w,sqrtPriceX96:v});if(C<=0n||C>ne)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:U,amount1:X}=yn({liquidity:C,tickLower:k,tickUpper:w,sqrtPriceX96:v,roundUp:!0});if(U>I||X>h)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let G=t.recipient!==void 0?String(t.recipient):d;if($(G),y(G)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let Z=await wn(l),te=await Me(l,t.deadline,Z.toString()),ae=te<Z+Ze?te:Z+Ze,Y=t.permit2Expiration===void 0?ae:D(String(t.permit2Expiration));if(Y<=Z||Y>ae||Y>pn)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let M=typeof t.hookData=="string"?t.hookData:"0x",K=(q,F)=>{let z=P?[ln(e,u,m,P.sqrtPriceX96,b,S)]:[];if(!R(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),q.toString(),f)),z.push(en(ce,T.toLowerCase(),q.toString(),Y.toString(),f))}if(!R(u.currency1)&&F>0n){let ce=u.currency1.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),F.toString(),f)),z.push(en(ce,T.toLowerCase(),F.toString(),Y.toString(),f))}let O={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Se=A(_n,[O,k,w,C,q,F,G.toLowerCase(),M]),gn=A(En,[O.currency0,O.currency1]),Ve=A(Un,[g,G.toLowerCase()]),kn=A(ge,[a??0n,C,q,F,M]),hn=a===void 0?A(le,["0x020d14",[Se,gn,Ve]]):A(le,["0x00121214",[kn,A(Ye,[O.currency0]),A(Ye,[O.currency1]),Ve]]),Pn=re({abi:H,functionName:"modifyLiquidities",args:[hn,te]}),vn=R(u.currency0)?q.toString():"0";return z.push(e.unsignedTx({to:T.toLowerCase(),data:Pn,value:vn,chainId:f,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${m} (liquidity +${C}).`:`Mint Uniswap v4 position on pool ${m} (ticks [${k}, ${w}], liquidity ${C}).`})),z},Q=K(U,X),J=await e.preview(Q,d),B=(q,F)=>{let z=R(F)?de:F.toLowerCase();return-q.changes.filter(O=>O.token.address.toLowerCase()===z).reduce((O,Se)=>O+BigInt(Se.amount),0n)},N=B(J,u.currency0),ie=B(J,u.currency1);if(N<0n||ie<0n||N>U||ie>X||N===0n&&ie===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Fe=a===void 0?K(N,ie):Q,we=a!==void 0||N===U&&ie===X?J:await e.preview(Fe,d);if(B(we,u.currency0)!==N||B(we,u.currency1)!==ie)throw new o("V4 mint spend changed. Refresh the liquidity preview.");let bn=$e(we.changes,e.formatAmount),xe=Je(u,E);return{txs:Fe,preview:we,poolId:m,poolKey:u,tickLower:k,tickUpper:w,liquidity:C.toString(),amount0Max:{token:b,amount:I.toString()},amount1Max:{token:S,amount:h.toString()},dynamicFee:xe.dynamicFee,swapsAreFree:xe.swapsAreFree,action:a!==void 0?"increase":P?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:be(P.sqrtPriceX96,b.decimals,S.decimals),initialTick:qe(P.sqrtPriceX96),priceCheck:P.note}:{},summary:`${a!==void 0?`Increase Uniswap v4 position #${a}`:P?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${C} L, ticks [${k}, ${w}]) on pool ${m}. Preview deltas: ${bn.join(", ")||"none"}. ${xe.feeNote}${P?` ${P.note}`:""}`}}},{name:"uniswap_collect",inputSchema:jn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),u=t.amount0Min!==void 0?W(t.amount0Min,"amount0Min"):0n,k=t.amount1Min!==void 0?W(t.amount1Min,"amount1Min"):0n;if(u>ne||k>ne)throw new o("amount0Min and amount1Min must fit in uint128.");let w=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:b,poolId:S}=await he(p,a,t),[I,h]=await Promise.all([V(p,b.currency0,f),V(p,b.currency1,f)]),x=A(ge,[a,0n,u,k,w]),v=A(Te,[b.currency0.toLowerCase(),b.currency1.toLowerCase(),l.toLowerCase()]),E=A(le,["0x0111",[x,v]]),P=re({abi:H,functionName:"modifyLiquidities",args:[E,m]}),C=[e.unsignedTx({to:T.toLowerCase(),data:P,value:"0",chainId:f,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],U=await e.preview(C,d),X=$e(U.changes,e.formatAmount);return{txs:C,preview:U,tokenId:a.toString(),poolId:S,recipient:l,currencies:[I,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${X.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:zn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),{poolKey:u,poolId:k}=await he(p,a,t),[w,b]=await Promise.all([V(p,u.currency0,f),V(p,u.currency1,f)]),S=t.slippageBps??Ie;if(typeof S!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Ce("0",S);let I=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let x=t.liquidity===void 0||t.liquidity==="all"?void 0:W(t.liquidity,"liquidity");if(x!==void 0&&(x<0n||x===0n&&!h||x>ne))throw new o("Provide positive liquidity within uint128 for v4 removal.");let v;try{v=BigInt(await p.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}))}catch(M){throw new o(`Could not read v4 position liquidity. ${oe(M)}`)}if(v<0n||v===0n&&!h||x!==void 0&&x>v)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&x!==void 0&&x!==v)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let E=h?"0x0311":"0x0111",P=(M,K,Q)=>{let J=h?A(Dn,[a,M,K,I]):A(ge,[a,x,M,K,I]),B=A(Te,[u.currency0,u.currency1,Q]);return e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,[E,[J,B]]),m]}),value:"0",chainId:f,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${E}).`})},C=0n,U=0n;if(v>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let M=e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,["0x0111",[A(ge,[a,0n,0n,0n,I]),A(Te,[u.currency0,u.currency1,T])]]),m]}),value:"0",chainId:f,description:"Simulation only: separate fees from removal principal."}),K=await e.preview([M,P(2n,2n,d)],d),Q=J=>K.changes.reduce((B,N)=>N.token.chainId===f&&N.token.address.toLowerCase()===J.address.toLowerCase()?B+BigInt(N.amount):B,0n);if(C=Q(w),U=Q(b),C<0n||U<0n)throw new o("Removal simulation did not return the expected currencies.")}let X=(M,K)=>{if(M!==void 0&&W(M,K)!==0n)throw new o(`${K} must be zero for an empty position burn.`);return 0n},G=v===0n?X(t.amount0Min,"amount0Min"):sn(t.amount0Min,C,S,"amount0Min"),Z=v===0n?X(t.amount1Min,"amount1Min"):sn(t.amount1Min,U,S,"amount1Min"),te=[P(G,Z,l)],ae=await e.preview(te,d),Y=$e(ae.changes,e.formatAmount);return{txs:te,preview:ae,action:E,tokenId:a.toString(),poolId:k,amount0Min:{token:w,amount:G.toString()},amount1Min:{token:b,amount:Z.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${E})${h?`; burns position #${a} at ${T}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:Wn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=await an(e,d,{tokenIds:a,includeZero:p});return{version:"v4",positions:l,summary:`Found ${l.length} active Uniswap v4 position(s) for ${d}.`}}},{name:"uniswap_create_pool",inputSchema:Rn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');cn(t);let a=e.clientFor(f),{poolId:p,poolKey:l}=await Ue(a,t),[m,u]=await Promise.all([V(a,l.currency0,f),V(a,l.currency1,f)]),k=await a.readContract({address:fe,abi:me,functionName:"getSlot0",args:[p]});if(BigInt(k[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let w=dn(t,m.decimals,u.decimals),b=Le(w,await un(a,l),t.acceptPriceDeviation===!0,m.decimals,u.decimals),S=be(w,m.decimals,u.decimals),I=[ln(e,l,p,w,m,u)],h=await e.preview(I,d),x=Je(l,l.fee);return{txs:I,preview:h,poolId:p,poolKey:l,sqrtPriceX96:w.toString(),initialPrice:S,initialTick:qe(w),priceCheck:b,action:"createPool",summary:`${I[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${x.feeNote} ${b}`}}}],positions:t=>an(e,t)}),ct=Zn;export{Cn as a,T as b,fe as c,_e as d,at as e,se as f,_ as g,g as h,De as i,Ee as j,Pe as k,Ln as l,Ke as m,Ne as n,fn as o,Tn as p,$n as q,R as r,ye as s,mn as t,Je as u,ke as v,Vn as w,Hn as x,en as y,Xn as z,yn as A,Bn as B,$e as C,rn as D,V as E,he as F,an as G,On as H,Rn as I,jn as J,zn as K,Wn as L,un as M,Zn as N,ct as O};
@@ -1 +1 @@
1
- import{c as A}from"./5HCXZWUH.js";import{n as y}from"./IWALIX7Q.js";import{a as b}from"./5YS5V2LK.js";import{erc20Abi as F,getAddress as $}from"viem";var P=new WeakMap,E=3e3,k=new WeakMap;async function q(C,h,u,m,c){u=$(u);let n=A(C),e=P.get(n);e||(e=new Map,P.set(n,e));let i=`${h}:${u.toLowerCase()}:${m}:${c??"latest"}`,t=e.get(i);if(t&&(e.delete(i),e.set(i,t)),!t){for(t=new Promise((s,T)=>{let a=k.get(n);a||(a=new Map,k.set(n,a));let f=`${h}:${c??"latest"}`,l=a.get(f);if(!l){l=[],a.set(f,l);let d=l;queueMicrotask(async()=>{a.delete(f);let w=d.map(r=>({address:r.address,abi:F,functionName:r.field}));try{if(d.length>1&&n.chain?.contracts?.multicall3&&typeof n.multicall=="function"){let r=await y(()=>n.multicall({contracts:w,blockNumber:c,allowFailure:!0}));d.forEach((o,p)=>{let g=r[p];g?.status==="success"?o.resolve(g.result):o.reject(g?.error??new b("Token metadata could not be read."))})}else await Promise.all(d.map(async(r,o)=>{try{r.resolve(await y(()=>n.readContract({...w[o],blockNumber:c})))}catch(p){r.reject(p)}}))}catch(r){d.forEach(o=>o.reject(r))}})}l.push({address:u,field:m,resolve:s,reject:T})}).then(s=>{if(m==="decimals"?!Number.isInteger(s)||Number(s)<0||Number(s)>255:typeof s!="string"||!s.trim())throw new b("The contract returned invalid token metadata.");return s});e.size>=E;)e.delete(e.keys().next().value);e.set(i,t);let M=t;t.catch(()=>{e.get(i)===M&&e.delete(i)})}try{return await t}finally{c!==void 0&&e.get(i)===t&&e.delete(i)}}export{q as a};
1
+ import{c as A}from"./5HCXZWUH.js";import{n as y}from"./CXLEQCP3.js";import{a as b}from"./5YS5V2LK.js";import{erc20Abi as F,getAddress as $}from"viem";var P=new WeakMap,E=3e3,k=new WeakMap;async function q(C,h,u,m,c){u=$(u);let n=A(C),e=P.get(n);e||(e=new Map,P.set(n,e));let i=`${h}:${u.toLowerCase()}:${m}:${c??"latest"}`,t=e.get(i);if(t&&(e.delete(i),e.set(i,t)),!t){for(t=new Promise((s,T)=>{let a=k.get(n);a||(a=new Map,k.set(n,a));let f=`${h}:${c??"latest"}`,l=a.get(f);if(!l){l=[],a.set(f,l);let d=l;queueMicrotask(async()=>{a.delete(f);let w=d.map(r=>({address:r.address,abi:F,functionName:r.field}));try{if(d.length>1&&n.chain?.contracts?.multicall3&&typeof n.multicall=="function"){let r=await y(()=>n.multicall({contracts:w,blockNumber:c,allowFailure:!0}));d.forEach((o,p)=>{let g=r[p];g?.status==="success"?o.resolve(g.result):o.reject(g?.error??new b("Token metadata could not be read."))})}else await Promise.all(d.map(async(r,o)=>{try{r.resolve(await y(()=>n.readContract({...w[o],blockNumber:c})))}catch(p){r.reject(p)}}))}catch(r){d.forEach(o=>o.reject(r))}})}l.push({address:u,field:m,resolve:s,reject:T})}).then(s=>{if(m==="decimals"?!Number.isInteger(s)||Number(s)<0||Number(s)>255:typeof s!="string"||!s.trim())throw new b("The contract returned invalid token metadata.");return s});e.size>=E;)e.delete(e.keys().next().value);e.set(i,t);let M=t;t.catch(()=>{e.get(i)===M&&e.delete(i)})}try{return await t}finally{c!==void 0&&e.get(i)===t&&e.delete(i)}}export{q as a};
@@ -1 +1 @@
1
- import{b as M}from"./7LDAJ6BM.js";import{a as U}from"./6HV5BR7P.js";import{b as I}from"./ZPM2MFXZ.js";import{b as C}from"./AXYOJBX6.js";import{a as W}from"./6IM6A5VA.js";import{a as P}from"./UWOFA6GV.js";import{g as $}from"./73N3TOJL.js";import{a as R}from"./RETS2ZEK.js";import{a as h,d as D,i as T,j as b}from"./XPFVT2EA.js";import{a as p}from"./5YS5V2LK.js";import{encodeFunctionData as A,erc20Abi as O,parseAbi as E}from"viem";var f=T[h].vaults.spark.address,i={address:b,chainId:h,symbol:"USDG",decimals:D},u={address:f,chainId:h,symbol:"spUSDG",decimals:6},G=(1n<<256n)-1n,k=E(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function maxDeposit(address receiver) view returns (uint256)","function maxWithdraw(address owner) view returns (uint256)","function maxRedeem(address owner) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewWithdraw(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),t=(s,l)=>({token:{...s},amount:l.toString()});function y(s,l,v=!1){if(!s||typeof s!="object"||Array.isArray(s)||Object.keys(s).some(S=>!l||S!=="amount"))throw new p(l?"Provide only the amount for this Spark action.":"Spark listing takes no arguments.");if(!l)return 0n;if(v&&s.amount==="max")return"max";if(typeof s.amount!="string")throw new p("Amount must be a positive integer string in base units.");let n=R(s.amount);if(n===0n||n>G)throw new p("Amount must be positive and within the uint256 range.");return n}var N=s=>{async function l(a){try{return await a()}catch(e){throw new p(s.plainError(e))}}async function v(a){W(a);let e=s.clientFor(h);if(await e.getChainId()!==h)throw new p("Spark requires an endpoint on chain 4663.");let[r,c,o]=await Promise.all([e.readContract({address:f,abi:k,functionName:"asset"}),e.readContract({address:f,abi:k,functionName:"decimals"}),e.readContract({address:b,abi:O,functionName:"decimals"})]);if(typeof r!="string"||!$(r,b))throw new p("Spark does not report the expected USDG asset on chain 4663.");if(c!==u.decimals||o!==i.decimals)throw new p("Spark shares and USDG must both have 6 decimals.");return async(d,x=[])=>{let m=await e.readContract({address:f,abi:k,functionName:d,args:x});if(typeof m!="bigint"||m<0n||m>G)throw new p(`Spark returned an invalid ${d} value.`);return m}}function n(a){let e=a.amount.startsWith("-"),r=e?a.amount.slice(1):a.amount;return`${e?"-":""}${s.formatAmount(r,a.token.decimals)} ${a.token.symbol}`}async function S(a,e,r,c){let o=await s.preview(a,e),d=o.changes.map(n).join(", ");return{txs:a,amounts:r,preview:o,summary:`${c} Preview values can change before execution. ${o.summary}${d?` Changes: ${d}.`:""}`}}return{positions:a=>l(async()=>{let e=await v(a),r=await e("balanceOf",[a]);if(r===0n)return[];let[c,o,d]=await Promise.all([e("previewRedeem",[r]),e("maxRedeem",[a]),e("maxWithdraw",[a])]);return[{module:"spark",id:`${h}:${f}`,chainId:h,assets:[t(u,r)],description:`${n(t(u,r))}; redeem preview ${n(t(i,c))} (rounded down). Current maximum redeem ${n(t(u,o))}; maximum withdrawal ${n(t(i,d))}.`}]}),tools:[I(s),...M(s),...U(s),{name:"spark_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(a,e)=>l(async()=>{y(a,!1);let r=await v(e),c=await r("totalAssets"),[o,d,x,m,w]=await Promise.all([r("balanceOf",[e]),r("maxDeposit",[e]),r("maxWithdraw",[e]),r("maxRedeem",[e]),r("previewDeposit",[1000000n])]),g=await r("previewRedeem",[o]);return[{chainId:h,address:f,name:"Spark Savings USDG",asset:{...i},shareToken:{...u},totalAssets:t(i,c),balance:t(u,o),maxDeposit:t(i,d),maxWithdraw:t(i,x),maxRedeem:t(u,m),previewDepositAssets:t(i,1000000n),previewDeposit:t(u,w),previewRedeemShares:t(u,o),previewRedeem:t(i,g),rounding:"Deposit shares and redeemed assets round down; exact-asset withdrawals round shares up. Previews can change before execution."}]})},{name:"spark_deposit",inputSchema:{type:"object",properties:{amount:P("Positive USDG base-unit integer (6 decimals).")},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=y(a,!0),c=await v(e),[o,d]=await Promise.all([c("maxDeposit",[e]),c("previewDeposit",[r])]);if(r>o)throw new p("The deposit exceeds Spark\u2019s current maximum deposit.");if(d===0n)throw new p("This deposit would return zero Spark shares.");let x=[s.approval(b,f,r.toString(),h),s.unsignedTx({to:f,data:A({abi:k,functionName:"deposit",args:[r,e]}),value:"0",chainId:h,description:`Deposit ${n(t(i,r))} into Spark for this wallet.`})];return S(x,e,{assets:t(i,r),shares:t(u,d),maxDeposit:t(i,o)},`Approve exactly ${n(t(i,r))} for Spark ${f}, then deposit. Expected ${n(t(u,d))}, rounded down; current maximum deposit ${n(t(i,o))}.`)})},{name:"spark_withdraw",inputSchema:{type:"object",properties:{amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:"Positive USDG base-unit integer (6 decimals), or max to redeem all held shares."}},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=y(a,!0,!0),c=await v(e),[o,d,x]=await Promise.all([c("balanceOf",[e]),c("maxWithdraw",[e]),c("maxRedeem",[e])]);if(o===0n)throw new p("This wallet has no Spark shares to withdraw.");let m,w,g;if(r==="max"){if(w=o,w>x)throw new p("The full share balance exceeds Spark\u2019s current maximum redeem. Request an asset amount within the current maximum withdrawal.");m=await c("previewRedeem",[w]),g=A({abi:k,functionName:"redeem",args:[w,e,e]})}else{if(m=r,m>d)throw new p("The withdrawal exceeds Spark\u2019s current maximum withdrawal.");if(w=await c("previewWithdraw",[m]),w>o)throw new p("This wallet has insufficient Spark shares for the withdrawal.");g=A({abi:k,functionName:"withdraw",args:[m,e,e]})}if(m===0n||w===0n)throw new p("Spark returned a zero asset or share preview for this withdrawal.");let _=r==="max"?`Redeem all ${n(t(u,w))} from Spark to this wallet.`:`Withdraw ${n(t(i,m))} from Spark to this wallet.`,j=[s.unsignedTx({to:f,data:g,value:"0",chainId:h,description:_})];return S(j,e,{assets:t(i,m),shares:t(u,w),maxWithdraw:t(i,d),maxRedeem:t(u,x)},r==="max"?`Redeem all ${n(t(u,w))} for an expected ${n(t(i,m))}, rounded down. Current maximum redeem ${n(t(u,x))}.`:`Withdraw ${n(t(i,m))} using an expected ${n(t(u,w))}, rounded up. Current maximum withdrawal ${n(t(i,d))}.`)})}]}};function Z(s){return C("spark",[N(s)])}export{N as a,Z as b};
1
+ import{a as U}from"./6AWTAE4Q.js";import{b as I}from"./52DHGSG4.js";import{b as M}from"./S3HNPTXA.js";import{b as C}from"./AXYOJBX6.js";import{a as W}from"./6IM6A5VA.js";import{a as P}from"./UWOFA6GV.js";import{g as $}from"./73N3TOJL.js";import{a as R}from"./RETS2ZEK.js";import{a as h,d as D,i as T,j as b}from"./G6HCV67X.js";import{a as p}from"./5YS5V2LK.js";import{encodeFunctionData as A,erc20Abi as O,parseAbi as E}from"viem";var f=T[h].vaults.spark.address,i={address:b,chainId:h,symbol:"USDG",decimals:D},u={address:f,chainId:h,symbol:"spUSDG",decimals:6},G=(1n<<256n)-1n,k=E(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function maxDeposit(address receiver) view returns (uint256)","function maxWithdraw(address owner) view returns (uint256)","function maxRedeem(address owner) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewWithdraw(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),t=(s,l)=>({token:{...s},amount:l.toString()});function y(s,l,v=!1){if(!s||typeof s!="object"||Array.isArray(s)||Object.keys(s).some(S=>!l||S!=="amount"))throw new p(l?"Provide only the amount for this Spark action.":"Spark listing takes no arguments.");if(!l)return 0n;if(v&&s.amount==="max")return"max";if(typeof s.amount!="string")throw new p("Amount must be a positive integer string in base units.");let n=R(s.amount);if(n===0n||n>G)throw new p("Amount must be positive and within the uint256 range.");return n}var N=s=>{async function l(a){try{return await a()}catch(e){throw new p(s.plainError(e))}}async function v(a){W(a);let e=s.clientFor(h);if(await e.getChainId()!==h)throw new p("Spark requires an endpoint on chain 4663.");let[r,c,o]=await Promise.all([e.readContract({address:f,abi:k,functionName:"asset"}),e.readContract({address:f,abi:k,functionName:"decimals"}),e.readContract({address:b,abi:O,functionName:"decimals"})]);if(typeof r!="string"||!$(r,b))throw new p("Spark does not report the expected USDG asset on chain 4663.");if(c!==u.decimals||o!==i.decimals)throw new p("Spark shares and USDG must both have 6 decimals.");return async(d,x=[])=>{let m=await e.readContract({address:f,abi:k,functionName:d,args:x});if(typeof m!="bigint"||m<0n||m>G)throw new p(`Spark returned an invalid ${d} value.`);return m}}function n(a){let e=a.amount.startsWith("-"),r=e?a.amount.slice(1):a.amount;return`${e?"-":""}${s.formatAmount(r,a.token.decimals)} ${a.token.symbol}`}async function S(a,e,r,c){let o=await s.preview(a,e),d=o.changes.map(n).join(", ");return{txs:a,amounts:r,preview:o,summary:`${c} Preview values can change before execution. ${o.summary}${d?` Changes: ${d}.`:""}`}}return{positions:a=>l(async()=>{let e=await v(a),r=await e("balanceOf",[a]);if(r===0n)return[];let[c,o,d]=await Promise.all([e("previewRedeem",[r]),e("maxRedeem",[a]),e("maxWithdraw",[a])]);return[{module:"spark",id:`${h}:${f}`,chainId:h,assets:[t(u,r)],description:`${n(t(u,r))}; redeem preview ${n(t(i,c))} (rounded down). Current maximum redeem ${n(t(u,o))}; maximum withdrawal ${n(t(i,d))}.`}]}),tools:[I(s),...M(s),...U(s),{name:"spark_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(a,e)=>l(async()=>{y(a,!1);let r=await v(e),c=await r("totalAssets"),[o,d,x,m,w]=await Promise.all([r("balanceOf",[e]),r("maxDeposit",[e]),r("maxWithdraw",[e]),r("maxRedeem",[e]),r("previewDeposit",[1000000n])]),g=await r("previewRedeem",[o]);return[{chainId:h,address:f,name:"Spark Savings USDG",asset:{...i},shareToken:{...u},totalAssets:t(i,c),balance:t(u,o),maxDeposit:t(i,d),maxWithdraw:t(i,x),maxRedeem:t(u,m),previewDepositAssets:t(i,1000000n),previewDeposit:t(u,w),previewRedeemShares:t(u,o),previewRedeem:t(i,g),rounding:"Deposit shares and redeemed assets round down; exact-asset withdrawals round shares up. Previews can change before execution."}]})},{name:"spark_deposit",inputSchema:{type:"object",properties:{amount:P("Positive USDG base-unit integer (6 decimals).")},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=y(a,!0),c=await v(e),[o,d]=await Promise.all([c("maxDeposit",[e]),c("previewDeposit",[r])]);if(r>o)throw new p("The deposit exceeds Spark\u2019s current maximum deposit.");if(d===0n)throw new p("This deposit would return zero Spark shares.");let x=[s.approval(b,f,r.toString(),h),s.unsignedTx({to:f,data:A({abi:k,functionName:"deposit",args:[r,e]}),value:"0",chainId:h,description:`Deposit ${n(t(i,r))} into Spark for this wallet.`})];return S(x,e,{assets:t(i,r),shares:t(u,d),maxDeposit:t(i,o)},`Approve exactly ${n(t(i,r))} for Spark ${f}, then deposit. Expected ${n(t(u,d))}, rounded down; current maximum deposit ${n(t(i,o))}.`)})},{name:"spark_withdraw",inputSchema:{type:"object",properties:{amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:"Positive USDG base-unit integer (6 decimals), or max to redeem all held shares."}},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=y(a,!0,!0),c=await v(e),[o,d,x]=await Promise.all([c("balanceOf",[e]),c("maxWithdraw",[e]),c("maxRedeem",[e])]);if(o===0n)throw new p("This wallet has no Spark shares to withdraw.");let m,w,g;if(r==="max"){if(w=o,w>x)throw new p("The full share balance exceeds Spark\u2019s current maximum redeem. Request an asset amount within the current maximum withdrawal.");m=await c("previewRedeem",[w]),g=A({abi:k,functionName:"redeem",args:[w,e,e]})}else{if(m=r,m>d)throw new p("The withdrawal exceeds Spark\u2019s current maximum withdrawal.");if(w=await c("previewWithdraw",[m]),w>o)throw new p("This wallet has insufficient Spark shares for the withdrawal.");g=A({abi:k,functionName:"withdraw",args:[m,e,e]})}if(m===0n||w===0n)throw new p("Spark returned a zero asset or share preview for this withdrawal.");let _=r==="max"?`Redeem all ${n(t(u,w))} from Spark to this wallet.`:`Withdraw ${n(t(i,m))} from Spark to this wallet.`,j=[s.unsignedTx({to:f,data:g,value:"0",chainId:h,description:_})];return S(j,e,{assets:t(i,m),shares:t(u,w),maxWithdraw:t(i,d),maxRedeem:t(u,x)},r==="max"?`Redeem all ${n(t(u,w))} for an expected ${n(t(i,m))}, rounded down. Current maximum redeem ${n(t(u,x))}.`:`Withdraw ${n(t(i,m))} using an expected ${n(t(u,w))}, rounded up. Current maximum withdrawal ${n(t(i,d))}.`)})}]}};function Z(s){return C("spark",[N(s)])}export{N as a,Z as b};
@@ -1 +1 @@
1
- import{d as b,h as v,l as I,n as k,r as S}from"./2EDXKJ3B.js";import{a as T}from"./X5V2Z2NM.js";import{e as c,g as y}from"./73N3TOJL.js";import{a as i}from"./5YS5V2LK.js";import{a as l}from"./JXOEJPJ4.js";import{lookup as C}from"node:dns/promises";import{isIP as p}from"node:net";var N="/.well-known/agent-registration.json",P=262144;function R(n){let r=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i.exec(n);if(r)return R(r[1]);if(p(n)===4){let[e,t]=n.split(".").map(Number);return!(e===0||e===10||e===127||e>=224||e===100&&t>=64&&t<=127||e===169&&t===254||e===172&&t>=16&&t<=31||e===192&&t===168||e===192&&t===0||e===198&&(t===18||t===19))}if(p(n)===6){let e=n.toLowerCase();return!(e==="::"||e==="::1"||/^f[cd]/.test(e)||/^fe[89ab]/.test(e)||e.startsWith("ff")||e.startsWith("2001:db8")||e.startsWith("64:ff9b"))}return!1}async function E(n){let r;try{r=new URL(n)}catch{throw new i("Not a valid URL.")}if(r.protocol!=="https:"||r.username||r.password||r.port||p(r.hostname.replace(/^\[|\]$/g,""))!==0||!r.hostname.includes(".")||/\.(?:local|internal|localhost|lan)$/i.test(r.hostname))throw new i("Only public HTTPS hostnames on the default port are checked.");let e=await C(r.hostname,{all:!0});if(!e.length||!e.every(t=>R(t.address)))throw new i("That hostname does not resolve to a public address.");return r.hostname}async function L(n,r){let e=await n.http(r,{method:"GET",headers:{accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(8e3)});if(!e.ok)throw new i(`The server answered HTTP ${e.status}.`);if(Number(e.headers.get("content-length")??0)>P)throw new i("The file is larger than 256 KiB.");let a=await e.text();if(a.length>P)throw new i("The file is larger than 256 KiB.");try{return JSON.parse(a)}catch{throw new i("The file is not JSON.")}}function O(n,r,e){return Array.isArray(n)&&n.some(t=>c(t)&&typeof t.agentRegistry=="string"&&y(t.agentRegistry,r)&&(typeof t.agentId=="number"||typeof t.agentId=="string")&&String(t.agentId)===e.toString())}var J=n=>({tools:[{name:"erc8004_verify_domain",inputSchema:{type:"object",additionalProperties:!1,required:["agentId"],description:"Read-only, optional ERC-8004 endpoint-domain verification: for each HTTPS service endpoint in the agent's on-chain profile, fetch https://{domain}/.well-known/agent-registration.json and check it lists this registry and agent ID. Only public HTTPS names are fetched; the profile itself is read only from a data: URI.",properties:{agentId:b,endpoint:{type:"string",description:"Check only this HTTPS endpoint (must be one of the profile's services)."}}},async execute(e){try{k(n,e.chainId);let t=I(e.agentId),{chainId:a,registry:H,registryId:u}=v(n),h=await n.clientFor(a).readContract({address:H,abi:T,functionName:"tokenURI",args:[t]});if(typeof h!="string")throw new i("The registry returned an invalid URI.");let f=S(h);if(!f)return{agentId:t.toString(),verified:null,reason:"The agent profile is not a base64 data: URI, so Oak will not fetch it from an agent-controlled location. Pass the endpoint host check yourself, or update the profile to a data: URI.",uri:l(h)};let g=(Array.isArray(f.services)?f.services.filter(c):[]).map(o=>String(o.endpoint??"")).filter(o=>/^https:\/\//i.test(o)),m=e.endpoint===void 0?g:g.filter(o=>o===e.endpoint);if(e.endpoint!==void 0&&!m.length)throw new i("That endpoint is not an HTTPS service in the agent's profile.");let U=[...new Set(m.map(o=>{try{return new URL(o).hostname}catch{return""}}).filter(Boolean))].slice(0,10),s=[];for(let o of U)try{await E(`https://${o}/`);let d=await L(n,`https://${o}${N}`),A=c(d)?d.registrations:void 0,w=O(A,u,t);s.push({domain:l(o),verified:w,reason:w?"The well-known file lists this registry and agent ID.":"The well-known file does not list this registry and agent ID."})}catch(d){s.push({domain:l(o),verified:!1,reason:n.plainError(d)})}return{agentId:t.toString(),registry:u,domains:s,checked:s.length,note:s.length?"Verified means that domain publishes a file naming this agent; it proves domain control by the agent, not that the endpoint is safe.":"The profile lists no HTTPS service endpoints to verify."}}catch(t){throw new i(n.plainError(t))}}}]});export{R as a,J as b};
1
+ import{d as b,h as v,l as I,n as k,r as S}from"./TWSTOFN3.js";import{a as T}from"./X5V2Z2NM.js";import{e as c,g as y}from"./73N3TOJL.js";import{a as i}from"./5YS5V2LK.js";import{a as l}from"./JXOEJPJ4.js";import{lookup as C}from"node:dns/promises";import{isIP as p}from"node:net";var N="/.well-known/agent-registration.json",P=262144;function R(n){let r=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i.exec(n);if(r)return R(r[1]);if(p(n)===4){let[e,t]=n.split(".").map(Number);return!(e===0||e===10||e===127||e>=224||e===100&&t>=64&&t<=127||e===169&&t===254||e===172&&t>=16&&t<=31||e===192&&t===168||e===192&&t===0||e===198&&(t===18||t===19))}if(p(n)===6){let e=n.toLowerCase();return!(e==="::"||e==="::1"||/^f[cd]/.test(e)||/^fe[89ab]/.test(e)||e.startsWith("ff")||e.startsWith("2001:db8")||e.startsWith("64:ff9b"))}return!1}async function E(n){let r;try{r=new URL(n)}catch{throw new i("Not a valid URL.")}if(r.protocol!=="https:"||r.username||r.password||r.port||p(r.hostname.replace(/^\[|\]$/g,""))!==0||!r.hostname.includes(".")||/\.(?:local|internal|localhost|lan)$/i.test(r.hostname))throw new i("Only public HTTPS hostnames on the default port are checked.");let e=await C(r.hostname,{all:!0});if(!e.length||!e.every(t=>R(t.address)))throw new i("That hostname does not resolve to a public address.");return r.hostname}async function L(n,r){let e=await n.http(r,{method:"GET",headers:{accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(8e3)});if(!e.ok)throw new i(`The server answered HTTP ${e.status}.`);if(Number(e.headers.get("content-length")??0)>P)throw new i("The file is larger than 256 KiB.");let a=await e.text();if(a.length>P)throw new i("The file is larger than 256 KiB.");try{return JSON.parse(a)}catch{throw new i("The file is not JSON.")}}function O(n,r,e){return Array.isArray(n)&&n.some(t=>c(t)&&typeof t.agentRegistry=="string"&&y(t.agentRegistry,r)&&(typeof t.agentId=="number"||typeof t.agentId=="string")&&String(t.agentId)===e.toString())}var J=n=>({tools:[{name:"erc8004_verify_domain",inputSchema:{type:"object",additionalProperties:!1,required:["agentId"],description:"Read-only, optional ERC-8004 endpoint-domain verification: for each HTTPS service endpoint in the agent's on-chain profile, fetch https://{domain}/.well-known/agent-registration.json and check it lists this registry and agent ID. Only public HTTPS names are fetched; the profile itself is read only from a data: URI.",properties:{agentId:b,endpoint:{type:"string",description:"Check only this HTTPS endpoint (must be one of the profile's services)."}}},async execute(e){try{k(n,e.chainId);let t=I(e.agentId),{chainId:a,registry:H,registryId:u}=v(n),h=await n.clientFor(a).readContract({address:H,abi:T,functionName:"tokenURI",args:[t]});if(typeof h!="string")throw new i("The registry returned an invalid URI.");let f=S(h);if(!f)return{agentId:t.toString(),verified:null,reason:"The agent profile is not a base64 data: URI, so Oak will not fetch it from an agent-controlled location. Pass the endpoint host check yourself, or update the profile to a data: URI.",uri:l(h)};let g=(Array.isArray(f.services)?f.services.filter(c):[]).map(o=>String(o.endpoint??"")).filter(o=>/^https:\/\//i.test(o)),m=e.endpoint===void 0?g:g.filter(o=>o===e.endpoint);if(e.endpoint!==void 0&&!m.length)throw new i("That endpoint is not an HTTPS service in the agent's profile.");let U=[...new Set(m.map(o=>{try{return new URL(o).hostname}catch{return""}}).filter(Boolean))].slice(0,10),s=[];for(let o of U)try{await E(`https://${o}/`);let d=await L(n,`https://${o}${N}`),A=c(d)?d.registrations:void 0,w=O(A,u,t);s.push({domain:l(o),verified:w,reason:w?"The well-known file lists this registry and agent ID.":"The well-known file does not list this registry and agent ID."})}catch(d){s.push({domain:l(o),verified:!1,reason:n.plainError(d)})}return{agentId:t.toString(),registry:u,domains:s,checked:s.length,note:s.length?"Verified means that domain publishes a file naming this agent; it proves domain control by the agent, not that the endpoint is safe.":"The profile lists no HTTPS service endpoints to verify."}}catch(t){throw new i(n.plainError(t))}}}]});export{R as a,J as b};
@@ -1 +1 @@
1
- import{e as h}from"./2SNQWKHA.js";import{c as k}from"./MYBDO5SA.js";import{a as p}from"./UWOFA6GV.js";import{i as u}from"./73N3TOJL.js";import{a as n}from"./5YS5V2LK.js";var _="hoodlock_public",t="https://hoodlock.tech",f=["lp_locks","lp_lock","airdrop_history","airdrop_list","airdrop_list_by_root","featured","feature_tiers","buyback_status","referral_available","links"];function x(c){return{tools:[{name:_,inputSchema:{type:"object",properties:{route:{type:"string",enum:[...f]},id:p(),account:{type:"string"},token:{type:"string"},root:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},code:{type:"string",minLength:1,maxLength:64}},required:["route"],additionalProperties:!1},async execute(e,b){try{let i=String(e.route);if(!f.includes(i))throw new n("Choose a published HoodLock public read route.");let m=e.account??b,s=r=>u(r,"Provide a checksummed wallet or token address."),a=()=>h(e.id,"id").toString(),o;switch(i){case"links":{let r=e.id===void 0?void 0:a();return{source:t,links:{lockChecker:`${t}/lock-checker`,liquidityChecker:`${t}/liquidity-lock-checker`,burnChecker:`${t}/burn-checker`,vestingChecker:`${t}/vesting-checker`,embedDocs:`${t}/docs/embed`,badgeDocs:`${t}/docs/badge`,...e.token===void 0?{}:{token:`${t}/token/${s(e.token)}`},...r===void 0?{}:Object.fromEntries(["lock","burn","vesting","position"].map(l=>[l,`${t}/proof/${l}/${r}`]))},summary:"HoodLock-only records and integration links. Empty HoodLock results do not establish that no external locks or burns exist."}}case"lp_locks":o="/api/lp/locks";break;case"lp_lock":o=`/api/lp/lock/${a()}`;break;case"airdrop_history":o=`/api/airdrop/history?address=${s(m)}`;break;case"airdrop_list":o=`/api/airdrop/${a()}/list.json`;break;case"airdrop_list_by_root":if(typeof e.root!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.root))throw new n("Provide a bytes32 Merkle root.");o=`/api/airdrop/list-by-root/${e.root}.json`;break;case"featured":o="/api/featured";break;case"feature_tiers":o="/api/feature/tiers";break;case"referral_available":if(typeof e.code!="string"||e.code.length<1||e.code.length>64)throw new n("Provide a referral code with 1 to 64 characters.");o=`/api/aff/available?code=${encodeURIComponent(e.code)}`;break;default:o="/api/revenue/pool"}let d=`${t}${o}`,y=await k(c.http,d,{method:"GET",redirect:"error",signal:AbortSignal.timeout(1e4)},r=>r!==null&&typeof r=="object");return{source:d,data:y,untrusted:!0,summary:"Public off-chain HoodLock data. Verify custody, proofs, balances and authority on chain; API labels and indexes may lag. No transaction, authentication, payment or publication was performed."}}catch(i){throw new n(c.plainError(i))}}}]}}export{_ as a,x as b};
1
+ import{e as h}from"./VFSRRDLY.js";import{c as k}from"./MYBDO5SA.js";import{a as p}from"./UWOFA6GV.js";import{i as u}from"./73N3TOJL.js";import{a as n}from"./5YS5V2LK.js";var _="hoodlock_public",t="https://hoodlock.tech",f=["lp_locks","lp_lock","airdrop_history","airdrop_list","airdrop_list_by_root","featured","feature_tiers","buyback_status","referral_available","links"];function x(c){return{tools:[{name:_,inputSchema:{type:"object",properties:{route:{type:"string",enum:[...f]},id:p(),account:{type:"string"},token:{type:"string"},root:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},code:{type:"string",minLength:1,maxLength:64}},required:["route"],additionalProperties:!1},async execute(e,b){try{let i=String(e.route);if(!f.includes(i))throw new n("Choose a published HoodLock public read route.");let m=e.account??b,s=r=>u(r,"Provide a checksummed wallet or token address."),a=()=>h(e.id,"id").toString(),o;switch(i){case"links":{let r=e.id===void 0?void 0:a();return{source:t,links:{lockChecker:`${t}/lock-checker`,liquidityChecker:`${t}/liquidity-lock-checker`,burnChecker:`${t}/burn-checker`,vestingChecker:`${t}/vesting-checker`,embedDocs:`${t}/docs/embed`,badgeDocs:`${t}/docs/badge`,...e.token===void 0?{}:{token:`${t}/token/${s(e.token)}`},...r===void 0?{}:Object.fromEntries(["lock","burn","vesting","position"].map(l=>[l,`${t}/proof/${l}/${r}`]))},summary:"HoodLock-only records and integration links. Empty HoodLock results do not establish that no external locks or burns exist."}}case"lp_locks":o="/api/lp/locks";break;case"lp_lock":o=`/api/lp/lock/${a()}`;break;case"airdrop_history":o=`/api/airdrop/history?address=${s(m)}`;break;case"airdrop_list":o=`/api/airdrop/${a()}/list.json`;break;case"airdrop_list_by_root":if(typeof e.root!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.root))throw new n("Provide a bytes32 Merkle root.");o=`/api/airdrop/list-by-root/${e.root}.json`;break;case"featured":o="/api/featured";break;case"feature_tiers":o="/api/feature/tiers";break;case"referral_available":if(typeof e.code!="string"||e.code.length<1||e.code.length>64)throw new n("Provide a referral code with 1 to 64 characters.");o=`/api/aff/available?code=${encodeURIComponent(e.code)}`;break;default:o="/api/revenue/pool"}let d=`${t}${o}`,y=await k(c.http,d,{method:"GET",redirect:"error",signal:AbortSignal.timeout(1e4)},r=>r!==null&&typeof r=="object");return{source:d,data:y,untrusted:!0,summary:"Public off-chain HoodLock data. Verify custody, proofs, balances and authority on chain; API labels and indexes may lag. No transaction, authentication, payment or publication was performed."}}catch(i){throw new n(c.plainError(i))}}}]}}export{_ as a,x as b};
@@ -1 +1 @@
1
- import{e as g,f as T,g as k,i as E}from"./JC4SYMBV.js";import{c as _,d as S}from"./46ZA2R5L.js";import{g as h}from"./73N3TOJL.js";import{a as l}from"./XPFVT2EA.js";import{a as i}from"./5YS5V2LK.js";import{decodeAbiParameters as B,encodeAbiParameters as H,getAddress as d}from"viem";var D=d("0xcEF685D4796FA80F71a97e803D2c0b6719F1b4E2"),O=[{name:"items",type:"tuple[]",components:[{...k[0],name:"offer"},{name:"ratifierData",type:"bytes"}]}],G=p=>({tools:[{name:"longbow_fixed_offers",inputSchema:{type:"object",additionalProperties:!1,properties:{limit:{type:"integer",minimum:1,maximum:50},marketId:{type:"string"}}},execute:async o=>{try{let a=o.limit??20;if(Object.keys(o).some(s=>!["limit","marketId"].includes(s))||!Number.isInteger(a)||Number(a)<1||Number(a)>50||o.marketId!==void 0&&(typeof o.marketId!="string"||!/^0x[0-9a-f]{64}$/i.test(o.marketId)))throw new i("Use limit 1..50 and an optional exact bytes32 marketId.");let f=await p.http("https://longbow.credit/api/fixed/offers",{method:"GET",redirect:"error"});if(!f.ok)throw new i(`Longbow fixed order book returned HTTP ${f.status}; offers are unavailable.`);let x=await f.text();if(x.length>2e6)throw new i("Longbow fixed order book exceeds the supported response size.");let t=JSON.parse(x);if(!t||t.chainId!==l||typeof t.mempool!="string"||d(t.mempool)!==D||!Array.isArray(t.publications)||t.publications.length>1e3||!Number.isSafeInteger(t.head)||Number(t.head)<0)throw new i("Longbow fixed indexer does not match the pinned chain, mempool or publication schema.");let c=[],u=[],y=0;for(let[s,m]of t.publications.entries())try{if(!m||typeof m!="object")throw new i("Invalid publication.");let r=m,n=r.itemsAbi;if(!Number.isSafeInteger(r.blockNumber)||Number(r.blockNumber)<0||Number(r.blockNumber)>Number(t.head))throw new i("Invalid publication block.");if(typeof n!="string"||!/^0x[0-9a-f]+$/i.test(n)||n.length>1e6||n.length<130||BigInt(`0x${n.slice(2,66)}`)!==32n||BigInt(`0x${n.slice(66,130)}`)>512n)throw new i("Invalid or oversized publication encoding.");let[I]=B(O,n);if(I.length!==r.items)throw new i("Publication count mismatch.");for(let b of I){y++;let e=b.offer;if(e.market.chainId!==BigInt(l)||d(e.market.midnight)!==g||b.ratifierData.length>32770)throw new i("Publication market or proof is unqualified.");let w=E(e.market);if(o.marketId!==void 0&&!h(w,String(o.marketId)))continue;let N=[_,S].find(P=>h(P.address,e.market.loanToken));c.push({marketId:w,offer:H(k,[e]),ratifierData:b.ratifierData,maker:d(e.maker),buy:e.buy,maturity:e.market.maturity.toString(),start:e.start.toString(),expiry:e.expiry.toString(),tick:e.tick.toString(),loanToken:N??null,directBuilderSupported:!!N&&/^0x0{40}$/i.test(e.callback)&&e.callbackData==="0x"&&T.includes(d(e.ratifier)),sourceBlock:String(r.blockNumber)})}}catch(r){u.push({publication:s,reason:p.plainError(r)})}return c.sort((s,m)=>BigInt(s.expiry)>BigInt(m.expiry)?-1:BigInt(s.expiry)<BigInt(m.expiry)?1:0),{chainId:l,midnight:g,mempool:D,indexedHead:String(t.head),decodedCount:y,matchingCount:c.length,offers:c.slice(0,Number(a)),incomplete:u.length>0||t.skipped!==0,rejected:u,warning:"Historical off-chain publications, not executable quotes. Expiry, consumption, authorization, signatures and liquidity are not verified here. Use morpho_midnight_status and preview morpho_midnight_take with the returned exact offer/proof; callback offers need a separately qualified builder. This read publishes nothing and creates no signature."}}catch(a){throw new i(p.plainError(a))}}}]});export{D as a,O as b,G as c};
1
+ import{e as g,f as T,g as k,i as E}from"./L3ZM77SJ.js";import{c as _,d as S}from"./JPOYTTTW.js";import{g as h}from"./73N3TOJL.js";import{a as l}from"./G6HCV67X.js";import{a as i}from"./5YS5V2LK.js";import{decodeAbiParameters as B,encodeAbiParameters as H,getAddress as d}from"viem";var D=d("0xcEF685D4796FA80F71a97e803D2c0b6719F1b4E2"),O=[{name:"items",type:"tuple[]",components:[{...k[0],name:"offer"},{name:"ratifierData",type:"bytes"}]}],G=p=>({tools:[{name:"longbow_fixed_offers",inputSchema:{type:"object",additionalProperties:!1,properties:{limit:{type:"integer",minimum:1,maximum:50},marketId:{type:"string"}}},execute:async o=>{try{let a=o.limit??20;if(Object.keys(o).some(s=>!["limit","marketId"].includes(s))||!Number.isInteger(a)||Number(a)<1||Number(a)>50||o.marketId!==void 0&&(typeof o.marketId!="string"||!/^0x[0-9a-f]{64}$/i.test(o.marketId)))throw new i("Use limit 1..50 and an optional exact bytes32 marketId.");let f=await p.http("https://longbow.credit/api/fixed/offers",{method:"GET",redirect:"error"});if(!f.ok)throw new i(`Longbow fixed order book returned HTTP ${f.status}; offers are unavailable.`);let x=await f.text();if(x.length>2e6)throw new i("Longbow fixed order book exceeds the supported response size.");let t=JSON.parse(x);if(!t||t.chainId!==l||typeof t.mempool!="string"||d(t.mempool)!==D||!Array.isArray(t.publications)||t.publications.length>1e3||!Number.isSafeInteger(t.head)||Number(t.head)<0)throw new i("Longbow fixed indexer does not match the pinned chain, mempool or publication schema.");let c=[],u=[],y=0;for(let[s,m]of t.publications.entries())try{if(!m||typeof m!="object")throw new i("Invalid publication.");let r=m,n=r.itemsAbi;if(!Number.isSafeInteger(r.blockNumber)||Number(r.blockNumber)<0||Number(r.blockNumber)>Number(t.head))throw new i("Invalid publication block.");if(typeof n!="string"||!/^0x[0-9a-f]+$/i.test(n)||n.length>1e6||n.length<130||BigInt(`0x${n.slice(2,66)}`)!==32n||BigInt(`0x${n.slice(66,130)}`)>512n)throw new i("Invalid or oversized publication encoding.");let[I]=B(O,n);if(I.length!==r.items)throw new i("Publication count mismatch.");for(let b of I){y++;let e=b.offer;if(e.market.chainId!==BigInt(l)||d(e.market.midnight)!==g||b.ratifierData.length>32770)throw new i("Publication market or proof is unqualified.");let w=E(e.market);if(o.marketId!==void 0&&!h(w,String(o.marketId)))continue;let N=[_,S].find(P=>h(P.address,e.market.loanToken));c.push({marketId:w,offer:H(k,[e]),ratifierData:b.ratifierData,maker:d(e.maker),buy:e.buy,maturity:e.market.maturity.toString(),start:e.start.toString(),expiry:e.expiry.toString(),tick:e.tick.toString(),loanToken:N??null,directBuilderSupported:!!N&&/^0x0{40}$/i.test(e.callback)&&e.callbackData==="0x"&&T.includes(d(e.ratifier)),sourceBlock:String(r.blockNumber)})}}catch(r){u.push({publication:s,reason:p.plainError(r)})}return c.sort((s,m)=>BigInt(s.expiry)>BigInt(m.expiry)?-1:BigInt(s.expiry)<BigInt(m.expiry)?1:0),{chainId:l,midnight:g,mempool:D,indexedHead:String(t.head),decodedCount:y,matchingCount:c.length,offers:c.slice(0,Number(a)),incomplete:u.length>0||t.skipped!==0,rejected:u,warning:"Historical off-chain publications, not executable quotes. Expiry, consumption, authorization, signatures and liquidity are not verified here. Use morpho_midnight_status and preview morpho_midnight_take with the returned exact offer/proof; callback offers need a separately qualified builder. This read publishes nothing and creates no signature."}}catch(a){throw new i(p.plainError(a))}}}]});export{D as a,O as b,G as c};
@@ -1 +1 @@
1
- import{a as q}from"./RETS2ZEK.js";import{c as h}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";var Y="12333333",I=1800,N=9000n,O=9607n,C=150n,U=(1n<<256n)-1n,f=10000n,g=10n**18n,X=10n**30n,R=1n<<192n,D=20n*g,E=75n*g,_=100n*g,x=300n*g,P=100000n*g,S=500000n*g,w=1000000n*g,B=10000000n*g;function c(n){let t=typeof n=="bigint"?n:q(n);if(t<0n||t>U)throw new o("Amount must be within the uint256 range.");return t}function p(n){if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new o("Integer parameter must be a safe integer.");return BigInt(n)}if(typeof n!="string"||!/^-?\d+$/.test(n))throw new o("Value must be a signed integer decimal string.");return BigInt(n)}function A(n,t=77){let i=typeof n=="number"?n:typeof n=="string"&&/^\d+$/.test(n)?Number(n):NaN;if(!Number.isInteger(i)||i<0||i>t)throw new o(`Token decimals must be an integer from 0 to ${t}.`);return i}function k(n){return 10n**BigInt(n)}function T(n,t="Result"){if(n<0n||n>U)throw new o(`${t} exceeds uint256 bounds.`);return n}function b(n,t,i="Factor"){return T(n*t,i)}function a(n,t,i,s="floor"){if(i<=0n)throw new o("The denominator must be positive.");let e=n*t;if(e===0n)return 0n;let r=s==="ceil"?e/i+(e%i===0n?0n:1n):e/i;return T(r,"Math.mulDiv result")}function $(n){let t=c(n);return t<P?D.toString():t<S?(D+a(t-P,E-D,S-P)).toString():t<w?(E+a(t-S,_-E,w-S)).toString():t<B?(_+a(t-w,x-_,B-w)).toString():x.toString()}function Q(n){let t=c(n);return T(9000000n+t/1000000000000n/6n,"noHoldPriceBase").toString()}function j(n){let t=c(n);return a(t,5n,100n,"ceil").toString()}function z(n,t){let i=c(n),s=c(t);if(s<=0n)throw new o("OAK-per-ETH price must be positive.");return a(i,g,s,"floor").toString()}function G(n,t,i=h){let s=c(n),e=c(t);if(e<=0n)throw new o("OAK USD price must be positive.");let r=k(A(i));return a(s,r,e,"ceil").toString()}function J(n,t,i=h){let s=c(n),e=c(t),r=k(A(i));return a(s,e,r,"floor").toString()}function Z(n,t){let i=c(n),s=c(t);if(i>f||s>f)throw new o("FeePolicyOutOfBounds: hook fee or creator tax exceeds 10000 bps.");let e=i+s+C;if(e>f-N)throw new o("FeePolicyOutOfBounds: fees and impact allowance exceed 1000 bps.");let r=f-e;return(r>O?O:r).toString()}function nn(n,t,i,s,e){let r=A(s,83);if(r<6)throw new o("OAK decimals must be at least 6 for burner conversion.");let u=c(e);if(u<N||u>O)throw new o("InvalidBurnerFloor: floor must be from 9000 to 9607 bps.");let m=c(n),d=c(t),l=c(i);if(l<=0n)throw new o("ETH USD price must be positive.");let v=k(r-6),y=b(m,v,"burnerMinOut usdgIn * decimalScale"),W=b(d,u,"burnerMinOut oakPerEthE18 * floorBps"),M=b(l,f,"burnerMinOut ethUsdE18 * 10000");return a(y,W,M,"floor").toString()}function tn(n,t,i=I){let s=p(n),e=p(t),r=p(i);if(r<=0n)throw new o("Observation window seconds must be positive.");let u=e-s,d=u/r-(u<0n&&u%r!==0n?1n:0n);return Number(d)}function en(n){let t=c(n);if(t<=0n)throw new o("sqrtRatioX96 must be positive.");let i=b(t,t,"sqrtRatioX96 squared");return a(i,X,R,"floor").toString()}function F(n){let t=c(n);if(t<=0n)throw new o("sqrtPriceX96 must be positive.");let i=b(t,t,"sqrtPriceX96 squared");return a(i,g,R,"floor").toString()}function L(n){let t="ethAmountWei"in n&&n.ethAmountWei!==void 0?n.ethAmountWei:"ethVolumeWei"in n?n.ethVolumeWei:void 0;if(t===void 0)throw new o("SwapTrade must provide ethAmountWei.");let i=p(t),s=i<0n?-i:i;if(s<=0n)throw new o("SwapTrade ETH volume must be positive.");let e;n.sqrtPriceX96!==void 0&&n.sqrtPriceX96!==""&&n.sqrtPriceX96!=="0"&&(e=BigInt(F(n.sqrtPriceX96)));let r;if(n.oakPerEthE18!==void 0&&n.oakPerEthE18!==""&&(r=c(n.oakPerEthE18)),e!==void 0&&r!==void 0&&e!==r)throw new o("SwapTrade oakPerEthE18 does not match post-swap sqrtPriceX96.");let u=e??r;if(u===void 0||u<=0n)throw new o("SwapTrade must provide a positive post-swap price.");let m=n.timestamp!==void 0&&n.timestamp!==""?c(n.timestamp):void 0;return{volumeWei:s,oakPerEth:u,timestamp:m}}function rn(n,t){if(!Array.isArray(n)||n.length===0)throw new o("At least one SwapTrade is required to compute the 30-minute average.");let i=t?.windowEnd!==void 0?c(BigInt(t.windowEnd)):t?.now!==void 0?c(BigInt(t.now)):void 0,s=t?.windowStart!==void 0?c(BigInt(t.windowStart)):i!==void 0?i-BigInt(I):void 0,e=0n,r=0n;for(let u of n){let{volumeWei:m,oakPerEth:d,timestamp:l}=L(u);s!==void 0&&i!==void 0&&l!==void 0&&(l<s||l>=i)||(e+=m*d,r+=m)}if(r<=0n)throw new o("No trades with positive ETH volume fell inside the 30-minute window.");return(e/r).toString()}export{Y as a,I as b,N as c,O as d,C as e,$ as f,Q as g,j as h,z as i,G as j,J as k,Z as l,nn as m,tn as n,en as o,F as p,rn as q};
1
+ import{a as q}from"./RETS2ZEK.js";import{c as h}from"./G6HCV67X.js";import{a as o}from"./5YS5V2LK.js";var Y="12333333",I=1800,N=9000n,O=9607n,C=150n,U=(1n<<256n)-1n,f=10000n,g=10n**18n,X=10n**30n,R=1n<<192n,D=20n*g,E=75n*g,_=100n*g,x=300n*g,P=100000n*g,S=500000n*g,w=1000000n*g,B=10000000n*g;function c(n){let t=typeof n=="bigint"?n:q(n);if(t<0n||t>U)throw new o("Amount must be within the uint256 range.");return t}function p(n){if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new o("Integer parameter must be a safe integer.");return BigInt(n)}if(typeof n!="string"||!/^-?\d+$/.test(n))throw new o("Value must be a signed integer decimal string.");return BigInt(n)}function A(n,t=77){let i=typeof n=="number"?n:typeof n=="string"&&/^\d+$/.test(n)?Number(n):NaN;if(!Number.isInteger(i)||i<0||i>t)throw new o(`Token decimals must be an integer from 0 to ${t}.`);return i}function k(n){return 10n**BigInt(n)}function T(n,t="Result"){if(n<0n||n>U)throw new o(`${t} exceeds uint256 bounds.`);return n}function b(n,t,i="Factor"){return T(n*t,i)}function a(n,t,i,s="floor"){if(i<=0n)throw new o("The denominator must be positive.");let e=n*t;if(e===0n)return 0n;let r=s==="ceil"?e/i+(e%i===0n?0n:1n):e/i;return T(r,"Math.mulDiv result")}function $(n){let t=c(n);return t<P?D.toString():t<S?(D+a(t-P,E-D,S-P)).toString():t<w?(E+a(t-S,_-E,w-S)).toString():t<B?(_+a(t-w,x-_,B-w)).toString():x.toString()}function Q(n){let t=c(n);return T(9000000n+t/1000000000000n/6n,"noHoldPriceBase").toString()}function j(n){let t=c(n);return a(t,5n,100n,"ceil").toString()}function z(n,t){let i=c(n),s=c(t);if(s<=0n)throw new o("OAK-per-ETH price must be positive.");return a(i,g,s,"floor").toString()}function G(n,t,i=h){let s=c(n),e=c(t);if(e<=0n)throw new o("OAK USD price must be positive.");let r=k(A(i));return a(s,r,e,"ceil").toString()}function J(n,t,i=h){let s=c(n),e=c(t),r=k(A(i));return a(s,e,r,"floor").toString()}function Z(n,t){let i=c(n),s=c(t);if(i>f||s>f)throw new o("FeePolicyOutOfBounds: hook fee or creator tax exceeds 10000 bps.");let e=i+s+C;if(e>f-N)throw new o("FeePolicyOutOfBounds: fees and impact allowance exceed 1000 bps.");let r=f-e;return(r>O?O:r).toString()}function nn(n,t,i,s,e){let r=A(s,83);if(r<6)throw new o("OAK decimals must be at least 6 for burner conversion.");let u=c(e);if(u<N||u>O)throw new o("InvalidBurnerFloor: floor must be from 9000 to 9607 bps.");let m=c(n),d=c(t),l=c(i);if(l<=0n)throw new o("ETH USD price must be positive.");let v=k(r-6),y=b(m,v,"burnerMinOut usdgIn * decimalScale"),W=b(d,u,"burnerMinOut oakPerEthE18 * floorBps"),M=b(l,f,"burnerMinOut ethUsdE18 * 10000");return a(y,W,M,"floor").toString()}function tn(n,t,i=I){let s=p(n),e=p(t),r=p(i);if(r<=0n)throw new o("Observation window seconds must be positive.");let u=e-s,d=u/r-(u<0n&&u%r!==0n?1n:0n);return Number(d)}function en(n){let t=c(n);if(t<=0n)throw new o("sqrtRatioX96 must be positive.");let i=b(t,t,"sqrtRatioX96 squared");return a(i,X,R,"floor").toString()}function F(n){let t=c(n);if(t<=0n)throw new o("sqrtPriceX96 must be positive.");let i=b(t,t,"sqrtPriceX96 squared");return a(i,g,R,"floor").toString()}function L(n){let t="ethAmountWei"in n&&n.ethAmountWei!==void 0?n.ethAmountWei:"ethVolumeWei"in n?n.ethVolumeWei:void 0;if(t===void 0)throw new o("SwapTrade must provide ethAmountWei.");let i=p(t),s=i<0n?-i:i;if(s<=0n)throw new o("SwapTrade ETH volume must be positive.");let e;n.sqrtPriceX96!==void 0&&n.sqrtPriceX96!==""&&n.sqrtPriceX96!=="0"&&(e=BigInt(F(n.sqrtPriceX96)));let r;if(n.oakPerEthE18!==void 0&&n.oakPerEthE18!==""&&(r=c(n.oakPerEthE18)),e!==void 0&&r!==void 0&&e!==r)throw new o("SwapTrade oakPerEthE18 does not match post-swap sqrtPriceX96.");let u=e??r;if(u===void 0||u<=0n)throw new o("SwapTrade must provide a positive post-swap price.");let m=n.timestamp!==void 0&&n.timestamp!==""?c(n.timestamp):void 0;return{volumeWei:s,oakPerEth:u,timestamp:m}}function rn(n,t){if(!Array.isArray(n)||n.length===0)throw new o("At least one SwapTrade is required to compute the 30-minute average.");let i=t?.windowEnd!==void 0?c(BigInt(t.windowEnd)):t?.now!==void 0?c(BigInt(t.now)):void 0,s=t?.windowStart!==void 0?c(BigInt(t.windowStart)):i!==void 0?i-BigInt(I):void 0,e=0n,r=0n;for(let u of n){let{volumeWei:m,oakPerEth:d,timestamp:l}=L(u);s!==void 0&&i!==void 0&&l!==void 0&&(l<s||l>=i)||(e+=m*d,r+=m)}if(r<=0n)throw new o("No trades with positive ETH volume fell inside the 30-minute window.");return(e/r).toString()}export{Y as a,I as b,N as c,O as d,C as e,$ as f,Q as g,j as h,z as i,G as j,J as k,Z as l,nn as m,tn as n,en as o,F as p,rn as q};