@oakagentkit/core 0.2.4 → 0.2.5

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 (448) hide show
  1. package/build/dist/api/amounts.d.ts +2 -0
  2. package/build/dist/api/amounts.js +1 -1
  3. package/build/dist/api/args.js +1 -1
  4. package/build/dist/api/gas.js +1 -1
  5. package/build/dist/api/grandfather.js +1 -1
  6. package/build/dist/api/guards.js +1 -1
  7. package/build/dist/api/history.js +1 -1
  8. package/build/dist/api/http.js +1 -1
  9. package/build/dist/api/merkle.js +1 -1
  10. package/build/dist/api/module.js +1 -1
  11. package/build/dist/api/modules/beefy/boosts.js +1 -1
  12. package/build/dist/api/modules/beefy/clm.js +1 -1
  13. package/build/dist/api/modules/beefy/guard.js +1 -1
  14. package/build/dist/api/modules/beefy/index.js +1 -1
  15. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  16. package/build/dist/api/modules/beefy/management.js +1 -1
  17. package/build/dist/api/modules/beefy/vaults.js +1 -1
  18. package/build/dist/api/modules/borro/abi.d.ts +149 -0
  19. package/build/dist/api/modules/borro/abi.js +1 -0
  20. package/build/dist/api/modules/borro/actions.d.ts +2 -0
  21. package/build/dist/api/modules/borro/actions.js +1 -0
  22. package/build/dist/api/modules/borro/checks.d.ts +151 -0
  23. package/build/dist/api/modules/borro/checks.js +1 -0
  24. package/build/dist/api/modules/borro/copy.d.ts +174 -0
  25. package/build/dist/api/modules/borro/copy.js +1 -0
  26. package/build/dist/api/modules/borro/index.d.ts +13 -0
  27. package/build/dist/api/modules/borro/index.js +1 -0
  28. package/build/dist/api/modules/borro/liquidity.d.ts +4 -0
  29. package/build/dist/api/modules/borro/liquidity.js +1 -0
  30. package/build/dist/api/modules/borro/pins.d.ts +264 -0
  31. package/build/dist/api/modules/borro/pins.js +1 -0
  32. package/build/dist/api/modules/borro/positions.d.ts +8 -0
  33. package/build/dist/api/modules/borro/positions.js +1 -0
  34. package/build/dist/api/modules/borro/rates.d.ts +20 -0
  35. package/build/dist/api/modules/borro/rates.js +1 -0
  36. package/build/dist/api/modules/borro/reader.d.ts +32 -0
  37. package/build/dist/api/modules/borro/reader.js +1 -0
  38. package/build/dist/api/modules/borro/types.d.ts +120 -0
  39. package/build/dist/api/modules/borro/types.js +0 -0
  40. package/build/dist/api/modules/clanker/extensions.js +1 -1
  41. package/build/dist/api/modules/clanker/index.js +1 -1
  42. package/build/dist/api/modules/clanker/manage.js +1 -1
  43. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  44. package/build/dist/api/modules/clanker/protocol.js +1 -1
  45. package/build/dist/api/modules/clanker/state.js +1 -1
  46. package/build/dist/api/modules/earn/copy.d.ts +2 -2
  47. package/build/dist/api/modules/earn/copy.js +1 -1
  48. package/build/dist/api/modules/earn/index.js +1 -1
  49. package/build/dist/api/modules/earn/lp.js +1 -1
  50. package/build/dist/api/modules/earn/options.js +1 -1
  51. package/build/dist/api/modules/erc8004/common.js +1 -1
  52. package/build/dist/api/modules/erc8004/domain.js +1 -1
  53. package/build/dist/api/modules/erc8004/index.js +1 -1
  54. package/build/dist/api/modules/erc8004/management.js +1 -1
  55. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  56. package/build/dist/api/modules/erc8004/services.js +1 -1
  57. package/build/dist/api/modules/erc8004/validation.js +1 -1
  58. package/build/dist/api/modules/grove/index.js +1 -1
  59. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  60. package/build/dist/api/modules/heyresearch/index.js +1 -1
  61. package/build/dist/api/modules/heyresearch/proof-reads.js +1 -1
  62. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  63. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  64. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  65. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  66. package/build/dist/api/modules/hoodag/index.js +1 -1
  67. package/build/dist/api/modules/hoodag/management.js +1 -1
  68. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  69. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  70. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  71. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  72. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  73. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  74. package/build/dist/api/modules/hoodlock/index.js +1 -1
  75. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  76. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  77. package/build/dist/api/modules/hoodlock/public.js +1 -1
  78. package/build/dist/api/modules/hookr/actions.js +1 -1
  79. package/build/dist/api/modules/hookr/addons.js +1 -1
  80. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  81. package/build/dist/api/modules/hookr/contracts.js +1 -1
  82. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  83. package/build/dist/api/modules/hookr/discovery.js +1 -1
  84. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  85. package/build/dist/api/modules/hookr/index.js +1 -1
  86. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  87. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  88. package/build/dist/api/modules/hookr/launch.js +1 -1
  89. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  90. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  91. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  92. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  93. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  94. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  95. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  96. package/build/dist/api/modules/hookr/relay.js +1 -1
  97. package/build/dist/api/modules/hookr/revenue.js +1 -1
  98. package/build/dist/api/modules/kyberswap/index.js +1 -1
  99. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  100. package/build/dist/api/modules/layerbank/actions.js +1 -1
  101. package/build/dist/api/modules/layerbank/checks.js +1 -1
  102. package/build/dist/api/modules/layerbank/index.js +1 -1
  103. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  104. package/build/dist/api/modules/layerbank/reader.js +1 -1
  105. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  106. package/build/dist/api/modules/lighter/index.js +1 -1
  107. package/build/dist/api/modules/longbow/administration.js +1 -1
  108. package/build/dist/api/modules/longbow/analytics.js +1 -1
  109. package/build/dist/api/modules/longbow/fixed.js +1 -1
  110. package/build/dist/api/modules/longbow/index.js +1 -1
  111. package/build/dist/api/modules/longbow/nft.js +1 -1
  112. package/build/dist/api/modules/longbow/rebates.js +1 -1
  113. package/build/dist/api/modules/longbow/staking.js +1 -1
  114. package/build/dist/api/modules/meridian/index.js +1 -1
  115. package/build/dist/api/modules/meridian/markets.js +1 -1
  116. package/build/dist/api/modules/meridian/perps-batch.js +1 -1
  117. package/build/dist/api/modules/meridian/perps-common.js +1 -1
  118. package/build/dist/api/modules/meridian/perps-guards.js +1 -1
  119. package/build/dist/api/modules/meridian/perps-intents.js +1 -1
  120. package/build/dist/api/modules/meridian/perps-stream.js +1 -1
  121. package/build/dist/api/modules/meridian/perps.d.ts +1 -0
  122. package/build/dist/api/modules/meridian/perps.js +1 -1
  123. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  124. package/build/dist/api/modules/meridian/rfq.js +1 -1
  125. package/build/dist/api/modules/merkl/discovery.js +1 -1
  126. package/build/dist/api/modules/merkl/index.js +1 -1
  127. package/build/dist/api/modules/merkl/manage.js +1 -1
  128. package/build/dist/api/modules/merkl/protocol.js +1 -1
  129. package/build/dist/api/modules/morpho/allocator.js +1 -1
  130. package/build/dist/api/modules/morpho/bundles.js +1 -1
  131. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  132. package/build/dist/api/modules/morpho/index.js +1 -1
  133. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  134. package/build/dist/api/modules/morpho/midnight.js +1 -1
  135. package/build/dist/api/modules/morpho/protocol.js +1 -1
  136. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  137. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  138. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  139. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  140. package/build/dist/api/modules/netnet/card-read.js +1 -1
  141. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  142. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  143. package/build/dist/api/modules/netnet/financial.js +1 -1
  144. package/build/dist/api/modules/netnet/index.js +1 -1
  145. package/build/dist/api/modules/netnet/staking.js +1 -1
  146. package/build/dist/api/modules/orbio/gateway.js +1 -1
  147. package/build/dist/api/modules/orbio/index.js +1 -1
  148. package/build/dist/api/modules/orbio/positions.js +1 -1
  149. package/build/dist/api/modules/pendle/convert.js +1 -1
  150. package/build/dist/api/modules/pendle/costs.js +1 -1
  151. package/build/dist/api/modules/pendle/index.js +1 -1
  152. package/build/dist/api/modules/pendle/markets.js +1 -1
  153. package/build/dist/api/modules/pendle/positions.js +1 -1
  154. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  155. package/build/dist/api/modules/pendle/reader.js +1 -1
  156. package/build/dist/api/modules/pendle/redeem.js +1 -1
  157. package/build/dist/api/modules/pendle/trade.js +1 -1
  158. package/build/dist/api/modules/pendle/types.d.ts +16 -1
  159. package/build/dist/api/modules/pendle/validate.js +1 -1
  160. package/build/dist/api/modules/pendle/verify.js +1 -1
  161. package/build/dist/api/modules/pons/claim.js +1 -1
  162. package/build/dist/api/modules/pons/holder-directory.js +1 -1
  163. package/build/dist/api/modules/pons/index.js +1 -1
  164. package/build/dist/api/modules/pons/launch-status.js +1 -1
  165. package/build/dist/api/modules/pons/prices.js +1 -1
  166. package/build/dist/api/modules/pons/reads.js +1 -1
  167. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  168. package/build/dist/api/modules/pons/trade.js +1 -1
  169. package/build/dist/api/modules/poolstrade/index.js +1 -1
  170. package/build/dist/api/modules/priors/coverage.js +1 -1
  171. package/build/dist/api/modules/priors/discovery.js +1 -1
  172. package/build/dist/api/modules/priors/features.js +1 -1
  173. package/build/dist/api/modules/priors/holdings.js +1 -1
  174. package/build/dist/api/modules/priors/index.js +1 -1
  175. package/build/dist/api/modules/priors/integration.js +1 -1
  176. package/build/dist/api/modules/priors/market.js +1 -1
  177. package/build/dist/api/modules/priors/pt.js +1 -1
  178. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  179. package/build/dist/api/modules/priors/starter-line.js +1 -1
  180. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  181. package/build/dist/api/modules/relay/api.js +1 -1
  182. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  183. package/build/dist/api/modules/relay/discovery.js +1 -1
  184. package/build/dist/api/modules/relay/inbound.d.ts +2 -0
  185. package/build/dist/api/modules/relay/inbound.js +1 -1
  186. package/build/dist/api/modules/relay/index.js +1 -1
  187. package/build/dist/api/modules/relay/order.js +1 -1
  188. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  189. package/build/dist/api/modules/relay/readiness.js +1 -1
  190. package/build/dist/api/modules/relay/reads.js +1 -1
  191. package/build/dist/api/modules/relay/vaults.js +1 -1
  192. package/build/dist/api/modules/spark/actions.js +1 -1
  193. package/build/dist/api/modules/spark/details.js +1 -1
  194. package/build/dist/api/modules/spark/index.js +1 -1
  195. package/build/dist/api/modules/spark/management.js +1 -1
  196. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  197. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  198. package/build/dist/api/modules/steakhouse/index.js +1 -1
  199. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  200. package/build/dist/api/modules/steakhouse/management.js +1 -1
  201. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  202. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  203. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  204. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  205. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  206. package/build/dist/api/modules/tickerspring/index.js +1 -1
  207. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  208. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  209. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  210. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  211. package/build/dist/api/modules/tickerspring/research.js +1 -1
  212. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  213. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  214. package/build/dist/api/modules/uniswap/auction.js +1 -1
  215. package/build/dist/api/modules/uniswap/batch.js +1 -1
  216. package/build/dist/api/modules/uniswap/common.js +1 -1
  217. package/build/dist/api/modules/uniswap/fees.js +1 -1
  218. package/build/dist/api/modules/uniswap/index.js +1 -1
  219. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  220. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  221. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  222. package/build/dist/api/modules/uniswap/pools.js +1 -1
  223. package/build/dist/api/modules/uniswap/position.js +1 -1
  224. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  225. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  226. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  227. package/build/dist/api/modules/uniswap/trade.js +1 -1
  228. package/build/dist/api/modules/uniswap/v2.js +1 -1
  229. package/build/dist/api/modules/uniswap/v3.d.ts +11 -1
  230. package/build/dist/api/modules/uniswap/v3.js +1 -1
  231. package/build/dist/api/modules/uniswap/v4.js +1 -1
  232. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  233. package/build/dist/api/modules/velora/claims.js +1 -1
  234. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  235. package/build/dist/api/modules/velora/index.js +1 -1
  236. package/build/dist/api/modules/wormhole/index.js +1 -1
  237. package/build/dist/api/modules/wormhole/scan-text.js +1 -1
  238. package/build/dist/api/modules/wormhole/token-check.js +1 -1
  239. package/build/dist/api/positions.js +1 -1
  240. package/build/dist/api/pricenote.js +1 -1
  241. package/build/dist/api/prices.js +1 -1
  242. package/build/dist/api/pricing.js +1 -1
  243. package/build/dist/api/routes.js +1 -1
  244. package/build/dist/api/send.js +1 -1
  245. package/build/dist/api/signing-registry.js +1 -1
  246. package/build/dist/api/simulate.js +1 -1
  247. package/build/dist/api/swap.js +1 -1
  248. package/build/dist/api/tokens.d.ts +1 -0
  249. package/build/dist/api/tokens.js +1 -1
  250. package/build/dist/api/tool-policy.js +1 -1
  251. package/build/dist/api/tx.js +1 -1
  252. package/build/dist/api/vendor-limits.js +1 -1
  253. package/build/dist/chunks/{BAAXGB4K.js → 2KYAMXTS.js} +1 -1
  254. package/build/dist/chunks/{WVONJOWN.js → 2MAMJJJC.js} +1 -1
  255. package/build/dist/chunks/{MKAPRRKF.js → 2TK3ETUO.js} +1 -1
  256. package/build/dist/chunks/{CTMA4BTM.js → 326QMOTR.js} +1 -1
  257. package/build/dist/chunks/{ALRRW7SF.js → 3FUVMSCF.js} +1 -1
  258. package/build/dist/chunks/{YPM2UITD.js → 3GOHSYHW.js} +1 -1
  259. package/build/dist/chunks/{HTXKERNS.js → 3MLUCYCB.js} +1 -1
  260. package/build/dist/chunks/{GHPREYQK.js → 3NJ5KQ3Q.js} +1 -1
  261. package/build/dist/chunks/{WPFAEBE7.js → 3XNZUIRU.js} +1 -1
  262. package/build/dist/chunks/3XXBLNEX.js +1 -0
  263. package/build/dist/chunks/{PBQSJSZO.js → 43LI5NKJ.js} +1 -1
  264. package/build/dist/chunks/{NZXQWDGF.js → 45BRW2ZF.js} +1 -1
  265. package/build/dist/chunks/{QVYCJ6WV.js → 46KWRAYK.js} +1 -1
  266. package/build/dist/chunks/{UHRCM7AG.js → 4HG6FRVH.js} +1 -1
  267. package/build/dist/chunks/{TBCSZDAF.js → 4MXM6Q4W.js} +1 -1
  268. package/build/dist/chunks/{ZCOFMGPS.js → 4PY3UFNR.js} +1 -1
  269. package/build/dist/chunks/{WIVYKLQM.js → 52ELWNXJ.js} +1 -1
  270. package/build/dist/chunks/{F3BSEE52.js → 553UE2ZQ.js} +1 -1
  271. package/build/dist/chunks/{S2TAJHHK.js → 57MEFFCU.js} +1 -1
  272. package/build/dist/chunks/{ENX72ARB.js → 5APS4T2D.js} +1 -1
  273. package/build/dist/chunks/{UA4O226F.js → 5SMVQCAP.js} +1 -1
  274. package/build/dist/chunks/{6PY3IRDS.js → 64GOINYS.js} +1 -1
  275. package/build/dist/chunks/{5ZLOCQA4.js → 66F5ZH34.js} +1 -1
  276. package/build/dist/chunks/{HVM2EEXB.js → 6B3VVISQ.js} +1 -1
  277. package/build/dist/chunks/{E6RRXNV2.js → 6D5DJA5B.js} +1 -1
  278. package/build/dist/chunks/{XDZRO5JQ.js → 6I4NTKB2.js} +1 -1
  279. package/build/dist/chunks/{MFCPL6LF.js → 6OGDTEGH.js} +1 -1
  280. package/build/dist/chunks/6PBGEPUK.js +20 -0
  281. package/build/dist/chunks/{43CSMYDO.js → 6WD4HHID.js} +1 -1
  282. package/build/dist/chunks/{XJEOEMDS.js → 6WZX7C4T.js} +1 -1
  283. package/build/dist/chunks/{NA7R6J5N.js → 74Y2KDNR.js} +1 -1
  284. package/build/dist/chunks/{IKEJCBYU.js → 7WSHW7KW.js} +1 -1
  285. package/build/dist/chunks/{UPMGGK34.js → AFBEZXNV.js} +1 -1
  286. package/build/dist/chunks/{AUOXDNUO.js → AKYF5264.js} +1 -1
  287. package/build/dist/chunks/{BXHNYCH2.js → APGLZXIW.js} +1 -1
  288. package/build/dist/chunks/{7UOOIDR3.js → AVG4W3Y7.js} +1 -1
  289. package/build/dist/chunks/{Y7PRJOIK.js → B3RXD5ET.js} +1 -1
  290. package/build/dist/chunks/{JPNYUEQP.js → BBS3ODWZ.js} +1 -1
  291. package/build/dist/chunks/{I4TGMF2C.js → BJ2VGRF4.js} +1 -1
  292. package/build/dist/chunks/{WD37MEMZ.js → BTD5SMOW.js} +1 -1
  293. package/build/dist/chunks/{57JFKIMK.js → BTPXJAUX.js} +1 -1
  294. package/build/dist/chunks/{BIRMUW7Z.js → C36BFZH6.js} +1 -1
  295. package/build/dist/chunks/{ZGKVXFM5.js → C7AXJHBT.js} +1 -1
  296. package/build/dist/chunks/{5U7TCKX2.js → CBG5HARQ.js} +1 -1
  297. package/build/dist/chunks/{ET23SES4.js → CCTXCMH4.js} +1 -1
  298. package/build/dist/chunks/{5N4A5XAW.js → CHXBOXOD.js} +1 -1
  299. package/build/dist/chunks/D3YLXQPW.js +1 -0
  300. package/build/dist/chunks/{L7OQUHM5.js → DJN3JAWB.js} +1 -1
  301. package/build/dist/chunks/{CERNEJ2F.js → DW4V5PUY.js} +1 -1
  302. package/build/dist/chunks/E3RACZUY.js +1 -0
  303. package/build/dist/chunks/{TPL4U3AQ.js → E674J2MD.js} +1 -1
  304. package/build/dist/chunks/EE64JSLY.js +1 -0
  305. package/build/dist/chunks/EJ7O75A7.js +1 -0
  306. package/build/dist/chunks/{3AXVB23N.js → ELSXLZN5.js} +1 -1
  307. package/build/dist/chunks/{IQGY5FW7.js → ER47KGRM.js} +1 -1
  308. package/build/dist/chunks/FQ6UZCM6.js +1 -0
  309. package/build/dist/chunks/{WPAF55SP.js → GEIFITAQ.js} +1 -1
  310. package/build/dist/chunks/{4ALMYJJV.js → GGSAKCND.js} +1 -1
  311. package/build/dist/chunks/{EKNSLLJK.js → GL4NCUMH.js} +1 -1
  312. package/build/dist/chunks/GNC6RXLT.js +1 -0
  313. package/build/dist/chunks/{VVA72C6O.js → GQ5GYUEH.js} +1 -1
  314. package/build/dist/chunks/{6AAARNZ3.js → GW626GG2.js} +1 -1
  315. package/build/dist/chunks/{LROVANUR.js → H2XDMFQQ.js} +1 -1
  316. package/build/dist/chunks/H43RNCX2.js +1 -0
  317. package/build/dist/chunks/{VHLINDDS.js → HAQPIBYR.js} +1 -1
  318. package/build/dist/chunks/{ZE7EU2CS.js → HCUHMCBW.js} +1 -1
  319. package/build/dist/chunks/{64WKYWZV.js → HKEMQBFA.js} +1 -1
  320. package/build/dist/chunks/{4YFVAYKR.js → HM72DH4V.js} +1 -1
  321. package/build/dist/chunks/HSCQZ66A.js +1 -0
  322. package/build/dist/chunks/{QRC4ZPDA.js → I26DMNJG.js} +1 -1
  323. package/build/dist/chunks/{S3FPF537.js → IMO3GDA5.js} +1 -1
  324. package/build/dist/chunks/{ECWGKLBW.js → INOZIE55.js} +1 -1
  325. package/build/dist/chunks/{BQICZFLR.js → IOYRL6AY.js} +1 -1
  326. package/build/dist/chunks/IX3GZMTM.js +1 -0
  327. package/build/dist/chunks/IY7BXLT4.js +1 -0
  328. package/build/dist/chunks/{NYNJITCM.js → J2OT4KAH.js} +1 -1
  329. package/build/dist/chunks/{Y7RPSDD2.js → JKD2B6OX.js} +1 -1
  330. package/build/dist/chunks/{PSVOVZH7.js → JUZ5JU6D.js} +5 -5
  331. package/build/dist/chunks/{YEXUSRIZ.js → JVLLVNF2.js} +1 -1
  332. package/build/dist/chunks/{SSIENQVU.js → K3RDPI5J.js} +1 -1
  333. package/build/dist/chunks/{PADWZX7J.js → K4DHHQBI.js} +1 -1
  334. package/build/dist/chunks/KIFSRO5K.js +1 -0
  335. package/build/dist/chunks/{NB3LYS3G.js → KIFZ5ZSK.js} +1 -1
  336. package/build/dist/chunks/{QSN6Y2K6.js → KPCY5V35.js} +1 -1
  337. package/build/dist/chunks/{3ESNHZT5.js → L4N2RSK2.js} +1 -1
  338. package/build/dist/chunks/{EYFBVQ46.js → L5BLHY34.js} +1 -1
  339. package/build/dist/chunks/{E6UU7DL2.js → LSXUAHOE.js} +1 -1
  340. package/build/dist/chunks/{BNG2IWZL.js → M37654RL.js} +1 -1
  341. package/build/dist/chunks/{XFKVU46U.js → MJ6WEWMI.js} +1 -1
  342. package/build/dist/chunks/{47YN4OUI.js → MR5L7V6Z.js} +1 -1
  343. package/build/dist/chunks/{DVVFT42J.js → MRMR4QHA.js} +1 -1
  344. package/build/dist/chunks/{WWHCEMNB.js → N4Q6GN65.js} +1 -1
  345. package/build/dist/chunks/{S5WICHIS.js → NAZPDRIF.js} +1 -1
  346. package/build/dist/chunks/{MKBNLGDD.js → NDCLTVIU.js} +1 -1
  347. package/build/dist/chunks/{5WUKOQIJ.js → NEEZBJBC.js} +1 -1
  348. package/build/dist/chunks/{HSFOWJ3Z.js → NKZKKCK2.js} +1 -1
  349. package/build/dist/chunks/{5KUWLUPM.js → NWNYJ26T.js} +1 -1
  350. package/build/dist/chunks/{KBXU7U6Q.js → O7HCEPQY.js} +1 -1
  351. package/build/dist/chunks/{LDT3QTSY.js → OJ4WJUPP.js} +1 -1
  352. package/build/dist/chunks/{QJFXLYZG.js → OJPG45AC.js} +1 -1
  353. package/build/dist/chunks/{5MQ5KSSV.js → OKUO3BVM.js} +1 -1
  354. package/build/dist/chunks/OTXSKFUD.js +1 -0
  355. package/build/dist/chunks/{4TQQH7N6.js → P3S4BR5G.js} +1 -1
  356. package/build/dist/chunks/P56RZC2M.js +1 -0
  357. package/build/dist/chunks/{BK23XJXE.js → P5PYFK7L.js} +1 -1
  358. package/build/dist/chunks/{ZYH4B2GR.js → P7I62KFR.js} +1 -1
  359. package/build/dist/chunks/{SQL6HD5E.js → PK66GCDT.js} +1 -1
  360. package/build/dist/chunks/{6FTYNYGF.js → PSBQWDYI.js} +1 -1
  361. package/build/dist/chunks/{W76QC2AW.js → PV5FDT6O.js} +1 -1
  362. package/build/dist/chunks/{42DQTKEO.js → PXT5YTWU.js} +1 -1
  363. package/build/dist/chunks/{IMRXZ7JB.js → Q42YI3EP.js} +1 -1
  364. package/build/dist/chunks/{ZBFKKUNP.js → QA3UHEO3.js} +1 -1
  365. package/build/dist/chunks/QC3HH5UD.js +3 -0
  366. package/build/dist/chunks/{MQYOG66Q.js → QF52OIBS.js} +1 -1
  367. package/build/dist/chunks/{7WQEPZJY.js → QO3KCJMP.js} +1 -1
  368. package/build/dist/chunks/QQECG3WP.js +1 -0
  369. package/build/dist/chunks/QSHCBASA.js +1 -0
  370. package/build/dist/chunks/{RVO3QK2B.js → QU5XKRGK.js} +1 -1
  371. package/build/dist/chunks/{GVPX5XCL.js → QZZ4O34L.js} +1 -1
  372. package/build/dist/chunks/{A6YQ5H24.js → RQ4GHJXE.js} +1 -1
  373. package/build/dist/chunks/{3WXK2FUA.js → RUC7KH7A.js} +1 -1
  374. package/build/dist/chunks/{MBTARLZQ.js → RUX3RY7Y.js} +1 -1
  375. package/build/dist/chunks/{3VAJW6TQ.js → RVDUSNWW.js} +1 -1
  376. package/build/dist/chunks/{SDHPFXRM.js → S47VUTHM.js} +1 -1
  377. package/build/dist/chunks/{OTIXQZ3X.js → S7IFAQPG.js} +1 -1
  378. package/build/dist/chunks/{WMNRP3YH.js → SIYUNOLI.js} +1 -1
  379. package/build/dist/chunks/{TNKVRVTH.js → SJJR4ZBZ.js} +1 -1
  380. package/build/dist/chunks/{UFVPMWPJ.js → SMYWWIE6.js} +1 -1
  381. package/build/dist/chunks/{Z4SRGAVL.js → SPJCSEKP.js} +1 -1
  382. package/build/dist/chunks/{IQIWASRD.js → SSHCD6RZ.js} +1 -1
  383. package/build/dist/chunks/{SGEZIYJW.js → T2WHOZXM.js} +1 -1
  384. package/build/dist/chunks/{WOEKXQAH.js → T3AJSQYT.js} +1 -1
  385. package/build/dist/chunks/{SKMPKAZI.js → TAEZTP4L.js} +1 -1
  386. package/build/dist/chunks/{E3UBHTJO.js → TEJ7W534.js} +1 -1
  387. package/build/dist/chunks/{AWXJV2YH.js → TFDPEAVZ.js} +1 -1
  388. package/build/dist/chunks/{MGPHD4VV.js → TM2XCRU7.js} +1 -1
  389. package/build/dist/chunks/{UOGHQLQX.js → TMVO2DAK.js} +1 -1
  390. package/build/dist/chunks/{MXW2TP5P.js → TVWMTMEF.js} +1 -1
  391. package/build/dist/chunks/{GRIGSPD4.js → TX2EOIRS.js} +1 -1
  392. package/build/dist/chunks/{VV2HEIFI.js → U5PMVP56.js} +1 -1
  393. package/build/dist/chunks/{K72EYD6R.js → U67J4BCH.js} +1 -1
  394. package/build/dist/chunks/{MDDHG34Y.js → UHTRW2R6.js} +1 -1
  395. package/build/dist/chunks/{PQC5635W.js → UHVSINR5.js} +1 -1
  396. package/build/dist/chunks/{MOPETB64.js → UMIZMJWW.js} +1 -1
  397. package/build/dist/chunks/{F26FK47J.js → UNJJRQIU.js} +1 -1
  398. package/build/dist/chunks/V74F6IDY.js +1 -0
  399. package/build/dist/chunks/{MYFAKCQI.js → VEQBHI6O.js} +1 -1
  400. package/build/dist/chunks/VHV6WQ5F.js +1 -0
  401. package/build/dist/chunks/{EOQYLFXA.js → VJS4DHQQ.js} +1 -1
  402. package/build/dist/chunks/{AG67Z3SC.js → VOMGT5SG.js} +1 -1
  403. package/build/dist/chunks/{D6ZJPNK7.js → VY7XRHZQ.js} +1 -1
  404. package/build/dist/chunks/{W2OJ57ZO.js → VYAJXLND.js} +1 -1
  405. package/build/dist/chunks/{LVLVP5KQ.js → VYN2NRAP.js} +1 -1
  406. package/build/dist/chunks/{MDV7GECM.js → VYYSL557.js} +1 -1
  407. package/build/dist/chunks/{KA7BPBCV.js → W2BYU5JQ.js} +1 -1
  408. package/build/dist/chunks/W6BS3T7S.js +1 -0
  409. package/build/dist/chunks/WCNHZYQQ.js +1 -0
  410. package/build/dist/chunks/{ALPYEM7B.js → WDK6VOG4.js} +1 -1
  411. package/build/dist/chunks/{K22EXPWN.js → WIRBCS4W.js} +1 -1
  412. package/build/dist/chunks/{YRXT3HTW.js → WLMWWEP7.js} +1 -1
  413. package/build/dist/chunks/{NDW5DAFL.js → WP6RHXGN.js} +1 -1
  414. package/build/dist/chunks/{PLZKXQ76.js → WTXC3XKW.js} +1 -1
  415. package/build/dist/chunks/{WGL46F3S.js → WU7XIAXB.js} +1 -1
  416. package/build/dist/chunks/{5OKJEGBH.js → WV3A3OUU.js} +1 -1
  417. package/build/dist/chunks/{4ISR2U72.js → X2KFXCVD.js} +1 -1
  418. package/build/dist/chunks/{RPNAFUM5.js → X3BYCOWS.js} +1 -1
  419. package/build/dist/chunks/{6L5KTE6Y.js → X3PQMS4N.js} +1 -1
  420. package/build/dist/chunks/{RNC463IM.js → XBE3B6Y2.js} +1 -1
  421. package/build/dist/chunks/XLOYBLFI.js +1 -0
  422. package/build/dist/chunks/{2ZUP7ZEV.js → XR7VK24E.js} +1 -1
  423. package/build/dist/chunks/{ZSQOMSOC.js → Y25EXZCO.js} +1 -1
  424. package/build/dist/chunks/{TJWVY4VO.js → YCZPSMZ5.js} +1 -1
  425. package/build/dist/chunks/{JZXYLHI7.js → YDNTY67T.js} +1 -1
  426. package/build/dist/chunks/{2DUCTO5C.js → YN56C7PN.js} +1 -1
  427. package/build/dist/chunks/{G7XSFUDL.js → YWRDZQI6.js} +1 -1
  428. package/build/dist/chunks/{DP2NIYBP.js → YXTSWRV5.js} +1 -1
  429. package/build/dist/chunks/{I6KUORFT.js → Z43BTOTE.js} +1 -1
  430. package/build/dist/chunks/{PWH464CJ.js → Z4FZVJ5Z.js} +1 -1
  431. package/build/dist/chunks/{YAJYDD6C.js → ZMFRMWHR.js} +1 -1
  432. package/build/dist/chunks/{OFI3Y55L.js → ZQAFFWDK.js} +1 -1
  433. package/build/dist/chunks/{TBIVTEP5.js → ZSN4IRI5.js} +1 -1
  434. package/build/dist/chunks/{ZET37EIG.js → ZV5HIQXC.js} +1 -1
  435. package/package.json +1 -1
  436. package/build/dist/chunks/24CQ2SPB.js +0 -1
  437. package/build/dist/chunks/2OJAOVMG.js +0 -1
  438. package/build/dist/chunks/65EQECL3.js +0 -1
  439. package/build/dist/chunks/6YYCGUCU.js +0 -1
  440. package/build/dist/chunks/EU3OAJU2.js +0 -1
  441. package/build/dist/chunks/H4NYYJ3Z.js +0 -1
  442. package/build/dist/chunks/JG27HM4P.js +0 -1
  443. package/build/dist/chunks/L6D26AMO.js +0 -1
  444. package/build/dist/chunks/O6L4BJP4.js +0 -1
  445. package/build/dist/chunks/SUFA2GKR.js +0 -1
  446. package/build/dist/chunks/UP7FBDMJ.js +0 -1
  447. package/build/dist/chunks/YHRUAQQK.js +0 -1
  448. package/build/dist/chunks/ZCUXM52B.js +0 -1
@@ -1 +1 @@
1
- import{a as s,d as h,e as u}from"./L7OQUHM5.js";import{a as l}from"./5ZLOCQA4.js";import{a as c}from"./FWD4L3CJ.js";import{a as d}from"./XSD5NL7J.js";import{concatHex as P,encodeAbiParameters as x,encodeFunctionData as w,getAddress as m,keccak256 as f,parseAbi as k,stringToHex as v}from"viem";var g=k(["function ownerOf(uint256) view returns (address)","function tokenURI(uint256) view returns (string)","function setMetadata(uint256,string,bytes)","function approve(address,uint256)"]),I=k(["function listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))","function recordHash(uint256) view returns (bytes32)"]),_=(t,r)=>f(P(BigInt(t)<BigInt(r)?[t,r]:[r,t]));function C(t){if(!Array.isArray(t)||t.length<1||t.length>1e4)throw new d("Provide 1 to 10000 identity IDs.");let r=[...new Set(t.map(e=>u(e,"agentIds").toString()))].sort((e,a)=>BigInt(e)<BigInt(a)?-1:1),n=[r.map(e=>f(f(x([{type:"uint256"}],[BigInt(e)]))))];for(;n.at(-1).length>1;){let e=n.at(-1),a=[];for(let o=0;o<e.length;o+=2)a.push(e[o+1]?_(e[o],e[o+1]):e[o]);n.push(a)}return{root:n.at(-1)[0],ids:r,proofs:r.map((e,a)=>{let o=[],p=a;for(let b of n.slice(0,-1)){let y=b[p^1];y&&o.push(y),p=Math.floor(p/2)}return{agentId:e,proof:o}})}}function A(t){return{tools:[{name:"priors_market_origin",inputSchema:{type:"object",properties:{agentIds:{type:"array",minItems:1,maxItems:1e4,items:l()}},required:["agentIds"],additionalProperties:!1},async execute(r){return{chainId:c,...C(r.agentIds),caveat:"Locally commits exactly these IDs. This does not verify third-party origin, quality, current owner or a seller claim."}}},{name:"priors_market_pins",inputSchema:{type:"object",properties:{agentId:l()},required:["agentId"],additionalProperties:!1},async execute(r){if(t.network==="testnet")throw new d("Priors market requires mainnet chain 4663.");let i=u(r.agentId,"agentId"),n=t.clientFor(c),e=await n.getBlockNumber({cacheTime:0}),[a,o,p]=await Promise.all([n.readContract({address:s.market,abi:I,functionName:"listingOf",args:[i],blockNumber:e}),n.readContract({address:s.market,abi:I,functionName:"recordHash",args:[i],blockNumber:e}),n.readContract({address:s.registry,abi:g,functionName:"tokenURI",args:[i],blockNumber:e})]);return{chainId:c,blockNumber:e.toString(),listing:h(a),recordHash:o,currentUriHash:f(v(p)),caveat:"Pins bind identity file and credit state, not included code, servers or keys. Listing and current URI hashes may differ; preview refuses an altered listing."}}},{name:"priors_market_clear_bid_budget",inputSchema:{type:"object",properties:{},additionalProperties:!1},async execute(r,i){if(t.network==="testnet")throw new d("Priors market requires mainnet chain 4663.");let n=[t.approval(s.usdg,s.bidSpender,"0",c)],e=await t.preview(n,m(i));return{txs:n,summary:`Clear all this wallet future bid spending allowance to ${s.bidSpender}. Existing bids cannot fill from it until approved again. ${e.summary}`}}},{name:"priors_market_revoke_nft",inputSchema:{type:"object",properties:{agentId:l()},required:["agentId"],additionalProperties:!1},async execute(r,i){let n=u(r.agentId,"agentId");if(t.network==="testnet")throw new d("Priors market requires mainnet chain 4663.");if(m(await t.clientFor(c).readContract({address:s.registry,abi:g,functionName:"ownerOf",args:[n]}))!==m(i))throw new d("Only current NFT owner may revoke this per-token approval.");let e=[t.unsignedTx({to:s.registry,data:w({abi:g,functionName:"approve",args:["0x0000000000000000000000000000000000000000",n]}),value:"0",chainId:c,description:`Revoke exact ERC-8004 NFT ${n} market approval.`})],a=await t.preview(e,i);return{txs:e,summary:`Clear this identity per-token transfer approval. Also cancel its listing before granting any new market approval. ${a.summary}`}}},{name:"priors_x_link",inputSchema:{type:"object",properties:{agentId:l(),postUrl:{type:"string",maxLength:160,description:"Canonical https://x.com/<handle>/status/<id> owner proof post URL, or empty to unlink. Owner creates the public post themselves."}},required:["agentId","postUrl"],additionalProperties:!1},async execute(r,i){if(t.network==="testnet")throw new d("Priors X metadata is mainnet only.");let n=u(r.agentId,"agentId");if(m(await t.clientFor(c).readContract({address:s.registry,abi:g,functionName:"ownerOf",args:[n]}))!==m(i))throw new d("Only the identity owner can link or clear X metadata.");if(typeof r.postUrl!="string"||r.postUrl!==""&&!/^https:\/\/x\.com\/[A-Za-z0-9_]{1,15}\/status\/[0-9]{1,30}$/.test(r.postUrl))throw new d("Provide a canonical X status URL or empty string to unlink.");let e=[t.unsignedTx({to:s.registry,data:w({abi:g,functionName:"setMetadata",args:[n,"x",v(r.postUrl)]}),value:"0",chainId:c,description:"Set/clear the owner identity X proof-post metadata."})],a=await t.preview(e,i);return{txs:e,summary:`Publish ${r.postUrl?"the specified X post URL":"empty X metadata"} on public ERC-8004 identity ${n}. Priors independently verifies the post; metadata alone does not prove the X account or affect credit terms. ${a.summary}`}}}]}}export{C as a,A as b};
1
+ import{a as s,d as h,e as u}from"./DJN3JAWB.js";import{a as l}from"./66F5ZH34.js";import{a as c}from"./FWD4L3CJ.js";import{a as d}from"./XSD5NL7J.js";import{concatHex as P,encodeAbiParameters as x,encodeFunctionData as w,getAddress as m,keccak256 as f,parseAbi as k,stringToHex as v}from"viem";var g=k(["function ownerOf(uint256) view returns (address)","function tokenURI(uint256) view returns (string)","function setMetadata(uint256,string,bytes)","function approve(address,uint256)"]),I=k(["function listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))","function recordHash(uint256) view returns (bytes32)"]),_=(t,r)=>f(P(BigInt(t)<BigInt(r)?[t,r]:[r,t]));function C(t){if(!Array.isArray(t)||t.length<1||t.length>1e4)throw new d("Provide 1 to 10000 identity IDs.");let r=[...new Set(t.map(e=>u(e,"agentIds").toString()))].sort((e,a)=>BigInt(e)<BigInt(a)?-1:1),n=[r.map(e=>f(f(x([{type:"uint256"}],[BigInt(e)]))))];for(;n.at(-1).length>1;){let e=n.at(-1),a=[];for(let o=0;o<e.length;o+=2)a.push(e[o+1]?_(e[o],e[o+1]):e[o]);n.push(a)}return{root:n.at(-1)[0],ids:r,proofs:r.map((e,a)=>{let o=[],p=a;for(let b of n.slice(0,-1)){let y=b[p^1];y&&o.push(y),p=Math.floor(p/2)}return{agentId:e,proof:o}})}}function A(t){return{tools:[{name:"priors_market_origin",inputSchema:{type:"object",properties:{agentIds:{type:"array",minItems:1,maxItems:1e4,items:l()}},required:["agentIds"],additionalProperties:!1},async execute(r){return{chainId:c,...C(r.agentIds),caveat:"Locally commits exactly these IDs. This does not verify third-party origin, quality, current owner or a seller claim."}}},{name:"priors_market_pins",inputSchema:{type:"object",properties:{agentId:l()},required:["agentId"],additionalProperties:!1},async execute(r){if(t.network==="testnet")throw new d("Priors market requires mainnet chain 4663.");let i=u(r.agentId,"agentId"),n=t.clientFor(c),e=await n.getBlockNumber({cacheTime:0}),[a,o,p]=await Promise.all([n.readContract({address:s.market,abi:I,functionName:"listingOf",args:[i],blockNumber:e}),n.readContract({address:s.market,abi:I,functionName:"recordHash",args:[i],blockNumber:e}),n.readContract({address:s.registry,abi:g,functionName:"tokenURI",args:[i],blockNumber:e})]);return{chainId:c,blockNumber:e.toString(),listing:h(a),recordHash:o,currentUriHash:f(v(p)),caveat:"Pins bind identity file and credit state, not included code, servers or keys. Listing and current URI hashes may differ; preview refuses an altered listing."}}},{name:"priors_market_clear_bid_budget",inputSchema:{type:"object",properties:{},additionalProperties:!1},async execute(r,i){if(t.network==="testnet")throw new d("Priors market requires mainnet chain 4663.");let n=[t.approval(s.usdg,s.bidSpender,"0",c)],e=await t.preview(n,m(i));return{txs:n,summary:`Clear all this wallet future bid spending allowance to ${s.bidSpender}. Existing bids cannot fill from it until approved again. ${e.summary}`}}},{name:"priors_market_revoke_nft",inputSchema:{type:"object",properties:{agentId:l()},required:["agentId"],additionalProperties:!1},async execute(r,i){let n=u(r.agentId,"agentId");if(t.network==="testnet")throw new d("Priors market requires mainnet chain 4663.");if(m(await t.clientFor(c).readContract({address:s.registry,abi:g,functionName:"ownerOf",args:[n]}))!==m(i))throw new d("Only current NFT owner may revoke this per-token approval.");let e=[t.unsignedTx({to:s.registry,data:w({abi:g,functionName:"approve",args:["0x0000000000000000000000000000000000000000",n]}),value:"0",chainId:c,description:`Revoke exact ERC-8004 NFT ${n} market approval.`})],a=await t.preview(e,i);return{txs:e,summary:`Clear this identity per-token transfer approval. Also cancel its listing before granting any new market approval. ${a.summary}`}}},{name:"priors_x_link",inputSchema:{type:"object",properties:{agentId:l(),postUrl:{type:"string",maxLength:160,description:"Canonical https://x.com/<handle>/status/<id> owner proof post URL, or empty to unlink. Owner creates the public post themselves."}},required:["agentId","postUrl"],additionalProperties:!1},async execute(r,i){if(t.network==="testnet")throw new d("Priors X metadata is mainnet only.");let n=u(r.agentId,"agentId");if(m(await t.clientFor(c).readContract({address:s.registry,abi:g,functionName:"ownerOf",args:[n]}))!==m(i))throw new d("Only the identity owner can link or clear X metadata.");if(typeof r.postUrl!="string"||r.postUrl!==""&&!/^https:\/\/x\.com\/[A-Za-z0-9_]{1,15}\/status\/[0-9]{1,30}$/.test(r.postUrl))throw new d("Provide a canonical X status URL or empty string to unlink.");let e=[t.unsignedTx({to:s.registry,data:w({abi:g,functionName:"setMetadata",args:[n,"x",v(r.postUrl)]}),value:"0",chainId:c,description:"Set/clear the owner identity X proof-post metadata."})],a=await t.preview(e,i);return{txs:e,summary:`Publish ${r.postUrl?"the specified X post URL":"empty X metadata"} on public ERC-8004 identity ${n}. Priors independently verifies the post; metadata alone does not prove the X account or affect credit terms. ${a.summary}`}}}]}}export{C as a,A as b};
@@ -1 +1 @@
1
- import{f as s,g as u,k as v}from"./QVYCJ6WV.js";import{a as y}from"./XSD5NL7J.js";var k=["L2Book","Ticker","TradeFill","SubaccountLiquidation","PositionUpdate","OrderUpdate","OrderFill","TokenTransfer"],A=p=>({tools:[{name:"meridian_perps_stream",inputSchema:{type:"object",additionalProperties:!1,required:["stream"],description:"Read a bounded sample of an official perps WebSocket stream, then close. Empty timed-out samples do not prove no activity. L2Book starts with up to 100 levels per side, followed by deltas.",properties:{stream:{type:"string",enum:k},symbol:{type:"string",pattern:"^[A-Za-z0-9]{1,32}$"},subaccountId:{type:"string",format:"uuid"},maxEvents:{type:"integer",minimum:1,maximum:20,default:1},timeoutSeconds:{type:"integer",minimum:1,maximum:30,default:10}}},execute:async e=>{try{p.network==="testnet"&&s("Meridian perps streams require mainnet."),(Object.keys(e).some(c=>!["stream","symbol","subaccountId","maxEvents","timeoutSeconds"].includes(c))||!k.includes(e.stream))&&s("Choose a Meridian perps stream from the schema.");let i=["L2Book","Ticker","TradeFill"].includes(String(e.stream)),M=i?{type:e.stream,symbol:e.symbol}:{type:e.stream,subaccountId:v(e.subaccountId)};(i?e.subaccountId!==void 0||typeof e.symbol!="string"||!/^[A-Za-z0-9]{1,32}$/.test(e.symbol):e.symbol!==void 0)&&s("Market streams need symbol only; account streams need subaccountId only.");let o=e.maxEvents??1,d=e.timeoutSeconds??10;return(typeof o!="number"||!Number.isInteger(o)||o<1||o>20||typeof d!="number"||!Number.isInteger(d)||d<1||d>30)&&s("Choose 1\u201320 events and a timeout of 1\u201330 seconds."),await new Promise((c,S)=>{let n=new globalThis.WebSocket("wss://ws.meridian.xyz/v1/stream"),l=[],h=!1,f=!1,b,m=(a,r=!1)=>{if(!f){f=!0,clearTimeout(I);try{n.readyState<2&&n.close()}catch{}a?S(new y(a)):c({chainId:4663,stream:e.stream,events:l,timedOut:r,scope:"Bounded event sample; no durable subscription or complete history. L2Book events after the first are absolute-quantity deltas; zero removes a level."})}},I=setTimeout(()=>m(h?void 0:"Meridian perps stream did not connect.",!0),d*1e3);n.addEventListener("open",()=>{h=!0,n.send(JSON.stringify({event:"subscribe",data:M}))}),n.addEventListener("error",()=>m("Meridian perps stream is unavailable; retry or inspect the HTTP history.")),n.addEventListener("close",()=>m("Meridian perps stream closed before the requested sample completed.")),n.addEventListener("message",a=>{if(!f)try{(typeof a.data!="string"||a.data.length>262144)&&s("Meridian perps stream returned an oversized or invalid message.");let r=u(JSON.parse(a.data));if(r.ok===!1&&s("Meridian perps stream rejected the subscription. Verify the symbol, subaccount and subscription limits."),r.e==="pong"||r.ok===!0&&r.e===void 0)return;(r.e!==e.stream||typeof r.t!="number"||!Number.isSafeInteger(r.t))&&s("Meridian perps stream returned a different or invalid event.");let t=u(r.data);if(i&&t.s!==e.symbol&&s("Meridian perps stream returned a different product."),!i){let w=Array.isArray(t.d)?t.d.map(u):[t];(!(e.stream==="SubaccountLiquidation"?t.sid===e.subaccountId:w.every(E=>E.sid===e.subaccountId))||t.sid!==void 0&&t.sid!==e.subaccountId)&&s("Meridian perps stream returned a different subaccount.")}e.stream==="L2Book"&&((typeof t.t!="number"||!Number.isSafeInteger(t.t)||t.t<0||!Array.isArray(t.a)||!Array.isArray(t.b))&&s("Meridian perps book snapshot is malformed."),b!==void 0&&t.pt!==void 0&&t.pt!==b&&s("Meridian perps book updates have a gap. Request a fresh snapshot."),b=t.t),l.push(r),l.length>=o&&m()}catch(r){m(p.plainError(r))}})})}catch(i){throw new y(p.plainError(i))}}}]});export{k as a,A as b};
1
+ import{f as s,g as u,k as v}from"./46KWRAYK.js";import{a as y}from"./XSD5NL7J.js";var k=["L2Book","Ticker","TradeFill","SubaccountLiquidation","PositionUpdate","OrderUpdate","OrderFill","TokenTransfer"],A=p=>({tools:[{name:"meridian_perps_stream",inputSchema:{type:"object",additionalProperties:!1,required:["stream"],description:"Read a bounded sample of an official perps WebSocket stream, then close. Empty timed-out samples do not prove no activity. L2Book starts with up to 100 levels per side, followed by deltas.",properties:{stream:{type:"string",enum:k},symbol:{type:"string",pattern:"^[A-Za-z0-9]{1,32}$"},subaccountId:{type:"string",format:"uuid"},maxEvents:{type:"integer",minimum:1,maximum:20,default:1},timeoutSeconds:{type:"integer",minimum:1,maximum:30,default:10}}},execute:async e=>{try{p.network==="testnet"&&s("Meridian perps streams require mainnet."),(Object.keys(e).some(c=>!["stream","symbol","subaccountId","maxEvents","timeoutSeconds"].includes(c))||!k.includes(e.stream))&&s("Choose a Meridian perps stream from the schema.");let i=["L2Book","Ticker","TradeFill"].includes(String(e.stream)),M=i?{type:e.stream,symbol:e.symbol}:{type:e.stream,subaccountId:v(e.subaccountId)};(i?e.subaccountId!==void 0||typeof e.symbol!="string"||!/^[A-Za-z0-9]{1,32}$/.test(e.symbol):e.symbol!==void 0)&&s("Market streams need symbol only; account streams need subaccountId only.");let o=e.maxEvents??1,d=e.timeoutSeconds??10;return(typeof o!="number"||!Number.isInteger(o)||o<1||o>20||typeof d!="number"||!Number.isInteger(d)||d<1||d>30)&&s("Choose 1\u201320 events and a timeout of 1\u201330 seconds."),await new Promise((c,S)=>{let n=new globalThis.WebSocket("wss://ws.meridian.xyz/v1/stream"),l=[],h=!1,f=!1,b,m=(a,r=!1)=>{if(!f){f=!0,clearTimeout(I);try{n.readyState<2&&n.close()}catch{}a?S(new y(a)):c({chainId:4663,stream:e.stream,events:l,timedOut:r,scope:"Bounded event sample; no durable subscription or complete history. L2Book events after the first are absolute-quantity deltas; zero removes a level."})}},I=setTimeout(()=>m(h?void 0:"Meridian perps stream did not connect.",!0),d*1e3);n.addEventListener("open",()=>{h=!0,n.send(JSON.stringify({event:"subscribe",data:M}))}),n.addEventListener("error",()=>m("Meridian perps stream is unavailable; retry or inspect the HTTP history.")),n.addEventListener("close",()=>m("Meridian perps stream closed before the requested sample completed.")),n.addEventListener("message",a=>{if(!f)try{(typeof a.data!="string"||a.data.length>262144)&&s("Meridian perps stream returned an oversized or invalid message.");let r=u(JSON.parse(a.data));if(r.ok===!1&&s("Meridian perps stream rejected the subscription. Verify the symbol, subaccount and subscription limits."),r.e==="pong"||r.ok===!0&&r.e===void 0)return;(r.e!==e.stream||typeof r.t!="number"||!Number.isSafeInteger(r.t))&&s("Meridian perps stream returned a different or invalid event.");let t=u(r.data);if(i&&t.s!==e.symbol&&s("Meridian perps stream returned a different product."),!i){let w=Array.isArray(t.d)?t.d.map(u):[t];(!(e.stream==="SubaccountLiquidation"?t.sid===e.subaccountId:w.every(E=>E.sid===e.subaccountId))||t.sid!==void 0&&t.sid!==e.subaccountId)&&s("Meridian perps stream returned a different subaccount.")}e.stream==="L2Book"&&((typeof t.t!="number"||!Number.isSafeInteger(t.t)||t.t<0||!Array.isArray(t.a)||!Array.isArray(t.b))&&s("Meridian perps book snapshot is malformed."),b!==void 0&&t.pt!==void 0&&t.pt!==b&&s("Meridian perps book updates have a gap. Request a fresh snapshot."),b=t.t),l.push(r),l.length>=o&&m()}catch(r){m(p.plainError(r))}})})}catch(i){throw new y(p.plainError(i))}}}]});export{k as a,A as b};
@@ -1 +1 @@
1
- import{b as U,c as G}from"./JZXYLHI7.js";import{L as K}from"./IQIWASRD.js";import{a as N}from"./SSIENQVU.js";import{c as P}from"./W2OJ57ZO.js";import{c as R,f as L,g as H,h as W,i as z}from"./IKEJCBYU.js";import{a as F}from"./PBQSJSZO.js";import{a as u}from"./5ZLOCQA4.js";import{g as I}from"./5KUWLUPM.js";import{a as _}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as S,erc20Abi as j,getAddress as T,parseAbi as k}from"viem";var w=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function q(t,s=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!s&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function le(t,s,v){return["details","analytics","manage","mint",s==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...s==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...s==="longbow"?{vault:{type:"string",enum:v.map(i=>i.vault)}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(),maxShares:u(),maxPenaltyAssets:u(),deadline:u()}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u(),maxAssets:u()}),e==="redeem"&&(m.shares=u()),e==="withdraw_assets"&&(m.amount=u()),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(),minAmountOut:u()});let J=P(t,`${s}_manage`,v[0].vault,v[0].asset),E=N(t,`${s}_analytics`,v[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:E.inputSchema;Object.assign(m,i.properties),e==="analytics"&&s==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"]}),$.push(...i.required)}return{name:`${s}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&s==="netnet"?{allOf:E.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(F(r),Object.keys(i).some(l=>!Object.hasOwn(m,l)))throw new o("Unsupported vault feature argument.");let A=s==="netnet"?v[0]:v.find(l=>typeof i.vault=="string"&&I(l.vault,i.vault));if(!A)throw new o("Choose a current vault returned by the project list tool.");let{vault:n,asset:a}=A,b={...i};if(delete b.vault,e==="details")return H(t,`${s}_details`,n,a).execute(b,r);if(e==="manage")return P(t,`${s}_manage`,n,a).execute(b,r);if(e==="analytics"){if(s==="longbow"&&i.view==="published_apy")return G(t,n,a,b);if(s==="longbow"&&i.view==="apy")return U(t,n,a,b);if(s==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await N(t,`${s}_analytics`,n).execute(b,r),asset:{...a,address:T(a.address)}}}if(e==="in_kind_exit")return K(t,n,a,i,r);let f=t.clientFor(_);if(await f.getChainId()!==_)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([f.readContract({address:n,abi:w,functionName:"asset"}),f.readContract({address:n,abi:w,functionName:"decimals"}),f.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(T(Q)!==T(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let M=e==="force_exit"?await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let l=await L(t,f,n,r,M,R(i.maxPenaltyAssets),a),C=q(i.minAmountOut),p=[l.tx],y=await t.preview(p,r);return z(y.changes,n,M,C,a),{txs:p,preview:y,summary:`${W(l.plan,a.symbol)} ${y.summary}`}}let d=e==="mint",g=e==="redeem",c=q(d||g?i.shares:i.amount),x=await f.readContract({address:n,abi:w,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[c]});if(x<=0n||d&&x>q(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let V=d?void 0:await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]});if(!d&&(g?c:x)>V)throw new o("The wallet share balance cannot cover this exit.");let Z=d?S({abi:w,functionName:"mint",args:[c,r]}):g?S({abi:w,functionName:"redeem",args:[c,r,r]}):S({abi:w,functionName:"withdraw",args:[c,r,r]}),B=`${e} ${c} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${n}; beneficiary ${r}.`,D=[...d?[t.approval(a.address,n,x.toString(),_)]:[],t.unsignedTx({to:n,data:Z,value:"0",chainId:_,description:B})],O=await t.preview(D,r),h=(l,C)=>O.changes.filter(p=>p.token.chainId===_&&I(p.token.address,l)).reduce((p,y)=>{if(y.token.decimals!==C||!/^-?\d+$/.test(y.amount))throw new o("Invalid vault preview metadata.");return p+BigInt(y.amount)},0n);if(d?h(a.address,a.decimals)!==-x||h(n,18)!==c:g?h(n,18)!==-c||h(a.address,a.decimals)<=0n:h(a.address,a.decimals)!==c||-h(n,18)<=0n||-h(n,18)>V)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:D,preview:O,summary:`${B} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${O.summary}`}}catch(A){throw new o(t.plainError(A))}}}})}export{le as a};
1
+ import{b as U,c as G}from"./YDNTY67T.js";import{L as K}from"./SSHCD6RZ.js";import{a as N}from"./K3RDPI5J.js";import{c as P}from"./VYAJXLND.js";import{c as R,f as L,g as H,h as W,i as z}from"./7WSHW7KW.js";import{a as F}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as I}from"./NWNYJ26T.js";import{a as _}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as S,erc20Abi as j,getAddress as T,parseAbi as k}from"viem";var w=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function q(t,s=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!s&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function le(t,s,v){return["details","analytics","manage","mint",s==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...s==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...s==="longbow"?{vault:{type:"string",enum:v.map(i=>i.vault)}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(),maxShares:u(),maxPenaltyAssets:u(),deadline:u()}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u(),maxAssets:u()}),e==="redeem"&&(m.shares=u()),e==="withdraw_assets"&&(m.amount=u()),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(),minAmountOut:u()});let J=P(t,`${s}_manage`,v[0].vault,v[0].asset),E=N(t,`${s}_analytics`,v[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:E.inputSchema;Object.assign(m,i.properties),e==="analytics"&&s==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"]}),$.push(...i.required)}return{name:`${s}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&s==="netnet"?{allOf:E.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(F(r),Object.keys(i).some(l=>!Object.hasOwn(m,l)))throw new o("Unsupported vault feature argument.");let A=s==="netnet"?v[0]:v.find(l=>typeof i.vault=="string"&&I(l.vault,i.vault));if(!A)throw new o("Choose a current vault returned by the project list tool.");let{vault:n,asset:a}=A,b={...i};if(delete b.vault,e==="details")return H(t,`${s}_details`,n,a).execute(b,r);if(e==="manage")return P(t,`${s}_manage`,n,a).execute(b,r);if(e==="analytics"){if(s==="longbow"&&i.view==="published_apy")return G(t,n,a,b);if(s==="longbow"&&i.view==="apy")return U(t,n,a,b);if(s==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await N(t,`${s}_analytics`,n).execute(b,r),asset:{...a,address:T(a.address)}}}if(e==="in_kind_exit")return K(t,n,a,i,r);let f=t.clientFor(_);if(await f.getChainId()!==_)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([f.readContract({address:n,abi:w,functionName:"asset"}),f.readContract({address:n,abi:w,functionName:"decimals"}),f.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(T(Q)!==T(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let M=e==="force_exit"?await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let l=await L(t,f,n,r,M,R(i.maxPenaltyAssets),a),C=q(i.minAmountOut),p=[l.tx],y=await t.preview(p,r);return z(y.changes,n,M,C,a),{txs:p,preview:y,summary:`${W(l.plan,a.symbol)} ${y.summary}`}}let d=e==="mint",g=e==="redeem",c=q(d||g?i.shares:i.amount),x=await f.readContract({address:n,abi:w,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[c]});if(x<=0n||d&&x>q(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let V=d?void 0:await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]});if(!d&&(g?c:x)>V)throw new o("The wallet share balance cannot cover this exit.");let Z=d?S({abi:w,functionName:"mint",args:[c,r]}):g?S({abi:w,functionName:"redeem",args:[c,r,r]}):S({abi:w,functionName:"withdraw",args:[c,r,r]}),B=`${e} ${c} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${n}; beneficiary ${r}.`,D=[...d?[t.approval(a.address,n,x.toString(),_)]:[],t.unsignedTx({to:n,data:Z,value:"0",chainId:_,description:B})],O=await t.preview(D,r),h=(l,C)=>O.changes.filter(p=>p.token.chainId===_&&I(p.token.address,l)).reduce((p,y)=>{if(y.token.decimals!==C||!/^-?\d+$/.test(y.amount))throw new o("Invalid vault preview metadata.");return p+BigInt(y.amount)},0n);if(d?h(a.address,a.decimals)!==-x||h(n,18)!==c:g?h(n,18)!==-c||h(a.address,a.decimals)<=0n:h(a.address,a.decimals)!==c||-h(n,18)<=0n||-h(n,18)>V)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:D,preview:O,summary:`${B} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${O.summary}`}}catch(A){throw new o(t.plainError(A))}}}})}export{le as a};
@@ -1 +1 @@
1
- import{c as o}from"./UP7FBDMJ.js";import{a as g}from"./XSD5NL7J.js";var s=10000000n;function A(t,i){let n=s;return typeof t=="bigint"&&t>0n&&t<n&&(n=t),typeof i=="bigint"&&i>0n&&i*2n<n&&(n=i*2n),n}function b(t,i,n,r){return`needs ETH for network fees: need at least ${n} wei including transaction value; held ${r} wei. Send ETH to ${t} on chain ${i}. Approximately ${o(n.toString(),18)} ETH needed; ${o(r.toString(),18)} ETH held.`}function a(t,i,n,r,d,u){let e=n+21000n*r;if(i<e)throw new g(b(d,u,e,i));let f=r>0n?(i-n)/r:t;return f<t?f:t}export{s as a,A as b,b as c,a as d};
1
+ import{d as o}from"./IX3GZMTM.js";import{a as g}from"./XSD5NL7J.js";var s=10000000n;function A(t,i){let n=s;return typeof t=="bigint"&&t>0n&&t<n&&(n=t),typeof i=="bigint"&&i>0n&&i*2n<n&&(n=i*2n),n}function b(t,i,n,r){return`needs ETH for network fees: need at least ${n} wei including transaction value; held ${r} wei. Send ETH to ${t} on chain ${i}. Approximately ${o(n.toString(),18)} ETH needed; ${o(r.toString(),18)} ETH held.`}function a(t,i,n,r,d,u){let e=n+21000n*r;if(i<e)throw new g(b(d,u,e,i));let f=r>0n?(i-n)/r:t;return f<t?f:t}export{s as a,A as b,b as c,a as d};
@@ -0,0 +1 @@
1
+ import{a as e}from"./XSD5NL7J.js";function f(){return new e('Amount must be a non-negative integer string in base units. For example, "10000000" = 10 USDG (6 decimals).')}function s(t){if(typeof t!="string"||!/^\d+$/.test(t))throw f();return BigInt(t)}function g(t){if(!Number.isInteger(t)||t<0||t>255)throw new e("Token decimals must be an integer from 0 to 255.");return 10n**BigInt(t)}function l(t,i,n){if(i<=0n)throw new e("The denominator must be positive.");if(n!=="floor"&&n!=="ceil")throw new e("Choose floor or ceil rounding.");return t/i+(n==="ceil"&&t%i!==0n?1n:0n)}function a(t,i,n){let r=g(i);if(typeof t!="string"||!/^\d+(\.\d+)?$/.test(t))throw new e("Amount must be a non-negative decimal string.");let[o="0",c=""]=t.split("."),u=c.slice(i);if(n===void 0&&/[1-9]/.test(u))throw new e("Amount exceeds the token precision. Choose floor or ceil rounding.");if(n!==void 0&&n!=="floor"&&n!=="ceil")throw new e("Choose floor or ceil rounding.");return(BigInt(o)*r+BigInt(c.slice(0,i).padEnd(i,"0")||"0")+(n==="ceil"&&/[1-9]/.test(u)?1n:0n)).toString()}function b(t,i){let n=s(t),r=g(i),o=(n%r).toString().padStart(i,"0").replace(/0+$/,"");return`${n/r}${o?`.${o}`:""}`}function w(t,i,n,r){return l(s(t)*s(i),s(n),r).toString()}export{f as a,s as b,a as c,b as d,w as e};
@@ -0,0 +1 @@
1
+ import{b as W}from"./P56RZC2M.js";import{c as K}from"./VEQBHI6O.js";import{d as N}from"./UNJJRQIU.js";import{g as S}from"./NWNYJ26T.js";import{a as j,b as M,c as O}from"./IX3GZMTM.js";import{a as q,i as z}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeAbiParameters as ce,encodeFunctionData as J,erc20Abi as V,getAddress as Z,isAddress as me,keccak256 as X,parseAbi as ue,parseAbiParameters as ye,zeroAddress as ee}from"viem";var x=q,C=Z(z[x].hoodlock.airdrop.address),oe="https://hoodlock.tech",P=25e4,ge=256,fe=604800n,pe=30n,Q=250000000000000000n,Y=0xffffffffn,be=(1n<<64n)-1n,ne=(1n<<128n)-1n,re="0x0000000000000000000000000000000000000000000000000000000000000000",xe="0x1111111111111111111111111111111111111111",Ae=ye("uint256, address, uint256"),T=ue(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function he(o,e,r){let n=e.trim();if(n.startsWith("-")){let t=n.slice(1);return`-${o.formatAmount(t,r)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,r)}function te(o,e){if(!e.changes.length)return e.summary;let r=e.changes.map(n=>`${he(o,n.amount,n.token.decimals)} ${$(n.token.symbol)}`).join(", ");return`${e.summary} (${r})`}async function we(o,e){try{let[r,n]=await Promise.all([o.readContract({address:e,abi:V,functionName:"symbol"}),o.readContract({address:e,abi:V,functionName:"decimals"})]),d=typeof r=="string"&&r.trim()?r.trim():"TOKEN",t=Number(n);return{symbol:d,decimals:Number.isInteger(t)&&t>=0&&t<=255?t:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,r){if(typeof e=="string"&&e.includes(".")){if(r?.decimals===void 0)throw new a(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=r.rounding!==void 0?O(e,r.decimals,r.rounding):o?o.parseAmount(e,r.decimals):O(e,r.decimals),t=M(d);if(t<=0n)throw new a("Airdrop entry amount must be positive.");return t}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=M(e.trim());else throw j()}catch(d){throw d instanceof a?d:new a(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new a("Airdrop entry amount must be strictly positive (> 0).");return n}function H(o,e){try{let r=typeof o=="bigint"?o:BigInt(String(o).trim());if(r<0n)throw new a(`${e} must be non-negative.`);return r}catch(r){throw r instanceof a?r:new a(`Invalid ${e}: ${String(o)}`,{cause:r})}}function A(o,e){if(typeof o!="string"||!me(o,{strict:!1}))throw new a(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return Z(o)}function L(o,e,r){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>Y)throw new a(`Airdrop leaf index must be in 0..${Y.toString()}.`);let d=A(e,"account"),t=w(void 0,r),s=ce(Ae,[n,d,t]);return X(X(s))}function ie(o,e){let r=o;for(let n of e)r=N(r,n);return r}function Ne(o){try{let e=L(o.index,o.account,o.amount),r=ie(e,o.proof);return S(r,o.root)}catch{return!1}}function U(o,e){if(!Array.isArray(o)||o.length===0)throw new a("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new a(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let r=[],n=0n;for(let i=0;i<o.length;i+=1){let l=o[i];if(!l)throw new a(`Missing airdrop entry at position ${i}.`);let c=l.index??i;if(!Number.isInteger(c)||c!==i)throw new a(`Airdrop entry index at position ${i} must be contiguous ${i} (got ${String(c)}).`);let u=A(l.account,`entries[${i}].account`),g=w(e?.context,l.amount,e);n+=g,r.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ne)throw new a("Airdrop total amount must be > 0 and fit in uint128.");let d=r.map(i=>L(i.index,i.account,i.amount)),t=[d];for(;t[t.length-1].length>1;){let i=t[t.length-1],l=[];for(let c=0;c<i.length;c+=2){let u=i[c],g=i[c+1];g===void 0?l.push(u):l.push(N(u,g))}t.push(l)}let s=t[t.length-1][0];if(s.toLowerCase()===re)throw new a("Computed Merkle root cannot be zero.");let f=t.length>1?t[1]:t[0],m=r.map((i,l)=>{let c=[],u=l;for(let g=0;g<t.length-1;g+=1){let y=t[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:i.index,account:i.account,amount:i.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:r.length,values:r.map(i=>[i.index,i.account,i.amount]),entries:r};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:r.length,entries:r,proofs:m,list:p}}function ke(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new a("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,t])=>({index:n,account:d,amount:t})),r=U(e);if(o.root&&!S(r.root,o.root))throw new a(`Rebuilt tree root ${r.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&r.maxClaims!==o.maxClaims)throw new a(`Rebuilt maxClaims (${r.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&r.totalAmount!==o.totalAmount)throw new a(`Rebuilt totalAmount (${r.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return r}async function ae(o,e){return K(o.http,e,{method:"GET"},r=>r!==null&&typeof r=="object")}async function $e(o,e,r){let n=A(e.token,"token");if(n===ee)throw new a("Airdrop token cannot be the zero address.");let d=U(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),t=e.maxClaims??d.maxClaims;if(!Number.isInteger(t)||t<1||t>P||t!==d.maxClaims)throw new a(`maxClaims (${String(t)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new a(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ne)throw new a("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ge)throw new a(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let i=e.endTime!==void 0?H(e.endTime,"endTime"):0n;if(i>be)throw new a("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new a(`Token ${n} has no contract code on chain ${x}.`);let u;if(i!==0n){let _=(await l.getBlock()).timestamp,B=e.inclusionMargin!==void 0?H(e.inclusionMargin,"inclusionMargin"):pe;if(B<=0n)throw new a("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let D=_+B,I=e.inclusionTime!==void 0?H(e.inclusionTime,"inclusionTime"):D;if(I<D)throw new a(`inclusionTime (${I.toString()}) must be after the already-mined block (${_.toString()}) with room for signing and inclusion (>= ${D.toString()}).`);u=I;let F=I+fe;if(i<F)throw new a(`endTime (${i.toString()}) is too short (window too short): must be 0 or at least inclusion time (${I.toString()}) + 604800 (7 days >= ${F.toString()}, after already-mined block.timestamp ${_.toString()}).`)}let g=await l.readContract({address:C,abi:T,functionName:"quote",args:[t]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>Q)throw new a(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${Q.toString()}).`);let b=o.formatAmount(y.toString(),W.decimals),h=o.approval(n,C,f.toString(),x),k=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"create",args:[n,d.root,f,t,i,m]}),value:y.toString(),description:`Create HoodLock airdrop (${t} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),v=[h,k],E=A(e.account??r??xe,"wallet"),R=await o.preview(v,E),le=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",se=`${te(o,R)}${le}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:t,endTime:i,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:v,preview:R,summary:se}}async function G(o,e,r,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==r)throw new a(`savedProof account (${m}) does not match claim account (${r}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new a(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?ke(n.list):U(n.entries,{context:o})).proofs.find(i=>!(!S(i.account,r)||n.index!==void 0&&i.index!==Number(n.index)));if(!p)throw new a(`Account ${r} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${oe}/api/airdrop/${e.toString()}/proof?address=${r}`,t=await ae(o,d),s=t?.data??t;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new a(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${r}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new a(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function de(o,e){let r=o.clientFor(x),n=await r.readContract({address:C,abi:T,functionName:"getAirdrop",args:[e.id]}),[d,t,s,f,m,p,i,,l]=n,c=BigInt(t),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===ee||i.toLowerCase()===re)throw new a(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new a(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await r.getBlock()).timestamp>=c)throw new a(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new a(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([r.readContract({address:C,abi:T,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),we(r,b)]);if(h)throw new a(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new a(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let v=L(e.index,e.account,e.amount),E=ie(v,e.proof);if(!S(E,i))throw new a(`Computed Merkle root ${E} does not match on-chain airdrop root ${i} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:i,leaf:v}}async function Se(o,e){let{tokenAddress:r,tokenMeta:n,merkleRoot:d,leaf:t}=await de(o,e),s=e.caller??e.account,f=!S(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),i=[p],l=await o.preview(i,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${te(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:r,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:t,merkleRoot:d,proof:[...e.proof],tx:p,txs:i,preview:c,summary:u}}async function Ce(o,e,r){let n=A(e.account??r??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):r!==void 0?A(r,"wallet"):void 0;if(e.id!==void 0){let l=H(e.id,"id"),c=await G(o,l,n,e);return Se(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let t=`${oe}/api/airdrop/eligible?address=${n}`,s=await ae(o,t),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=H(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await G(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await de(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var ve=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,r)=>$e(o,e,r)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,r)=>Ce(o,e,r)}]}),Le=ve;export{V as a,x as b,C as c,oe as d,P as e,ge as f,fe as g,pe as h,Q as i,T as j,he as k,L as l,ie as m,Ne as n,U as o,ke as p,ve as q,Le as r};
@@ -1 +1 @@
1
- import{a as W}from"./ZGKVXFM5.js";import{a as H}from"./L6D26AMO.js";import{b as Z,c as z,d as J,e as K}from"./PWH464CJ.js";import{a as j}from"./SSIENQVU.js";import{a as L}from"./A3PN3PK3.js";import{c as V}from"./IKEJCBYU.js";import{b as $,o as q}from"./GHPREYQK.js";import{b as _}from"./Z4SRGAVL.js";import{a as x,d as I,e as B}from"./PBQSJSZO.js";import{a as P}from"./5ZLOCQA4.js";import{g as A,m as R,n as E}from"./5KUWLUPM.js";import{a as h,d as F,i as N,j as S}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{getAddress as O,parseAbi as te}from"viem";var n=O(N[4663].vaults.groveAlm.address),ne="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",m=te(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),T=P("Positive integer in token base units."),U={type:"string",description:`Public Grove vault only: ${n}. Defaults to this vault.`},Q={type:"integer",minimum:0,maximum:9999,default:$};function C(t){return E(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return R(t,"Grove returned an invalid integer read.")}function M(t,d,l){if(x(d),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===ne)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(x(t.vault),!A(t.vault,n))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function X(t,d,l){let u=l===void 0?$:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),a=d===void 0?e:C(d);if(a<=0n||a>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return a}function Y(t,d){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==d.chainId||!A(u.token.address,d.address))){if(u.token.decimals!==d.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ae=t=>{async function d(e){try{return await e()}catch(a){throw new o(t.plainError(a))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let a=await e.readContract({address:n,abi:m,functionName:"asset"});if(typeof a!="string"||!A(a,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,s,r]=await Promise.all([e.readContract({address:O(S),abi:m,functionName:"decimals"}),e.readContract({address:n,abi:m,functionName:"decimals"}),L(e,n)]);if(i!==F||s!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let p={address:O(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:p,shareToken:{address:n,chainId:h,decimals:s,symbol:r}}}async function u(e,a,i,s,r,p){let f=await t.preview(e,a);if(Y(f,i)!==-s)throw new o("Grove simulation did not show the exact requested token outflow.");if(Y(f,r)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${r.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[z(t,"grove_details",n),j(t,"grove_analytics",n),H(t,"grove_manage",n),...W(t,"grove",n),{name:"grove_list",inputSchema:{type:"object",properties:{vault:U},additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,[]);let{client:i,asset:s,shareToken:r}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:n,abi:m,functionName:"totalAssets"}),i.readContract({address:n,abi:m,functionName:"totalSupply"}),i.readContract({address:n,abi:m,functionName:"maxDeposit",args:[a]}),i.readContract({address:n,abi:m,functionName:"maxWithdraw",args:[a]}),i.readContract({address:n,abi:m,functionName:"performanceFee"}),i.readContract({address:n,abi:m,functionName:"managementFee"})]);return[{vault:n,chainId:h,name:"Grove x Steakhouse USDG",asset:s,shareToken:r,totalAssets:{token:s,amount:v(p).toString()},totalSupply:{token:r,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",description:"Deposit USDG in base units (1 USDG = 1000000) for 18-decimal vault shares. Exit with grove_withdraw; check positions after confirmation.",properties:{vault:U,amount:T,minSharesOut:T,slippageBps:Q},required:["amount"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["amount","minSharesOut","slippageBps"]);let i=C(e.amount),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:n,abi:m,functionName:"previewDeposit",args:[i]})),c=X(f,e.minSharesOut,e.slippageBps),g=I(n,r.address,i.toString(),a,h),w=[t.approval(r.address,n,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,a,r,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",description:"Redeem shares in 18-decimal base units, or shares all for a full exit to USDG. Check positions after confirmation.",properties:{vault:U,shares:{oneOf:[T,{const:"all",description:"Redeem the fresh full share balance."}]},minAmountOut:T,slippageBps:Q,force:{type:"boolean"},maxPenaltyAssets:P()},required:["shares"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:C(e.shares),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:n,abi:m,functionName:"balanceOf",args:[a]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let k=V(e.maxPenaltyAssets),ee=C(e.minAmountOut),G=await Z(t,s,n,a,c,k),D=await t.preview([G.tx],a);return K(D.changes,n,c,ee),{txs:[G.tx],preview:D,summary:`${J(G.plan)} ${D.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await s.readContract({address:n,abi:m,functionName:"previewRedeem",args:[c]})),w=X(g,e.minAmountOut,e.slippageBps),y=B(n,c.toString(),a,h).txs.map(k=>t.unsignedTx({...k,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,a,p,c,r,w)})}],positions:e=>d(async()=>{x(e);let{client:a,asset:i,shareToken:s}=await l(),r=v(await a.readContract({address:n,abi:m,functionName:"balanceOf",args:[e]}));if(r===0n)return[];let p=v(await a.readContract({address:n,abi:m,functionName:"previewRedeem",args:[r]}));return[{module:"grove",id:`${h}:${n.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(r.toString(),s.decimals)} Grove shares (${r} base units, ${s.decimals} decimals, ${n}); estimated USDG redemption, subject to simulation.`}]})}},we=t=>_("grove",[ae(t)]);export{ae as a,we as b};
1
+ import{b as Z,c as z,d as J,e as K}from"./Z4FZVJ5Z.js";import{a as W}from"./C7AXJHBT.js";import{a as H}from"./XLOYBLFI.js";import{a as j}from"./K3RDPI5J.js";import{a as L}from"./A3PN3PK3.js";import{c as V}from"./7WSHW7KW.js";import{b as $,o as q}from"./3NJ5KQ3Q.js";import{b as _}from"./SPJCSEKP.js";import{a as x,d as I,e as B}from"./43LI5NKJ.js";import{a as P}from"./66F5ZH34.js";import{g as A,m as R,n as E}from"./NWNYJ26T.js";import{a as h,d as F,i as N,j as S}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{getAddress as O,parseAbi as te}from"viem";var n=O(N[4663].vaults.groveAlm.address),ne="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",m=te(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),T=P("Positive integer in token base units."),U={type:"string",description:`Public Grove vault only: ${n}. Defaults to this vault.`},Q={type:"integer",minimum:0,maximum:9999,default:$};function C(t){return E(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return R(t,"Grove returned an invalid integer read.")}function M(t,d,l){if(x(d),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===ne)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(x(t.vault),!A(t.vault,n))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function X(t,d,l){let u=l===void 0?$:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),a=d===void 0?e:C(d);if(a<=0n||a>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return a}function Y(t,d){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==d.chainId||!A(u.token.address,d.address))){if(u.token.decimals!==d.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ae=t=>{async function d(e){try{return await e()}catch(a){throw new o(t.plainError(a))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let a=await e.readContract({address:n,abi:m,functionName:"asset"});if(typeof a!="string"||!A(a,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,s,r]=await Promise.all([e.readContract({address:O(S),abi:m,functionName:"decimals"}),e.readContract({address:n,abi:m,functionName:"decimals"}),L(e,n)]);if(i!==F||s!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let p={address:O(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:p,shareToken:{address:n,chainId:h,decimals:s,symbol:r}}}async function u(e,a,i,s,r,p){let f=await t.preview(e,a);if(Y(f,i)!==-s)throw new o("Grove simulation did not show the exact requested token outflow.");if(Y(f,r)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${r.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[z(t,"grove_details",n),j(t,"grove_analytics",n),H(t,"grove_manage",n),...W(t,"grove",n),{name:"grove_list",inputSchema:{type:"object",properties:{vault:U},additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,[]);let{client:i,asset:s,shareToken:r}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:n,abi:m,functionName:"totalAssets"}),i.readContract({address:n,abi:m,functionName:"totalSupply"}),i.readContract({address:n,abi:m,functionName:"maxDeposit",args:[a]}),i.readContract({address:n,abi:m,functionName:"maxWithdraw",args:[a]}),i.readContract({address:n,abi:m,functionName:"performanceFee"}),i.readContract({address:n,abi:m,functionName:"managementFee"})]);return[{vault:n,chainId:h,name:"Grove x Steakhouse USDG",asset:s,shareToken:r,totalAssets:{token:s,amount:v(p).toString()},totalSupply:{token:r,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",description:"Deposit USDG in base units (1 USDG = 1000000) for 18-decimal vault shares. Exit with grove_withdraw; check positions after confirmation.",properties:{vault:U,amount:T,minSharesOut:T,slippageBps:Q},required:["amount"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["amount","minSharesOut","slippageBps"]);let i=C(e.amount),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:n,abi:m,functionName:"previewDeposit",args:[i]})),c=X(f,e.minSharesOut,e.slippageBps),g=I(n,r.address,i.toString(),a,h),w=[t.approval(r.address,n,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,a,r,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",description:"Redeem shares in 18-decimal base units, or shares all for a full exit to USDG. Check positions after confirmation.",properties:{vault:U,shares:{oneOf:[T,{const:"all",description:"Redeem the fresh full share balance."}]},minAmountOut:T,slippageBps:Q,force:{type:"boolean"},maxPenaltyAssets:P()},required:["shares"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:C(e.shares),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:n,abi:m,functionName:"balanceOf",args:[a]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let k=V(e.maxPenaltyAssets),ee=C(e.minAmountOut),G=await Z(t,s,n,a,c,k),D=await t.preview([G.tx],a);return K(D.changes,n,c,ee),{txs:[G.tx],preview:D,summary:`${J(G.plan)} ${D.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await s.readContract({address:n,abi:m,functionName:"previewRedeem",args:[c]})),w=X(g,e.minAmountOut,e.slippageBps),y=B(n,c.toString(),a,h).txs.map(k=>t.unsignedTx({...k,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,a,p,c,r,w)})}],positions:e=>d(async()=>{x(e);let{client:a,asset:i,shareToken:s}=await l(),r=v(await a.readContract({address:n,abi:m,functionName:"balanceOf",args:[e]}));if(r===0n)return[];let p=v(await a.readContract({address:n,abi:m,functionName:"previewRedeem",args:[r]}));return[{module:"grove",id:`${h}:${n.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(r.toString(),s.decimals)} Grove shares (${r} base units, ${s.decimals} decimals, ${n}); estimated USDG redemption, subject to simulation.`}]})}},we=t=>_("grove",[ae(t)]);export{ae as a,we as b};
@@ -1 +1 @@
1
- import{b as B}from"./AWXJV2YH.js";import{a as u,b,c,e as k,f as m,g as l,h as w}from"./2MZXTOZU.js";import{e as y,m as o}from"./5KUWLUPM.js";import{a as n}from"./XSD5NL7J.js";import{erc20Abi as L,formatUnits as x}from"viem";var a="LayerBank returned a malformed reserve read. Please try again.";function N(r){let s=o(r,a);if(s>=1n<<128n)throw new n(a);return s}async function I(r,s){try{let e=s??await r.getBlockNumber({cacheTime:0}),p=await B(r,e),[f,h,R,v]=await Promise.all([r.readContract({address:u,abi:l,functionName:"getConfiguration",args:[c.address],blockNumber:e}),r.readContract({address:c.address,abi:L,functionName:"balanceOf",args:[b],blockNumber:e}),r.readContract({address:b,abi:w,functionName:"scaledTotalSupply",blockNumber:e}),r.readContract({address:u,abi:l,functionName:"getReserveNormalizedIncome",args:[c.address],blockNumber:e})]);if(!y(f))throw new n(a);let t=o(f.data,a);if((t>>48n&255n)!==6n)throw new n(a);let C=N(p.currentLiquidityRate),P=N(p.accruedToTreasury),T=o(R,a),g=o(v,a);if(g===0n)throw new n(a);let d=((T+P)*g+m/2n)/m,i=(t>>116n&(1n<<36n)-1n)*10n**6n;return{blockNumber:e,active:(t&1n<<56n)!==0n,frozen:(t&1n<<57n)!==0n,paused:(t&1n<<60n)!==0n,supplyCapBase:i,suppliedBase:d,capRoomBase:i===0n?k:d>=i?0n:i-d,cashUsdgBase:o(h,a),rateBasePct:Number(x(C,25))}}catch(e){throw e instanceof n?e:new n("LayerBank reserve could not be read. Please try again.")}}export{I as a};
1
+ import{b as B}from"./TFDPEAVZ.js";import{a as u,b,c,e as k,f as m,g as l,h as w}from"./2MZXTOZU.js";import{e as y,m as o}from"./NWNYJ26T.js";import{a as n}from"./XSD5NL7J.js";import{erc20Abi as L,formatUnits as x}from"viem";var a="LayerBank returned a malformed reserve read. Please try again.";function N(r){let s=o(r,a);if(s>=1n<<128n)throw new n(a);return s}async function I(r,s){try{let e=s??await r.getBlockNumber({cacheTime:0}),p=await B(r,e),[f,h,R,v]=await Promise.all([r.readContract({address:u,abi:l,functionName:"getConfiguration",args:[c.address],blockNumber:e}),r.readContract({address:c.address,abi:L,functionName:"balanceOf",args:[b],blockNumber:e}),r.readContract({address:b,abi:w,functionName:"scaledTotalSupply",blockNumber:e}),r.readContract({address:u,abi:l,functionName:"getReserveNormalizedIncome",args:[c.address],blockNumber:e})]);if(!y(f))throw new n(a);let t=o(f.data,a);if((t>>48n&255n)!==6n)throw new n(a);let C=N(p.currentLiquidityRate),P=N(p.accruedToTreasury),T=o(R,a),g=o(v,a);if(g===0n)throw new n(a);let d=((T+P)*g+m/2n)/m,i=(t>>116n&(1n<<36n)-1n)*10n**6n;return{blockNumber:e,active:(t&1n<<56n)!==0n,frozen:(t&1n<<57n)!==0n,paused:(t&1n<<60n)!==0n,supplyCapBase:i,suppliedBase:d,capRoomBase:i===0n?k:d>=i?0n:i-d,cashUsdgBase:o(h,a),rateBasePct:Number(x(C,25))}}catch(e){throw e instanceof n?e:new n("LayerBank reserve could not be read. Please try again.")}}export{I as a};
@@ -1,8 +1,8 @@
1
- import{a as ot}from"./63YRSLDK.js";var yt={};ot(yt,{ACCESS_FEE_LINE:()=>M,ACCESS_NO_PLAN:()=>T,BANNED_COPY:()=>pt,BONUS_CLAUSE:()=>h,CARD_FOOTER_ASK:()=>E,CARD_FOOTER_NO_ASK:()=>k,CARD_HEADER:()=>s,CARD_HEADER_AMOUNT:()=>r,CARD_HEADER_AMOUNT_NOT_HELD:()=>i,ETH_HINT:()=>f,FEES_ESTIMATED_HIGH:()=>K,LAYERBANK_RISK_SUMMARY:()=>u,LAYERBANK_SETUP_MISMATCH:()=>Q,LAYERBANK_SITE:()=>st,LB_BONUS_NOTE:()=>N,LB_CASH_NOTE:()=>O,LB_DEPOSIT_SCREEN:()=>x,LB_WITHDRAW_SCREEN:()=>S,LP_ADD_BUTTON:()=>lt,LP_BLOCK:()=>q,LP_BLOCK_UNREADABLE:()=>j,LP_DECLINE_BUTTON:()=>ht,LP_NOT_WORTH_CLAUSE:()=>X,MATURED_NOTICE:()=>W,MATURED_STOCK_NOTICE:()=>F,MATURED_STOCK_NOTICE_NO_AMOUNT:()=>z,NOTHING_TO_EARN:()=>b,NO_NEW_TERM:()=>$,OPTION_A:()=>l,OPTION_A_CANT_CHECK:()=>y,OPTION_A_CLOSED:()=>g,OPTION_A_NO_ROOM:()=>m,OPTION_B:()=>c,OPTION_B_CANT_CHECK:()=>w,OPTION_B_NONE:()=>p,PAYOUT_APPROX:()=>U,PAYOUT_EXACT:()=>v,PENDLE_BUY_STABLE_SCREEN:()=>A,PENDLE_BUY_STOCK_SCREEN:()=>L,PENDLE_CONTRACT_CHANGE:()=>ut,PENDLE_EARLY_EXIT:()=>_,PENDLE_FIXED_RATE:()=>it,PENDLE_REDEEM_SCREEN:()=>I,PENDLE_REDEEM_STOCK_SCREEN:()=>R,PENDLE_RISK_SUMMARY:()=>d,PENDLE_SELL_DEFAULT_BUTTON:()=>dt,PENDLE_SELL_GAP_LINE:()=>D,PENDLE_SELL_NO_GAP_LINE:()=>C,PENDLE_SELL_SCREEN:()=>P,PENDLE_SERVICE_DOWN:()=>tt,PENDLE_SITE:()=>rt,PRICE_MISMATCH_REFUSAL:()=>J,SLIPPAGE_CAP_REFUSAL:()=>V,STOCK_PAID_IN:()=>B,STOCK_SHORT_TERM:()=>Y,STOCK_SHORT_TERM_DAYS:()=>_t,TEMPLATES:()=>ct,THIN_MARKET_REFUSAL:()=>Z,TOO_SMALL:()=>G,TOO_SMALL_NO_SIZE:()=>H,fill:()=>nt,placeholdersOf:()=>at});function t(e){return{text:e}}function at(e){return[...new Set([...e.text.matchAll(/\{([a-z][a-z0-9_]*)\}/g)].map(o=>o[1]))]}function nt(e,o){let et=o;return e.text.replace(/\{([a-z][a-z0-9_]*)\}/g,(wt,a)=>{let n=et[a];if(typeof n!="string")throw new Error(`Missing value for {${a}}`);return n})}var st="layerbank.finance",rt="app.pendle.finance",s=t("You have {amount_usd} in USDG that isn't earning anything. Here are two ways to make it earn. Pick one, or neither."),r=t("Looking at {amount_usd} of your USDG. Here are two ways to make it earn. Pick one, or neither."),i=t("Looking at {amount_usd} of USDG. Here are two ways to make it earn. Pick one, or neither."),u="LayerBank is a lending app; if its code fails or almost everything is lent out, you could lose money or have to wait.",d="Pendle is a trading app; thin trading can make leaving early cost you, and its code can fail or be changed by its team.",_="If you leave early you sell at the market price that day, and that can be less than you put in.",it="The rate is fixed only if you hold until the end date.",ut="Pendle's router can be upgraded by Pendle's team, so its code can change.",l=t(`A. LayerBank: lending, take it out any time
1
+ import{a as ot}from"./63YRSLDK.js";var yt={};ot(yt,{ACCESS_FEE_LINE:()=>M,ACCESS_NO_PLAN:()=>T,BANNED_COPY:()=>pt,BONUS_CLAUSE:()=>l,CARD_FOOTER_ASK:()=>E,CARD_FOOTER_NO_ASK:()=>k,CARD_HEADER:()=>s,CARD_HEADER_AMOUNT:()=>r,CARD_HEADER_AMOUNT_NOT_HELD:()=>i,ETH_HINT:()=>f,FEES_ESTIMATED_HIGH:()=>K,LAYERBANK_RISK_SUMMARY:()=>u,LAYERBANK_SETUP_MISMATCH:()=>Q,LAYERBANK_SITE:()=>st,LB_BONUS_NOTE:()=>N,LB_CASH_NOTE:()=>O,LB_DEPOSIT_SCREEN:()=>x,LB_WITHDRAW_SCREEN:()=>S,LP_ADD_BUTTON:()=>ht,LP_BLOCK:()=>$,LP_BLOCK_UNREADABLE:()=>j,LP_DECLINE_BUTTON:()=>lt,LP_NOT_WORTH_CLAUSE:()=>X,MATURED_NOTICE:()=>W,MATURED_STOCK_NOTICE:()=>F,MATURED_STOCK_NOTICE_NO_AMOUNT:()=>z,NOTHING_TO_EARN:()=>b,NO_NEW_TERM:()=>q,OPTION_A:()=>h,OPTION_A_CANT_CHECK:()=>y,OPTION_A_CLOSED:()=>g,OPTION_A_NO_ROOM:()=>m,OPTION_B:()=>c,OPTION_B_CANT_CHECK:()=>w,OPTION_B_NONE:()=>p,PAYOUT_APPROX:()=>U,PAYOUT_EXACT:()=>v,PENDLE_BUY_STABLE_SCREEN:()=>A,PENDLE_BUY_STOCK_SCREEN:()=>L,PENDLE_CONTRACT_CHANGE:()=>ut,PENDLE_EARLY_EXIT:()=>_,PENDLE_FIXED_RATE:()=>it,PENDLE_REDEEM_SCREEN:()=>I,PENDLE_REDEEM_STOCK_SCREEN:()=>R,PENDLE_RISK_SUMMARY:()=>d,PENDLE_SELL_DEFAULT_BUTTON:()=>dt,PENDLE_SELL_GAP_LINE:()=>D,PENDLE_SELL_NO_GAP_LINE:()=>C,PENDLE_SELL_SCREEN:()=>P,PENDLE_SERVICE_DOWN:()=>tt,PENDLE_SITE:()=>rt,PRICE_MISMATCH_REFUSAL:()=>J,SLIPPAGE_CAP_REFUSAL:()=>V,STOCK_PAID_IN:()=>B,STOCK_SHORT_TERM:()=>Y,STOCK_SHORT_TERM_DAYS:()=>_t,TEMPLATES:()=>ct,THIN_MARKET_REFUSAL:()=>Z,TOO_SMALL:()=>G,TOO_SMALL_NO_SIZE:()=>H,fill:()=>nt,placeholdersOf:()=>at});function t(e){return{text:e}}function at(e){return[...new Set([...e.text.matchAll(/\{([a-z][a-z0-9_]*)\}/g)].map(o=>o[1]))]}function nt(e,o){let et=o;return e.text.replace(/\{([a-z][a-z0-9_]*)\}/g,(wt,a)=>{let n=et[a];if(typeof n!="string")throw new Error(`Missing value for {${a}}`);return n})}var st="layerbank.finance",rt="app.pendle.finance",s=t("You have {amount_usd} in USDG that isn't earning anything. Here are two ways to make it earn. Pick one, or neither."),r=t("Looking at {amount_usd} of your USDG. Here are two ways to make it earn. Pick one, or neither."),i=t("Looking at {amount_usd} of USDG. Here are two ways to make it earn. Pick one, or neither."),u="LayerBank is a lending app; if its code fails or almost everything is lent out, you could lose money or have to wait.",d="Pendle is a trading app; thin trading can make leaving early cost you, and its code can fail or be changed by its team.",_="If you leave early you sell at the market price that day, and that can be less than you put in.",it="The rate is fixed only if you hold until the end date.",ut="Pendle's router can be upgraded by Pendle's team, so its code can change.",h=t(`A. LayerBank: lending, take it out any time
2
2
  Pays about {lb_total_rate}% a year today ({lb_base_rate}% from borrowers{bonus_clause}). The rate changes, up or down.
3
3
  You can take your money out any time while LayerBank has cash on hand (right now {lb_cash_usd}).
4
4
  Risk: ${u}
5
- Cost: network fees of about {lb_gas_in_usd} to put it in and {lb_gas_out_usd} to take it out.`),h=t(", plus a bonus of {lb_bonus_rate}% that ends {bonus_end}"),c=t(`B. Pendle: a fixed rate until {pendle_end_date}
5
+ Cost: network fees of about {lb_gas_in_usd} to put it in and {lb_gas_out_usd} to take it out.`),l=t(", plus a bonus of {lb_bonus_rate}% that ends {bonus_end}"),c=t(`B. Pendle: a fixed rate until {pendle_end_date}
6
6
  Pays a fixed {pendle_rate}% a year if you keep it until {pendle_end_date}. You get {pendle_payout_usd} back for every {pendle_unit_usd} you put in.
7
7
  ${_}
8
8
  Risk: ${d}
@@ -41,7 +41,7 @@ If you sell now, the market pays about {sell_now} {unit}, and Oak accepts no les
41
41
  Selling early can lose money. The price today may be lower than what you paid.
42
42
  Cost: about {fees_usd} in trading and network fees.
43
43
 
44
- Sell now? [Yes, sell now] [No, keep waiting]`),D=t("That is {gap} less than waiting."),C=t("The market pays at least what waiting would, so selling now loses you nothing."),dt="No, keep waiting",I=t(`Cash out {pt_amount} tokens for {usdg_out} USDG?
44
+ Sell now? [Yes, sell now] [No, keep waiting]`),D=t("That is {gap} less than waiting."),C=t("The quoted output before fees is at least the payout at the end of the term. Fees, the minimum output and what you paid still affect whether you lose money."),dt="No, keep waiting",I=t(`Cash out {pt_amount} tokens for {usdg_out} USDG?
45
45
 
46
46
  The term ended on {pendle_end_date}. Each token pays out {payout_per_pt_phrase} now, with no market price involved.
47
47
  Cost: about {gas_usd} in network fees.
@@ -53,7 +53,7 @@ To end up in USDG, I can swap the {stock_symbol} afterwards with Oak's swap tool
53
53
  Cost: about {gas_usd} in network fees.
54
54
 
55
55
  Cash out? [Yes] [No]`),v=t("exactly 1 {unit}"),U=t("about {x} {unit} at today's exchange rate"),B=t("Paid in {stock_symbol}, not dollars."),Y=t("ends in {days_left} days, usually too short to be worth the fees"),_t=7,G=t("At {amount_usd}, this is too small to be worth it. You would earn about {gross_usd} over {horizon}, and fees would take about {costs_usd}, leaving about {net_usd}. Putting in {suggest_usd} or more would be worth it, and I can still do it if you want."),H=t("At {amount_usd}, this is too small to be worth it. You would earn about {gross_usd} over {horizon}, and fees would take about {costs_usd}, leaving about {net_usd}. At today's rate no amount would make up for the fees, and I can still do it if you want."),M=t("Also: Oak access costs {plan_price} per 30 days, which you pay whether or not you earn. At this size that is more than you would earn in a month."),K=t("Fees estimated high because the live price was unavailable."),W=t(`Your fixed term on Pendle ended on {pendle_end_date}. Your {pt_amount} tokens are worth {usdg_out} USDG now.
56
- Want me to cash out to USDG, or start a new term? One "yes" is enough; say "cash out" or "new term".`),F=t('Your fixed term on Pendle ended on {pendle_end_date}. Your {pt_amount} tokens pay out about {unit_out} {stock_symbol} now, worth about {value_usd}. Want me to cash out and swap that to USDG, or start a new term? One "yes" is enough.'),z=t('Your fixed term on Pendle in {stock_symbol} ended on {pendle_end_date}. Your tokens pay out in {stock_symbol}, not USDG; I will show the exact amount before anything is sent. Want me to cash out and swap that to USDG, or start a new term? One "yes" is enough.'),$=t("There is no new fixed-rate USDG term open right now. I cashed out to USDG; want me to show LayerBank instead?"),q=t(`Before you add liquidity: what it is worth, and what can go wrong
56
+ Want me to cash out to USDG, or start a new term? One "yes" is enough; say "cash out" or "new term".`),F=t('Your fixed term on Pendle ended on {pendle_end_date}. Your {pt_amount} tokens pay out about {unit_out} {stock_symbol} now, worth about {value_usd}. Want me to cash out and swap that to USDG, or start a new term? One "yes" is enough.'),z=t('Your fixed term on Pendle in {stock_symbol} ended on {pendle_end_date}. Your tokens pay out in {stock_symbol}, not USDG; I will show the exact amount before anything is sent. Want me to cash out and swap that to USDG, or start a new term? One "yes" is enough.'),q=t("There is no new fixed-rate USDG term open right now. I cashed out to USDG; want me to show LayerBank instead?"),$=t(`Before you add liquidity: what it is worth, and what can go wrong
57
57
 
58
58
  Worth: at today's reward rate of about {apr}% a year, {amount_usd} would earn about {gross_usd} until the campaign ends on {end_date}, and about {gas_usd} of that goes to network fees, leaving about {net_usd}. {worth_clause}
59
59
  What can go wrong:
@@ -67,4 +67,4 @@ What can go wrong:
67
67
  - Price exposure: you put in two coins. If one moves a lot against the other, you can end up with less than you started with, even if you earn rewards.
68
68
  - Going out of range: if the price leaves the range you chose, you stop earning until it comes back, and you hold mostly the weaker coin.
69
69
  - The rewards can end: a campaign can end at any time, and any rate shown is the rate of that day, which changes.
70
- Your call. If you say nothing, the answer is Don't. [Don't] [Add liquidity]`),lt="Add liquidity",ht="Don't",V=t("Oak won't accept a price move that big. The most it allows is {cap_pct}%."),Z=t("This is a thin market and your size moves the price too much. Try a smaller amount."),J=t("Pendle's price doesn't match what Oak checked on the chain. Nothing was signed."),Q=t("LayerBank's setup no longer matches what Oak checked. Nothing was signed."),tt=t("Pendle's price service isn't answering, so I can't quote or start a new term; I can still cash out ended terms."),ct={CARD_HEADER:s,CARD_HEADER_AMOUNT:r,CARD_HEADER_AMOUNT_NOT_HELD:i,OPTION_A:l,BONUS_CLAUSE:h,OPTION_B:c,OPTION_B_NONE:p,OPTION_A_CANT_CHECK:y,OPTION_B_CANT_CHECK:w,OPTION_A_CLOSED:g,OPTION_A_NO_ROOM:m,CARD_FOOTER_ASK:E,CARD_FOOTER_NO_ASK:k,ETH_HINT:f,NOTHING_TO_EARN:b,ACCESS_NO_PLAN:T,LB_DEPOSIT_SCREEN:x,LB_WITHDRAW_SCREEN:S,LB_BONUS_NOTE:N,LB_CASH_NOTE:O,PENDLE_BUY_STABLE_SCREEN:A,PENDLE_BUY_STOCK_SCREEN:L,PENDLE_SELL_SCREEN:P,PENDLE_SELL_GAP_LINE:D,PENDLE_SELL_NO_GAP_LINE:C,PENDLE_REDEEM_SCREEN:I,PENDLE_REDEEM_STOCK_SCREEN:R,PAYOUT_EXACT:v,PAYOUT_APPROX:U,STOCK_PAID_IN:B,STOCK_SHORT_TERM:Y,TOO_SMALL:G,TOO_SMALL_NO_SIZE:H,ACCESS_FEE_LINE:M,FEES_ESTIMATED_HIGH:K,MATURED_NOTICE:W,MATURED_STOCK_NOTICE:F,MATURED_STOCK_NOTICE_NO_AMOUNT:z,NO_NEW_TERM:$,LP_BLOCK:q,LP_NOT_WORTH_CLAUSE:X,LP_BLOCK_UNREADABLE:j,SLIPPAGE_CAP_REFUSAL:V,THIN_MARKET_REFUSAL:Z,PRICE_MISMATCH_REFUSAL:J,LAYERBANK_SETUP_MISMATCH:Q,PENDLE_SERVICE_DOWN:tt},pt=[/\bsafe(ly|ty)?\b/i,/\bguaranteed\b/i,/\brisk-free\b/i,/\bpassive\b/i,/\binvest/i,/\bAPY\b(?! a year)/];export{at as a,nt as b,st as c,rt as d,s as e,r as f,i as g,u as h,d as i,_ as j,it as k,ut as l,l as m,h as n,c as o,p,y as q,w as r,g as s,m as t,E as u,k as v,f as w,b as x,T as y,x as z,S as A,N as B,O as C,A as D,L as E,P as F,D as G,C as H,dt as I,I as J,R as K,v as L,U as M,B as N,Y as O,_t as P,G as Q,H as R,M as S,K as T,W as U,F as V,z as W,$ as X,q as Y,X as Z,j as _,lt as $,ht as aa,V as ba,Z as ca,J as da,Q as ea,tt as fa,ct as ga,pt as ha,yt as ia};
70
+ Your call. If you say nothing, the answer is Don't. [Don't] [Add liquidity]`),ht="Add liquidity",lt="Don't",V=t("Oak won't accept a price move that big. The most it allows is {cap_pct}%."),Z=t("This is a thin market and your size moves the price too much. Try a smaller amount."),J=t("Pendle's price doesn't match what Oak checked on the chain. Nothing was signed."),Q=t("LayerBank's setup no longer matches what Oak checked. Nothing was signed."),tt=t("Pendle's price service isn't answering, so I can't quote or start a new term; I can still cash out ended terms."),ct={CARD_HEADER:s,CARD_HEADER_AMOUNT:r,CARD_HEADER_AMOUNT_NOT_HELD:i,OPTION_A:h,BONUS_CLAUSE:l,OPTION_B:c,OPTION_B_NONE:p,OPTION_A_CANT_CHECK:y,OPTION_B_CANT_CHECK:w,OPTION_A_CLOSED:g,OPTION_A_NO_ROOM:m,CARD_FOOTER_ASK:E,CARD_FOOTER_NO_ASK:k,ETH_HINT:f,NOTHING_TO_EARN:b,ACCESS_NO_PLAN:T,LB_DEPOSIT_SCREEN:x,LB_WITHDRAW_SCREEN:S,LB_BONUS_NOTE:N,LB_CASH_NOTE:O,PENDLE_BUY_STABLE_SCREEN:A,PENDLE_BUY_STOCK_SCREEN:L,PENDLE_SELL_SCREEN:P,PENDLE_SELL_GAP_LINE:D,PENDLE_SELL_NO_GAP_LINE:C,PENDLE_REDEEM_SCREEN:I,PENDLE_REDEEM_STOCK_SCREEN:R,PAYOUT_EXACT:v,PAYOUT_APPROX:U,STOCK_PAID_IN:B,STOCK_SHORT_TERM:Y,TOO_SMALL:G,TOO_SMALL_NO_SIZE:H,ACCESS_FEE_LINE:M,FEES_ESTIMATED_HIGH:K,MATURED_NOTICE:W,MATURED_STOCK_NOTICE:F,MATURED_STOCK_NOTICE_NO_AMOUNT:z,NO_NEW_TERM:q,LP_BLOCK:$,LP_NOT_WORTH_CLAUSE:X,LP_BLOCK_UNREADABLE:j,SLIPPAGE_CAP_REFUSAL:V,THIN_MARKET_REFUSAL:Z,PRICE_MISMATCH_REFUSAL:J,LAYERBANK_SETUP_MISMATCH:Q,PENDLE_SERVICE_DOWN:tt},pt=[/\bsafe(ly|ty)?\b/i,/\bguaranteed\b/i,/\brisk-free\b/i,/\bpassive\b/i,/\binvest/i,/\bAPY\b(?! a year)/];export{at as a,nt as b,st as c,rt as d,s as e,r as f,i as g,u as h,d as i,_ as j,it as k,ut as l,h as m,l as n,c as o,p,y as q,w as r,g as s,m as t,E as u,k as v,f as w,b as x,T as y,x as z,S as A,N as B,O as C,A as D,L as E,P as F,D as G,C as H,dt as I,I as J,R as K,v as L,U as M,B as N,Y as O,_t as P,G as Q,H as R,M as S,K as T,W as U,F as V,z as W,q as X,$ as Y,X as Z,j as _,ht as $,lt as aa,V as ba,Z as ca,J as da,Q as ea,tt as fa,ct as ga,pt as ha,yt as ia};
@@ -1 +1 @@
1
- import{b as s}from"./MQK6OP7S.js";import{a as p}from"./LT5P6PZW.js";import{a as u}from"./HTXKERNS.js";import{f as a}from"./5KUWLUPM.js";import{a as r}from"./XSD5NL7J.js";import{erc20Abi as f,getAddress as i,parseAbi as g,zeroAddress as b}from"viem";var w={type:"string",pattern:"^(0|[1-9][0-9]*)$",maxLength:78},O={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},R={blockNumber:{...w,description:"Optional named chain-4663 block; defaults to the head captured once for this read."}},T=g(["function launchFee() view returns (uint256 fee,address treasury,uint256 pendingFee,address pendingTreasury,uint256 readyAt)"]),k=p;function B(e,n,t=[]){let o=a(e,"Provide the documented Hookr object.");if(Object.keys(o).some(d=>!n.includes(d))||t.some(d=>!Object.hasOwn(o,d)))throw new r("Provide exactly the documented Hookr fields; wallet overrides are not accepted.");return o}function l(e,n=256){if(typeof e!="string"||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>78||BigInt(e)>=1n<<BigInt(n))throw new r(`Provide a decimal integer string within uint${n}.`);return BigInt(e)}function N(e){return e.blockNumber===void 0?void 0:l(e.blockNumber,64)}function S(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r("Provide an exact bytes32 Hookr ID.");return e.toLowerCase()}function $(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{40}$/.test(e)||i(e)!==e)throw new r("Provide an EIP-55 checksummed address.");return i(e)}function y(e,n=256){if(typeof e!="bigint"&&(typeof e!="number"||!Number.isSafeInteger(e)))throw new r("Hookr integer read is incomplete. Retry the named-block read.");let t=BigInt(e);if(t<0n||t>=1n<<BigInt(n))throw new r("Hookr integer read is outside its ABI bounds.");return t}function E(e){if(typeof e!="boolean")throw new r("Hookr boolean read is incomplete.");return e}function j(e,n){if(!Array.isArray(e)||e.length!==n)throw new r("Hookr tuple read is incomplete.");return e}var C=e=>a(e,"Hookr struct read is incomplete.");function F(e){return JSON.parse(JSON.stringify(e,(n,t)=>typeof t=="bigint"||typeof t=="number"?String(t):t))}function V(e){return k[e].abi}function m(e,n,t,o,d,c){return e.readContract({address:n,abi:t,functionName:o,args:d,blockNumber:c})}var L=i(s.rootV1),_=i(s.registry),D=i(s.poolManager),J=i(s.agentGateV1);function K(e){if(e===i(s.rulesV1))return"rulesV1";if(e===i(s.rulesPrevious))return"rules";if(e===i(s.rulesLegacy))return"rulesLegacy";throw new r("Unknown Hookr core deployment. Review and pin it before reading this position.")}async function U(e,n,t){if(n===b)return{address:u,symbol:"ETH",decimals:18,chainId:4663};let[o,d]=await Promise.all([m(e,n,f,"symbol",[],t),m(e,n,f,"decimals",[],t)]),c=y(d,8);if(typeof o!="string"||o.length===0||new TextEncoder().encode(o).length>128)throw new r("Hookr token metadata is incomplete. Retry before valuing this currency.");return{address:n,symbol:o,decimals:Number(c),chainId:4663}}export{w as a,O as b,R as c,T as d,B as e,l as f,N as g,S as h,$ as i,y as j,E as k,j as l,C as m,F as n,V as o,m as p,L as q,_ as r,D as s,J as t,K as u,U as v};
1
+ import{b as s}from"./MQK6OP7S.js";import{a as p}from"./LT5P6PZW.js";import{a as u}from"./3MLUCYCB.js";import{f as a}from"./NWNYJ26T.js";import{a as r}from"./XSD5NL7J.js";import{erc20Abi as f,getAddress as i,parseAbi as g,zeroAddress as b}from"viem";var w={type:"string",pattern:"^(0|[1-9][0-9]*)$",maxLength:78},O={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},R={blockNumber:{...w,description:"Optional named chain-4663 block; defaults to the head captured once for this read."}},T=g(["function launchFee() view returns (uint256 fee,address treasury,uint256 pendingFee,address pendingTreasury,uint256 readyAt)"]),k=p;function B(e,n,t=[]){let o=a(e,"Provide the documented Hookr object.");if(Object.keys(o).some(d=>!n.includes(d))||t.some(d=>!Object.hasOwn(o,d)))throw new r("Provide exactly the documented Hookr fields; wallet overrides are not accepted.");return o}function l(e,n=256){if(typeof e!="string"||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>78||BigInt(e)>=1n<<BigInt(n))throw new r(`Provide a decimal integer string within uint${n}.`);return BigInt(e)}function N(e){return e.blockNumber===void 0?void 0:l(e.blockNumber,64)}function S(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r("Provide an exact bytes32 Hookr ID.");return e.toLowerCase()}function $(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{40}$/.test(e)||i(e)!==e)throw new r("Provide an EIP-55 checksummed address.");return i(e)}function y(e,n=256){if(typeof e!="bigint"&&(typeof e!="number"||!Number.isSafeInteger(e)))throw new r("Hookr integer read is incomplete. Retry the named-block read.");let t=BigInt(e);if(t<0n||t>=1n<<BigInt(n))throw new r("Hookr integer read is outside its ABI bounds.");return t}function E(e){if(typeof e!="boolean")throw new r("Hookr boolean read is incomplete.");return e}function j(e,n){if(!Array.isArray(e)||e.length!==n)throw new r("Hookr tuple read is incomplete.");return e}var C=e=>a(e,"Hookr struct read is incomplete.");function F(e){return JSON.parse(JSON.stringify(e,(n,t)=>typeof t=="bigint"||typeof t=="number"?String(t):t))}function V(e){return k[e].abi}function m(e,n,t,o,d,c){return e.readContract({address:n,abi:t,functionName:o,args:d,blockNumber:c})}var L=i(s.rootV1),_=i(s.registry),D=i(s.poolManager),J=i(s.agentGateV1);function K(e){if(e===i(s.rulesV1))return"rulesV1";if(e===i(s.rulesPrevious))return"rules";if(e===i(s.rulesLegacy))return"rulesLegacy";throw new r("Unknown Hookr core deployment. Review and pin it before reading this position.")}async function U(e,n,t){if(n===b)return{address:u,symbol:"ETH",decimals:18,chainId:4663};let[o,d]=await Promise.all([m(e,n,f,"symbol",[],t),m(e,n,f,"decimals",[],t)]),c=y(d,8);if(typeof o!="string"||o.length===0||new TextEncoder().encode(o).length>128)throw new r("Hookr token metadata is incomplete. Retry before valuing this currency.");return{address:n,symbol:o,decimals:Number(c),chainId:4663}}export{w as a,O as b,R as c,T as d,B as e,l as f,N as g,S as h,$ as i,y as j,E as k,j as l,C as m,F as n,V as o,m as p,L as q,_ as r,D as s,J as t,K as u,U as v};
@@ -1 +1 @@
1
- import{a as S}from"./A3PN3PK3.js";import{a as M}from"./PBQSJSZO.js";import{a as s,j as I}from"./FWD4L3CJ.js";import{a as n}from"./XSD5NL7J.js";import{getAddress as c}from"viem";var j=["one_hour","six_hours","one_day","seven_days","thirty_days","ninety_days","one_year","inception"],v=["one_day","seven_days","thirty_days","ninety_days","one_year","inception"],A={apy:["v1","apy-averages"],allocations:["v0","allocations"],history:["v0","state/history"],pending_governance:["v0","pending-governance-actions"]};function f(o){if(!o||typeof o!="object"||Array.isArray(o))throw new n("Morpho analytics returned an invalid object.");return o}function b(o){if(typeof o!="string"||!/^\d+$/.test(o)||BigInt(o)>=1n<<256n)throw new n("Morpho analytics returned an invalid decimal base-unit amount.");return o}function N(o,d){let r=f(o);if(![s,String(s)].includes(r.chain_id)||typeof r.vault_address!="string"||c(r.vault_address)!==c(d))throw new n("Morpho analytics returned another chain or vault.")}function k(o,d=0){if(d>12)throw new n("Morpho analytics response is too deeply nested.");if(Array.isArray(o))return o.map(r=>k(r,d+1));if(o&&typeof o=="object")return Object.fromEntries(Object.entries(o).map(([r,e])=>{if(e!==null&&/(?:_assets|_shares|_supply|_cap|_wad|_ray)$/.test(r)&&typeof e!="object")return[r,b(e)];if(e!==null&&/_address$/.test(r)){if(typeof e!="string")throw new n("Morpho analytics returned an invalid address.");return[r,c(e)]}return[r,k(e,d+1)]}));if(typeof o=="number"&&!Number.isFinite(o))throw new n("Morpho analytics returned a non-finite value.");return o}function U(o,d,r){return{name:d,inputSchema:{type:"object",additionalProperties:!1,required:["view"],properties:{view:{type:"string",enum:Object.keys(A)},lookback:{type:"string",enum:j,description:"APY window: one_hour through inception. History: one_day, seven_days, thirty_days, ninety_days, one_year or inception. Defaults to six_hours for APY or seven_days for history."},cursor:{type:"string",maxLength:4096,description:"Opaque cursor from pending_governance only."},limit:{type:"integer",minimum:1,maximum:100}},allOf:[{if:{properties:{view:{const:"history"}},required:["view"]},then:{properties:{lookback:{enum:v}}}}]},execute:async(e,O)=>{try{if(M(O),Object.keys(e).some(t=>!["view","lookback","cursor","limit"].includes(t))||typeof e.view!="string"||!Object.hasOwn(A,e.view))throw new n("Choose a documented Morpho analytics view.");let a=e.view,u=a==="history",w=a==="apy",_=a==="pending_governance";if(e.lookback!==void 0&&(!u&&!w||typeof e.lookback!="string"||!j.includes(e.lookback)))throw new n("lookback is available only for APY/history with a documented window.");if(u&&e.lookback!==void 0&&!v.includes(e.lookback))throw new n(`Choose a history lookback from ${v.join(", ")}; sub-day history is unavailable.`);if(!_&&(e.cursor!==void 0||e.limit!==void 0))throw new n("Pagination applies only to pending_governance.");if(e.cursor!==void 0&&(typeof e.cursor!="string"||e.cursor.length>4096))throw new n("Provide the opaque pending-governance cursor string.");let y=e.limit??100;if(typeof y!="number"||!Number.isInteger(y)||y<1||y>100)throw new n("Pagination limit must be an integer from 1 to 100.");let[Y,$]=A[a],p=new URL(`https://api.morpho.org/${Y}/vaults-v2/${s}:${c(r)}/${$}`);(u||w)&&p.searchParams.set("lookback",String(e.lookback??(u?"seven_days":"six_hours"))),_&&(p.searchParams.set("limit",String(y)),e.cursor!==void 0&&p.searchParams.set("cursor",e.cursor));let g=await o.http(p.toString(),{headers:{accept:"application/json"},signal:AbortSignal.timeout(15e3)});if(!g.ok)throw new n(`Morpho analytics HTTP ${g.status}. Retry when the service is reachable; no zero APY or empty book was inferred.`);let i=f(await g.json());N(w||a==="allocations"?i.data:i.params,r);let m,h=i.last_indexed_block,P=null;if(w){let t=f(i.data);if(t.lookback!==(e.lookback??"six_hours")||t.apy!==null&&(typeof t.apy!="number"||!Number.isFinite(t.apy)||t.apy<-1))throw new n("Morpho analytics returned an invalid APY or lookback.");m={annualYieldFraction:t.apy===null?null:String(t.apy),...t.apy===null?{status:"unavailable",reason:"Not enough history for the requested APY window."}:{},lookback:t.lookback,basis:"Realized post-fee share-price APY, excluding rewards; historical observation, not a promised return."},h=t.last_indexed_block}else if(a==="allocations"){let t=f(i.data);if(!Array.isArray(t.allocations))throw new n("Morpho analytics omitted adapter allocations.");m=k(t.allocations),h=t.last_indexed_block}else{if(!Array.isArray(i.data))throw new n("Morpho analytics omitted its record array.");if(u)for(let t of i.data){let l=f(t);if(typeof l.timestamp!="number"||!Number.isSafeInteger(l.timestamp)||l.timestamp<0)throw new n("Morpho history returned an invalid timestamp.");for(let C of["total_assets","total_supply","withdrawable_assets","allocated_assets","idle_assets"])b(l[C]);l.share_price_ray!==null&&b(l.share_price_ray)}if(_){if(i.cursor!==null&&typeof i.cursor!="string")throw new n("Morpho analytics returned an invalid pagination cursor.");P=i.cursor}m=k(i.data)}h!==void 0&&b(h);let x=o.clientFor(s);if(await x.getChainId()!==s)throw new n("Vault share metadata requires chain 4663.");let D=await S(x,c(r));return{vault:c(r),chainId:s,sourceUrl:p.toString(),view:a,lastIndexedBlock:h??null,cursor:P,data:m,asset:{address:c(I),symbol:"USDG",decimals:6,chainId:s},shareToken:{address:c(r),symbol:D,decimals:18,chainId:s},scales:{sharePriceRay:"1000000000000000000000000000",capWad:"1000000000000000000"},caveat:"Indexer data may lag the chain. APY excludes rewards; empty records describe only this API window/page. Re-read onchain state and preview before any action. API book data is never executed as calldata automatically."}}catch(a){throw new n(o.plainError(a))}}}}export{U as a};
1
+ import{a as S}from"./A3PN3PK3.js";import{a as M}from"./43LI5NKJ.js";import{a as s,j as I}from"./FWD4L3CJ.js";import{a as n}from"./XSD5NL7J.js";import{getAddress as c}from"viem";var j=["one_hour","six_hours","one_day","seven_days","thirty_days","ninety_days","one_year","inception"],v=["one_day","seven_days","thirty_days","ninety_days","one_year","inception"],A={apy:["v1","apy-averages"],allocations:["v0","allocations"],history:["v0","state/history"],pending_governance:["v0","pending-governance-actions"]};function f(o){if(!o||typeof o!="object"||Array.isArray(o))throw new n("Morpho analytics returned an invalid object.");return o}function b(o){if(typeof o!="string"||!/^\d+$/.test(o)||BigInt(o)>=1n<<256n)throw new n("Morpho analytics returned an invalid decimal base-unit amount.");return o}function N(o,d){let r=f(o);if(![s,String(s)].includes(r.chain_id)||typeof r.vault_address!="string"||c(r.vault_address)!==c(d))throw new n("Morpho analytics returned another chain or vault.")}function k(o,d=0){if(d>12)throw new n("Morpho analytics response is too deeply nested.");if(Array.isArray(o))return o.map(r=>k(r,d+1));if(o&&typeof o=="object")return Object.fromEntries(Object.entries(o).map(([r,e])=>{if(e!==null&&/(?:_assets|_shares|_supply|_cap|_wad|_ray)$/.test(r)&&typeof e!="object")return[r,b(e)];if(e!==null&&/_address$/.test(r)){if(typeof e!="string")throw new n("Morpho analytics returned an invalid address.");return[r,c(e)]}return[r,k(e,d+1)]}));if(typeof o=="number"&&!Number.isFinite(o))throw new n("Morpho analytics returned a non-finite value.");return o}function U(o,d,r){return{name:d,inputSchema:{type:"object",additionalProperties:!1,required:["view"],properties:{view:{type:"string",enum:Object.keys(A)},lookback:{type:"string",enum:j,description:"APY window: one_hour through inception. History: one_day, seven_days, thirty_days, ninety_days, one_year or inception. Defaults to six_hours for APY or seven_days for history."},cursor:{type:"string",maxLength:4096,description:"Opaque cursor from pending_governance only."},limit:{type:"integer",minimum:1,maximum:100}},allOf:[{if:{properties:{view:{const:"history"}},required:["view"]},then:{properties:{lookback:{enum:v}}}}]},execute:async(e,O)=>{try{if(M(O),Object.keys(e).some(t=>!["view","lookback","cursor","limit"].includes(t))||typeof e.view!="string"||!Object.hasOwn(A,e.view))throw new n("Choose a documented Morpho analytics view.");let a=e.view,u=a==="history",w=a==="apy",_=a==="pending_governance";if(e.lookback!==void 0&&(!u&&!w||typeof e.lookback!="string"||!j.includes(e.lookback)))throw new n("lookback is available only for APY/history with a documented window.");if(u&&e.lookback!==void 0&&!v.includes(e.lookback))throw new n(`Choose a history lookback from ${v.join(", ")}; sub-day history is unavailable.`);if(!_&&(e.cursor!==void 0||e.limit!==void 0))throw new n("Pagination applies only to pending_governance.");if(e.cursor!==void 0&&(typeof e.cursor!="string"||e.cursor.length>4096))throw new n("Provide the opaque pending-governance cursor string.");let y=e.limit??100;if(typeof y!="number"||!Number.isInteger(y)||y<1||y>100)throw new n("Pagination limit must be an integer from 1 to 100.");let[Y,$]=A[a],p=new URL(`https://api.morpho.org/${Y}/vaults-v2/${s}:${c(r)}/${$}`);(u||w)&&p.searchParams.set("lookback",String(e.lookback??(u?"seven_days":"six_hours"))),_&&(p.searchParams.set("limit",String(y)),e.cursor!==void 0&&p.searchParams.set("cursor",e.cursor));let g=await o.http(p.toString(),{headers:{accept:"application/json"},signal:AbortSignal.timeout(15e3)});if(!g.ok)throw new n(`Morpho analytics HTTP ${g.status}. Retry when the service is reachable; no zero APY or empty book was inferred.`);let i=f(await g.json());N(w||a==="allocations"?i.data:i.params,r);let m,h=i.last_indexed_block,P=null;if(w){let t=f(i.data);if(t.lookback!==(e.lookback??"six_hours")||t.apy!==null&&(typeof t.apy!="number"||!Number.isFinite(t.apy)||t.apy<-1))throw new n("Morpho analytics returned an invalid APY or lookback.");m={annualYieldFraction:t.apy===null?null:String(t.apy),...t.apy===null?{status:"unavailable",reason:"Not enough history for the requested APY window."}:{},lookback:t.lookback,basis:"Realized post-fee share-price APY, excluding rewards; historical observation, not a promised return."},h=t.last_indexed_block}else if(a==="allocations"){let t=f(i.data);if(!Array.isArray(t.allocations))throw new n("Morpho analytics omitted adapter allocations.");m=k(t.allocations),h=t.last_indexed_block}else{if(!Array.isArray(i.data))throw new n("Morpho analytics omitted its record array.");if(u)for(let t of i.data){let l=f(t);if(typeof l.timestamp!="number"||!Number.isSafeInteger(l.timestamp)||l.timestamp<0)throw new n("Morpho history returned an invalid timestamp.");for(let C of["total_assets","total_supply","withdrawable_assets","allocated_assets","idle_assets"])b(l[C]);l.share_price_ray!==null&&b(l.share_price_ray)}if(_){if(i.cursor!==null&&typeof i.cursor!="string")throw new n("Morpho analytics returned an invalid pagination cursor.");P=i.cursor}m=k(i.data)}h!==void 0&&b(h);let x=o.clientFor(s);if(await x.getChainId()!==s)throw new n("Vault share metadata requires chain 4663.");let D=await S(x,c(r));return{vault:c(r),chainId:s,sourceUrl:p.toString(),view:a,lastIndexedBlock:h??null,cursor:P,data:m,asset:{address:c(I),symbol:"USDG",decimals:6,chainId:s},shareToken:{address:c(r),symbol:D,decimals:18,chainId:s},scales:{sharePriceRay:"1000000000000000000000000000",capWad:"1000000000000000000"},caveat:"Indexer data may lag the chain. APY excludes rewards; empty records describe only this API window/page. Re-read onchain state and preview before any action. API book data is never executed as calldata automatically."}}catch(a){throw new n(o.plainError(a))}}}}export{U as a};
@@ -1,4 +1,4 @@
1
- import{a as I}from"./NKX3FE34.js";import{f as t,g as c,i as y}from"./QVYCJ6WV.js";import{a as m}from"./XSD5NL7J.js";var s={GetAccountBalance:{query:`query GetAccountBalance($address: Address!, $interval: TimeInterval!, $from: Int, $to: Int) {
1
+ import{a as I}from"./NKX3FE34.js";import{f as t,g as c,i as y}from"./46KWRAYK.js";import{a as m}from"./XSD5NL7J.js";var s={GetAccountBalance:{query:`query GetAccountBalance($address: Address!, $interval: TimeInterval!, $from: Int, $to: Int) {
2
2
  account(address: $address) {
3
3
  statsHistory(interval: $interval, filter: { timestamp: { gte: $from, lte: $to } }) {
4
4
  nodes {
@@ -0,0 +1 @@
1
+ import{c as qe,d as $e,e as be,f as ie,i as ke,j as Me}from"./6B3VVISQ.js";import{b as ne,o as we}from"./3NJ5KQ3Q.js";import{a as F,b as ge}from"./43LI5NKJ.js";import{a as Te}from"./IOYRL6AY.js";import{b as z,d as Ue}from"./IX3GZMTM.js";import{a as y,i as O}from"./FWD4L3CJ.js";import{a,b as me,e as N}from"./XSD5NL7J.js";import{decodeFunctionResult as ve,encodeFunctionData as B,getAddress as m,parseAbi as J,zeroAddress as $}from"viem";var re=-887272,se=887272,G=(1n<<128n)-1n,je="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",Ke="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Qe="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,Ye=5,Le=64n,Ze=1800n,Be="^v3:(0x[0-9a-fA-F]{40}):(0|[1-9][0-9]{0,19}):(0|[1-9][0-9]{0,19})$",Je=new RegExp(Be),et=Object.freeze({type:"string",pattern:Be,description:"v3 only. Pass the nextCursor of the previous page to read the next 64 owner indices at the same block. Cannot be combined with tokenIds."}),w=Object.freeze({factory:m(O[4663].uniswap.v3_factory.address),positionManager:m(O[4663].uniswap.v3_position_manager.address),swapRouter02:m(O[4663].uniswap.swap_router02.address),permit2:m(O[4663].uniswap.permit2.address),weth:m(O[4663].uniswap.WETH.address),usdg:m(O[4663].uniswap.USDG.address),ethUsdgPool:m(O[4663].oracle.ethUsdgPool.address)}),Pe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),Nt=Object.freeze([{fee:100,tickSpacing:1,address:m("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:w.weth,token1:w.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:m("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:w.weth,token1:w.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:m("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:w.weth,token1:w.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:m("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:w.weth,token1:w.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),P=J(["function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)","function ownerOf(uint256 tokenId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)","function mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)","function increaseLiquidity((uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)","function decreaseLiquidity((uint256 tokenId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint256 amount0, uint256 amount1)","function collect((uint256 tokenId, address recipient, uint128 amount0Max, uint128 amount1Max) params) payable returns (uint256 amount0, uint256 amount1)","function burn(uint256 tokenId) payable","function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) payable returns (address pool)"]),Y=J(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),he=J(["function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)","function liquidity() view returns (uint128)","function tickSpacing() view returns (int24)","function fee() view returns (uint24)","function token0() view returns (address)","function token1() view returns (address)"]),tt=J(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),xe=J(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),nt="0xd0e30db0";function it(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===$||e===je||e==="eth"||e==="native"}function D(t,e){if(it(t))throw new a(`Uniswap v3 requires wrapped ERC-20 WETH (${w.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new a(`${e} must be a valid 20-byte hex address.`);return F(t),m(t)}function ot(t,e,n){let s=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new a("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(s)||!Number.isInteger(o))throw new a("Uniswap v3 tickLower and tickUpper must be integers.");if(s<re||o>se||s>se||o<re)throw new a(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(s>=o)throw new a("Uniswap v3 tickLower must be strictly less than tickUpper.");if(s%i!==0||o%i!==0)throw new a(`Uniswap v3 tickLower (${s}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:s,tickUpper:o,tickSpacing:i}}function rt(t,e){let n=t.trim(),s=n.startsWith("-"),o=s||n.startsWith("+")?n.slice(1):n,i=Ue(z(o).toString(),e);return s&&i!=="0"?`-${i}`:i}function st(t){let e=typeof t=="string"?ve({abi:P,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:m(String(e[1])),token0:m(String(e[2])),token1:m(String(e[3])),fee:Number(e[4]),tickLower:Number(e[5]),tickUpper:Number(e[6]),liquidity:BigInt(e[7]),feeGrowthInside0LastX128:BigInt(e[8]),feeGrowthInside1LastX128:BigInt(e[9]),tokensOwed0:BigInt(e[10]),tokensOwed1:BigInt(e[11])}}function Re(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?m(e).toLowerCase():void 0,s=w.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==s)continue;let c=Array.isArray(i.topics)?i.topics.map(f=>String(f).toLowerCase()):[],r=c[0];if(r===Ke&&c.length>=4){let d=`0x${c[2].slice(-40)}`;if(!n||d===n){let u=BigInt(c[3]).toString();u!=="0"&&o.add(u)}}else if(r===Qe&&c.length>=2&&!n){let f=BigInt(c[1]).toString();f!=="0"&&o.add(f)}}return[...o]}function Ut(t){let e=n=>typeof n=="bigint"?n:z(n);return B({abi:tt,functionName:"exactInputSingle",args:[{tokenIn:m(t.tokenIn),tokenOut:m(t.tokenOut),fee:t.fee,recipient:m(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var _e=1n<<96n;function Ee(t){let e=Math.abs(t),n=(e&1)!==0?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&2)!==0&&(n=n*0xfff97272373d413259a46990580e213an>>128n),(e&4)!==0&&(n=n*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&8)!==0&&(n=n*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&16)!==0&&(n=n*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&32)!==0&&(n=n*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&64)!==0&&(n=n*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&128)!==0&&(n=n*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&256)!==0&&(n=n*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&512)!==0&&(n=n*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&1024)!==0&&(n=n*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&2048)!==0&&(n=n*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&4096)!==0&&(n=n*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&8192)!==0&&(n=n*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&16384)!==0&&(n=n*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&32768)!==0&&(n=n*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&65536)!==0&&(n=n*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&131072)!==0&&(n=n*0x5d6af8dedb81196699c329225ee604n>>128n),(e&262144)!==0&&(n=n*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&524288)!==0&&(n=n*0x48a170391f7dc42444e8fa2n>>128n),t>0&&(n=((1n<<256n)-1n)/n),(n>>32n)+(n%(1n<<32n)===0n?0n:1n)}function at(t,e,n,s){if(s<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(s<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let r=(s<<96n)*(i-t)/i/t,f=s*(t-o)/_e;return{amount0:r,amount1:f}}return{amount0:0n,amount1:s*(i-o)/_e}}async function M(t,e,n,s){let o=m(e),i,c;if(n===y&&o===w.weth?(i=18,c="WETH"):n===y&&o===w.usdg&&(i=6,c="USDG"),i===void 0){let r=await t.readContract({address:o,abi:xe,functionName:"decimals"});i=Number(r)}if(c===void 0)try{let r=await t.readContract({address:o,abi:xe,functionName:"symbol"});if(typeof r!="string"||!r.trim())throw new a("Token symbol is unavailable.");c=Me(r.trim(),o)}catch(r){throw new a(`Could not read token metadata. ${N(r)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new a("Token decimals are invalid.");if(s!=null){let r=Number(s);if(!Number.isInteger(r)||r!==i)throw new a(`Token ${o} on chain ${n} has ${i} decimals, not ${String(s)}.`)}return{address:o,symbol:c,decimals:i,chainId:n}}async function ct(t){try{if(!t.getBlock)throw new a("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new a("Invalid block timestamp.");return e.timestamp}catch(e){throw new a(`Could not read the current block timestamp. ${N(e)}`)}}function ee(t,e){if(typeof t=="bigint"){if(t<0n)throw new a(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new a(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return z(t);throw new a(`${e} must be a non-negative integer.`)}async function Oe(t,e){let n=await ct(t);if(e==null)return n+Ze;let s=ee(e,"deadline");if(s<=n)throw new a(`Uniswap v3 deadline (${s.toString()}) has expired at timestamp ${n.toString()}.`);return s}function W(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new a(`${e} must be a non-negative integer string in base units.`);return z(t)}function De(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new a("Slippage must be an integer from 0 to 9999 bps.");return we("0",e),e}function ae(t,e,n,s){let o=t===void 0?z(we(e.toString(),n)):W(t,s);if(o<=1n)throw new a(`${s} must exceed 1 base unit; the simulated amount may be too small.`);return o}function H(t,e){return ge({to:w.positionManager,data:t,value:"0",chainId:y,description:e})}async function Z(t,e,n){try{if(!t.request)throw new a("Sequential transaction simulation is unavailable.");let o=await t.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:n,gas:`0x${Te.toString(16)}`,to:i.to,data:i.data,value:`0x${BigInt(i.value).toString(16)}`}))}],validation:!1,traceTransfers:!0},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!Array.isArray(o[0]?.calls)||o[0].calls.length!==e.length)throw new a("Unexpected batch simulation response.");return o[0].calls.map((i,c)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new a(`Simulation call ${c+1} failed. ${N(i.error)}`);return i.returnData})}catch(s){throw new a(`Uniswap v3 simulation failed. ${N(s)}`)}}function ce(t,e){try{return ve({abi:P,functionName:t,data:e})}catch{throw new a(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Ve(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new a("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new a("sqrtPriceX96 must be a non-negative integer string.");return $e(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new a("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return qe(t.initialPrice,e,n)}async function Xe(t,e,n,s){let o=[];for(let i of Object.keys(Pe).map(Number)){if(i===s)continue;let c=m(String(await t.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[e,n,i]})));if(c===$||BigInt(await t.readContract({address:c,abi:he,functionName:"liquidity"}))===0n)continue;let f=await t.readContract({address:c,abi:he,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${c}`,sqrtPriceX96:BigInt(f[0])})}return o}function j(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==y)throw new a(`Uniswap v3 is only supported on Robinhood Chain (${y}).`);if(e.version!==void 0&&e.version!=="v3")throw new a(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(y);return{...n,readContract:async s=>{try{return await n.readContract(s)}catch(o){throw new a(`Could not read Uniswap v3 ${s.functionName}. ${N(o)}`,{cause:o})}}}}async function Ie(t,e,n){let s;try{s=await t.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[e]})}catch(c){throw new a(`Could not verify owner of Uniswap v3 position #${e}. ${N(c)}`)}let o=m(String(s)),i=m(n);if(o!==i)throw new a(`Wallet ${i} is not the owner of Uniswap v3 position #${e.toString()} (owned by ${o}).`);return o}async function de(t,e){let n=await t.readContract({address:w.positionManager,abi:P,functionName:"positions",args:[e]});return st(n)}function Se(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(s=>`${rt(s.amount,s.token.decimals)} ${s.token.symbol}`);return`${t} (${n.join(", ")})`}async function dt(t,e,n){F(n);let s=m(n),o=j(t,e),i=await Oe(o,e.deadline),c=De(e),r=e.tokenId===void 0?void 0:ee(e.tokenId,"tokenId"),f;if(r!==void 0){if(r<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,r,s),f=await de(o,r)}let d=f?.token0??D(e.token0,"token0"),u=f?.token1??D(e.token1,"token1");if(BigInt(d)>=BigInt(u))throw new a("Uniswap v3 requires distinct sorted token addresses.");let g=f?.fee??Number(e.fee??100),p=Pe[g];if(!p)throw new a("Unsupported Uniswap v3 fee tier.");let b=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[d,u,g]}))),l=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(b===$&&!l)throw new a("No Uniswap v3 pool exists for these tokens and fee tier. To create it and add the first liquidity in one tool call with separately confirmed transactions, add initialPrice (token1 per 1 token0, human units) to this call; to create it without liquidity use uniswap_create_pool.");if(b!==$&&l)throw new a(`The Uniswap v3 pool already exists at ${b}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(r!==void 0&&l)throw new a("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new a("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||f))throw new a("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:k,tickUpper:U,tickSpacing:A}=ot(f?.tickLower??(e.fullRange===!0?Math.ceil(re/p)*p:e.tickLower),f?.tickUpper??(e.fullRange===!0?Math.floor(se/p)*p:e.tickUpper),p),v=await M(o,d,y,e.token0Decimals),h=await M(o,u,y,e.token1Decimals),C;if(b===$){let q=Ve(e,v.decimals,h.decimals),E=ke(q,await Xe(o,d,u,g),e.acceptPriceDeviation===!0,v.decimals,h.decimals);C={sqrtPriceX96:q,note:E}}let I=W(e.amount0Desired,"amount0Desired"),S=W(e.amount1Desired,"amount1Desired");if(I===0n&&S===0n)throw new a("Liquidity addition requires a positive desired amount.");let x=e.recipient===void 0?s:D(e.recipient,"recipient");if(x!==s)throw new a("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==w.weth&&u!==w.weth)throw new a("Wrapping requires a positive WETH desired amount.");let V=await Promise.all([d,u].map(async q=>BigInt(await o.readContract({address:q,abi:xe,functionName:"allowance",args:[s,w.positionManager]})))),X=(q,E)=>{let fe=[];if(e.wrapNative===!0){let Q=d===w.weth?q:E;Q>0n&&fe.push(ge({to:w.weth,data:nt,value:Q.toString(),chainId:y,description:"Wrap ETH into WETH."}))}for(let[Q,Ge]of[d,u].entries()){let pe=Q===0?q:E;pe>0n&&V[Q]<pe&&fe.push(t.approval(Ge,w.positionManager,pe.toString(),y))}return fe},L=r===void 0?"mint":"increaseLiquidity",R=(q,E)=>H(r===void 0?B({abi:P,functionName:"mint",args:[{token0:d,token1:u,fee:g,tickLower:k,tickUpper:U,amount0Desired:I,amount1Desired:S,amount0Min:q,amount1Min:E,recipient:x,deadline:i}]}):B({abi:P,functionName:"increaseLiquidity",args:[{tokenId:r,amount0Desired:I,amount1Desired:S,amount0Min:q,amount1Min:E,deadline:i}]}),`${L==="mint"?"Mint":"Increase"} Uniswap v3 ${v.symbol}/${h.symbol} liquidity.`),_=C&&H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[d,u,g,C.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${v.symbol}/${h.symbol} fee ${g} pool at ${ie(C.sqrtPriceX96,v.decimals,h.decimals)} ${h.symbol} per ${v.symbol}.`),K=_?[_]:[],Ae=await Z(o,[...K,...X(I,S),R(0n,0n)],s),T=ce(L,Ae[Ae.length-1]),We=T[T.length-2],ze=T[T.length-1];if(We>I||ze>S)throw new a("Simulated liquidity spend exceeds the desired amounts.");let te=[...K,...X(I,S)],ue=ae(e.amount0Min,T[T.length-2],c,"amount0Min"),le=ae(e.amount1Min,T[T.length-1],c,"amount1Min");if(ue>I||le>S)throw new a("Uniswap v3 minimum amount cannot exceed desired amount.");let Ce=R(ue,le);te.push(Ce);for(let[q,E]of[d,u].entries())(q===0?I:S)>0n&&te.push(t.approval(E,w.positionManager,"0",y));let Ne=await t.preview(te,s);return{txs:te,preview:Ne,summary:Se(Ce.description,Ne),details:{version:"v3",action:L,...r===void 0?{}:{tokenId:r.toString()},pool:b===$?null:b,fee:g,tickSpacing:A,tickLower:k,tickUpper:U,token0:v,token1:h,amount0Desired:I.toString(),amount1Desired:S.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:x,expectedAmount0:T[T.length-2].toString(),expectedAmount1:T[T.length-1].toString(),...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:ie(C.sqrtPriceX96,v.decimals,h.decimals),initialTick:be(C.sqrtPriceX96),priceCheck:C.note}:{}}}}async function ut(t,e,n){F(n);let s=m(n),o=j(t,e),i=D(e.token0,"token0"),c=D(e.token1,"token1");if(BigInt(i)>=BigInt(c))throw new a(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(c)?i:c}, token1=${BigInt(i)<BigInt(c)?c:i}; initialPrice is token1 per 1 token0 in that order.`);let r=Number(e.fee),f=Pe[r];if(!f){let h=Number(await o.readContract({address:w.factory,abi:Y,functionName:"feeAmountTickSpacing",args:[r]}));if(!Number.isInteger(r)||h<=0)throw new a("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");f=h}let d=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[i,c,r]})));if(d!==$)throw new a(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let u=await M(o,i,y,e.token0Decimals),g=await M(o,c,y,e.token1Decimals),p=Ve(e,u.decimals,g.decimals),b=ke(p,await Xe(o,i,c,r),e.acceptPriceDeviation===!0,u.decimals,g.decimals),l=ie(p,u.decimals,g.decimals),k=[H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[i,c,r,p]}),`Create and initialize the Uniswap v3 ${u.symbol}/${g.symbol} fee ${r} pool at ${l} ${g.symbol} per ${u.symbol}.`)],U=await Z(o,k,s),A;try{A=m(String(ve({abi:P,functionName:"createAndInitializePoolIfNecessary",data:U[0]})))}catch{throw new a("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(A===$)throw new a("Uniswap v3 pool creation simulation returned no pool.");let v=await t.preview(k,s);return{txs:k,preview:v,summary:`${k[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:A,fee:r,tickSpacing:f,token0:u,token1:g,sqrtPriceX96:p.toString(),initialPrice:l,initialTick:be(p),priceCheck:b}}}async function lt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=await M(o,c.token0,y),f=await M(o,c.token1,y),d=e.recipient===void 0?s:D(e.recipient,"recipient");if(d!==s)throw new a("Uniswap recipient must be the signing wallet.");let u=e.amount0Max===void 0?G:W(e.amount0Max,"amount0Max"),g=e.amount1Max===void 0?G:W(e.amount1Max,"amount1Max");if(u===0n&&g===0n||u>G||g>G)throw new a("Collect requires a positive amountMax within uint128.");let p=[H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:u,amount1Max:g}]}),`Collect Uniswap v3 fees from position #${i}.`)],b=ce("collect",(await Z(o,p,s))[0]),l=await t.preview(p,s);return{txs:p,preview:l,summary:Se(p[0].description,l),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:r,token1:f,amount0Max:u.toString(),amount1Max:g.toString(),expectedAmount0:b[0].toString(),expectedAmount1:b[1].toString()}}}async function ft(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=c.liquidity===0n&&e.burn===!0;if(c.liquidity<=0n&&!r)throw new a("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!r)throw new a('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let f=e.liquidity==="all"||e.liquidity===void 0?c.liquidity:W(e.liquidity,"liquidity");if(f<=0n&&!r)throw new a("Liquidity to remove must be positive.");if(f>c.liquidity)throw new a("Requested liquidity exceeds position liquidity.");let d=await Oe(o,e.deadline),u=De(e),g=await M(o,c.token0,y),p=await M(o,c.token1,y),b=e.recipient===void 0?s:D(e.recipient,"recipient");if(b!==s)throw new a("Uniswap recipient must be the signing wallet.");let l=(R,_)=>H(B({abi:P,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:f,amount0Min:R,amount1Min:_,deadline:d}]}),`Decrease ${f} liquidity on Uniswap v3 position #${i}.`),k=r?[0n,0n]:ce("decreaseLiquidity",(await Z(o,[l(0n,0n)],s))[0]),U=(R,_)=>{if(R!==void 0&&W(R,_)!==0n)throw new a(`${_} must be zero for an empty position burn.`);return 0n},A=r?U(e.amount0Min,"amount0Min"):ae(e.amount0Min,k[0],u,"amount0Min"),v=r?U(e.amount1Min,"amount1Min"):ae(e.amount1Min,k[1],u,"amount1Min"),h=r?[]:[l(A,v)],C=h.length,I=!r||c.tokensOwed0>0n||c.tokensOwed1>0n;I&&h.push(H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:b,amount0Max:G,amount1Max:G}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let S=f===c.liquidity,x=S&&e.burn===!0;x&&h.push(H(B({abi:P,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let V=await Z(o,h,s),X=I?ce("collect",V[C]):[0n,0n],L=await t.preview(h,s);return{txs:h,preview:L,summary:Se(`Remove Uniswap v3 liquidity from position #${i}${x?`; burns position #${i} at ${w.positionManager}`:""}`,L),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:b,token0:g,token1:p,liquidityRemoved:f.toString(),amount0Min:A.toString(),amount1Min:v.toString(),deadline:d.toString(),expectedAmount0:X[0].toString(),expectedAmount1:X[1].toString(),fullExit:S,burned:x}}}function pt(t,e){let n=typeof t=="string"?Je.exec(t):null;if(!n)throw new a('cursor is not a Uniswap v3 position cursor. Pass the nextCursor exactly as a previous uniswap_list_positions {"version":"v3"} page returned it.');if(m(n[1])!==e)throw new a("This cursor was issued for a different wallet. Start again without a cursor to page this wallet.");return{block:BigInt(n[2]),next:BigInt(n[3])}}function mt(t,e,n){return`v3:${t.toLowerCase()}:${e}:${n}`}function gt(t,e){return{...t,readContract:n=>t.readContract({...n,blockNumber:e})}}var ye=t=>me(t,3,-32601,-32004);async function wt(t,e,n={}){let s=m(e),o=new Set;if(Array.isArray(n.tokenIds))for(let d of n.tokenIds){let u=ee(d,"tokenId");u>0n&&o.add(u.toString())}if(Array.isArray(n.receipts))for(let d of n.receipts)for(let u of Re(d,s))o.add(u);if(Array.isArray(n.tokenIds)&&n.tokenIds.length>0)return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0);let i=n.cursor,c=()=>new a("This Uniswap v3 position manager cannot enumerate NFTs by owner, so there are no pages to continue. Pass tokenIds to check specific positions."),r=!1,f=!1;try{let d;try{d=BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"balanceOf",args:[s]}))}catch(l){throw ye(l)||!i?l:new a(`Could not read this wallet's Uniswap v3 holdings at the cursor's snapshot block ${i.block}; the node may no longer serve it. Start again without a cursor. ${N(l)}`)}let u=i?.next??0n;if(u>d)throw new a(`This cursor starts at owner index ${u}, but the wallet held ${d} Uniswap v3 NFTs at block ${i?.block}. Start again without a cursor.`);let g=d-u>Le?u+Le:d,p=[],b=!0;for(let l=u;l<g;l++)try{p.push(BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"tokenOfOwnerByIndex",args:[s,l]})))}catch(k){if(!ye(k))throw k;b=!1;break}if(b){r=!0,f=u===0n&&g===d;for(let k of p)k>0n&&o.add(k.toString());let l=n.blockNumber;n.onPage?.({balance:d,from:u,to:g,blockNumber:l,...g<d&&l!==void 0?{nextCursor:mt(s,l,g)}:{}})}}catch(d){if(!ye(d))throw d}if(i&&!r)throw c();if((!r||f)&&typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let d=n.toBlock??await t.getBlockNumber(),u=n.maxChunks??Ye,g=n.fromBlock??(d>oe*BigInt(u)?d-oe*BigInt(u)+1n:0n),p=d,b=0;for(;p>=g&&b<u;){let l=p>=oe-1n?p-(oe-1n):0n,k=l<g?g:l,U=await t.getLogs({address:w.positionManager,fromBlock:k,toBlock:p});for(let A of Re({logs:U},s))o.add(A);if(b+=1,k===0n||k<=g)break;p=k-1n}}catch(d){throw new a(`Could not discover Uniswap v3 positions from logs. ${N(d)}`)}else if(!r&&n.tokenIds===void 0&&n.receipts===void 0)throw new a("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0)}async function Fe(t,e,n={}){F(e);let s=m(e),o=j(t),i=Array.isArray(n.tokenIds)&&n.tokenIds.length>0,c=Array.isArray(n.receipts)&&n.receipts.length>0;if(n.cursor!==void 0&&(i||c))throw new a(`${i?"tokenIds":"receipts"} and cursor cannot be combined: ${i?"tokenIds":"receipts"} inspects exactly those NFTs and has no pages. Send one or the other.`);let r=n.cursor===void 0?void 0:pt(n.cursor,s),f=o,d;if(!i){let p;if(typeof o.getBlockNumber=="function")try{p=await o.getBlockNumber()}catch(b){throw new a(`Could not read the latest block for the Uniswap v3 listing. ${N(b)}`)}if(r&&p!==void 0&&r.block>p)throw new a(`This cursor is from block ${r.block}, ahead of the chain's latest block ${p}. Start again without a cursor.`);d=r?.block??p,d!==void 0&&(f=gt(o,d))}let u=await wt(f,s,{...n,cursor:r,blockNumber:d}),g=[];for(let p of u){let b;try{let x=await f.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[p]});b=m(String(x))}catch(x){if(me(x,3))continue;throw new a(`Could not verify owner of position #${p}. ${N(x)}`)}if(b!==s)continue;let l;try{l=await de(f,p)}catch(x){throw new a(`Could not read position #${p}. ${N(x)}`)}if(l.liquidity===0n&&l.tokensOwed0===0n&&l.tokensOwed1===0n&&!n.includeEmpty)continue;let U=await M(f,l.token0,y),A=await M(f,l.token1,y),v=0n,h=0n;if(l.liquidity>0n)try{let x=await f.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[l.token0,l.token1,l.fee]}),V=m(String(x));if(V===$)throw new a("Position pool was not found.");if(V!==$){let X=await f.readContract({address:V,abi:he,functionName:"slot0"}),L=BigInt(X[0]);if(L<=0n)throw new a("Position pool has no initialized price.");let R=Ee(l.tickLower),_=Ee(l.tickUpper),K=at(L,R,_,l.liquidity);v=K.amount0,h=K.amount1}}catch(x){throw new a(`Could not value Uniswap v3 position #${p}. ${N(x)}`)}let C=v+l.tokensOwed0,I=h+l.tokensOwed1,S=[{token:U,amount:C.toString()},{token:A,amount:I.toString()}];g.push({module:"uniswap",id:`uniswap:v3:${p.toString()}`,chainId:y,assets:S,description:`Uniswap v3 LP position #${p.toString()} (${U.symbol}/${A.symbol} fee ${l.fee} ticks [${l.tickLower}, ${l.tickUpper}] liquidity ${l.liquidity.toString()})`})}return g}function bt(t){let e=t.nextCursor?`Pass cursor "${t.nextCursor}" to read the next page, or tokenIds to check specific positions.`:"Pass tokenIds to check specific positions.";return t.from===0n?`This wallet holds ${t.balance} Uniswap v3 position NFTs and only the first ${t.to} were checked, so later positions are not listed. ${e}`:`This page checked owner indices ${t.from}-${t.to-1n} of ${t.balance} Uniswap v3 position NFTs, so later positions are not listed. ${e}`}async function kt(t,e,n){j(t,e);let s=e.wallet!==void 0?D(e.wallet,"wallet"):m(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,c=e.includeZero===!0||e.includeEmpty===!0,r,f=await Fe(t,s,{tokenIds:o,receipts:i,includeEmpty:c,cursor:e.cursor,onPage:u=>{r=u}}),d=r!==void 0&&r.to<r.balance;return{positions:f,...r?.nextCursor?{nextCursor:r.nextCursor}:{},details:{version:"v3",wallet:s,count:f.length,positionManager:w.positionManager,...r?{balance:Number(r.balance),from:Number(r.from),to:Number(r.to),examined:Number(r.to-r.from),...r.blockNumber!==void 0?{blockNumber:r.blockNumber.toString()}:{}}:{},...r&&d?{truncated:!0,incomplete:!0,note:bt(r)}:{}}}}function yt(t){return[{name:"uniswap_add",inputSchema:{type:"object",description:"Mint a new Uniswap v3 concentrated liquidity position or increase liquidity on an existing v3 NFT position on Robinhood Chain (4663).",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Optional existing v3 NFT tokenId for increaseLiquidity."},token0:{type:"string",description:"Sorted ERC-20 token0 address (e.g. WETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address (e.g. USDG)."},fee:{type:"integer",enum:[100,500,3e3,1e4],default:100},fullRange:{type:"boolean",description:"For a new v3 position, use the widest ticks aligned to the pool fee tier; omit explicit ticks."},tickLower:{type:"integer",description:"Lower tick boundary divisible by tickSpacing."},tickUpper:{type:"integer",description:"Upper tick boundary divisible by tickSpacing."},amount0Desired:{type:"string",description:"Desired token0 amount in decimal base units."},amount1Desired:{type:"string",description:"Desired token1 amount in decimal base units."},amount0Min:{type:"string",description:"Minimum token0 amount in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 amount in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units. The pool is created then liquidity is minted 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."}}},execute:(c,r)=>dt(t,c,r)},{name:"uniswap_collect",inputSchema:{type:"object",description:"Collect accrued Uniswap v3 LP fees for an owned NonfungiblePositionManager NFT.",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:"Max token0 to collect (defaults to uint128 max)."},amount1Max:{type:"string",description:"Max token1 to collect (defaults to uint128 max)."}},required:["tokenId"]},execute:(c,r)=>lt(t,c,r)},{name:"uniswap_remove",inputSchema:{type:"object",description:"Decrease liquidity on an owned Uniswap v3 NFT position, collect principal and fees, and optionally burn the empty NFT.",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},liquidity:{type:"string",description:"Positive base-unit liquidity amount, or all for a full exit."},amount0Min:{type:"string",description:"Minimum token0 principal in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 principal in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},burn:{type:"boolean",description:"Whether to burn the NFT after removing 100% of liquidity, or burn an already-empty position."}},required:["tokenId"]},execute:(c,r)=>ft(t,c,r)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet, 64 owner indices per page at one pinned block; follow nextCursor for more. Falls back to a bounded Transfer-log scan for managers that cannot enumerate by owner.",properties:{version:{type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:"Optional candidate v3 NFT tokenIds to inspect. Inspects exactly these NFTs; there is no paging in this mode."},cursor:et}},execute:(c,r)=>kt(t,c,r)},{name:"uniswap_create_pool",inputSchema:{type:"object",description:"Create and initialize an empty Uniswap v3 pool on Robinhood Chain (4663). Add liquidity afterwards with uniswap_add.",properties:{version:{type:"string",enum:["v3"],default:"v3"},token0:{type:"string",description:"Sorted ERC-20 token0 address (WETH, not native ETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address."},fee:{type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 WETH = 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."}},required:["token0","token1","fee"]},execute:(c,r)=>ut(t,c,r)}]}var He=t=>({tools:yt(t),positions:async e=>{let n,s=await Fe(t,e,{onPage:o=>{o.to>=o.balance||(n={module:"uniswap",id:"uniswap-v3-discovery-truncated",chainId:y,assets:[],incomplete:!0,description:`This wallet holds ${o.balance} Uniswap v3 position NFTs and only the first ${o.to} were checked, so later positions may be missing. Pass tokenIds to uniswap_list_positions to check the others, or page through them with uniswap_list_positions {"version":"v3"} and each nextCursor.`})}});return n?[...s,n]:s}}),Tt=He,qt=He;export{re as a,se as b,G as c,et as d,w as e,Pe as f,Nt as g,P as h,Y as i,he as j,tt as k,ot as l,rt as m,st as n,Re as o,Ut as p,Ve as q,dt as r,ut as s,lt as t,ft as u,Fe as v,kt as w,yt as x,He as y,Tt as z,qt as A};
@@ -1 +1 @@
1
- import{b as I,c as M}from"./RVO3QK2B.js";import{a as b,c as s,d as k,f as E}from"./UHRCM7AG.js";import{g}from"./EU3OAJU2.js";import{a as N}from"./PBQSJSZO.js";import{a as C,i as D,j as i}from"./FWD4L3CJ.js";import{a as y}from"./XSD5NL7J.js";import{erc20Abi as U,parseAbi as P}from"viem";var o=P(["function isValidMarket(address market) view returns(bool)","function readTokens() view returns(address sy,address pt,address yt)","function expiry() view returns(uint256)","function isExpired() view returns(bool)","function getTokensIn() view returns(address[])","function getTokensOut() view returns(address[])"]);async function H(u,r,d){if(N(r),I(d,!0),u.network==="testnet")throw new y("Pendle is available on chain 4663 only.");let e=u.clientFor(C),w=await e.getBlock(),t=w.number;s(await e.readContract({address:D[4663].pendle.marketFactory.address,abi:o,functionName:"isValidMarket",args:[r],blockNumber:t})===!0,"market is not verified by Pendle\u2019s factory");let[[c,m,O],p,h]=await Promise.all([e.readContract({address:r,abi:o,functionName:"readTokens",blockNumber:t}),e.readContract({address:r,abi:o,functionName:"expiry",blockNumber:t}),e.readContract({address:r,abi:o,functionName:"isExpired",blockNumber:t})]),[v,T]=await Promise.all([e.readContract({address:c,abi:o,functionName:"getTokensIn",blockNumber:t}),e.readContract({address:c,abi:o,functionName:"getTokensOut",blockNumber:t})]);s(v.some(n=>k(n,i)),"the earn cost comparison requires a USDG term"),s(T.some(n=>k(n,i)),"this term cannot cash out to USDG"),s(!h&&p>w.timestamp&&p<=BigInt(Number.MAX_SAFE_INTEGER),"this term has ended or its end date is unreadable");let l=n=>e.readContract({address:n,abi:U,functionName:"decimals",blockNumber:t}),[S,x,R]=await Promise.all([l(i),l(m),l(c)]),A={market:r,sy:c,pt:m,yt:O,expiry:Number(p),expired:h,kind:"stable",inputToken:i,inputSymbol:"USDG",inputDecimals:S,ptDecimals:x,syDecimals:R,tokensIn:[...v],tokensOut:[...T]},f=await g(u.http,{inputToken:i,outputToken:m,amount:d,wallet:b,slippageBps:50}),a=E(f.body,{market:A,wallet:b,amount:d,slippageBps:50});if(Math.abs(a.priceImpact)>.03)throw new y("This is a thin market and your size moves the price too much. Try a smaller amount.");return await M(e,A,"buy",d,a.amountOut,a.priceImpact),s(Date.now()-f.receivedAt>=0&&Date.now()-f.receivedAt<=3e4,"display quote is too old; try again"),{feeUsd:a.feeUsd,impactPct:Math.abs(a.priceImpact)*100,ptOutBase:a.amountOut}}export{H as a};
1
+ import{b as I,c as M}from"./QU5XKRGK.js";import{a as b,c as s,d as k,f as E}from"./4HG6FRVH.js";import{g}from"./H43RNCX2.js";import{a as N}from"./43LI5NKJ.js";import{a as C,i as D,j as i}from"./FWD4L3CJ.js";import{a as y}from"./XSD5NL7J.js";import{erc20Abi as U,parseAbi as P}from"viem";var o=P(["function isValidMarket(address market) view returns(bool)","function readTokens() view returns(address sy,address pt,address yt)","function expiry() view returns(uint256)","function isExpired() view returns(bool)","function getTokensIn() view returns(address[])","function getTokensOut() view returns(address[])"]);async function H(u,r,d){if(N(r),I(d,!0),u.network==="testnet")throw new y("Pendle is available on chain 4663 only.");let e=u.clientFor(C),w=await e.getBlock(),t=w.number;s(await e.readContract({address:D[4663].pendle.marketFactory.address,abi:o,functionName:"isValidMarket",args:[r],blockNumber:t})===!0,"market is not verified by Pendle\u2019s factory");let[[c,m,O],p,h]=await Promise.all([e.readContract({address:r,abi:o,functionName:"readTokens",blockNumber:t}),e.readContract({address:r,abi:o,functionName:"expiry",blockNumber:t}),e.readContract({address:r,abi:o,functionName:"isExpired",blockNumber:t})]),[v,T]=await Promise.all([e.readContract({address:c,abi:o,functionName:"getTokensIn",blockNumber:t}),e.readContract({address:c,abi:o,functionName:"getTokensOut",blockNumber:t})]);s(v.some(n=>k(n,i)),"the earn cost comparison requires a USDG term"),s(T.some(n=>k(n,i)),"this term cannot cash out to USDG"),s(!h&&p>w.timestamp&&p<=BigInt(Number.MAX_SAFE_INTEGER),"this term has ended or its end date is unreadable");let l=n=>e.readContract({address:n,abi:U,functionName:"decimals",blockNumber:t}),[S,x,R]=await Promise.all([l(i),l(m),l(c)]),A={market:r,sy:c,pt:m,yt:O,expiry:Number(p),expired:h,kind:"stable",inputToken:i,inputSymbol:"USDG",inputDecimals:S,ptDecimals:x,syDecimals:R,tokensIn:[...v],tokensOut:[...T]},f=await g(u.http,{inputToken:i,outputToken:m,amount:d,wallet:b,slippageBps:50}),a=E(f.body,{market:A,wallet:b,amount:d,slippageBps:50});if(Math.abs(a.priceImpact)>.03)throw new y("This is a thin market and your size moves the price too much. Try a smaller amount.");return await M(e,A,"buy",d,a.amountOut,a.priceImpact),s(Date.now()-f.receivedAt>=0&&Date.now()-f.receivedAt<=3e4,"display quote is too old; try again"),{feeUsd:a.feeUsd,impactPct:Math.abs(a.priceImpact)*100,ptOutBase:a.amountOut}}export{H as a};
@@ -1 +1 @@
1
- import{n as k}from"./GHPREYQK.js";import{a as y}from"./U4JGEMKT.js";import{b as T}from"./PBQSJSZO.js";import{b as R}from"./5ZLOCQA4.js";import{c as _,d as I,g as v,i as $,n as V}from"./5KUWLUPM.js";import{a as u}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as D,erc20Abi as O,getAddress as C,parseAbi as S}from"viem";var N=C("0x0000000000bbf5c5fd284e657f01bd000933c96d"),b=C("0x0a0d53b6684c7b32b4cbef5fe8483bfcc8406742"),U=C("0x00700052c0608F670705380a4900e0a8080010CC"),x=S(["function getCollectedFees(address partner,address token) view returns (uint256)","function withdrawAllFees(address token,address recipient) returns (uint256 amount)","function getBalance(address token,address partner) view returns (uint256)","function withdrawAllERC20(address token,address recipient) returns (bool)","function withdrawNative(uint256 amount,address owner,address receiver)"]),H=(1n<<256n)-1n,P={type:"string",enum:["market","delta"]};function p(t){return $(t,"Provide a token or wallet address.",I)}function A(t){if(t!=="market"&&t!=="delta")throw new o("Choose market or delta fees.");return t}function B(t){return V(t,"Amount must be positive and within uint256.",{notString:"Amount must be a decimal base-unit string.",positive:!0}).toString()}function E(t,m,d){if(d=p(d),t==="velora_unwrap_deth"){for(let e of Object.keys(m))if(e!=="amount")throw new o(`Unsupported ${t} argument: ${e}.`);let a=B(m.amount);return{tx:T({to:b,chainId:u,value:"0",data:D({abi:x,functionName:"withdrawNative",args:[BigInt(a),d,d]}),description:`Unwrap ${a} dETH base units into the same amount of native ETH for ${d} on chain ${u}.`}),inputs:[{token:b,amount:a}]}}if(t!=="velora_claim_fees")throw new o("Unknown Velora claim action.");for(let a of Object.keys(m))if(!["token","kind"].includes(a))throw new o(`Unsupported ${t} argument: ${a}.`);let f=p(m.token);if(k(f))throw new o("Velora fee claims require an ERC-20 token address.");let c=A(m.kind);return{tx:T({to:c==="delta"?N:U,chainId:u,value:"0",data:D({abi:x,functionName:c==="delta"?"withdrawAllFees":"withdrawAllERC20",args:[f,d]}),description:`Claim the full accrued ${c} fee balance of ${f} to ${d} on chain ${u}. Receipt amount can change before mining; no minimum is encoded.`}),inputs:[]}}function Q(t,m,d,f){let{tx:c}=E(m,d,f),a=t[0];if(t.length!==1||!a||a.chainId!==c.chainId||!v(a.to,c.to)||!v(a.data,c.data)||a.value!==c.value)throw new o("Velora claim calldata, recipient, amount or destination differs from the request.")}function X(t){let m=async()=>{let e=t.clientFor(u);if(await e.getChainId()!==u)throw new o("Velora requires an RPC on chain 4663.");return e};async function d(e){if(e===b)return{address:e,symbol:"dETH",decimals:18,chainId:u};let n=await m(),[s,i]=await Promise.all([y(n,u,e,"symbol"),y(n,u,e,"decimals")]);if(typeof s!="string"||!s.trim()||!Number.isInteger(i)||i<0||i>255)throw new o("Velora fee token metadata is unavailable.");return{address:e,symbol:s,decimals:i,chainId:u}}async function f(e,n){let s=A(e.kind),i=p(e.token);if(k(i))throw new o("Velora fee claims require an ERC-20 token address.");let r=await(await m()).readContract({address:s==="delta"?N:U,abi:x,functionName:s==="delta"?"getCollectedFees":"getBalance",args:s==="delta"?[n,i]:[i,n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Velora fee balance is unavailable.");return r}function c(e,n,s,i){return{name:e,inputSchema:{type:"object",additionalProperties:!1,properties:n,required:s},execute:async(w,r)=>{try{r=p(r);for(let l of Object.keys(w))if(!Object.hasOwn(n,l))throw new o(`Unsupported ${e} argument: ${l}.`);return await i(w,r)}catch(l){throw new o(t.plainError(l))}}}}let a={token:_,kind:P};return[c("velora_fee_balance",a,["token","kind"],async(e,n)=>({kind:A(e.kind),token:await d(p(e.token)),amount:(await f(e,n)).toString()})),c("velora_claim_fees",a,["token","kind"],async(e,n)=>{let{tx:s}=E("velora_claim_fees",e,n),i=await f(e,n);if(i===0n)throw new o("No accrued Velora fees for this wallet and token.");let w=await d(p(e.token)),r=[s],l=await t.preview(r,n);return{txs:r,preview:l,estimatedReceipt:{token:w,amount:i.toString()},summary:`${s.description} ${l.summary}`}}),c("velora_unwrap_deth",{amount:R("Positive amount of wallet-held dETH in base units (18 decimals).")},["amount"],async(e,n)=>{let{tx:s,inputs:i}=E("velora_unwrap_deth",e,n),r=await(await m()).readContract({address:b,abi:O,functionName:"balanceOf",args:[n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Wallet dETH balance is unavailable.");if(r<BigInt(i[0].amount))throw new o("Insufficient wallet-held dETH. An active native Delta order must first settle, expire or cancel.");let l=[s],g=await t.preview(l,n);if(g.changes.filter(h=>h.token.chainId===u&&k(h.token.address)).reduce((h,F)=>h+BigInt(F.amount),0n)<BigInt(i[0].amount))throw new o("Velora dETH preview does not return the requested native ETH amount.");return{txs:l,preview:g,summary:`${s.description} ${g.summary}`}})]}export{N as a,b,U as c,x as d,E as e,Q as f,X as g};
1
+ import{n as k}from"./3NJ5KQ3Q.js";import{a as y}from"./U4JGEMKT.js";import{b as T}from"./43LI5NKJ.js";import{b as R}from"./66F5ZH34.js";import{c as _,d as I,g as v,i as $,n as V}from"./NWNYJ26T.js";import{a as u}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as D,erc20Abi as O,getAddress as C,parseAbi as S}from"viem";var N=C("0x0000000000bbf5c5fd284e657f01bd000933c96d"),b=C("0x0a0d53b6684c7b32b4cbef5fe8483bfcc8406742"),U=C("0x00700052c0608F670705380a4900e0a8080010CC"),x=S(["function getCollectedFees(address partner,address token) view returns (uint256)","function withdrawAllFees(address token,address recipient) returns (uint256 amount)","function getBalance(address token,address partner) view returns (uint256)","function withdrawAllERC20(address token,address recipient) returns (bool)","function withdrawNative(uint256 amount,address owner,address receiver)"]),H=(1n<<256n)-1n,P={type:"string",enum:["market","delta"]};function p(t){return $(t,"Provide a token or wallet address.",I)}function A(t){if(t!=="market"&&t!=="delta")throw new o("Choose market or delta fees.");return t}function B(t){return V(t,"Amount must be positive and within uint256.",{notString:"Amount must be a decimal base-unit string.",positive:!0}).toString()}function E(t,m,d){if(d=p(d),t==="velora_unwrap_deth"){for(let e of Object.keys(m))if(e!=="amount")throw new o(`Unsupported ${t} argument: ${e}.`);let a=B(m.amount);return{tx:T({to:b,chainId:u,value:"0",data:D({abi:x,functionName:"withdrawNative",args:[BigInt(a),d,d]}),description:`Unwrap ${a} dETH base units into the same amount of native ETH for ${d} on chain ${u}.`}),inputs:[{token:b,amount:a}]}}if(t!=="velora_claim_fees")throw new o("Unknown Velora claim action.");for(let a of Object.keys(m))if(!["token","kind"].includes(a))throw new o(`Unsupported ${t} argument: ${a}.`);let f=p(m.token);if(k(f))throw new o("Velora fee claims require an ERC-20 token address.");let c=A(m.kind);return{tx:T({to:c==="delta"?N:U,chainId:u,value:"0",data:D({abi:x,functionName:c==="delta"?"withdrawAllFees":"withdrawAllERC20",args:[f,d]}),description:`Claim the full accrued ${c} fee balance of ${f} to ${d} on chain ${u}. Receipt amount can change before mining; no minimum is encoded.`}),inputs:[]}}function Q(t,m,d,f){let{tx:c}=E(m,d,f),a=t[0];if(t.length!==1||!a||a.chainId!==c.chainId||!v(a.to,c.to)||!v(a.data,c.data)||a.value!==c.value)throw new o("Velora claim calldata, recipient, amount or destination differs from the request.")}function X(t){let m=async()=>{let e=t.clientFor(u);if(await e.getChainId()!==u)throw new o("Velora requires an RPC on chain 4663.");return e};async function d(e){if(e===b)return{address:e,symbol:"dETH",decimals:18,chainId:u};let n=await m(),[s,i]=await Promise.all([y(n,u,e,"symbol"),y(n,u,e,"decimals")]);if(typeof s!="string"||!s.trim()||!Number.isInteger(i)||i<0||i>255)throw new o("Velora fee token metadata is unavailable.");return{address:e,symbol:s,decimals:i,chainId:u}}async function f(e,n){let s=A(e.kind),i=p(e.token);if(k(i))throw new o("Velora fee claims require an ERC-20 token address.");let r=await(await m()).readContract({address:s==="delta"?N:U,abi:x,functionName:s==="delta"?"getCollectedFees":"getBalance",args:s==="delta"?[n,i]:[i,n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Velora fee balance is unavailable.");return r}function c(e,n,s,i){return{name:e,inputSchema:{type:"object",additionalProperties:!1,properties:n,required:s},execute:async(w,r)=>{try{r=p(r);for(let l of Object.keys(w))if(!Object.hasOwn(n,l))throw new o(`Unsupported ${e} argument: ${l}.`);return await i(w,r)}catch(l){throw new o(t.plainError(l))}}}}let a={token:_,kind:P};return[c("velora_fee_balance",a,["token","kind"],async(e,n)=>({kind:A(e.kind),token:await d(p(e.token)),amount:(await f(e,n)).toString()})),c("velora_claim_fees",a,["token","kind"],async(e,n)=>{let{tx:s}=E("velora_claim_fees",e,n),i=await f(e,n);if(i===0n)throw new o("No accrued Velora fees for this wallet and token.");let w=await d(p(e.token)),r=[s],l=await t.preview(r,n);return{txs:r,preview:l,estimatedReceipt:{token:w,amount:i.toString()},summary:`${s.description} ${l.summary}`}}),c("velora_unwrap_deth",{amount:R("Positive amount of wallet-held dETH in base units (18 decimals).")},["amount"],async(e,n)=>{let{tx:s,inputs:i}=E("velora_unwrap_deth",e,n),r=await(await m()).readContract({address:b,abi:O,functionName:"balanceOf",args:[n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Wallet dETH balance is unavailable.");if(r<BigInt(i[0].amount))throw new o("Insufficient wallet-held dETH. An active native Delta order must first settle, expire or cancel.");let l=[s],g=await t.preview(l,n);if(g.changes.filter(h=>h.token.chainId===u&&k(h.token.address)).reduce((h,F)=>h+BigInt(F.amount),0n)<BigInt(i[0].amount))throw new o("Velora dETH preview does not return the requested native ETH amount.");return{txs:l,preview:g,summary:`${s.description} ${g.summary}`}})]}export{N as a,b,U as c,x as d,E as e,Q as f,X as g};
@@ -1 +1 @@
1
- import{b as q,o as U}from"./GHPREYQK.js";import{a as le,b as ue,c as me}from"./ZET37EIG.js";import{a as ce}from"./MBTARLZQ.js";import{a as fe,b as pe}from"./RNC463IM.js";import{a as ye}from"./3VAJW6TQ.js";import{e as F,h as O,m as de}from"./W76QC2AW.js";import{b as se}from"./Z4SRGAVL.js";import{a as B}from"./BQICZFLR.js";import{c as ae}from"./MYFAKCQI.js";import{c as D,e as x,g as k,k as te,l as oe,m as re,n as ie}from"./5KUWLUPM.js";import{a as h,i as ne}from"./FWD4L3CJ.js";import{a as i}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ie,encodeAbiParameters as j,encodeFunctionData as M,erc20Abi as J,isAddress as Pe,parseAbi as Ae,parseAbiParameters as V,toHex as W,zeroAddress as z}from"viem";var A=ne[h].clanker,he=Ae(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),T=Ae(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),C={address:A.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},Se="https://www.clanker.world/api/tokens",ge={type:"string",pattern:"^\\d+$"},be={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function I(e){return oe(te(e,F),F)}function we(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i(`Provide an explicit bytes32 ${t}.`);return e}function P(e,t,s=!1){if(e===void 0&&!s)return"";if(typeof e!="string"||s&&!e.trim())throw new i(`Provide ${t} as text.`);return e}function Z(e,t=256){return ie(e,`Amount exceeds the uint${t} range.`,{bits:t})}function G(e){return re(e,"The contract returned an invalid amount.").toString()}function L(e,t){let s=Object.keys(e).find(u=>!t.includes(u));if(s)throw new i(`Unsupported Clanker input: ${s}.`)}function ke(e,t){return t.changes.map(({token:s,amount:u})=>{let b=u.startsWith("-");return`${b?"-":"+"}${e.formatAmount(b?u.slice(1):u,s.decimals)} ${s.symbol} (${s.address}, chain ${s.chainId})`}).join("; ")}function ve(e){return x(e)&&Array.isArray(e.data)&&Number.isSafeInteger(e.total)&&Number(e.total)>=0&&Number.isSafeInteger(e.tokensDeployed)&&Number(e.tokensDeployed)>=0&&(e.cursor===null||e.cursor===void 0||typeof e.cursor=="string")&&e.data.every(t=>x(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(s=>typeof t[s]=="string"&&Pe(t[s],{strict:!1})))}function K(e,t=0){return typeof e=="string"?N(e):e===null||typeof e=="boolean"?e:typeof e=="number"?Number.isFinite(e)?e:null:t>=4?null:Array.isArray(e)?e.slice(0,20).map(s=>K(s,t+1)):x(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,u])=>[s,K(u,t+1)])):null}function _e(e){return{...K(e),contract_address:e.contract_address,admin:e.admin,msg_sender:e.msg_sender,chain_id:e.chain_id,factory_address:e.factory_address,name:N(e.name),symbol:N(e.symbol)}}function $e(e){try{if(typeof e!="string"||!/^[A-Za-z0-9_-]{1,256}={0,2}$/.test(e))throw new Error;let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));if(!x(t)||typeof t.id!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z?$/.test(t.id)||!Number.isFinite(Date.parse(t.id)))throw new Error;return e}catch{throw new i("Use the cursor returned by the previous clanker_browse page.")}}async function Ne(e,t={}){L(t,["q","limit","cursor","deployer"]);let s=t.limit??10;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>20)throw new i("Choose an indexer limit from 1 to 20.");let u=new URL(Se);u.searchParams.set("chainId",String(h)),u.searchParams.set("limit",String(s)),t.q!==void 0&&u.searchParams.set("q",P(t.q,"search")),t.cursor!==void 0&&u.searchParams.set("cursor",P(t.cursor,"cursor",!0)),t.deployer!==void 0&&u.searchParams.set("msgSender",I(t.deployer));let b=await ae(e.http,u.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},ve);return{tokens:b.data.filter(S=>S.chain_id===h&&k(S.factory_address,A.factory.address)),total:b.total,cursor:b.cursor||null,tokensDeployed:b.tokensDeployed}}var De=e=>{let t=()=>e.clientFor(h),s=async n=>{try{return await n()}catch(o){throw new i(e.plainError(o))}},u=(n,o,a,c="0")=>e.unsignedTx({to:n,data:o,value:c,chainId:h,description:a}),b=async(n,o)=>G(await t().readContract({address:A.fee_locker.address,abi:T,functionName:"availableFees",args:[n,o]})),S=async n=>{if(k(n,C.address))return C;let[o,a]=await Promise.all([t().readContract({address:n,abi:J,functionName:"symbol"}),t().readContract({address:n,abi:J,functionName:"decimals"})]);if(typeof o!="string"||!o.trim()||!Number.isInteger(a)||a<0||a>255)throw new i("The contract returned invalid token metadata.");return{address:n,chainId:h,symbol:o,decimals:a}},Q=async n=>{n.cursor!==void 0&&$e(n.cursor);let o=await Ne(e,n);return{...o,tokens:o.tokens.map(_e)}},xe=async(n,o)=>{if(L(n,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),n.vanity!==void 0&&n.vanity!==!1)throw new i("Clanker launches use vanity false and an explicit salt.");let a=P(n.name,"token name",!0),c=P(n.symbol,"token symbol",!0),g=we(n.salt,"salt"),y=Z(n.initialBuy??"0"),l=n.slippageBps??q;if(typeof l!="number")throw new i("Slippage must be an integer from 0 to 9999 bps.");U("0",l);let r=n.minAmountOut===void 0?void 0:Z(n.minAmountOut,128);if(r!==void 0&&r<=1n)throw new i("Initial-buy minimum must exceed one base unit.");if(!y&&r!==void 0)throw new i("A minimum requires a positive initial buy.");let m=ue(n,o);O(n.feeBps??100,0,1e3);let f=pe(n);if(y&&!k(f.poolConfig.pairedToken,C.address))throw new i("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let d=n.rewards??[{admin:o,recipient:o,bps:1e4,feePreference:0}];if(!Array.isArray(d)||!d.length||d.length>7)throw new i("Provide one to seven reward allocations.");let w=d.map(p=>{if(!x(p))throw new i("Provide reward allocations as objects.");return L(p,["admin","recipient","bps","feePreference"]),{admin:I(p.admin),recipient:I(p.recipient),bps:O(p.bps,1,1e4),feePreference:O(p.feePreference??0,0,2)}});if(w.reduce((p,v)=>p+v.bps,0)!==1e4)throw new i("Reward allocations must total 10000 bps.");let _={tokenConfig:{tokenAdmin:o,name:a,symbol:c,salt:g,image:P(n.image,"image"),metadata:P(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):P(n.context,"context"),originatingChainId:BigInt(h)},poolConfig:f.poolConfig,lockerConfig:{locker:A.locker.address,rewardAdmins:w.map(p=>p.admin),rewardRecipients:w.map(p=>p.recipient),rewardBps:w.map(p=>p.bps),tickLower:f.tickLower,tickUpper:f.tickUpper,positionBps:f.positionBps,lockerData:j(V("(uint8[])"),[[w.map(p=>p.feePreference)]])},mevModuleConfig:{mevModule:A.mev_module.address,mevModuleData:j(V("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:m},Ce=await t().simulateContract({address:A.factory.address,abi:he,functionName:"deployToken",args:[_],account:o,value:0n,gas:B}),E=I(Ce.result),X=p=>{let v=[...m,...y?[{extension:A.devbuy.address,msgValue:y,extensionBps:0,extensionData:j(V("(address,address,uint24,int24,address),uint128,address"),[[z,z,0,0,z],p,o])}]:[]];return u(A.factory.address,M({abi:he,functionName:"deployToken",args:[{..._,extensionConfigs:v}]}),`Launch ${a} (${c}); initial buy ${y} native ETH base units.`,y.toString())};if(y&&r===void 0){let v=(await e.preview([X(0n)],o)).changes.filter($=>$.token.chainId===h&&k($.token.address,E)&&$.token.decimals===18).reduce(($,ee)=>$+(/^-?\d+$/.test(ee.amount)?BigInt(ee.amount):(()=>{throw new i("Invalid initial-buy simulation amount.")})()),0n);if(v<=0n)throw new i("Initial-buy simulation returned no token output.");if(r=Z(U(v.toString(),l),128),r<=1n)throw new i("Initial-buy output is too small for a protected minimum.")}let Y=[X(r??0n)],H=await e.preview(Y,o);return{txs:Y,preview:H,predictedToken:E,token:{address:E,chainId:h,symbol:c,decimals:18},...r!==void 0?{minAmountOut:r.toString()}:{},summary:`Launch ${c} at ${E} (CREATE2 address predicted from simulation); vanity false; salt ${g}. Supply 100000000000000000000000000000 base units (18 decimals). ${f.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(f)}. Reward allocations: ${JSON.stringify(w)}. Extensions: ${JSON.stringify({vault:n.vault,airdrop:n.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${H.summary} ${ke(e,H)}`}},Te=async(n,o)=>{if(L(n,["token","poolId","collect"]),n.collect!==void 0&&typeof n.collect!="boolean")throw new i("collect must be boolean.");if(n.collect===!1&&n.poolId!==void 0)throw new i("poolId requires collection.");if(n.collect===!0&&n.token===void 0)throw new i("Collection requires a Clanker token.");if(n.poolId!==void 0&&n.token===void 0)throw new i("A pool ID requires its Clanker token.");let a=[C],c=[];if(n.token!==void 0){let r=I(n.token);if(k(r,C.address))throw new i("Provide the launched Clanker token, not WETH.");if(n.collect!==!1){let m=await de(e,r),{poolId:f,hook:d,locker:w}=m;if(n.poolId!==void 0&&!k(we(n.poolId,"pool ID for fee collection"),f))throw new i("The supplied pool ID does not match the onchain Clanker pool.");k(m.pairedToken,C.address)||a.splice(0,1,await S(m.pairedToken));let _=await t().readContract({address:d,abi:T,functionName:"mevModuleEnabled",args:[f]});if(typeof _!="boolean")throw new i("The hook returned an invalid MEV guard state.");_&&c.push(u(d,M({abi:T,functionName:"mevModuleOperational",args:[f]}),"Update the Clanker pool MEV guard before collection.")),c.push(u(w,M({abi:T,functionName:"collectRewards",args:[r]}),"Collect pending LP fees into the fee locker."))}a.push(await S(r))}let g;if(c.length){if(await t().getChainId()!==h)throw new i("Fee simulation endpoint is on the wrong chain.");let r=[...c.map(d=>({from:o,gas:W(B),to:d.to,data:d.data,value:W(BigInt(d.value))})),...a.map(d=>({from:o,gas:W(B),to:A.fee_locker.address,data:M({abi:T,functionName:"availableFees",args:[o,d.address]}),value:"0x0"}))],m=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:r}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(m)||m.length!==1||!x(m[0])||!Array.isArray(m[0].calls)||m[0].calls.length!==r.length)throw new i("The endpoint returned an unexpected fee simulation response.");let f=m[0].calls;if(!f.every(d=>x(d)&&d.status==="0x1"&&!d.error))throw new i("Clanker fee collection simulation failed.");g=f.slice(c.length).map(d=>{if(!x(d)||typeof d.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(d.returnData))throw new i("The endpoint returned an invalid fee balance.");return G(Ie({abi:T,functionName:"availableFees",data:d.returnData}))})}else g=await Promise.all(a.map(r=>b(o,r.address)));let y=a.flatMap((r,m)=>BigInt(g[m])>0n?[{token:r,amount:g[m]}]:[]);if(!y.length)throw new i("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:r}of y)c.push(u(A.fee_locker.address,M({abi:T,functionName:"claim",args:[o,r.address]}),`Claim ${r.symbol} fees to ${o}.`));let l=await e.preview(c,o);return{txs:c,preview:l,fees:y,summary:`Claim fees to ${o}. WETH fees aggregate across all Clanker launches for this recipient. ${l.summary} ${ke(e,l)}`}},R=(n,o,a,c)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:o,required:a,additionalProperties:!1},execute:(g,y)=>s(async()=>c(g,I(y)))});return{tools:[R("launch",{name:{type:"string"},symbol:{type:"string"},salt:be,image:{type:"string"},metadata:{type:"string"},context:{type:"string"},vanity:{const:!1},initialBuy:{...ge,description:"Native ETH base units, 18 decimals."},minAmountOut:{...ge,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:q},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100},pool:fe,rewards:{type:"array",minItems:1,maxItems:7,items:{type:"object",properties:{admin:D,recipient:D,bps:{type:"integer",minimum:1,maximum:1e4},feePreference:{type:"integer",minimum:0,maximum:2}},required:["admin","recipient","bps"],additionalProperties:!1}},...le},["name","symbol","salt"],async(n,o)=>{let a=await xe(n,o);return{...a,summary:`${a.summary} After the launch is mined, use clanker_status to inspect ${a.predictedToken} and clanker_claim to collect creator fees.`}}),R("claim",{token:{...D,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...be,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Te),R("browse",{q:{type:"string"},limit:{type:"integer",minimum:1,maximum:20},cursor:{type:"string"},deployer:D},[],Q)],positions:n=>s(async()=>{I(n);let o=new Map,a=new Set,c;do{let l=await Q({deployer:n,limit:20,...c?{cursor:c}:{}});for(let r of l.tokens)k(r.msg_sender,n)&&o.set(r.contract_address.toLowerCase(),r);if(l.cursor&&a.has(l.cursor))throw new i("The Clanker indexer repeated a pagination cursor.");l.cursor&&a.add(l.cursor),c=l.cursor??void 0}while(c);let g=[],y=[C];for(let[l,r]of o){let m=await S(r.contract_address),f={...m,symbol:N(m.symbol)},d=G(await t().readContract({address:f.address,abi:J,functionName:"balanceOf",args:[n]}));g.push({module:"clanker",id:`launch:${l}`,chainId:h,assets:[{token:f,amount:d}],description:`Indexed launch ${r.name}; wallet token balance, not locked LP principal.`}),y.some(w=>k(w.address,f.address))||y.push(f)}for(let l of y){let r=await b(n,l.address);BigInt(r)>0n&&g.push({module:"clanker",id:`fees:${l.address.toLowerCase()}`,chainId:h,assets:[{token:l,amount:r}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return g})}},ze=e=>se("clanker",[De(e),ce(e),me(e),ye(e)]);export{Ne as a,De as b,ze as c};
1
+ import{b as q,o as U}from"./3NJ5KQ3Q.js";import{a as ye}from"./RVDUSNWW.js";import{a as le,b as ue,c as me}from"./ZV5HIQXC.js";import{a as ce}from"./RUX3RY7Y.js";import{a as fe,b as pe}from"./XBE3B6Y2.js";import{e as F,h as O,m as de}from"./PV5FDT6O.js";import{b as se}from"./SPJCSEKP.js";import{a as B}from"./IOYRL6AY.js";import{c as ae}from"./VEQBHI6O.js";import{c as D,e as x,g as k,k as te,l as oe,m as re,n as ie}from"./NWNYJ26T.js";import{a as h,i as ne}from"./FWD4L3CJ.js";import{a as i}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ie,encodeAbiParameters as j,encodeFunctionData as M,erc20Abi as J,isAddress as Pe,parseAbi as Ae,parseAbiParameters as V,toHex as W,zeroAddress as z}from"viem";var A=ne[h].clanker,he=Ae(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),T=Ae(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),C={address:A.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},Se="https://www.clanker.world/api/tokens",ge={type:"string",pattern:"^\\d+$"},be={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function I(e){return oe(te(e,F),F)}function we(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i(`Provide an explicit bytes32 ${t}.`);return e}function P(e,t,s=!1){if(e===void 0&&!s)return"";if(typeof e!="string"||s&&!e.trim())throw new i(`Provide ${t} as text.`);return e}function Z(e,t=256){return ie(e,`Amount exceeds the uint${t} range.`,{bits:t})}function G(e){return re(e,"The contract returned an invalid amount.").toString()}function L(e,t){let s=Object.keys(e).find(u=>!t.includes(u));if(s)throw new i(`Unsupported Clanker input: ${s}.`)}function ke(e,t){return t.changes.map(({token:s,amount:u})=>{let b=u.startsWith("-");return`${b?"-":"+"}${e.formatAmount(b?u.slice(1):u,s.decimals)} ${s.symbol} (${s.address}, chain ${s.chainId})`}).join("; ")}function ve(e){return x(e)&&Array.isArray(e.data)&&Number.isSafeInteger(e.total)&&Number(e.total)>=0&&Number.isSafeInteger(e.tokensDeployed)&&Number(e.tokensDeployed)>=0&&(e.cursor===null||e.cursor===void 0||typeof e.cursor=="string")&&e.data.every(t=>x(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(s=>typeof t[s]=="string"&&Pe(t[s],{strict:!1})))}function K(e,t=0){return typeof e=="string"?N(e):e===null||typeof e=="boolean"?e:typeof e=="number"?Number.isFinite(e)?e:null:t>=4?null:Array.isArray(e)?e.slice(0,20).map(s=>K(s,t+1)):x(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,u])=>[s,K(u,t+1)])):null}function _e(e){return{...K(e),contract_address:e.contract_address,admin:e.admin,msg_sender:e.msg_sender,chain_id:e.chain_id,factory_address:e.factory_address,name:N(e.name),symbol:N(e.symbol)}}function $e(e){try{if(typeof e!="string"||!/^[A-Za-z0-9_-]{1,256}={0,2}$/.test(e))throw new Error;let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));if(!x(t)||typeof t.id!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z?$/.test(t.id)||!Number.isFinite(Date.parse(t.id)))throw new Error;return e}catch{throw new i("Use the cursor returned by the previous clanker_browse page.")}}async function Ne(e,t={}){L(t,["q","limit","cursor","deployer"]);let s=t.limit??10;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>20)throw new i("Choose an indexer limit from 1 to 20.");let u=new URL(Se);u.searchParams.set("chainId",String(h)),u.searchParams.set("limit",String(s)),t.q!==void 0&&u.searchParams.set("q",P(t.q,"search")),t.cursor!==void 0&&u.searchParams.set("cursor",P(t.cursor,"cursor",!0)),t.deployer!==void 0&&u.searchParams.set("msgSender",I(t.deployer));let b=await ae(e.http,u.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},ve);return{tokens:b.data.filter(S=>S.chain_id===h&&k(S.factory_address,A.factory.address)),total:b.total,cursor:b.cursor||null,tokensDeployed:b.tokensDeployed}}var De=e=>{let t=()=>e.clientFor(h),s=async n=>{try{return await n()}catch(o){throw new i(e.plainError(o))}},u=(n,o,a,c="0")=>e.unsignedTx({to:n,data:o,value:c,chainId:h,description:a}),b=async(n,o)=>G(await t().readContract({address:A.fee_locker.address,abi:T,functionName:"availableFees",args:[n,o]})),S=async n=>{if(k(n,C.address))return C;let[o,a]=await Promise.all([t().readContract({address:n,abi:J,functionName:"symbol"}),t().readContract({address:n,abi:J,functionName:"decimals"})]);if(typeof o!="string"||!o.trim()||!Number.isInteger(a)||a<0||a>255)throw new i("The contract returned invalid token metadata.");return{address:n,chainId:h,symbol:o,decimals:a}},Q=async n=>{n.cursor!==void 0&&$e(n.cursor);let o=await Ne(e,n);return{...o,tokens:o.tokens.map(_e)}},xe=async(n,o)=>{if(L(n,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),n.vanity!==void 0&&n.vanity!==!1)throw new i("Clanker launches use vanity false and an explicit salt.");let a=P(n.name,"token name",!0),c=P(n.symbol,"token symbol",!0),g=we(n.salt,"salt"),y=Z(n.initialBuy??"0"),l=n.slippageBps??q;if(typeof l!="number")throw new i("Slippage must be an integer from 0 to 9999 bps.");U("0",l);let r=n.minAmountOut===void 0?void 0:Z(n.minAmountOut,128);if(r!==void 0&&r<=1n)throw new i("Initial-buy minimum must exceed one base unit.");if(!y&&r!==void 0)throw new i("A minimum requires a positive initial buy.");let m=ue(n,o);O(n.feeBps??100,0,1e3);let f=pe(n);if(y&&!k(f.poolConfig.pairedToken,C.address))throw new i("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let d=n.rewards??[{admin:o,recipient:o,bps:1e4,feePreference:0}];if(!Array.isArray(d)||!d.length||d.length>7)throw new i("Provide one to seven reward allocations.");let w=d.map(p=>{if(!x(p))throw new i("Provide reward allocations as objects.");return L(p,["admin","recipient","bps","feePreference"]),{admin:I(p.admin),recipient:I(p.recipient),bps:O(p.bps,1,1e4),feePreference:O(p.feePreference??0,0,2)}});if(w.reduce((p,v)=>p+v.bps,0)!==1e4)throw new i("Reward allocations must total 10000 bps.");let _={tokenConfig:{tokenAdmin:o,name:a,symbol:c,salt:g,image:P(n.image,"image"),metadata:P(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):P(n.context,"context"),originatingChainId:BigInt(h)},poolConfig:f.poolConfig,lockerConfig:{locker:A.locker.address,rewardAdmins:w.map(p=>p.admin),rewardRecipients:w.map(p=>p.recipient),rewardBps:w.map(p=>p.bps),tickLower:f.tickLower,tickUpper:f.tickUpper,positionBps:f.positionBps,lockerData:j(V("(uint8[])"),[[w.map(p=>p.feePreference)]])},mevModuleConfig:{mevModule:A.mev_module.address,mevModuleData:j(V("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:m},Ce=await t().simulateContract({address:A.factory.address,abi:he,functionName:"deployToken",args:[_],account:o,value:0n,gas:B}),E=I(Ce.result),X=p=>{let v=[...m,...y?[{extension:A.devbuy.address,msgValue:y,extensionBps:0,extensionData:j(V("(address,address,uint24,int24,address),uint128,address"),[[z,z,0,0,z],p,o])}]:[]];return u(A.factory.address,M({abi:he,functionName:"deployToken",args:[{..._,extensionConfigs:v}]}),`Launch ${a} (${c}); initial buy ${y} native ETH base units.`,y.toString())};if(y&&r===void 0){let v=(await e.preview([X(0n)],o)).changes.filter($=>$.token.chainId===h&&k($.token.address,E)&&$.token.decimals===18).reduce(($,ee)=>$+(/^-?\d+$/.test(ee.amount)?BigInt(ee.amount):(()=>{throw new i("Invalid initial-buy simulation amount.")})()),0n);if(v<=0n)throw new i("Initial-buy simulation returned no token output.");if(r=Z(U(v.toString(),l),128),r<=1n)throw new i("Initial-buy output is too small for a protected minimum.")}let Y=[X(r??0n)],H=await e.preview(Y,o);return{txs:Y,preview:H,predictedToken:E,token:{address:E,chainId:h,symbol:c,decimals:18},...r!==void 0?{minAmountOut:r.toString()}:{},summary:`Launch ${c} at ${E} (CREATE2 address predicted from simulation); vanity false; salt ${g}. Supply 100000000000000000000000000000 base units (18 decimals). ${f.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(f)}. Reward allocations: ${JSON.stringify(w)}. Extensions: ${JSON.stringify({vault:n.vault,airdrop:n.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${H.summary} ${ke(e,H)}`}},Te=async(n,o)=>{if(L(n,["token","poolId","collect"]),n.collect!==void 0&&typeof n.collect!="boolean")throw new i("collect must be boolean.");if(n.collect===!1&&n.poolId!==void 0)throw new i("poolId requires collection.");if(n.collect===!0&&n.token===void 0)throw new i("Collection requires a Clanker token.");if(n.poolId!==void 0&&n.token===void 0)throw new i("A pool ID requires its Clanker token.");let a=[C],c=[];if(n.token!==void 0){let r=I(n.token);if(k(r,C.address))throw new i("Provide the launched Clanker token, not WETH.");if(n.collect!==!1){let m=await de(e,r),{poolId:f,hook:d,locker:w}=m;if(n.poolId!==void 0&&!k(we(n.poolId,"pool ID for fee collection"),f))throw new i("The supplied pool ID does not match the onchain Clanker pool.");k(m.pairedToken,C.address)||a.splice(0,1,await S(m.pairedToken));let _=await t().readContract({address:d,abi:T,functionName:"mevModuleEnabled",args:[f]});if(typeof _!="boolean")throw new i("The hook returned an invalid MEV guard state.");_&&c.push(u(d,M({abi:T,functionName:"mevModuleOperational",args:[f]}),"Update the Clanker pool MEV guard before collection.")),c.push(u(w,M({abi:T,functionName:"collectRewards",args:[r]}),"Collect pending LP fees into the fee locker."))}a.push(await S(r))}let g;if(c.length){if(await t().getChainId()!==h)throw new i("Fee simulation endpoint is on the wrong chain.");let r=[...c.map(d=>({from:o,gas:W(B),to:d.to,data:d.data,value:W(BigInt(d.value))})),...a.map(d=>({from:o,gas:W(B),to:A.fee_locker.address,data:M({abi:T,functionName:"availableFees",args:[o,d.address]}),value:"0x0"}))],m=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:r}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(m)||m.length!==1||!x(m[0])||!Array.isArray(m[0].calls)||m[0].calls.length!==r.length)throw new i("The endpoint returned an unexpected fee simulation response.");let f=m[0].calls;if(!f.every(d=>x(d)&&d.status==="0x1"&&!d.error))throw new i("Clanker fee collection simulation failed.");g=f.slice(c.length).map(d=>{if(!x(d)||typeof d.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(d.returnData))throw new i("The endpoint returned an invalid fee balance.");return G(Ie({abi:T,functionName:"availableFees",data:d.returnData}))})}else g=await Promise.all(a.map(r=>b(o,r.address)));let y=a.flatMap((r,m)=>BigInt(g[m])>0n?[{token:r,amount:g[m]}]:[]);if(!y.length)throw new i("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:r}of y)c.push(u(A.fee_locker.address,M({abi:T,functionName:"claim",args:[o,r.address]}),`Claim ${r.symbol} fees to ${o}.`));let l=await e.preview(c,o);return{txs:c,preview:l,fees:y,summary:`Claim fees to ${o}. WETH fees aggregate across all Clanker launches for this recipient. ${l.summary} ${ke(e,l)}`}},R=(n,o,a,c)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:o,required:a,additionalProperties:!1},execute:(g,y)=>s(async()=>c(g,I(y)))});return{tools:[R("launch",{name:{type:"string"},symbol:{type:"string"},salt:be,image:{type:"string"},metadata:{type:"string"},context:{type:"string"},vanity:{const:!1},initialBuy:{...ge,description:"Native ETH base units, 18 decimals."},minAmountOut:{...ge,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:q},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100},pool:fe,rewards:{type:"array",minItems:1,maxItems:7,items:{type:"object",properties:{admin:D,recipient:D,bps:{type:"integer",minimum:1,maximum:1e4},feePreference:{type:"integer",minimum:0,maximum:2}},required:["admin","recipient","bps"],additionalProperties:!1}},...le},["name","symbol","salt"],async(n,o)=>{let a=await xe(n,o);return{...a,summary:`${a.summary} After the launch is mined, use clanker_status to inspect ${a.predictedToken} and clanker_claim to collect creator fees.`}}),R("claim",{token:{...D,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...be,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Te),R("browse",{q:{type:"string"},limit:{type:"integer",minimum:1,maximum:20},cursor:{type:"string"},deployer:D},[],Q)],positions:n=>s(async()=>{I(n);let o=new Map,a=new Set,c;do{let l=await Q({deployer:n,limit:20,...c?{cursor:c}:{}});for(let r of l.tokens)k(r.msg_sender,n)&&o.set(r.contract_address.toLowerCase(),r);if(l.cursor&&a.has(l.cursor))throw new i("The Clanker indexer repeated a pagination cursor.");l.cursor&&a.add(l.cursor),c=l.cursor??void 0}while(c);let g=[],y=[C];for(let[l,r]of o){let m=await S(r.contract_address),f={...m,symbol:N(m.symbol)},d=G(await t().readContract({address:f.address,abi:J,functionName:"balanceOf",args:[n]}));g.push({module:"clanker",id:`launch:${l}`,chainId:h,assets:[{token:f,amount:d}],description:`Indexed launch ${r.name}; wallet token balance, not locked LP principal.`}),y.some(w=>k(w.address,f.address))||y.push(f)}for(let l of y){let r=await b(n,l.address);BigInt(r)>0n&&g.push({module:"clanker",id:`fees:${l.address.toLowerCase()}`,chainId:h,assets:[{token:l,amount:r}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return g})}},ze=e=>se("clanker",[De(e),ce(e),me(e),ye(e)]);export{Ne as a,De as b,ze as c};