@oakagentkit/core 0.2.7 → 0.3.0

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 (462) hide show
  1. package/build/dist/api/addresses.d.ts +9 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.d.ts +4 -0
  4. package/build/dist/api/chain.js +1 -1
  5. package/build/dist/api/history.js +1 -1
  6. package/build/dist/api/identity-link.js +1 -1
  7. package/build/dist/api/metadata.js +1 -1
  8. package/build/dist/api/modules/beefy/boosts.js +1 -1
  9. package/build/dist/api/modules/beefy/clm.js +1 -1
  10. package/build/dist/api/modules/beefy/guard.js +1 -1
  11. package/build/dist/api/modules/beefy/index.js +1 -1
  12. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  13. package/build/dist/api/modules/beefy/management.js +1 -1
  14. package/build/dist/api/modules/beefy/vaults.js +1 -1
  15. package/build/dist/api/modules/borro/abi.d.ts +54 -0
  16. package/build/dist/api/modules/borro/abi.js +1 -1
  17. package/build/dist/api/modules/borro/actions.d.ts +14 -1
  18. package/build/dist/api/modules/borro/actions.js +1 -1
  19. package/build/dist/api/modules/borro/checks.js +1 -1
  20. package/build/dist/api/modules/borro/copy.d.ts +10 -2
  21. package/build/dist/api/modules/borro/copy.js +1 -1
  22. package/build/dist/api/modules/borro/index.js +1 -1
  23. package/build/dist/api/modules/borro/liquidity.js +1 -1
  24. package/build/dist/api/modules/borro/pins.d.ts +30 -14
  25. package/build/dist/api/modules/borro/pins.js +1 -1
  26. package/build/dist/api/modules/borro/positions.js +1 -1
  27. package/build/dist/api/modules/borro/reader.js +1 -1
  28. package/build/dist/api/modules/borro/types.d.ts +1 -0
  29. package/build/dist/api/modules/chop/guard.js +1 -1
  30. package/build/dist/api/modules/chop/index.js +1 -1
  31. package/build/dist/api/modules/clanker/extensions.js +1 -1
  32. package/build/dist/api/modules/clanker/index.js +1 -1
  33. package/build/dist/api/modules/clanker/manage.js +1 -1
  34. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  35. package/build/dist/api/modules/clanker/protocol.js +1 -1
  36. package/build/dist/api/modules/clanker/state.js +1 -1
  37. package/build/dist/api/modules/earn/copy.d.ts +6 -6
  38. package/build/dist/api/modules/earn/copy.js +1 -1
  39. package/build/dist/api/modules/earn/cost.d.ts +1 -1
  40. package/build/dist/api/modules/earn/cost.js +1 -1
  41. package/build/dist/api/modules/earn/index.js +1 -1
  42. package/build/dist/api/modules/earn/lp.js +1 -1
  43. package/build/dist/api/modules/earn/options.js +1 -1
  44. package/build/dist/api/modules/erc8004/common.js +1 -1
  45. package/build/dist/api/modules/erc8004/domain.js +1 -1
  46. package/build/dist/api/modules/erc8004/index.js +1 -1
  47. package/build/dist/api/modules/erc8004/management.js +1 -1
  48. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  49. package/build/dist/api/modules/erc8004/services.js +1 -1
  50. package/build/dist/api/modules/erc8004/thesis.d.ts +61 -0
  51. package/build/dist/api/modules/erc8004/thesis.js +1 -0
  52. package/build/dist/api/modules/erc8004/validation.js +1 -1
  53. package/build/dist/api/modules/gloam/index.js +1 -1
  54. package/build/dist/api/modules/grove/index.js +1 -1
  55. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  56. package/build/dist/api/modules/heyresearch/index.js +1 -1
  57. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  58. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  59. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  60. package/build/dist/api/modules/hoodag/index.d.ts +12 -1
  61. package/build/dist/api/modules/hoodag/index.js +1 -1
  62. package/build/dist/api/modules/hoodag/management.js +1 -1
  63. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  64. package/build/dist/api/modules/hoodag/reconstruct.d.ts +14 -0
  65. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  66. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  67. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  68. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  69. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  70. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  71. package/build/dist/api/modules/hoodlock/index.js +1 -1
  72. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  73. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  74. package/build/dist/api/modules/hoodlock/public.js +1 -1
  75. package/build/dist/api/modules/hookr/actions.js +1 -1
  76. package/build/dist/api/modules/hookr/addons.js +1 -1
  77. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  78. package/build/dist/api/modules/hookr/contracts.js +1 -1
  79. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  80. package/build/dist/api/modules/hookr/discovery.js +1 -1
  81. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  82. package/build/dist/api/modules/hookr/index.js +1 -1
  83. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  84. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  85. package/build/dist/api/modules/hookr/launch.js +1 -1
  86. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  87. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  88. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  89. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  90. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  91. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  92. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  93. package/build/dist/api/modules/hookr/relay.js +1 -1
  94. package/build/dist/api/modules/hookr/revenue.js +1 -1
  95. package/build/dist/api/modules/kyberswap/index.d.ts +2 -1
  96. package/build/dist/api/modules/kyberswap/index.js +1 -1
  97. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  98. package/build/dist/api/modules/layerbank/abi.js +1 -1
  99. package/build/dist/api/modules/layerbank/actions.js +1 -1
  100. package/build/dist/api/modules/layerbank/checks.js +1 -1
  101. package/build/dist/api/modules/layerbank/index.js +1 -1
  102. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  103. package/build/dist/api/modules/layerbank/reader.js +1 -1
  104. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  105. package/build/dist/api/modules/lighter/index.js +1 -1
  106. package/build/dist/api/modules/longbow/administration.js +1 -1
  107. package/build/dist/api/modules/longbow/analytics.js +1 -1
  108. package/build/dist/api/modules/longbow/fixed.js +1 -1
  109. package/build/dist/api/modules/longbow/index.js +1 -1
  110. package/build/dist/api/modules/longbow/nft.js +1 -1
  111. package/build/dist/api/modules/longbow/rebates.js +1 -1
  112. package/build/dist/api/modules/longbow/staking.js +1 -1
  113. package/build/dist/api/modules/meridian/index.js +1 -1
  114. package/build/dist/api/modules/meridian/markets.js +1 -1
  115. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  116. package/build/dist/api/modules/meridian/rfq.js +1 -1
  117. package/build/dist/api/modules/merkl/discovery.js +1 -1
  118. package/build/dist/api/modules/merkl/index.js +1 -1
  119. package/build/dist/api/modules/merkl/manage.js +1 -1
  120. package/build/dist/api/modules/merkl/protocol.js +1 -1
  121. package/build/dist/api/modules/morpho/allocator.js +1 -1
  122. package/build/dist/api/modules/morpho/bundles.js +1 -1
  123. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  124. package/build/dist/api/modules/morpho/index.js +1 -1
  125. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  126. package/build/dist/api/modules/morpho/midnight.js +1 -1
  127. package/build/dist/api/modules/morpho/protocol.js +1 -1
  128. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  129. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  130. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  131. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  132. package/build/dist/api/modules/netnet/card-policy.d.ts +1 -0
  133. package/build/dist/api/modules/netnet/card-policy.js +1 -1
  134. package/build/dist/api/modules/netnet/card-read.js +1 -1
  135. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  136. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  137. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  138. package/build/dist/api/modules/netnet/financial.js +1 -1
  139. package/build/dist/api/modules/netnet/index.js +1 -1
  140. package/build/dist/api/modules/netnet/staking.js +1 -1
  141. package/build/dist/api/modules/orbio/index.d.ts +6 -0
  142. package/build/dist/api/modules/orbio/index.js +1 -1
  143. package/build/dist/api/modules/orbio/positions.js +1 -1
  144. package/build/dist/api/modules/pendle/costs.js +1 -1
  145. package/build/dist/api/modules/pendle/index.js +1 -1
  146. package/build/dist/api/modules/pendle/markets.js +1 -1
  147. package/build/dist/api/modules/pendle/positions.js +1 -1
  148. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  149. package/build/dist/api/modules/pendle/reader.js +1 -1
  150. package/build/dist/api/modules/pendle/redeem.js +1 -1
  151. package/build/dist/api/modules/pendle/trade.js +1 -1
  152. package/build/dist/api/modules/pendle/validate.js +1 -1
  153. package/build/dist/api/modules/pendle/verify.js +1 -1
  154. package/build/dist/api/modules/pons/claim.js +1 -1
  155. package/build/dist/api/modules/pons/index.js +1 -1
  156. package/build/dist/api/modules/pons/launch-status.js +1 -1
  157. package/build/dist/api/modules/pons/prices.js +1 -1
  158. package/build/dist/api/modules/pons/reads.js +1 -1
  159. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  160. package/build/dist/api/modules/pons/trade.js +1 -1
  161. package/build/dist/api/modules/poolstrade/index.js +1 -1
  162. package/build/dist/api/modules/priors/coverage.js +1 -1
  163. package/build/dist/api/modules/priors/discovery.js +1 -1
  164. package/build/dist/api/modules/priors/features.js +1 -1
  165. package/build/dist/api/modules/priors/holdings.js +1 -1
  166. package/build/dist/api/modules/priors/index.js +1 -1
  167. package/build/dist/api/modules/priors/integration.js +1 -1
  168. package/build/dist/api/modules/priors/market.js +1 -1
  169. package/build/dist/api/modules/priors/pt.js +1 -1
  170. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  171. package/build/dist/api/modules/priors/starter-line.js +1 -1
  172. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  173. package/build/dist/api/modules/raeto/index.js +1 -1
  174. package/build/dist/api/modules/relay/api.js +1 -1
  175. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  176. package/build/dist/api/modules/relay/discovery.js +1 -1
  177. package/build/dist/api/modules/relay/inbound.js +1 -1
  178. package/build/dist/api/modules/relay/index.js +1 -1
  179. package/build/dist/api/modules/relay/order.js +1 -1
  180. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  181. package/build/dist/api/modules/relay/readiness.js +1 -1
  182. package/build/dist/api/modules/relay/reads.js +1 -1
  183. package/build/dist/api/modules/relay/vaults.js +1 -1
  184. package/build/dist/api/modules/spark/actions.js +1 -1
  185. package/build/dist/api/modules/spark/details.js +1 -1
  186. package/build/dist/api/modules/spark/index.js +1 -1
  187. package/build/dist/api/modules/spark/management.js +1 -1
  188. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  189. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  190. package/build/dist/api/modules/steakhouse/index.js +1 -1
  191. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  192. package/build/dist/api/modules/steakhouse/management.js +1 -1
  193. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  194. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  195. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  196. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  197. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  198. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  199. package/build/dist/api/modules/tickerspring/index.js +1 -1
  200. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  201. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  202. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  203. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  204. package/build/dist/api/modules/tickerspring/research.js +1 -1
  205. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  206. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  207. package/build/dist/api/modules/uniswap/auction.js +1 -1
  208. package/build/dist/api/modules/uniswap/batch.js +1 -1
  209. package/build/dist/api/modules/uniswap/common.js +1 -1
  210. package/build/dist/api/modules/uniswap/fees.js +1 -1
  211. package/build/dist/api/modules/uniswap/index.js +1 -1
  212. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  213. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  214. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  215. package/build/dist/api/modules/uniswap/pools.js +1 -1
  216. package/build/dist/api/modules/uniswap/position.js +1 -1
  217. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  218. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  219. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  220. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  221. package/build/dist/api/modules/uniswap/trade.js +1 -1
  222. package/build/dist/api/modules/uniswap/v2.js +1 -1
  223. package/build/dist/api/modules/uniswap/v3.js +1 -1
  224. package/build/dist/api/modules/uniswap/v4.js +1 -1
  225. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  226. package/build/dist/api/modules/upoch/copy.d.ts +5 -0
  227. package/build/dist/api/modules/upoch/copy.js +1 -0
  228. package/build/dist/api/modules/upoch/index.d.ts +8 -0
  229. package/build/dist/api/modules/upoch/index.js +1 -0
  230. package/build/dist/api/modules/upoch/pins.d.ts +8 -0
  231. package/build/dist/api/modules/upoch/pins.js +1 -0
  232. package/build/dist/api/modules/upoch/reads.d.ts +509 -0
  233. package/build/dist/api/modules/upoch/reads.js +1 -0
  234. package/build/dist/api/modules/velora/claims.js +1 -1
  235. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  236. package/build/dist/api/modules/velora/index.js +1 -1
  237. package/build/dist/api/modules/wormhole/index.js +1 -1
  238. package/build/dist/api/modules/wormhole/x402-client.d.ts +17 -1
  239. package/build/dist/api/modules/wormhole/x402-client.js +1 -1
  240. package/build/dist/api/positions.js +1 -1
  241. package/build/dist/api/pricenote.js +1 -1
  242. package/build/dist/api/prices.js +1 -1
  243. package/build/dist/api/pricing.js +1 -1
  244. package/build/dist/api/rpc.js +1 -1
  245. package/build/dist/api/secret-fields.d.ts +2 -0
  246. package/build/dist/api/secret-fields.js +1 -1
  247. package/build/dist/api/send.js +1 -1
  248. package/build/dist/api/signing-registry.js +1 -1
  249. package/build/dist/api/signing.js +1 -1
  250. package/build/dist/api/simulate.js +1 -1
  251. package/build/dist/api/swap.js +1 -1
  252. package/build/dist/api/tokens.js +1 -1
  253. package/build/dist/api/tool-policy.d.ts +1 -0
  254. package/build/dist/api/tool-policy.js +1 -1
  255. package/build/dist/api/usd-estimate.js +1 -1
  256. package/build/dist/chunks/23HNDJ76.js +2 -0
  257. package/build/dist/chunks/{JS53DQVT.js → 24Q3FNGX.js} +1 -1
  258. package/build/dist/chunks/{N245WC5R.js → 25C4DTVA.js} +1 -1
  259. package/build/dist/chunks/{PV4AK32X.js → 2HN3U6OG.js} +1 -1
  260. package/build/dist/chunks/{GQYV4TFO.js → 2OVJ2BTJ.js} +1 -1
  261. package/build/dist/chunks/{DYYEA5HB.js → 2QGLPY2D.js} +1 -1
  262. package/build/dist/chunks/{ZFU65MB4.js → 2WRXH6BL.js} +1 -1
  263. package/build/dist/chunks/{EZZM2GQT.js → 2ZBSE2LD.js} +1 -1
  264. package/build/dist/chunks/{HIX5N25Z.js → 2ZQ7X223.js} +1 -1
  265. package/build/dist/chunks/{V37L4DU4.js → 3A2IKFTV.js} +1 -1
  266. package/build/dist/chunks/{FWIFTPSE.js → 3PU2SD3U.js} +1 -1
  267. package/build/dist/chunks/{SBY4RJ7I.js → 3ZH5SOC2.js} +1 -1
  268. package/build/dist/chunks/4NBXBKOX.js +2 -0
  269. package/build/dist/chunks/{FOKEFXGP.js → 4PLLS6CT.js} +1 -1
  270. package/build/dist/chunks/{KREBNL2D.js → 4R3G3H42.js} +1 -1
  271. package/build/dist/chunks/{XHYFISVV.js → 4Z3IGMU6.js} +1 -1
  272. package/build/dist/chunks/{CSDN4MYP.js → 5GQJVKVY.js} +1 -1
  273. package/build/dist/chunks/{JOKL5L6X.js → 5R576SDB.js} +1 -1
  274. package/build/dist/chunks/{UUID2E22.js → 5W74Z4WZ.js} +1 -1
  275. package/build/dist/chunks/{EH5G4O3U.js → 65356YKW.js} +1 -1
  276. package/build/dist/chunks/{QFSBDPLN.js → 65OITTDL.js} +1 -1
  277. package/build/dist/chunks/{DSTMEY5F.js → 6F527FLN.js} +1 -1
  278. package/build/dist/chunks/{CO4GCF4L.js → 6MDYKE2O.js} +1 -1
  279. package/build/dist/chunks/{IEG6GLFR.js → 6OCLWSMZ.js} +1 -1
  280. package/build/dist/chunks/75SULXNT.js +1 -0
  281. package/build/dist/chunks/{WU7XIAXB.js → 7EACRKFV.js} +1 -1
  282. package/build/dist/chunks/{AMTRDPVO.js → 7U62MMUQ.js} +1 -1
  283. package/build/dist/chunks/{DW4V5PUY.js → 7VH6JQ2H.js} +1 -1
  284. package/build/dist/chunks/{XVJ7ILKK.js → A2V4NFVA.js} +1 -1
  285. package/build/dist/chunks/A3BJSQ23.js +1 -0
  286. package/build/dist/chunks/{YSMWCKIX.js → ADIPEGNN.js} +1 -1
  287. package/build/dist/chunks/ANIF3JMV.js +4 -0
  288. package/build/dist/chunks/{RLI4JDOL.js → ATEVAJ5Y.js} +1 -1
  289. package/build/dist/chunks/{F3VDVTMS.js → B2HSLY5F.js} +1 -1
  290. package/build/dist/chunks/{N4XNNXOJ.js → B7BNDW35.js} +1 -1
  291. package/build/dist/chunks/{GLF7WEY2.js → C6VJAL5B.js} +1 -1
  292. package/build/dist/chunks/{5PI57UC2.js → C76D54YG.js} +1 -1
  293. package/build/dist/chunks/{GRSXWQWD.js → CD2JQ32C.js} +1 -1
  294. package/build/dist/chunks/{4GNUXN4K.js → CI5ENLYA.js} +1 -1
  295. package/build/dist/chunks/{F4UQEPJT.js → CZQ2CGYV.js} +1 -1
  296. package/build/dist/chunks/{APHNOGNS.js → D2IYA4LP.js} +1 -1
  297. package/build/dist/chunks/{4RQAOOO2.js → D7QXZM3S.js} +1 -1
  298. package/build/dist/chunks/{TDZTC5WR.js → DBOGRUPS.js} +1 -1
  299. package/build/dist/chunks/{Y77EVVT4.js → DGDMRATN.js} +1 -1
  300. package/build/dist/chunks/{3DNJTJ2X.js → DMB64UIN.js} +1 -1
  301. package/build/dist/chunks/{TM7Z5SA4.js → DMDOSHV7.js} +1 -1
  302. package/build/dist/chunks/{WHVZ372B.js → DRLBTB4E.js} +1 -1
  303. package/build/dist/chunks/{FZ6IJZZM.js → E76Z2TT4.js} +1 -1
  304. package/build/dist/chunks/{C75MT5SD.js → EHK7CDTU.js} +1 -1
  305. package/build/dist/chunks/{KKPMOAVI.js → ELHRXA5U.js} +1 -1
  306. package/build/dist/chunks/{XCKTE4ON.js → F7MGYRPU.js} +1 -1
  307. package/build/dist/chunks/{MRMR4QHA.js → FAH7FKUT.js} +1 -1
  308. package/build/dist/chunks/{M7ZXDLKM.js → FGEGJOAA.js} +1 -1
  309. package/build/dist/chunks/{N6GIC7HJ.js → FN6GNTPR.js} +1 -1
  310. package/build/dist/chunks/{ZF2VPDRQ.js → FTMA24EC.js} +1 -1
  311. package/build/dist/chunks/FXOFR432.js +1 -0
  312. package/build/dist/chunks/{VHV6WQ5F.js → G2AA73ZE.js} +1 -1
  313. package/build/dist/chunks/{JWR5XVP2.js → GBIBRYOV.js} +1 -1
  314. package/build/dist/chunks/{FNGIJKMZ.js → GDOHHXNH.js} +1 -1
  315. package/build/dist/chunks/{LR4XTZ37.js → GP6YO24Z.js} +1 -1
  316. package/build/dist/chunks/{2OKYXT25.js → GQITAJVF.js} +1 -1
  317. package/build/dist/chunks/H3E7UD2X.js +1 -0
  318. package/build/dist/chunks/HFVXNKA5.js +1 -0
  319. package/build/dist/chunks/HHYE42JG.js +21 -0
  320. package/build/dist/chunks/{UOCRYXAB.js → HRAHGYNK.js} +1 -1
  321. package/build/dist/chunks/{U363GQTF.js → HS5HWBMU.js} +1 -1
  322. package/build/dist/chunks/{ARI72OYT.js → HVFMIURK.js} +1 -1
  323. package/build/dist/chunks/IBL6TL2Q.js +1 -0
  324. package/build/dist/chunks/{HCBX4NFM.js → IT2JLILU.js} +1 -1
  325. package/build/dist/chunks/{REWXG6X6.js → JDSSYT6R.js} +1 -1
  326. package/build/dist/chunks/{XRDXFHIK.js → JFWJBZ7M.js} +1 -1
  327. package/build/dist/chunks/{523ZIR3J.js → JI5DXDMY.js} +1 -1
  328. package/build/dist/chunks/{7QKYDNF6.js → JPPQDELB.js} +1 -1
  329. package/build/dist/chunks/{ZP36DSOD.js → K4P5VYDP.js} +1 -1
  330. package/build/dist/chunks/{32RXFUOH.js → KBU3PYP7.js} +1 -1
  331. package/build/dist/chunks/{BB765L75.js → KH4QFN72.js} +1 -1
  332. package/build/dist/chunks/{YTLH4M4Y.js → KMSAUFYV.js} +1 -1
  333. package/build/dist/chunks/{6UVGQYZ3.js → KOTGFD2V.js} +1 -1
  334. package/build/dist/chunks/{4JTTA3BX.js → KZA5GYZR.js} +1 -1
  335. package/build/dist/chunks/{WUT7TZYM.js → LCH6F5HT.js} +1 -1
  336. package/build/dist/chunks/{ARLGF5MU.js → LDJI2JAL.js} +1 -1
  337. package/build/dist/chunks/LEV5SNNC.js +3 -0
  338. package/build/dist/chunks/{SPRVVJXI.js → LFSJDFMY.js} +1 -1
  339. package/build/dist/chunks/{J73ATSEQ.js → LJJYYUEG.js} +1 -1
  340. package/build/dist/chunks/{CAWTAR5V.js → LKX5WDOQ.js} +1 -1
  341. package/build/dist/chunks/M7BUKZW2.js +1 -0
  342. package/build/dist/chunks/{C5ZZAYXD.js → MI5HZDMH.js} +1 -1
  343. package/build/dist/chunks/{YWZQJJYY.js → MMCM3GSM.js} +1 -1
  344. package/build/dist/chunks/MQ5F2VOK.js +1 -0
  345. package/build/dist/chunks/{TE6D3OIX.js → MSMHS456.js} +1 -1
  346. package/build/dist/chunks/{JKD2B6OX.js → MSRCJ2BS.js} +1 -1
  347. package/build/dist/chunks/{YMV5TL5C.js → N64JJN37.js} +1 -1
  348. package/build/dist/chunks/{JKRBGAX2.js → NAO7VWZF.js} +1 -1
  349. package/build/dist/chunks/ND32LJWI.js +1 -0
  350. package/build/dist/chunks/{RT7IU6TI.js → NMJVQX5M.js} +1 -1
  351. package/build/dist/chunks/{67BWOVET.js → NMQBOBWJ.js} +1 -1
  352. package/build/dist/chunks/NQ4MTIU3.js +1 -0
  353. package/build/dist/chunks/{XWKK75TO.js → NWPAQER2.js} +1 -1
  354. package/build/dist/chunks/O2J5I4VA.js +1 -0
  355. package/build/dist/chunks/{2SUHQWND.js → O4S6XAYV.js} +1 -1
  356. package/build/dist/chunks/{TAEZTP4L.js → O5QTITN6.js} +1 -1
  357. package/build/dist/chunks/{NA424YAL.js → OB7BFDOV.js} +1 -1
  358. package/build/dist/chunks/{GW5IXLKU.js → OI3N4EW4.js} +1 -1
  359. package/build/dist/chunks/{FL5SSHUL.js → OIQTZOBN.js} +1 -1
  360. package/build/dist/chunks/{XPEDQBLI.js → OODSXDIH.js} +1 -1
  361. package/build/dist/chunks/OOPMZIG7.js +1 -0
  362. package/build/dist/chunks/{GG24LO2R.js → OQFNUDMQ.js} +1 -1
  363. package/build/dist/chunks/{Q2ACLVWR.js → ORG6LVKJ.js} +1 -1
  364. package/build/dist/chunks/{XYPGLG6A.js → OSMOBKRQ.js} +1 -1
  365. package/build/dist/chunks/{EGZREEG2.js → OTLUQWLF.js} +1 -1
  366. package/build/dist/chunks/{OYJFXEDU.js → OTYB6BHK.js} +1 -1
  367. package/build/dist/chunks/{OZ5MDUD2.js → OVM4QIET.js} +1 -1
  368. package/build/dist/chunks/{OYPAVXGQ.js → OYDKAIS2.js} +1 -1
  369. package/build/dist/chunks/P6OB2AFW.js +1 -0
  370. package/build/dist/chunks/{UQEEF5W5.js → PDPTJMTJ.js} +1 -1
  371. package/build/dist/chunks/PEHXHQVA.js +1 -0
  372. package/build/dist/chunks/PMFR47H3.js +1 -0
  373. package/build/dist/chunks/{HHO5ISMM.js → PQXYTOV5.js} +1 -1
  374. package/build/dist/chunks/{HKVQ646Q.js → PSGRZWES.js} +1 -1
  375. package/build/dist/chunks/Q7L3BX6U.js +1 -0
  376. package/build/dist/chunks/{753HZZTY.js → QBYV7NXH.js} +1 -1
  377. package/build/dist/chunks/{2LWBN35N.js → QIB6OMQV.js} +1 -1
  378. package/build/dist/chunks/{TPEKCXVE.js → QLAOBULN.js} +1 -1
  379. package/build/dist/chunks/{DNNFKDZR.js → QLFPAN6S.js} +1 -1
  380. package/build/dist/chunks/QMEGAKLI.js +1 -0
  381. package/build/dist/chunks/{TK55VASJ.js → QMNUB2GM.js} +1 -1
  382. package/build/dist/chunks/{YUHNPUNK.js → R73R4KN3.js} +1 -1
  383. package/build/dist/chunks/{VR344DAZ.js → RN3WUJIO.js} +1 -1
  384. package/build/dist/chunks/{5HIHUYA4.js → RNCMXKKS.js} +1 -1
  385. package/build/dist/chunks/{ZOMFHTB2.js → ROQQ62LP.js} +1 -1
  386. package/build/dist/chunks/{D742AYEV.js → RUTSEGGD.js} +1 -1
  387. package/build/dist/chunks/{TFDPEAVZ.js → S4JUFCT4.js} +1 -1
  388. package/build/dist/chunks/{KDGSYNOP.js → S4UJDZGN.js} +1 -1
  389. package/build/dist/chunks/{AI3VAPA3.js → SMSXZ3FN.js} +1 -1
  390. package/build/dist/chunks/{JLRHM2DQ.js → SUNTJ6IU.js} +1 -1
  391. package/build/dist/chunks/{2FHELZ7Y.js → TGFQQCRY.js} +1 -1
  392. package/build/dist/chunks/{4JRXEN7C.js → THL4TMQW.js} +2 -2
  393. package/build/dist/chunks/TI727O2H.js +1 -0
  394. package/build/dist/chunks/{RLMVA575.js → TMRAF2L2.js} +1 -1
  395. package/build/dist/chunks/{PV5FDT6O.js → TXGZ6NWN.js} +1 -1
  396. package/build/dist/chunks/U243AWCH.js +1 -0
  397. package/build/dist/chunks/U762746N.js +1 -0
  398. package/build/dist/chunks/{GDRQ2ANN.js → U7UPLF4F.js} +1 -1
  399. package/build/dist/chunks/{4Q2ZBZXM.js → UPKVD7WG.js} +1 -1
  400. package/build/dist/chunks/{ZQAFFWDK.js → URBEK2VV.js} +1 -1
  401. package/build/dist/chunks/{VTPT5544.js → USEF3QKG.js} +1 -1
  402. package/build/dist/chunks/{U2YCQWZK.js → UVAR6BHU.js} +1 -1
  403. package/build/dist/chunks/{7VC53B5X.js → V5YSJKRH.js} +13 -13
  404. package/build/dist/chunks/{7D73A6KS.js → VB36EHIR.js} +1 -1
  405. package/build/dist/chunks/VMZYFO6I.js +1 -0
  406. package/build/dist/chunks/{UEDGYZOC.js → VVAM3EAK.js} +1 -1
  407. package/build/dist/chunks/VVJO6OYK.js +1 -0
  408. package/build/dist/chunks/{JESMX2UC.js → VXCGMALF.js} +1 -1
  409. package/build/dist/chunks/{ZKZUS3QU.js → VZVW5J7J.js} +1 -1
  410. package/build/dist/chunks/{NUFZUKYS.js → W32UECOL.js} +1 -1
  411. package/build/dist/chunks/{O3JWCJIF.js → W4RYRLL5.js} +1 -1
  412. package/build/dist/chunks/{2MZXTOZU.js → WAKZWSHB.js} +1 -1
  413. package/build/dist/chunks/{BAIY32AV.js → WBNFRPAT.js} +1 -1
  414. package/build/dist/chunks/{HM72DH4V.js → WRUTW6CG.js} +1 -1
  415. package/build/dist/chunks/{VYYSL557.js → WSILNJS2.js} +1 -1
  416. package/build/dist/chunks/{L646YWDP.js → X24YTJST.js} +1 -1
  417. package/build/dist/chunks/{4FPV4CRC.js → X5AL3DUK.js} +1 -1
  418. package/build/dist/chunks/{SOTYQGPT.js → XBNZ7GTY.js} +1 -1
  419. package/build/dist/chunks/{BZ34ZR65.js → XEBMS5KU.js} +1 -1
  420. package/build/dist/chunks/{FOD34G2H.js → XL3W7DAQ.js} +1 -1
  421. package/build/dist/chunks/{GSFHM5L3.js → XPWGPZ2C.js} +1 -1
  422. package/build/dist/chunks/{2E4I7CJ7.js → XRDLMTBJ.js} +1 -1
  423. package/build/dist/chunks/{SKEKXEUU.js → XV3YJ4P6.js} +1 -1
  424. package/build/dist/chunks/XW3VGWXK.js +1 -0
  425. package/build/dist/chunks/{6WD4HHID.js → Y2QADJOB.js} +1 -1
  426. package/build/dist/chunks/Y64GFBTA.js +1 -0
  427. package/build/dist/chunks/{FJLJ7ZQ5.js → YARZE7SJ.js} +1 -1
  428. package/build/dist/chunks/{OARVU3RC.js → YBLJ75U5.js} +1 -1
  429. package/build/dist/chunks/YRSAZTTC.js +7 -0
  430. package/build/dist/chunks/{3VBIRLU3.js → YXXK6EPI.js} +1 -1
  431. package/build/dist/chunks/Z3IBPCY4.js +2 -0
  432. package/build/dist/chunks/{H5DY7CNB.js → Z7FGEWO2.js} +1 -1
  433. package/build/dist/chunks/{INOYMBWE.js → ZNPVBNC5.js} +1 -1
  434. package/build/dist/chunks/{EVBHQQQG.js → ZTKT3ZQK.js} +1 -1
  435. package/build/dist/chunks/{4BVP652W.js → ZZ6FZGHF.js} +1 -1
  436. package/package.json +1 -1
  437. package/build/dist/chunks/3K2N5VFH.js +0 -1
  438. package/build/dist/chunks/3ZABD6ZF.js +0 -2
  439. package/build/dist/chunks/44MB6SA6.js +0 -1
  440. package/build/dist/chunks/4D4ZRZUW.js +0 -1
  441. package/build/dist/chunks/4OVIMYNH.js +0 -2
  442. package/build/dist/chunks/6NUNCD5J.js +0 -1
  443. package/build/dist/chunks/6PZGDVHV.js +0 -1
  444. package/build/dist/chunks/7MBVTNLU.js +0 -1
  445. package/build/dist/chunks/7VNO46LV.js +0 -1
  446. package/build/dist/chunks/DPE7SPW7.js +0 -1
  447. package/build/dist/chunks/E3RACZUY.js +0 -1
  448. package/build/dist/chunks/EI6GGPDS.js +0 -20
  449. package/build/dist/chunks/FV4WZOTD.js +0 -1
  450. package/build/dist/chunks/FWD4L3CJ.js +0 -1
  451. package/build/dist/chunks/JBTOZ6IH.js +0 -1
  452. package/build/dist/chunks/MVD3KWPP.js +0 -1
  453. package/build/dist/chunks/P6OMKZMR.js +0 -3
  454. package/build/dist/chunks/PXVREXCS.js +0 -1
  455. package/build/dist/chunks/QJNLLI6N.js +0 -1
  456. package/build/dist/chunks/RPB46QAC.js +0 -1
  457. package/build/dist/chunks/TID4C2KC.js +0 -1
  458. package/build/dist/chunks/UWBKAWX3.js +0 -7
  459. package/build/dist/chunks/WHTRPRRD.js +0 -1
  460. package/build/dist/chunks/WLMWWEP7.js +0 -2
  461. package/build/dist/chunks/XQ24RSEI.js +0 -1
  462. package/build/dist/chunks/YDNTY67T.js +0 -1
@@ -1 +1 @@
1
- import{b as ne}from"./F4UQEPJT.js";import{b as ee,e as te}from"./ZOMFHTB2.js";import{a as D,b as W,c as _,d as J,e as z,f as Y,g as Z}from"./J73ATSEQ.js";import{d as V,e as $,w as U}from"./BAIY32AV.js";import{a as H}from"./IOYRL6AY.js";import{a as E}from"./66F5ZH34.js";import{c as b,g as G}from"./NWNYJ26T.js";import{a as S,i as N}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as w,encodeFunctionData as oe,encodePacked as he,erc20Abi as be,getAddress as ce,parseAbi as T,parseAbiParameters as g,zeroAddress as v}from"viem";var ie=ce("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),re=ce(N[4663].ponsTrade.quoter.address),xe=T(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),we=T(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),se=T(["function factory() view returns (address)","function quoteExactInput(bytes path,uint256 amountIn) returns (uint256,uint160[],uint32[],uint256)","function quoteExactOutput(bytes path,uint256 amountOut) returns (uint256,uint160[],uint32[],uint256)"]),F="(address intermediateCurrency,uint24 fee,int24 tickSpacing,address hooks,bytes hookData)",M="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",ae=T([`function quoteExactInput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactOutput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactInputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`,`function quoteExactOutputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`]),ke=g(`(address exactCurrency,${F}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function ve(u,t,r,l){let s=[],e=l?r:t,i=new Set([e]);for(let n of l?[...u].reverse():u){let c=n.currency0===e?n.currency1:n.currency1===e?n.currency0:void 0;if(!c||i.has(c))throw new o("V4 poolKeys must form a continuous route without repeated currencies.");s.push({intermediateCurrency:c,fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks,hookData:"0x"}),e=c,i.add(e)}if(e!==(l?t:r))throw new o("V4 route does not end at the requested currency.");return s}var ge=g(`(${M} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),Ae=g("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),Pe=g("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),ue=g("address,uint256"),Ie=g("bytes,bytes[]");function Se(u,t,r){let l=r?[...u].reverse():u,s=r?[...t].reverse():t,e=l[0];return s.forEach((i,n)=>{e=`${e}${he(["uint24","address"],[i,l[n+1]]).slice(2)}`}),e}var de={version:{description:'Uniswap version: "v2" for pairs, "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v2","v3","v4"]},tokenIn:{...b,description:"Input token address; the zero address means native ETH for v4."},tokenOut:{...b,description:"Output token address; the zero address means native ETH for v4."},path:{description:"Two to six distinct ERC-20 token addresses in input-to-output order for v2 or v3.",type:"array",minItems:2,maxItems:6,items:b},fees:{type:"array",description:"One v3 pool fee per path hop, in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",items:{type:"integer",minimum:0,maximum:1e6}},poolKeys:{description:"One to five v4 pool keys in input-to-output route order, without repeated currencies.",type:"array",minItems:1,maxItems:5,items:{type:"object",required:["currency0","currency1","fee","tickSpacing","hooks"],properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},additionalProperties:!1}},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},allowHighFeePools:{description:"Allow pools above Oak's usual fee threshold; review the fee warning before confirming.",type:"boolean"},acceptValueLoss:{description:"Acknowledge the quoted value-loss warning; review the measured loss before confirming.",type:"boolean"},amountIn:E('Amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),amountOut:E('Amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),minAmountOut:E('Minimum amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),maxAmountIn:E('Maximum amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999}};async function Ee(u,t,r,l=!1){Z(t,Object.keys(de));let s=t.version;if(!["v2","v3","v4"].includes(String(s)))throw new o("Provide version v2, v3 or v4.");let e=t.amountOut!==void 0;if(t.amountIn!==void 0===e)throw new o("Provide exactly one of amountIn or amountOut.");if(e&&t.minAmountOut!==void 0||!e&&t.maxAmountIn!==void 0)throw new o("Use maxAmountIn for exact output, minAmountOut for exact input.");let i=D(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",s==="v4"?128:160),n=_(t.tokenIn),c=_(t.tokenOut);if(n===c)throw new o("Swap requires different input and output currencies.");let x=u.clientFor(S),p=await x.getBlock(),L=J(t.slippageBps),j,I,m,O,A,f,d,C;if(s==="v4"){if(t.path!==void 0||t.fees!==void 0)throw new o("V4 uses poolKey or poolKeys; omit path and fees.");if(t.poolKey===void 0==(t.poolKeys===void 0))throw new o("Provide poolKey or poolKeys, not both.");if(t.poolKeys!==void 0){if(!Array.isArray(t.poolKeys)||t.poolKeys.length<1||t.poolKeys.length>5)throw new o("Provide 1 to 5 v4 poolKeys.");let a=t.poolKeys.map(P=>U(P));j=a,I=ve(a,n,c,e),m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?c:n,path:I,exactAmount:i}],account:r,gas:H,blockNumber:p.number})).result[0]}else{if(f=U(t.poolKey),![f.currency0,f.currency1].includes(n)||![f.currency0,f.currency1].includes(c))throw new o("PoolKey currencies differ from the requested swap.");m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:f,zeroForOne:n===f.currency0,exactAmount:i,hookData:"0x"}],account:r,gas:H,blockNumber:p.number})).result[0]}A="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===v||c===v)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(d=Array.isArray(t.path)?t.path.map(W):[n,c],d.length<2||d.length>6||d[0]!==n||d.at(-1)!==c||new Set(d).size!==d.length||d.includes(v))throw new o("Path must contain 2 to 6 distinct ERC-20 tokens in input-to-output order.");if(s==="v2"){if(t.fees!==void 0)throw new o("V2 fees are fixed by the pair; omit fees.");let a=await x.readContract({address:ee,abi:te,functionName:e?"getAmountsIn":"getAmountsOut",args:[i,d],blockNumber:p.number});m=e?a[0]:a.at(-1),A=e?"0x09":"0x08"}else{let a=t.fees;if(!Array.isArray(a)||a.length!==d.length-1||a.some(P=>typeof P!="number"||!Number.isInteger(P)||P<0||P>1e6))throw new o("Provide one integer pool fee in hundredths of a basis point (3000 = 0.3%) per v3 path hop.");if(!G(await x.readContract({address:ie,abi:se,functionName:"factory",blockNumber:p.number}),N[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");C=Se(d,a,e),m=(await x.simulateContract({address:ie,abi:se,functionName:e?"quoteExactOutput":"quoteExactInput",args:[C,i],account:r,gas:H,blockNumber:p.number})).result[0],A=e?"0x01":"0x00"}}if(m<=0n)throw new o("No positive Uniswap quote is available.");let k=await ne(x,{version:s,input:n,path:d,fees:t.fees,poolKeys:f?[f]:j,exactOutput:e,amount:i,quoted:m,blockNumber:p.number,allowHighFeePools:t.allowHighFeePools===!0,acceptValueLoss:t.acceptValueLoss===!0}),{confirmationWarnings:pe,...me}=k,R=e?t.maxAmountIn:t.minAmountOut;if(!l&&R===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let y=R===void 0?e?(m*BigInt(1e4+L)+9999n)/10000n:m*BigInt(1e4-L)/10000n:D(R,e?"maxAmountIn":"minAmountOut",s==="v4"?128:160);if(y<=0n||(e?y<m:y>m))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let h=e?y:i;if(h>=1n<<160n||s==="v4"&&(h>=1n<<128n||y>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[le,fe]=await Promise.all([z(u,n,p.number),z(u,c,p.number)]),X={...me,version:s,input:{token:le,amount:(e?m:i).toString()},output:{token:fe,amount:(e?i:m).toString()},[e?"maxAmountIn":"minAmountOut"]:y.toString(),blockNumber:p.number.toString(),expiresAt:(p.timestamp+60n).toString()};if(l)return{quote:X,...k.warnings?{warnings:k.warnings}:{},summary:"Read-only on-chain quote. Repeat the same route with the returned bound in uniswap_swap; execution gets a fresh quote and preview."};let q=p.timestamp+300n,K=[],B="Native ETH input; no token approvals.";if(n!==v){let a=await x.readContract({address:n,abi:be,functionName:"allowance",args:[r,V],blockNumber:p.number});a!==h&&K.push(u.approval(n,V,h.toString(),S)),B=`${a===h?"Reuse existing exact ERC-20 allowance of":"Set ERC-20 allowance to exactly"} ${h} input base units to Permit2; exact router permit.`,K.push(u.unsignedTx({to:V,data:oe({abi:we,functionName:"approve",args:[n,$,h,Number(q)]}),value:"0",chainId:S,description:`Permit exactly ${h} input base units to Universal Router until ${q}.`}))}if(s==="v4"){let a=I?w(ke,[{exactCurrency:e?c:n,path:I,minHopPriceX36:[],amount:i,limit:y}]):w(ge,[{poolKey:f,zeroForOne:n===f.currency0,amount:i,limit:y,minHopPriceX36:0n,hookData:"0x"}]);O=w(Ie,[I?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[a,w(ue,[n,h]),w(ue,[c,e?i:y])]])}else s==="v2"?O=w(Pe,[r,i,y,d,!0,[]]):O=w(Ae,[r,i,y,C,!0,[]]);let Q=[O];return n===v&&e&&(A=`${A}04`,Q.push(w(g("address,address,uint256"),[v,r,0n]))),K.push(u.unsignedTx({to:$,data:oe({abi:xe,functionName:"execute",args:[A,Q,q]}),value:n===v?h.toString():"0",chainId:S,description:`Uniswap ${s} ${e?"exact output":"exact input"} swap; recipient ${r}; deadline ${q}.`})),{...k.warnings?{warnings:k.warnings}:{},confirmationWarnings:pe,...await Y(u,K,r,`${(k.warnings??[]).join(" ")}${k.warnings?.length?" ":""}Swap through Universal Router 2.1.2. ${B} Fixed output/input bound and five-minute on-chain deadline. Venue fees included; gas excluded.`),quote:X}}function Ue(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:de},execute:(r,l)=>Ee(u,r,l,t)}))}}export{ie as a,re as b,xe as c,we as d,se as e,ae as f,ke as g,ve as h,ge as i,Ae as j,Pe as k,Se as l,Ee as m,Ue as n};
1
+ import{b as ne}from"./CZQ2CGYV.js";import{b as ee,e as te}from"./ROQQ62LP.js";import{a as D,b as W,c as _,d as J,e as z,f as Y,g as Z}from"./LJJYYUEG.js";import{d as V,e as $,w as U}from"./WBNFRPAT.js";import{a as H}from"./IOYRL6AY.js";import{a as E}from"./66F5ZH34.js";import{c as b,g as G}from"./NWNYJ26T.js";import{b as S,j as N}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as w,encodeFunctionData as oe,encodePacked as he,erc20Abi as be,getAddress as ce,parseAbi as T,parseAbiParameters as g,zeroAddress as v}from"viem";var ie=ce("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),re=ce(N[4663].ponsTrade.quoter.address),xe=T(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),we=T(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),se=T(["function factory() view returns (address)","function quoteExactInput(bytes path,uint256 amountIn) returns (uint256,uint160[],uint32[],uint256)","function quoteExactOutput(bytes path,uint256 amountOut) returns (uint256,uint160[],uint32[],uint256)"]),F="(address intermediateCurrency,uint24 fee,int24 tickSpacing,address hooks,bytes hookData)",M="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",ae=T([`function quoteExactInput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactOutput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactInputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`,`function quoteExactOutputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`]),ke=g(`(address exactCurrency,${F}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function ve(u,t,r,l){let s=[],e=l?r:t,i=new Set([e]);for(let n of l?[...u].reverse():u){let c=n.currency0===e?n.currency1:n.currency1===e?n.currency0:void 0;if(!c||i.has(c))throw new o("V4 poolKeys must form a continuous route without repeated currencies.");s.push({intermediateCurrency:c,fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks,hookData:"0x"}),e=c,i.add(e)}if(e!==(l?t:r))throw new o("V4 route does not end at the requested currency.");return s}var ge=g(`(${M} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),Ae=g("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),Pe=g("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),ue=g("address,uint256"),Ie=g("bytes,bytes[]");function Se(u,t,r){let l=r?[...u].reverse():u,s=r?[...t].reverse():t,e=l[0];return s.forEach((i,n)=>{e=`${e}${he(["uint24","address"],[i,l[n+1]]).slice(2)}`}),e}var de={version:{description:'Uniswap version: "v2" for pairs, "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v2","v3","v4"]},tokenIn:{...b,description:"Input token address; the zero address means native ETH for v4."},tokenOut:{...b,description:"Output token address; the zero address means native ETH for v4."},path:{description:"Two to six distinct ERC-20 token addresses in input-to-output order for v2 or v3.",type:"array",minItems:2,maxItems:6,items:b},fees:{type:"array",description:"One v3 pool fee per path hop, in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",items:{type:"integer",minimum:0,maximum:1e6}},poolKeys:{description:"One to five v4 pool keys in input-to-output route order, without repeated currencies.",type:"array",minItems:1,maxItems:5,items:{type:"object",required:["currency0","currency1","fee","tickSpacing","hooks"],properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},additionalProperties:!1}},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},allowHighFeePools:{description:"Allow pools above Oak's usual fee threshold; review the fee warning before confirming.",type:"boolean"},acceptValueLoss:{description:"Acknowledge the quoted value-loss warning; review the measured loss before confirming.",type:"boolean"},amountIn:E('Amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),amountOut:E('Amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),minAmountOut:E('Minimum amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),maxAmountIn:E('Maximum amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999}};async function Ee(u,t,r,l=!1){Z(t,Object.keys(de));let s=t.version;if(!["v2","v3","v4"].includes(String(s)))throw new o("Provide version v2, v3 or v4.");let e=t.amountOut!==void 0;if(t.amountIn!==void 0===e)throw new o("Provide exactly one of amountIn or amountOut.");if(e&&t.minAmountOut!==void 0||!e&&t.maxAmountIn!==void 0)throw new o("Use maxAmountIn for exact output, minAmountOut for exact input.");let i=D(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",s==="v4"?128:160),n=_(t.tokenIn),c=_(t.tokenOut);if(n===c)throw new o("Swap requires different input and output currencies.");let x=u.clientFor(S),p=await x.getBlock(),L=J(t.slippageBps),j,I,m,O,A,f,d,C;if(s==="v4"){if(t.path!==void 0||t.fees!==void 0)throw new o("V4 uses poolKey or poolKeys; omit path and fees.");if(t.poolKey===void 0==(t.poolKeys===void 0))throw new o("Provide poolKey or poolKeys, not both.");if(t.poolKeys!==void 0){if(!Array.isArray(t.poolKeys)||t.poolKeys.length<1||t.poolKeys.length>5)throw new o("Provide 1 to 5 v4 poolKeys.");let a=t.poolKeys.map(P=>U(P));j=a,I=ve(a,n,c,e),m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?c:n,path:I,exactAmount:i}],account:r,gas:H,blockNumber:p.number})).result[0]}else{if(f=U(t.poolKey),![f.currency0,f.currency1].includes(n)||![f.currency0,f.currency1].includes(c))throw new o("PoolKey currencies differ from the requested swap.");m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:f,zeroForOne:n===f.currency0,exactAmount:i,hookData:"0x"}],account:r,gas:H,blockNumber:p.number})).result[0]}A="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===v||c===v)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(d=Array.isArray(t.path)?t.path.map(W):[n,c],d.length<2||d.length>6||d[0]!==n||d.at(-1)!==c||new Set(d).size!==d.length||d.includes(v))throw new o("Path must contain 2 to 6 distinct ERC-20 tokens in input-to-output order.");if(s==="v2"){if(t.fees!==void 0)throw new o("V2 fees are fixed by the pair; omit fees.");let a=await x.readContract({address:ee,abi:te,functionName:e?"getAmountsIn":"getAmountsOut",args:[i,d],blockNumber:p.number});m=e?a[0]:a.at(-1),A=e?"0x09":"0x08"}else{let a=t.fees;if(!Array.isArray(a)||a.length!==d.length-1||a.some(P=>typeof P!="number"||!Number.isInteger(P)||P<0||P>1e6))throw new o("Provide one integer pool fee in hundredths of a basis point (3000 = 0.3%) per v3 path hop.");if(!G(await x.readContract({address:ie,abi:se,functionName:"factory",blockNumber:p.number}),N[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");C=Se(d,a,e),m=(await x.simulateContract({address:ie,abi:se,functionName:e?"quoteExactOutput":"quoteExactInput",args:[C,i],account:r,gas:H,blockNumber:p.number})).result[0],A=e?"0x01":"0x00"}}if(m<=0n)throw new o("No positive Uniswap quote is available.");let k=await ne(x,{version:s,input:n,path:d,fees:t.fees,poolKeys:f?[f]:j,exactOutput:e,amount:i,quoted:m,blockNumber:p.number,allowHighFeePools:t.allowHighFeePools===!0,acceptValueLoss:t.acceptValueLoss===!0}),{confirmationWarnings:pe,...me}=k,R=e?t.maxAmountIn:t.minAmountOut;if(!l&&R===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let y=R===void 0?e?(m*BigInt(1e4+L)+9999n)/10000n:m*BigInt(1e4-L)/10000n:D(R,e?"maxAmountIn":"minAmountOut",s==="v4"?128:160);if(y<=0n||(e?y<m:y>m))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let h=e?y:i;if(h>=1n<<160n||s==="v4"&&(h>=1n<<128n||y>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[le,fe]=await Promise.all([z(u,n,p.number),z(u,c,p.number)]),X={...me,version:s,input:{token:le,amount:(e?m:i).toString()},output:{token:fe,amount:(e?i:m).toString()},[e?"maxAmountIn":"minAmountOut"]:y.toString(),blockNumber:p.number.toString(),expiresAt:(p.timestamp+60n).toString()};if(l)return{quote:X,...k.warnings?{warnings:k.warnings}:{},summary:"Read-only on-chain quote. Repeat the same route with the returned bound in uniswap_swap; execution gets a fresh quote and preview."};let q=p.timestamp+300n,K=[],B="Native ETH input; no token approvals.";if(n!==v){let a=await x.readContract({address:n,abi:be,functionName:"allowance",args:[r,V],blockNumber:p.number});a!==h&&K.push(u.approval(n,V,h.toString(),S)),B=`${a===h?"Reuse existing exact ERC-20 allowance of":"Set ERC-20 allowance to exactly"} ${h} input base units to Permit2; exact router permit.`,K.push(u.unsignedTx({to:V,data:oe({abi:we,functionName:"approve",args:[n,$,h,Number(q)]}),value:"0",chainId:S,description:`Permit exactly ${h} input base units to Universal Router until ${q}.`}))}if(s==="v4"){let a=I?w(ke,[{exactCurrency:e?c:n,path:I,minHopPriceX36:[],amount:i,limit:y}]):w(ge,[{poolKey:f,zeroForOne:n===f.currency0,amount:i,limit:y,minHopPriceX36:0n,hookData:"0x"}]);O=w(Ie,[I?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[a,w(ue,[n,h]),w(ue,[c,e?i:y])]])}else s==="v2"?O=w(Pe,[r,i,y,d,!0,[]]):O=w(Ae,[r,i,y,C,!0,[]]);let Q=[O];return n===v&&e&&(A=`${A}04`,Q.push(w(g("address,address,uint256"),[v,r,0n]))),K.push(u.unsignedTx({to:$,data:oe({abi:xe,functionName:"execute",args:[A,Q,q]}),value:n===v?h.toString():"0",chainId:S,description:`Uniswap ${s} ${e?"exact output":"exact input"} swap; recipient ${r}; deadline ${q}.`})),{...k.warnings?{warnings:k.warnings}:{},confirmationWarnings:pe,...await Y(u,K,r,`${(k.warnings??[]).join(" ")}${k.warnings?.length?" ":""}Swap through Universal Router 2.1.2. ${B} Fixed output/input bound and five-minute on-chain deadline. Venue fees included; gas excluded.`),quote:X}}function Ue(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:de},execute:(r,l)=>Ee(u,r,l,t)}))}}export{ie as a,re as b,xe as c,we as d,se as e,ae as f,ke as g,ve as h,ge as i,Ae as j,Pe as k,Se as l,Ee as m,Ue as n};
@@ -1 +1 @@
1
- import{b as W,c as K}from"./YDNTY67T.js";import{L as z}from"./7QKYDNF6.js";import{a as D}from"./OARVU3RC.js";import{c as C}from"./WUT7TZYM.js";import{c as B,f as R,i as F,j as L,k as H}from"./L646YWDP.js";import{a as V}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as O}from"./NWNYJ26T.js";import{a as A}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as I,erc20Abi as j,getAddress as P,parseAbi as k}from"viem";var f=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 U(t,n=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!n&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function ce(t,n,y){return["details","analytics","manage","mint",n==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...n==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...n==="longbow"?{vault:{type:"string",enum:y.map(i=>i.vault),description:"Pinned vault address on chain 4663; use longbow_list to compare vault names."}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(`Assets to receive, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`),maxShares:u('Most vault shares you will burn, in share base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),deadline:u("Absolute Unix seconds deadline, no more than five minutes ahead. Example: 1800000000.")}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u('Vault shares to mint, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxAssets:u(`Most of the vault's asset you will pay, in base units (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)}),e==="redeem"&&(m.shares=u('Vault shares to redeem, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.')),e==="withdraw_assets"&&(m.amount=u(`Assets to withdraw, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),minAmountOut:u(`Least of the vault's asset you must receive, in base units (read its decimals). Example: "1000000" = 1 USDG.`)});let J=C(t,`${n}_manage`,y[0].vault,y[0].asset),N=D(t,`${n}_analytics`,y[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:N.inputSchema;Object.assign(m,i.properties),e==="analytics"&&n==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"],description:"Report: apy (realized yield from share price) or published_apy (yield published by the project)."}),$.push(...i.required)}return{name:`${n}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&n==="netnet"?{allOf:N.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(V(r),Object.keys(i).some(c=>!Object.hasOwn(m,c)))throw new o("Unsupported vault feature argument.");let _=n==="netnet"?y[0]:y.find(c=>typeof i.vault=="string"&&O(c.vault,i.vault));if(!_)throw new o("Choose a current vault returned by the project list tool.");let{vault:s,asset:a}=_,b={...i};if(delete b.vault,e==="details")return F(t,`${n}_details`,s,a).execute(b,r);if(e==="manage")return C(t,`${n}_manage`,s,a).execute(b,r);if(e==="analytics"){if(n==="longbow"&&i.view==="published_apy")return K(t,s,a,b);if(n==="longbow"&&i.view==="apy")return W(t,s,a,b);if(n==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await D(t,`${n}_analytics`,s).execute(b,r),asset:{...a,address:P(a.address)}}}if(e==="in_kind_exit")return z(t,s,a,i,r);let h=t.clientFor(A);if(await h.getChainId()!==A)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([h.readContract({address:s,abi:f,functionName:"asset"}),h.readContract({address:s,abi:f,functionName:"decimals"}),h.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(P(Q)!==P(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let T=e==="force_exit"?await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let c=await R(t,h,s,r,T,B(i.maxPenaltyAssets),a),E=U(i.minAmountOut),w=[c.tx],v=await t.preview(w,r);return H(v.changes,s,T,E,a),{txs:w,preview:v,summary:`${L(c.plan,a.symbol)} ${v.summary}`}}let d=e==="mint",g=e==="redeem",l=U(d||g?i.shares:i.amount),x=await h.readContract({address:s,abi:f,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[l]});if(x<=0n||d&&x>U(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let q=d?void 0:await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]});if(!d&&(g?l:x)>q)throw new o("The wallet share balance cannot cover this exit.");let Z=d?I({abi:f,functionName:"mint",args:[l,r]}):g?I({abi:f,functionName:"redeem",args:[l,r,r]}):I({abi:f,functionName:"withdraw",args:[l,r,r]}),G=`${e} ${l} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${s}; beneficiary ${r}.`,M=[...d?[t.approval(a.address,s,x.toString(),A)]:[],t.unsignedTx({to:s,data:Z,value:"0",chainId:A,description:G})],S=await t.preview(M,r),p=(c,E)=>S.changes.filter(w=>w.token.chainId===A&&O(w.token.address,c)).reduce((w,v)=>{if(v.token.decimals!==E||!/^-?\d+$/.test(v.amount))throw new o("Invalid vault preview metadata.");return w+BigInt(v.amount)},0n);if(d?p(a.address,a.decimals)!==-x||p(s,18)!==l:g?p(s,18)!==-l||p(a.address,a.decimals)<=0n:p(a.address,a.decimals)!==l||-p(s,18)<=0n||-p(s,18)>q)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:M,preview:S,summary:`${G} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${S.summary}`}}catch(_){throw new o(t.plainError(_))}}}})}export{ce as a};
1
+ import{L as z}from"./JPPQDELB.js";import{b as W,c as K}from"./A3BJSQ23.js";import{a as D}from"./YBLJ75U5.js";import{c as C}from"./LCH6F5HT.js";import{c as B,f as R,i as F,j as L,k as H}from"./X24YTJST.js";import{a as V}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as O}from"./NWNYJ26T.js";import{b as A}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as I,erc20Abi as j,getAddress as P,parseAbi as k}from"viem";var f=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 U(t,n=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!n&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function ce(t,n,y){return["details","analytics","manage","mint",n==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...n==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...n==="longbow"?{vault:{type:"string",enum:y.map(i=>i.vault),description:"Pinned vault address on chain 4663; use longbow_list to compare vault names."}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(`Assets to receive, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`),maxShares:u('Most vault shares you will burn, in share base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),deadline:u("Absolute Unix seconds deadline, no more than five minutes ahead. Example: 1800000000.")}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u('Vault shares to mint, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxAssets:u(`Most of the vault's asset you will pay, in base units (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)}),e==="redeem"&&(m.shares=u('Vault shares to redeem, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.')),e==="withdraw_assets"&&(m.amount=u(`Assets to withdraw, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),minAmountOut:u(`Least of the vault's asset you must receive, in base units (read its decimals). Example: "1000000" = 1 USDG.`)});let J=C(t,`${n}_manage`,y[0].vault,y[0].asset),N=D(t,`${n}_analytics`,y[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:N.inputSchema;Object.assign(m,i.properties),e==="analytics"&&n==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"],description:"Report: apy (realized yield from share price) or published_apy (yield published by the project)."}),$.push(...i.required)}return{name:`${n}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&n==="netnet"?{allOf:N.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(V(r),Object.keys(i).some(c=>!Object.hasOwn(m,c)))throw new o("Unsupported vault feature argument.");let _=n==="netnet"?y[0]:y.find(c=>typeof i.vault=="string"&&O(c.vault,i.vault));if(!_)throw new o("Choose a current vault returned by the project list tool.");let{vault:s,asset:a}=_,b={...i};if(delete b.vault,e==="details")return F(t,`${n}_details`,s,a).execute(b,r);if(e==="manage")return C(t,`${n}_manage`,s,a).execute(b,r);if(e==="analytics"){if(n==="longbow"&&i.view==="published_apy")return K(t,s,a,b);if(n==="longbow"&&i.view==="apy")return W(t,s,a,b);if(n==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await D(t,`${n}_analytics`,s).execute(b,r),asset:{...a,address:P(a.address)}}}if(e==="in_kind_exit")return z(t,s,a,i,r);let h=t.clientFor(A);if(await h.getChainId()!==A)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([h.readContract({address:s,abi:f,functionName:"asset"}),h.readContract({address:s,abi:f,functionName:"decimals"}),h.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(P(Q)!==P(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let T=e==="force_exit"?await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let c=await R(t,h,s,r,T,B(i.maxPenaltyAssets),a),E=U(i.minAmountOut),w=[c.tx],v=await t.preview(w,r);return H(v.changes,s,T,E,a),{txs:w,preview:v,summary:`${L(c.plan,a.symbol)} ${v.summary}`}}let d=e==="mint",g=e==="redeem",l=U(d||g?i.shares:i.amount),x=await h.readContract({address:s,abi:f,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[l]});if(x<=0n||d&&x>U(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let q=d?void 0:await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]});if(!d&&(g?l:x)>q)throw new o("The wallet share balance cannot cover this exit.");let Z=d?I({abi:f,functionName:"mint",args:[l,r]}):g?I({abi:f,functionName:"redeem",args:[l,r,r]}):I({abi:f,functionName:"withdraw",args:[l,r,r]}),G=`${e} ${l} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${s}; beneficiary ${r}.`,M=[...d?[t.approval(a.address,s,x.toString(),A)]:[],t.unsignedTx({to:s,data:Z,value:"0",chainId:A,description:G})],S=await t.preview(M,r),p=(c,E)=>S.changes.filter(w=>w.token.chainId===A&&O(w.token.address,c)).reduce((w,v)=>{if(v.token.decimals!==E||!/^-?\d+$/.test(v.amount))throw new o("Invalid vault preview metadata.");return w+BigInt(v.amount)},0n);if(d?p(a.address,a.decimals)!==-x||p(s,18)!==l:g?p(s,18)!==-l||p(a.address,a.decimals)<=0n:p(a.address,a.decimals)!==l||-p(s,18)<=0n||-p(s,18)>q)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:M,preview:S,summary:`${G} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${S.summary}`}}catch(_){throw new o(t.plainError(_))}}}})}export{ce as a};
@@ -1 +1 @@
1
- import{b as q,o as U}from"./CAWTAR5V.js";import{a as le}from"./KKPMOAVI.js";import{a as pe,b as fe}from"./Y77EVVT4.js";import{a as ye}from"./XHYFISVV.js";import{a as J,b as ue,c as me}from"./5PI57UC2.js";import{e as F,h as L,m as ce}from"./PV5FDT6O.js";import{b as ae}from"./SPJCSEKP.js";import{a as E}from"./IOYRL6AY.js";import{c as de}from"./SCG5HWMN.js";import{c as O,e as A,g as w,k as ie,l as oe,m as re,n as se}from"./NWNYJ26T.js";import{a as h,i as te}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ce,encodeAbiParameters as j,encodeFunctionData as D,erc20Abi as V,isAddress as Ie,parseAbi as xe,parseAbiParameters as W,toHex as z,zeroAddress as Z}from"viem";var x=te[h].clanker,he=xe(["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=xe(["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)"]),P={address:x.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},ve="https://www.clanker.world/api/tokens",be={type:"string",pattern:"^\\d+$"},ge={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function C(e){return oe(ie(e,F),F)}function ke(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r(`Provide an explicit bytes32 ${t}.`);return e}function I(e,t,s=!1){if(e===void 0&&!s)return"";if(typeof e!="string"||s&&!e.trim())throw new r(`Provide ${t} as text.`);return e}function G(e,t=256){return se(e,`Amount exceeds the uint${t} range.`,{bits:t})}function K(e){return re(e,"The contract returned an invalid amount.").toString()}function B(e,t){let s=Object.keys(e).find(u=>!t.includes(u));if(s)throw new r(`Unsupported Clanker input: ${s}.`)}function we(e,t){return t.changes.map(({token:s,amount:u})=>{let g=u.startsWith("-");return`${g?"-":"+"}${e.formatAmount(g?u.slice(1):u,s.decimals)} ${s.symbol} (${s.address}, chain ${s.chainId})`}).join("; ")}function Se(e){return A(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=>A(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"&&Ie(t[s],{strict:!1})))}function Q(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=>Q(s,t+1)):A(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,u])=>[s,Q(u,t+1)])):null}function _e(e){return{...Q(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(!A(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 r("Use the cursor returned by the previous clanker_browse page.")}}async function Ne(e,t={}){B(t,["q","limit","cursor","deployer"]);let s=t.limit??10;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>20)throw new r("Choose an indexer limit from 1 to 20.");let u=new URL(ve);u.searchParams.set("chainId",String(h)),u.searchParams.set("limit",String(s)),t.q!==void 0&&u.searchParams.set("q",I(t.q,"search")),t.cursor!==void 0&&u.searchParams.set("cursor",I(t.cursor,"cursor",!0)),t.deployer!==void 0&&u.searchParams.set("msgSender",C(t.deployer));let g=await de(e.http,u.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},Se);return{tokens:g.data.filter(v=>v.chain_id===h&&w(v.factory_address,x.factory.address)),total:g.total,cursor:g.cursor||null,tokensDeployed:g.tokensDeployed}}var Oe=e=>{let t=()=>e.clientFor(h),s=async n=>{try{return await n()}catch(i){throw new r(e.plainError(i))}},u=(n,i,a,c="0")=>e.unsignedTx({to:n,data:i,value:c,chainId:h,description:a}),g=async(n,i)=>K(await t().readContract({address:x.fee_locker.address,abi:T,functionName:"availableFees",args:[n,i]})),v=async n=>{if(w(n,P.address))return P;let[i,a]=await Promise.all([t().readContract({address:n,abi:V,functionName:"symbol"}),t().readContract({address:n,abi:V,functionName:"decimals"})]);if(typeof i!="string"||!i.trim()||!Number.isInteger(a)||a<0||a>255)throw new r("The contract returned invalid token metadata.");return{address:n,chainId:h,symbol:i,decimals:a}},X=async n=>{n.cursor!==void 0&&$e(n.cursor);let i=await Ne(e,n);return{...i,tokens:i.tokens.map(_e)}},Ae=async(n,i)=>{if(B(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 r("Clanker launches use vanity false and an explicit salt.");let a=I(n.name,"token name",!0),c=I(n.symbol,"token symbol",!0),b=ke(n.salt,"salt"),y=G(n.initialBuy??"0"),l=n.slippageBps??q;if(typeof l!="number")throw new r("Slippage must be an integer from 0 to 9999 bps.");U("0",l);let o=n.minAmountOut===void 0?void 0:G(n.minAmountOut,128);if(o!==void 0&&o<=1n)throw new r("Initial-buy minimum must exceed one base unit.");if(!y&&o!==void 0)throw new r("A minimum requires a positive initial buy.");let m=ue(n,i);L(n.feeBps??100,0,1e3);let p=fe(n);if(y&&!w(p.poolConfig.pairedToken,P.address))throw new r("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:i,recipient:i,bps:1e4,feePreference:0}];if(!Array.isArray(d)||!d.length||d.length>7)throw new r("Provide one to seven reward allocations.");let k=d.map(f=>{if(!A(f))throw new r("Provide reward allocations as objects.");return B(f,["admin","recipient","bps","feePreference"]),{admin:C(f.admin),recipient:C(f.recipient),bps:L(f.bps,1,1e4),feePreference:L(f.feePreference??0,0,2)}});if(k.reduce((f,S)=>f+S.bps,0)!==1e4)throw new r("Reward allocations must total 10000 bps.");let _={tokenConfig:{tokenAdmin:i,name:a,symbol:c,salt:b,image:I(n.image,"image"),metadata:I(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):I(n.context,"context"),originatingChainId:BigInt(h)},poolConfig:p.poolConfig,lockerConfig:{locker:x.locker.address,rewardAdmins:k.map(f=>f.admin),rewardRecipients:k.map(f=>f.recipient),rewardBps:k.map(f=>f.bps),tickLower:p.tickLower,tickUpper:p.tickUpper,positionBps:p.positionBps,lockerData:j(W("(uint8[])"),[[k.map(f=>f.feePreference)]])},mevModuleConfig:{mevModule:x.mev_module.address,mevModuleData:j(W("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:m},Pe=await t().simulateContract({address:x.factory.address,abi:he,functionName:"deployToken",args:[_],account:i,value:0n,gas:E}),M=C(Pe.result),Y=f=>{let S=[...m,...y?[{extension:x.devbuy.address,msgValue:y,extensionBps:0,extensionData:j(W("(address,address,uint24,int24,address),uint128,address"),[[Z,Z,0,0,Z],f,i])}]:[]];return u(x.factory.address,D({abi:he,functionName:"deployToken",args:[{..._,extensionConfigs:S}]}),`Launch ${a} (${c}); initial buy ${y} native ETH base units.`,y.toString())};if(y&&o===void 0){let S=(await e.preview([Y(0n)],i)).changes.filter($=>$.token.chainId===h&&w($.token.address,M)&&$.token.decimals===18).reduce(($,ne)=>$+(/^-?\d+$/.test(ne.amount)?BigInt(ne.amount):(()=>{throw new r("Invalid initial-buy simulation amount.")})()),0n);if(S<=0n)throw new r("Initial-buy simulation returned no token output.");if(o=G(U(S.toString(),l),128),o<=1n)throw new r("Initial-buy output is too small for a protected minimum.")}let ee=[Y(o??0n)],H=await e.preview(ee,i);return{txs:ee,preview:H,predictedToken:M,token:{address:M,chainId:h,symbol:c,decimals:18},...o!==void 0?{minAmountOut:o.toString()}:{},summary:`Launch ${c} at ${M} (CREATE2 address predicted from simulation); vanity false; salt ${b}. Supply 100000000000000000000000000000 base units (18 decimals). ${p.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(p)}. Reward allocations: ${JSON.stringify(k)}. Extensions: ${JSON.stringify({vault:n.vault,airdrop:n.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${H.summary} ${we(e,H)}`}},Te=async(n,i)=>{if(B(n,["token","poolId","collect"]),n.collect!==void 0&&typeof n.collect!="boolean")throw new r("collect must be boolean.");if(n.collect===!1&&n.poolId!==void 0)throw new r("poolId requires collection.");if(n.collect===!0&&n.token===void 0)throw new r("Collection requires a Clanker token.");if(n.poolId!==void 0&&n.token===void 0)throw new r("A pool ID requires its Clanker token.");let a=[P],c=[];if(n.token!==void 0){let o=C(n.token);if(w(o,P.address))throw new r("Provide the launched Clanker token, not WETH.");if(n.collect!==!1){let m=await ce(e,o),{poolId:p,hook:d,locker:k}=m;if(n.poolId!==void 0&&!w(ke(n.poolId,"pool ID for fee collection"),p))throw new r("The supplied pool ID does not match the onchain Clanker pool.");w(m.pairedToken,P.address)||a.splice(0,1,await v(m.pairedToken));let _=await t().readContract({address:d,abi:T,functionName:"mevModuleEnabled",args:[p]});if(typeof _!="boolean")throw new r("The hook returned an invalid MEV guard state.");_&&c.push(u(d,D({abi:T,functionName:"mevModuleOperational",args:[p]}),"Update the Clanker pool MEV guard before collection.")),c.push(u(k,D({abi:T,functionName:"collectRewards",args:[o]}),"Collect pending LP fees into the fee locker."))}a.push(await v(o))}let b;if(c.length){if(await t().getChainId()!==h)throw new r("Fee simulation endpoint is on the wrong chain.");let o=[...c.map(d=>({from:i,gas:z(E),to:d.to,data:d.data,value:z(BigInt(d.value))})),...a.map(d=>({from:i,gas:z(E),to:x.fee_locker.address,data:D({abi:T,functionName:"availableFees",args:[i,d.address]}),value:"0x0"}))],m=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:o}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(m)||m.length!==1||!A(m[0])||!Array.isArray(m[0].calls)||m[0].calls.length!==o.length)throw new r("The endpoint returned an unexpected fee simulation response.");let p=m[0].calls;if(!p.every(d=>A(d)&&d.status==="0x1"&&!d.error))throw new r("Clanker fee collection simulation failed.");b=p.slice(c.length).map(d=>{if(!A(d)||typeof d.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(d.returnData))throw new r("The endpoint returned an invalid fee balance.");return K(Ce({abi:T,functionName:"availableFees",data:d.returnData}))})}else b=await Promise.all(a.map(o=>g(i,o.address)));let y=a.flatMap((o,m)=>BigInt(b[m])>0n?[{token:o,amount:b[m]}]:[]);if(!y.length)throw new r("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:o}of y)c.push(u(x.fee_locker.address,D({abi:T,functionName:"claim",args:[i,o.address]}),`Claim ${o.symbol} fees to ${i}.`));let l=await e.preview(c,i);return{txs:c,preview:l,fees:y,summary:`Claim fees to ${i}. WETH fees aggregate across all Clanker launches for this recipient. ${l.summary} ${we(e,l)}`}},R=(n,i,a,c)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:i,required:a,additionalProperties:!1},execute:(b,y)=>s(async()=>c(b,C(y)))});return{tools:[R("launch",{name:{type:"string",description:"Token name, shown publicly."},symbol:{type:"string",description:"Token ticker symbol, shown publicly."},salt:{...ge,description:"Deployment salt as 0x followed by 64 hex digits; it fixes the predicted token address."},image:{type:"string",description:"Image URL for the token. Public."},metadata:{type:"string",description:"Token metadata as a JSON string (description, social links). Public."},context:{type:"string",description:"Launch context as a JSON string. Defaults to Oak on Robinhood."},vanity:{const:!1,description:"Vanity address mining is not supported; leave false or omit."},initialBuy:{...be,description:"Native ETH base units, 18 decimals."},minAmountOut:{...be,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:q,description:"Slippage in basis points (50 = 0.5%) applied to the initial buy when minAmountOut is omitted."},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100,description:"Static LP fee in basis points (100 = 1%). Not allowed together with pool.dynamicFee."},pool:{...pe,description:"Optional pool setup: paired token, starting tick, tick spacing, liquidity positions and dynamic fee. Defaults to a WETH pool."},rewards:{type:"array",minItems:1,maxItems:7,description:"How LP fees are split, 1 to 7 rows with bps totaling 10000. Default: all to the launching wallet.",items:{type:"object",properties:{admin:{...O,description:"Address that can later change this row."},recipient:{...O,description:"Address that receives this row's share of LP fees."},bps:{type:"integer",minimum:1,maximum:1e4,description:"This row's share of LP fees in basis points (5000 = 50%)."},feePreference:{type:"integer",minimum:0,maximum:2,description:"Which token this row is paid in: 0 = both tokens (default), 1 = paired token, 2 = launched token."}},required:["admin","recipient","bps"],additionalProperties:!1}},vault:{...J.vault,description:"Optional vault extension: lock part of the supply, then vest it to an admin."},airdrop:{...J.airdrop,description:"Optional airdrop extension: reserve part of the supply for a Merkle-tree airdrop."}},["name","symbol","salt"],async(n,i)=>{let a=await Ae(n,i);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:{...O,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...ge,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",description:"Optional search text matched against token name or symbol."},limit:{type:"integer",minimum:1,maximum:20,description:"Maximum tokens to return, 1 to 20 (default 10)."},cursor:{type:"string",description:"Opaque pagination cursor returned by a previous clanker_browse call."},deployer:{...O,description:"Optional address of the deploying wallet to filter tokens by."}},[],X)],positions:n=>s(async()=>{C(n);let i=new Map,a=new Set,c;do{let l=await X({deployer:n,limit:20,...c?{cursor:c}:{}});for(let o of l.tokens)w(o.msg_sender,n)&&i.set(o.contract_address.toLowerCase(),o);if(l.cursor&&a.has(l.cursor))throw new r("The Clanker indexer repeated a pagination cursor.");l.cursor&&a.add(l.cursor),c=l.cursor??void 0}while(c);let b=[],y=[P];for(let[l,o]of i){let m=await v(o.contract_address),p={...m,symbol:N(m.symbol)},d=K(await t().readContract({address:p.address,abi:V,functionName:"balanceOf",args:[n]}));b.push({module:"clanker",id:`launch:${l}`,chainId:h,assets:[{token:p,amount:d}],description:`Indexed launch ${o.name}; wallet token balance, not locked LP principal.`}),y.some(k=>w(k.address,p.address))||y.push(p)}for(let l of y){let o=await g(n,l.address);BigInt(o)>0n&&b.push({module:"clanker",id:`fees:${l.address.toLowerCase()}`,chainId:h,assets:[{token:l,amount:o}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return b})}},ze=e=>ae("clanker",[Oe(e),le(e),me(e),ye(e)]);export{Ne as a,Oe as b,ze as c};
1
+ import{b as q,o as U}from"./LKX5WDOQ.js";import{a as le}from"./ELHRXA5U.js";import{a as pe,b as fe}from"./DGDMRATN.js";import{a as ye}from"./4Z3IGMU6.js";import{a as J,b as ue,c as me}from"./C76D54YG.js";import{e as F,h as L,m as ce}from"./TXGZ6NWN.js";import{b as ae}from"./SPJCSEKP.js";import{a as E}from"./IOYRL6AY.js";import{c as de}from"./SCG5HWMN.js";import{c as O,e as A,g as w,k as ie,l as oe,m as re,n as se}from"./NWNYJ26T.js";import{b as h,j as te}from"./TI727O2H.js";import{a as r}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ce,encodeAbiParameters as j,encodeFunctionData as D,erc20Abi as V,isAddress as Ie,parseAbi as xe,parseAbiParameters as W,toHex as z,zeroAddress as Z}from"viem";var x=te[h].clanker,he=xe(["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=xe(["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)"]),P={address:x.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},ve="https://www.clanker.world/api/tokens",be={type:"string",pattern:"^\\d+$"},ge={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function C(e){return oe(ie(e,F),F)}function ke(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r(`Provide an explicit bytes32 ${t}.`);return e}function I(e,t,s=!1){if(e===void 0&&!s)return"";if(typeof e!="string"||s&&!e.trim())throw new r(`Provide ${t} as text.`);return e}function G(e,t=256){return se(e,`Amount exceeds the uint${t} range.`,{bits:t})}function K(e){return re(e,"The contract returned an invalid amount.").toString()}function B(e,t){let s=Object.keys(e).find(u=>!t.includes(u));if(s)throw new r(`Unsupported Clanker input: ${s}.`)}function we(e,t){return t.changes.map(({token:s,amount:u})=>{let g=u.startsWith("-");return`${g?"-":"+"}${e.formatAmount(g?u.slice(1):u,s.decimals)} ${s.symbol} (${s.address}, chain ${s.chainId})`}).join("; ")}function Se(e){return A(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=>A(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"&&Ie(t[s],{strict:!1})))}function Q(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=>Q(s,t+1)):A(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,u])=>[s,Q(u,t+1)])):null}function _e(e){return{...Q(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(!A(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 r("Use the cursor returned by the previous clanker_browse page.")}}async function Ne(e,t={}){B(t,["q","limit","cursor","deployer"]);let s=t.limit??10;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>20)throw new r("Choose an indexer limit from 1 to 20.");let u=new URL(ve);u.searchParams.set("chainId",String(h)),u.searchParams.set("limit",String(s)),t.q!==void 0&&u.searchParams.set("q",I(t.q,"search")),t.cursor!==void 0&&u.searchParams.set("cursor",I(t.cursor,"cursor",!0)),t.deployer!==void 0&&u.searchParams.set("msgSender",C(t.deployer));let g=await de(e.http,u.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},Se);return{tokens:g.data.filter(v=>v.chain_id===h&&w(v.factory_address,x.factory.address)),total:g.total,cursor:g.cursor||null,tokensDeployed:g.tokensDeployed}}var Oe=e=>{let t=()=>e.clientFor(h),s=async n=>{try{return await n()}catch(i){throw new r(e.plainError(i))}},u=(n,i,a,c="0")=>e.unsignedTx({to:n,data:i,value:c,chainId:h,description:a}),g=async(n,i)=>K(await t().readContract({address:x.fee_locker.address,abi:T,functionName:"availableFees",args:[n,i]})),v=async n=>{if(w(n,P.address))return P;let[i,a]=await Promise.all([t().readContract({address:n,abi:V,functionName:"symbol"}),t().readContract({address:n,abi:V,functionName:"decimals"})]);if(typeof i!="string"||!i.trim()||!Number.isInteger(a)||a<0||a>255)throw new r("The contract returned invalid token metadata.");return{address:n,chainId:h,symbol:i,decimals:a}},X=async n=>{n.cursor!==void 0&&$e(n.cursor);let i=await Ne(e,n);return{...i,tokens:i.tokens.map(_e)}},Ae=async(n,i)=>{if(B(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 r("Clanker launches use vanity false and an explicit salt.");let a=I(n.name,"token name",!0),c=I(n.symbol,"token symbol",!0),b=ke(n.salt,"salt"),y=G(n.initialBuy??"0"),l=n.slippageBps??q;if(typeof l!="number")throw new r("Slippage must be an integer from 0 to 9999 bps.");U("0",l);let o=n.minAmountOut===void 0?void 0:G(n.minAmountOut,128);if(o!==void 0&&o<=1n)throw new r("Initial-buy minimum must exceed one base unit.");if(!y&&o!==void 0)throw new r("A minimum requires a positive initial buy.");let m=ue(n,i);L(n.feeBps??100,0,1e3);let p=fe(n);if(y&&!w(p.poolConfig.pairedToken,P.address))throw new r("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:i,recipient:i,bps:1e4,feePreference:0}];if(!Array.isArray(d)||!d.length||d.length>7)throw new r("Provide one to seven reward allocations.");let k=d.map(f=>{if(!A(f))throw new r("Provide reward allocations as objects.");return B(f,["admin","recipient","bps","feePreference"]),{admin:C(f.admin),recipient:C(f.recipient),bps:L(f.bps,1,1e4),feePreference:L(f.feePreference??0,0,2)}});if(k.reduce((f,S)=>f+S.bps,0)!==1e4)throw new r("Reward allocations must total 10000 bps.");let _={tokenConfig:{tokenAdmin:i,name:a,symbol:c,salt:b,image:I(n.image,"image"),metadata:I(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):I(n.context,"context"),originatingChainId:BigInt(h)},poolConfig:p.poolConfig,lockerConfig:{locker:x.locker.address,rewardAdmins:k.map(f=>f.admin),rewardRecipients:k.map(f=>f.recipient),rewardBps:k.map(f=>f.bps),tickLower:p.tickLower,tickUpper:p.tickUpper,positionBps:p.positionBps,lockerData:j(W("(uint8[])"),[[k.map(f=>f.feePreference)]])},mevModuleConfig:{mevModule:x.mev_module.address,mevModuleData:j(W("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:m},Pe=await t().simulateContract({address:x.factory.address,abi:he,functionName:"deployToken",args:[_],account:i,value:0n,gas:E}),M=C(Pe.result),Y=f=>{let S=[...m,...y?[{extension:x.devbuy.address,msgValue:y,extensionBps:0,extensionData:j(W("(address,address,uint24,int24,address),uint128,address"),[[Z,Z,0,0,Z],f,i])}]:[]];return u(x.factory.address,D({abi:he,functionName:"deployToken",args:[{..._,extensionConfigs:S}]}),`Launch ${a} (${c}); initial buy ${y} native ETH base units.`,y.toString())};if(y&&o===void 0){let S=(await e.preview([Y(0n)],i)).changes.filter($=>$.token.chainId===h&&w($.token.address,M)&&$.token.decimals===18).reduce(($,ne)=>$+(/^-?\d+$/.test(ne.amount)?BigInt(ne.amount):(()=>{throw new r("Invalid initial-buy simulation amount.")})()),0n);if(S<=0n)throw new r("Initial-buy simulation returned no token output.");if(o=G(U(S.toString(),l),128),o<=1n)throw new r("Initial-buy output is too small for a protected minimum.")}let ee=[Y(o??0n)],H=await e.preview(ee,i);return{txs:ee,preview:H,predictedToken:M,token:{address:M,chainId:h,symbol:c,decimals:18},...o!==void 0?{minAmountOut:o.toString()}:{},summary:`Launch ${c} at ${M} (CREATE2 address predicted from simulation); vanity false; salt ${b}. Supply 100000000000000000000000000000 base units (18 decimals). ${p.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(p)}. Reward allocations: ${JSON.stringify(k)}. Extensions: ${JSON.stringify({vault:n.vault,airdrop:n.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${H.summary} ${we(e,H)}`}},Te=async(n,i)=>{if(B(n,["token","poolId","collect"]),n.collect!==void 0&&typeof n.collect!="boolean")throw new r("collect must be boolean.");if(n.collect===!1&&n.poolId!==void 0)throw new r("poolId requires collection.");if(n.collect===!0&&n.token===void 0)throw new r("Collection requires a Clanker token.");if(n.poolId!==void 0&&n.token===void 0)throw new r("A pool ID requires its Clanker token.");let a=[P],c=[];if(n.token!==void 0){let o=C(n.token);if(w(o,P.address))throw new r("Provide the launched Clanker token, not WETH.");if(n.collect!==!1){let m=await ce(e,o),{poolId:p,hook:d,locker:k}=m;if(n.poolId!==void 0&&!w(ke(n.poolId,"pool ID for fee collection"),p))throw new r("The supplied pool ID does not match the onchain Clanker pool.");w(m.pairedToken,P.address)||a.splice(0,1,await v(m.pairedToken));let _=await t().readContract({address:d,abi:T,functionName:"mevModuleEnabled",args:[p]});if(typeof _!="boolean")throw new r("The hook returned an invalid MEV guard state.");_&&c.push(u(d,D({abi:T,functionName:"mevModuleOperational",args:[p]}),"Update the Clanker pool MEV guard before collection.")),c.push(u(k,D({abi:T,functionName:"collectRewards",args:[o]}),"Collect pending LP fees into the fee locker."))}a.push(await v(o))}let b;if(c.length){if(await t().getChainId()!==h)throw new r("Fee simulation endpoint is on the wrong chain.");let o=[...c.map(d=>({from:i,gas:z(E),to:d.to,data:d.data,value:z(BigInt(d.value))})),...a.map(d=>({from:i,gas:z(E),to:x.fee_locker.address,data:D({abi:T,functionName:"availableFees",args:[i,d.address]}),value:"0x0"}))],m=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:o}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(m)||m.length!==1||!A(m[0])||!Array.isArray(m[0].calls)||m[0].calls.length!==o.length)throw new r("The endpoint returned an unexpected fee simulation response.");let p=m[0].calls;if(!p.every(d=>A(d)&&d.status==="0x1"&&!d.error))throw new r("Clanker fee collection simulation failed.");b=p.slice(c.length).map(d=>{if(!A(d)||typeof d.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(d.returnData))throw new r("The endpoint returned an invalid fee balance.");return K(Ce({abi:T,functionName:"availableFees",data:d.returnData}))})}else b=await Promise.all(a.map(o=>g(i,o.address)));let y=a.flatMap((o,m)=>BigInt(b[m])>0n?[{token:o,amount:b[m]}]:[]);if(!y.length)throw new r("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:o}of y)c.push(u(x.fee_locker.address,D({abi:T,functionName:"claim",args:[i,o.address]}),`Claim ${o.symbol} fees to ${i}.`));let l=await e.preview(c,i);return{txs:c,preview:l,fees:y,summary:`Claim fees to ${i}. WETH fees aggregate across all Clanker launches for this recipient. ${l.summary} ${we(e,l)}`}},R=(n,i,a,c)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:i,required:a,additionalProperties:!1},execute:(b,y)=>s(async()=>c(b,C(y)))});return{tools:[R("launch",{name:{type:"string",description:"Token name, shown publicly."},symbol:{type:"string",description:"Token ticker symbol, shown publicly."},salt:{...ge,description:"Deployment salt as 0x followed by 64 hex digits; it fixes the predicted token address."},image:{type:"string",description:"Image URL for the token. Public."},metadata:{type:"string",description:"Token metadata as a JSON string (description, social links). Public."},context:{type:"string",description:"Launch context as a JSON string. Defaults to Oak on Robinhood."},vanity:{const:!1,description:"Vanity address mining is not supported; leave false or omit."},initialBuy:{...be,description:"Native ETH base units, 18 decimals."},minAmountOut:{...be,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:q,description:"Slippage in basis points (50 = 0.5%) applied to the initial buy when minAmountOut is omitted."},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100,description:"Static LP fee in basis points (100 = 1%). Not allowed together with pool.dynamicFee."},pool:{...pe,description:"Optional pool setup: paired token, starting tick, tick spacing, liquidity positions and dynamic fee. Defaults to a WETH pool."},rewards:{type:"array",minItems:1,maxItems:7,description:"How LP fees are split, 1 to 7 rows with bps totaling 10000. Default: all to the launching wallet.",items:{type:"object",properties:{admin:{...O,description:"Address that can later change this row."},recipient:{...O,description:"Address that receives this row's share of LP fees."},bps:{type:"integer",minimum:1,maximum:1e4,description:"This row's share of LP fees in basis points (5000 = 50%)."},feePreference:{type:"integer",minimum:0,maximum:2,description:"Which token this row is paid in: 0 = both tokens (default), 1 = paired token, 2 = launched token."}},required:["admin","recipient","bps"],additionalProperties:!1}},vault:{...J.vault,description:"Optional vault extension: lock part of the supply, then vest it to an admin."},airdrop:{...J.airdrop,description:"Optional airdrop extension: reserve part of the supply for a Merkle-tree airdrop."}},["name","symbol","salt"],async(n,i)=>{let a=await Ae(n,i);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:{...O,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...ge,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",description:"Optional search text matched against token name or symbol."},limit:{type:"integer",minimum:1,maximum:20,description:"Maximum tokens to return, 1 to 20 (default 10)."},cursor:{type:"string",description:"Opaque pagination cursor returned by a previous clanker_browse call."},deployer:{...O,description:"Optional address of the deploying wallet to filter tokens by."}},[],X)],positions:n=>s(async()=>{C(n);let i=new Map,a=new Set,c;do{let l=await X({deployer:n,limit:20,...c?{cursor:c}:{}});for(let o of l.tokens)w(o.msg_sender,n)&&i.set(o.contract_address.toLowerCase(),o);if(l.cursor&&a.has(l.cursor))throw new r("The Clanker indexer repeated a pagination cursor.");l.cursor&&a.add(l.cursor),c=l.cursor??void 0}while(c);let b=[],y=[P];for(let[l,o]of i){let m=await v(o.contract_address),p={...m,symbol:N(m.symbol)},d=K(await t().readContract({address:p.address,abi:V,functionName:"balanceOf",args:[n]}));b.push({module:"clanker",id:`launch:${l}`,chainId:h,assets:[{token:p,amount:d}],description:`Indexed launch ${o.name}; wallet token balance, not locked LP principal.`}),y.some(k=>w(k.address,p.address))||y.push(p)}for(let l of y){let o=await g(n,l.address);BigInt(o)>0n&&b.push({module:"clanker",id:`fees:${l.address.toLowerCase()}`,chainId:h,assets:[{token:l,amount:o}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return b})}},ze=e=>ae("clanker",[Oe(e),le(e),me(e),ye(e)]);export{Ne as a,Oe as b,ze as c};
@@ -1 +1 @@
1
- import{a as x,c}from"./2OKYXT25.js";import{a}from"./XSD5NL7J.js";import{parseAbi as M}from"viem";var b=M(["function readState(address router) view returns ((int256 totalPt,int256 totalSy,int256 totalLp,address treasury,int256 scalarRoot,uint256 expiry,uint256 lnFeeRateRoot,uint256 reserveFeePercent,uint256 lastLnImpliedRate) market)","function pyIndexCurrent() returns(uint256)","function exchangeRate() view returns(uint256)","function previewDeposit(address tokenIn,uint256 amount) view returns(uint256)","function previewRedeem(address tokenOut,uint256 amount) view returns(uint256)"]),R=10n**18n,E=31536e3,P="Pendle's price doesn't match what Oak checked on the chain. Try a smaller amount. Nothing was signed.";function n(e,t=!1){if(typeof e!="bigint"||e<(t?1n:0n)||e>=1n<<256n)throw new a("Oak could not read the Pendle price check from the chain. Nothing was signed.");return e}function d(e){return c(Number.isInteger(e)&&e>=0&&e<=77,"unreadable token decimals"),10n**BigInt(e)}function k(e){if(!Number.isFinite(e)||Math.abs(e)>40)throw new a(P);return BigInt(Math.floor(Math.exp(e)*1e18))}async function A(e,t,v,p,u,f){try{c(Number.isFinite(f)&&Math.abs(f)<=.03,"unreadable or excessive price impact"),n(p,!0),n(u,!0);let i=await e.getBlock(),s=i.number,[h,C]=await Promise.all([e.readContract({address:t.market,abi:b,functionName:"readState",args:[x],blockNumber:s}),e.simulateContract({address:t.yt,abi:b,functionName:"pyIndexCurrent",blockNumber:s}).then(o=>o.result)]),I=n(h.lastLnImpliedRate),D=n(h.lnFeeRateRoot),w=n(C,!0);c(Number.isSafeInteger(t.expiry)&&t.expiry>Number(i.timestamp),"this term has ended; use pendle_redeem");let y=(t.expiry-Number(i.timestamp))/E,g=Number(I)/1e18*y,r;if(v==="buy")r=n(await e.readContract({address:t.sy,abi:b,functionName:"previewDeposit",args:[t.inputToken,p],blockNumber:s}),!0)*w*k(g)*d(t.ptDecimals)/(R*R*d(t.syDecimals));else{let o=p*k(-g)*d(t.syDecimals)/(w*d(t.ptDecimals));n(o,!0),r=n(await e.readContract({address:t.sy,abi:b,functionName:"previewRedeem",args:[t.inputToken,o],blockNumber:s}),!0)}n(r,!0);let m=1-Math.exp(-Number(D)/1e18*y);c(Number.isFinite(m)&&m>=0&&m<=1,"unreadable market fee");let N=.01+m,F=u>r?u-r:r-u,l=Number(F)/Number(r);if(!Number.isFinite(l)||l>N)throw new a(P);return{estimateBase:r,relativeDifference:l,tolerance:N,blockNumber:s}}catch(i){throw i instanceof a?i:new a("Oak could not read the Pendle price check from the chain. Nothing was signed.")}}export{b as a,n as b,A as c};
1
+ import{a as x,c}from"./GQITAJVF.js";import{a}from"./XSD5NL7J.js";import{parseAbi as M}from"viem";var b=M(["function readState(address router) view returns ((int256 totalPt,int256 totalSy,int256 totalLp,address treasury,int256 scalarRoot,uint256 expiry,uint256 lnFeeRateRoot,uint256 reserveFeePercent,uint256 lastLnImpliedRate) market)","function pyIndexCurrent() returns(uint256)","function exchangeRate() view returns(uint256)","function previewDeposit(address tokenIn,uint256 amount) view returns(uint256)","function previewRedeem(address tokenOut,uint256 amount) view returns(uint256)"]),R=10n**18n,E=31536e3,P="Pendle's price doesn't match what Oak checked on the chain. Try a smaller amount. Nothing was signed.";function n(e,t=!1){if(typeof e!="bigint"||e<(t?1n:0n)||e>=1n<<256n)throw new a("Oak could not read the Pendle price check from the chain. Nothing was signed.");return e}function d(e){return c(Number.isInteger(e)&&e>=0&&e<=77,"unreadable token decimals"),10n**BigInt(e)}function k(e){if(!Number.isFinite(e)||Math.abs(e)>40)throw new a(P);return BigInt(Math.floor(Math.exp(e)*1e18))}async function A(e,t,v,p,u,f){try{c(Number.isFinite(f)&&Math.abs(f)<=.03,"unreadable or excessive price impact"),n(p,!0),n(u,!0);let i=await e.getBlock(),s=i.number,[h,C]=await Promise.all([e.readContract({address:t.market,abi:b,functionName:"readState",args:[x],blockNumber:s}),e.simulateContract({address:t.yt,abi:b,functionName:"pyIndexCurrent",blockNumber:s}).then(o=>o.result)]),I=n(h.lastLnImpliedRate),D=n(h.lnFeeRateRoot),w=n(C,!0);c(Number.isSafeInteger(t.expiry)&&t.expiry>Number(i.timestamp),"this term has ended; use pendle_redeem");let y=(t.expiry-Number(i.timestamp))/E,g=Number(I)/1e18*y,r;if(v==="buy")r=n(await e.readContract({address:t.sy,abi:b,functionName:"previewDeposit",args:[t.inputToken,p],blockNumber:s}),!0)*w*k(g)*d(t.ptDecimals)/(R*R*d(t.syDecimals));else{let o=p*k(-g)*d(t.syDecimals)/(w*d(t.ptDecimals));n(o,!0),r=n(await e.readContract({address:t.sy,abi:b,functionName:"previewRedeem",args:[t.inputToken,o],blockNumber:s}),!0)}n(r,!0);let m=1-Math.exp(-Number(D)/1e18*y);c(Number.isFinite(m)&&m>=0&&m<=1,"unreadable market fee");let N=.01+m,F=u>r?u-r:r-u,l=Number(F)/Number(r);if(!Number.isFinite(l)||l>N)throw new a(P);return{estimateBase:r,relativeDifference:l,tolerance:N,blockNumber:s}}catch(i){throw i instanceof a?i:new a("Oak could not read the Pendle price check from the chain. Nothing was signed.")}}export{b as a,n as b,A as c};
@@ -1 +1 @@
1
- import{b as k,c as P,d as R}from"./DNNFKDZR.js";import{a as Z}from"./H5DY7CNB.js";import{a as H}from"./43LI5NKJ.js";import{g as G,i as Q}from"./NWNYJ26T.js";import{b as W,c as V}from"./IX3GZMTM.js";import{a as c,d as X,i as O}from"./FWD4L3CJ.js";import{a as u}from"./XSD5NL7J.js";import{a as T}from"./JXOEJPJ4.js";import{encodeFunctionData as nt,erc20Abi as J,getAddress as a,parseAbi as gt}from"viem";var At="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),wt=a(O[4663].hookr.HookrRoot.address),Ot=a(O[4663].hookr.HookrRouter.address),Bt=a(O[4663].hookr.HookrForwarder.address),ht=a(O[4663].hookr.PoolManager.address),It=a(O[4663].hookr.HOOKR_Token.address),N="0x0000000000000000000000000000000000000000",St="0x000000000000000000000000000000000000dEaD",Y=(1n<<128n)-1n,Tt=new Set([N.toLowerCase(),St.toLowerCase(),y.toLowerCase(),Ot.toLowerCase(),Bt.toLowerCase(),ht.toLowerCase(),wt.toLowerCase()]),B=gt(["function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function fill(uint256 orderId) returns (uint256 amountOut)","function claimBounty(address to) returns (uint256 amount)","function bountyOf(address keeper) view returns (uint256)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)"]);function Ht(t){let n=t.toLowerCase();return n===N.toLowerCase()||n===Z.toLowerCase()}function $t(t,n,i){let o=n.trim();if(o.startsWith("-")){let s=o.slice(1),r=t(s,i);return r==="0"?"0":`-${r}`}return t(o,i)}function Wt(t,n,i){return V(t,n,i)}function et(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${$t(n,i.amount,i.token.decimals)} ${T(i.token.symbol)} (${i.token.address})`).join(", ")}function xt(t){if(typeof t=="bigint"){if(t<=0n)throw new u("Hookr orderId must be a positive integer.");return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<=0)throw new u("Hookr orderId must be a positive integer.");return BigInt(t)}if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=BigInt(t.trim());if(n<=0n)throw new u("Hookr orderId must be a positive integer.");return n}throw new u("Provide a positive integer Hookr orderId.")}function ot(t){if(t==null)return c;if(typeof t!="number"||!Number.isSafeInteger(t)||t!==c)throw new u(`Hookr limit orders are only supported on chain ${c}.`);return c}function Rt(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function Ct(t){if(Array.isArray(t)){let[n,i,o,s,r,d,g,m,b,e,l]=t;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:i,createdAt:o,expiry:s,zeroForOne:!!r,status:d,recipient:g,amountIn:BigInt(m),minAmountOut:BigInt(b),bounty:BigInt(e),sqrtPriceLimitX96:BigInt(l)}}if(t&&typeof t=="object"){let n=t;if(n.key&&typeof n.key=="object")return{key:{currency0:n.key.currency0,currency1:n.key.currency1,fee:Number(n.key.fee),tickSpacing:Number(n.key.tickSpacing),hooks:n.key.hooks},owner:n.owner,createdAt:n.createdAt,expiry:n.expiry,zeroForOne:!!n.zeroForOne,status:n.status,recipient:n.recipient,amountIn:BigInt(n.amountIn),minAmountOut:BigInt(n.minAmountOut),bounty:BigInt(n.bounty),sqrtPriceLimitX96:BigInt(n.sqrtPriceLimitX96)}}throw new u("HookrLimitOrders returned a malformed order tuple.")}function Dt(t){if(Array.isArray(t)&&t.length>=2)return{fillable:!!t[0],amountOut:BigInt(t[1])};if(t&&typeof t=="object"&&"fillable"in t&&"amountOut"in t){let n=t;return{fillable:!!n.fillable,amountOut:BigInt(n.amountOut)}}throw new u("HookrLimitOrders returned a malformed quoteFill response.")}function Pt(t){if(Array.isArray(t)&&t.length>=3)return{minBounty:BigInt(t[0]),defaultBounty:BigInt(t[1]),maxBounty:BigInt(t[2])};if(t&&typeof t=="object"&&"minBounty"in t&&"defaultBounty"in t&&"maxBounty"in t){let n=t;return{minBounty:BigInt(n.minBounty),defaultBounty:BigInt(n.defaultBounty),maxBounty:BigInt(n.maxBounty)}}throw new u("HookrLimitOrders returned a malformed bountyBounds response.")}async function tt(t,n,i=c){if(i!==c)throw new u(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(Ht(n))return{...k,chainId:i};H(n);let o=a(n),s=o.toLowerCase();if(s===P.address.toLowerCase())return{address:o,symbol:P.symbol,decimals:X,chainId:i};if(s===R.address.toLowerCase())return{address:o,symbol:R.symbol,decimals:R.decimals,chainId:i};if(s===It.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:J,functionName:"symbol"}),t.readContract({address:o,abi:J,functionName:"decimals"})]),g=typeof r=="string"&&r.trim()?r.trim():o,m=Number(d);if(!Number.isInteger(m)||m<0||m>255)throw new u(`Invalid token decimals for ${o} on chain ${i}.`);return{address:o,symbol:g,decimals:m,chainId:i}}async function Et(t){if(typeof t.getBlock!="function")throw new u("Cannot read the latest block timestamp for Hookr order expiry.");let n=await t.getBlock().catch(()=>{throw new u("Cannot read the latest block timestamp for Hookr order expiry.")});if(!n||typeof n.timestamp!="bigint"||n.timestamp<=0n)throw new u("Hookr requires a usable latest block timestamp to check order expiry.");return n.timestamp}function E(t,n=[]){let i=Q(t,"Provide a valid recipient wallet address."),o=i.toLowerCase();if(Tt.has(o)||n.some(s=>s.toLowerCase()===o))throw new u(`Recipient ${i} is a reserved protocol or zero address (invalid recipient).`);return i}function rt(t){if(t.minBountyEth!==void 0||t.minAmountOutDecimal!==void 0||t.rounding!==void 0)throw new u("Use minBounty and minAmountOut as base-unit integer strings.")}function L(t,n){if(t!==void 0){if(typeof t!="string"||!/^\d+$/.test(t))throw new u(`Provide ${n} as a base-unit integer string.`);return W(t)}}function Lt(t){return{name:"hookr_fill",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"HookrLimitOrders orderId as a positive integer string."},minBounty:{type:"string",description:"Optional minimum keeper bounty in wei (decimal base-unit string)."},minAmountOut:{type:"string",description:"Optional quote pre-check only, in token base-unit integer strings. Not enforced on chain: fill(uint256) enforces only the order minAmountOut."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},required:["orderId"],additionalProperties:!1},async execute(n,i){try{rt(n),H(i);let o=a(i),s=ot(n.chainId),r=xt(n.orderId),d=t.clientFor(s),[g,m,b]=await Promise.all([d.readContract({address:y,abi:B,functionName:"getOrder",args:[r]}),d.readContract({address:y,abi:B,functionName:"quoteFill",args:[r]}),Et(d)]),e=Ct(g),l=Number(e.status),h=Rt(l);if(l===0||G(e.owner,N))throw new u(`Hookr order #${r} does not exist.`);if(l!==1)throw new u(`Hookr order #${r} is not open (current status: ${h}).`);let A=BigInt(e.expiry);if(A<b)throw new u(`Hookr order #${r} is expired (expiry ${A} < current timestamp ${b}).`);let f=Number(e.key.tickSpacing),$=Number(e.key.fee);if(!Number.isInteger(f)||f<=0)throw new u(`Hookr order #${r} has an invalid pool tickSpacing (${f}).`);if(e.amountIn<=0n||e.amountIn>Y)throw new u(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>Y)throw new u(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let C=a(e.key.hooks);E(e.recipient,[C]);let it=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:C},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Pt(it),D=L(n.minBounty,"minBounty"),F=D!==void 0&&D>w.minBounty?D:w.minBounty;if(e.bounty<F)throw new u(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${F} wei).`);if(e.bounty>w.maxBounty)throw new u(`Hookr order #${r} bounty (${e.bounty} wei) exceeds maximum bounty bound (${w.maxBounty} wei).`);let I=Dt(m),ut=e.zeroForOne?e.key.currency0:e.key.currency1,st=e.zeroForOne?e.key.currency1:e.key.currency0,[x,p]=await Promise.all([tt(d,ut,s),tt(d,st,s)]),S=L(n.minAmountOut,"minAmountOut"),v=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<v)throw new u(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${v} base units).`);let at=nt({abi:B,functionName:"fill",args:[r]}),mt=t.formatAmount(e.amountIn.toString(),x.decimals),dt=t.formatAmount(I.amountOut.toString(),p.decimals),ct=t.formatAmount(e.minAmountOut.toString(),p.decimals),lt=t.formatAmount(e.bounty.toString(),18),yt=S===void 0?"":` Caller minAmountOut ${S} base units is a quote pre-check only, not enforced on chain; fill(uint256) enforces the order minimum of ${e.minAmountOut} base units.`,q=`Fill Hookr order #${r}: maker's escrow pays ${mt} ${T(x.symbol)} (${e.amountIn} base units of ${x.address}); net output goes to ${a(e.recipient)} (quoted ${dt} ${T(p.symbol)}, order minimum ${ct} ${T(p.symbol)}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${lt} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${yt}`,M=t.unsignedTx({to:y,data:at,value:"0",chainId:s,description:q}),z=await t.preview([M],o),bt=et(z,t.formatAmount),K={token:x,amount:e.amountIn.toString()},U={token:p,amount:e.minAmountOut.toString()},ft={token:p,amount:I.amountOut.toString()},j={token:{...k,chainId:s},amount:e.bounty.toString()},pt={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:C},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:K,minAmountOut:U,bounty:j,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},kt={minBounty:{token:{...k,chainId:s},amount:w.minBounty.toString()},defaultBounty:{token:{...k,chainId:s},amount:w.defaultBounty.toString()},maxBounty:{token:{...k,chainId:s},amount:w.maxBounty.toString()}};return{txs:[M],summary:`${q} Preview deltas: ${bt}.`,preview:z,orderId:r.toString(),fillable:!0,amountIn:K,minAmountOut:U,quotedAmountOut:ft,bounty:j,bountyBounds:kt,order:pt}}catch(o){throw new u(t.plainError(o))}}}}function Nt(t){return{name:"hookr_claim_bounty",inputSchema:{type:"object",properties:{to:{type:"string",description:"Optional recipient address for the claimed native ETH bounty (must be the signing wallet)."},minBounty:{type:"string",description:"Optional minimum claimable bounty in wei (decimal base-unit string)."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},additionalProperties:!1},async execute(n,i){try{rt(n),H(i);let o=a(i),s=ot(n.chainId),r=n.to!==void 0&&n.to!==null?E(String(n.to)):E(o);if(r!==o)throw new u("Hookr bounty recipient must be the signing wallet.");let g=await t.clientFor(s).readContract({address:y,abi:B,functionName:"bountyOf",args:[o]}),m=BigInt(g);if(m<=0n)throw new u(`No claimable Hookr keeper bounty for ${o}.`);let b=L(n.minBounty,"minBounty");if(b!==void 0&&m<b)throw new u(`Claimable Hookr bounty (${m} wei) is below the requested minimum (${b} wei).`);let e=nt({abi:B,functionName:"claimBounty",args:[r]}),l=t.formatAmount(m.toString(),18),h=t.unsignedTx({to:y,data:e,value:"0",chainId:s,description:`Claim ${l} ETH (${m} wei) of accrued Hookr keeper bounty from ${y} to ${r}.`}),A=await t.preview([h],o),f=et(A,t.formatAmount),$={token:{...k,chainId:s},amount:m.toString()};return{txs:[h],summary:`Claim ${l} ETH (${m} wei) Hookr keeper bounty to ${r}. Preview deltas: ${f}.`,preview:A,recipient:r,claimableBounty:$}}catch(o){throw new u(t.plainError(o))}}}}async function _t(t,n){H(n);let i=a(n),o=t.clientFor(c);try{let s=await o.readContract({address:y,abi:B,functionName:"bountyOf",args:[i]}),r=BigInt(s);if(r<=0n)return[];let d=t.formatAmount(r.toString(),18);return[{module:At,id:`hookr:bounty:${i.toLowerCase()}`,chainId:c,assets:[{token:{...k,chainId:c},amount:r.toString()}],description:`Hookr claimable keeper bounty (${d} ETH)`}]}catch(s){throw new u(t.plainError(s))}}var _=t=>({tools:[Lt(t),Nt(t)],positions:n=>_t(t,n)}),Vt=_,Gt=_,Qt=_;export{At as a,y as b,wt as c,Ot as d,Bt as e,ht as f,It as g,B as h,$t as i,Wt as j,Lt as k,Nt as l,_t as m,_ as n,Vt as o,Gt as p,Qt as q};
1
+ import{b as k,c as P,d as R}from"./QLFPAN6S.js";import{a as Z}from"./Z7FGEWO2.js";import{a as H}from"./43LI5NKJ.js";import{g as G,i as Q}from"./NWNYJ26T.js";import{b as W,c as V}from"./IX3GZMTM.js";import{b as c,e as X,j as O}from"./TI727O2H.js";import{a as u}from"./XSD5NL7J.js";import{a as T}from"./JXOEJPJ4.js";import{encodeFunctionData as nt,erc20Abi as J,getAddress as a,parseAbi as gt}from"viem";var At="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),wt=a(O[4663].hookr.HookrRoot.address),Ot=a(O[4663].hookr.HookrRouter.address),Bt=a(O[4663].hookr.HookrForwarder.address),ht=a(O[4663].hookr.PoolManager.address),It=a(O[4663].hookr.HOOKR_Token.address),N="0x0000000000000000000000000000000000000000",St="0x000000000000000000000000000000000000dEaD",Y=(1n<<128n)-1n,Tt=new Set([N.toLowerCase(),St.toLowerCase(),y.toLowerCase(),Ot.toLowerCase(),Bt.toLowerCase(),ht.toLowerCase(),wt.toLowerCase()]),B=gt(["function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function fill(uint256 orderId) returns (uint256 amountOut)","function claimBounty(address to) returns (uint256 amount)","function bountyOf(address keeper) view returns (uint256)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)"]);function Ht(t){let n=t.toLowerCase();return n===N.toLowerCase()||n===Z.toLowerCase()}function $t(t,n,i){let o=n.trim();if(o.startsWith("-")){let s=o.slice(1),r=t(s,i);return r==="0"?"0":`-${r}`}return t(o,i)}function Wt(t,n,i){return V(t,n,i)}function et(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${$t(n,i.amount,i.token.decimals)} ${T(i.token.symbol)} (${i.token.address})`).join(", ")}function xt(t){if(typeof t=="bigint"){if(t<=0n)throw new u("Hookr orderId must be a positive integer.");return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<=0)throw new u("Hookr orderId must be a positive integer.");return BigInt(t)}if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=BigInt(t.trim());if(n<=0n)throw new u("Hookr orderId must be a positive integer.");return n}throw new u("Provide a positive integer Hookr orderId.")}function ot(t){if(t==null)return c;if(typeof t!="number"||!Number.isSafeInteger(t)||t!==c)throw new u(`Hookr limit orders are only supported on chain ${c}.`);return c}function Rt(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function Ct(t){if(Array.isArray(t)){let[n,i,o,s,r,d,g,m,b,e,l]=t;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:i,createdAt:o,expiry:s,zeroForOne:!!r,status:d,recipient:g,amountIn:BigInt(m),minAmountOut:BigInt(b),bounty:BigInt(e),sqrtPriceLimitX96:BigInt(l)}}if(t&&typeof t=="object"){let n=t;if(n.key&&typeof n.key=="object")return{key:{currency0:n.key.currency0,currency1:n.key.currency1,fee:Number(n.key.fee),tickSpacing:Number(n.key.tickSpacing),hooks:n.key.hooks},owner:n.owner,createdAt:n.createdAt,expiry:n.expiry,zeroForOne:!!n.zeroForOne,status:n.status,recipient:n.recipient,amountIn:BigInt(n.amountIn),minAmountOut:BigInt(n.minAmountOut),bounty:BigInt(n.bounty),sqrtPriceLimitX96:BigInt(n.sqrtPriceLimitX96)}}throw new u("HookrLimitOrders returned a malformed order tuple.")}function Dt(t){if(Array.isArray(t)&&t.length>=2)return{fillable:!!t[0],amountOut:BigInt(t[1])};if(t&&typeof t=="object"&&"fillable"in t&&"amountOut"in t){let n=t;return{fillable:!!n.fillable,amountOut:BigInt(n.amountOut)}}throw new u("HookrLimitOrders returned a malformed quoteFill response.")}function Pt(t){if(Array.isArray(t)&&t.length>=3)return{minBounty:BigInt(t[0]),defaultBounty:BigInt(t[1]),maxBounty:BigInt(t[2])};if(t&&typeof t=="object"&&"minBounty"in t&&"defaultBounty"in t&&"maxBounty"in t){let n=t;return{minBounty:BigInt(n.minBounty),defaultBounty:BigInt(n.defaultBounty),maxBounty:BigInt(n.maxBounty)}}throw new u("HookrLimitOrders returned a malformed bountyBounds response.")}async function tt(t,n,i=c){if(i!==c)throw new u(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(Ht(n))return{...k,chainId:i};H(n);let o=a(n),s=o.toLowerCase();if(s===P.address.toLowerCase())return{address:o,symbol:P.symbol,decimals:X,chainId:i};if(s===R.address.toLowerCase())return{address:o,symbol:R.symbol,decimals:R.decimals,chainId:i};if(s===It.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:J,functionName:"symbol"}),t.readContract({address:o,abi:J,functionName:"decimals"})]),g=typeof r=="string"&&r.trim()?r.trim():o,m=Number(d);if(!Number.isInteger(m)||m<0||m>255)throw new u(`Invalid token decimals for ${o} on chain ${i}.`);return{address:o,symbol:g,decimals:m,chainId:i}}async function Et(t){if(typeof t.getBlock!="function")throw new u("Cannot read the latest block timestamp for Hookr order expiry.");let n=await t.getBlock().catch(()=>{throw new u("Cannot read the latest block timestamp for Hookr order expiry.")});if(!n||typeof n.timestamp!="bigint"||n.timestamp<=0n)throw new u("Hookr requires a usable latest block timestamp to check order expiry.");return n.timestamp}function E(t,n=[]){let i=Q(t,"Provide a valid recipient wallet address."),o=i.toLowerCase();if(Tt.has(o)||n.some(s=>s.toLowerCase()===o))throw new u(`Recipient ${i} is a reserved protocol or zero address (invalid recipient).`);return i}function rt(t){if(t.minBountyEth!==void 0||t.minAmountOutDecimal!==void 0||t.rounding!==void 0)throw new u("Use minBounty and minAmountOut as base-unit integer strings.")}function L(t,n){if(t!==void 0){if(typeof t!="string"||!/^\d+$/.test(t))throw new u(`Provide ${n} as a base-unit integer string.`);return W(t)}}function Lt(t){return{name:"hookr_fill",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"HookrLimitOrders orderId as a positive integer string."},minBounty:{type:"string",description:"Optional minimum keeper bounty in wei (decimal base-unit string)."},minAmountOut:{type:"string",description:"Optional quote pre-check only, in token base-unit integer strings. Not enforced on chain: fill(uint256) enforces only the order minAmountOut."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},required:["orderId"],additionalProperties:!1},async execute(n,i){try{rt(n),H(i);let o=a(i),s=ot(n.chainId),r=xt(n.orderId),d=t.clientFor(s),[g,m,b]=await Promise.all([d.readContract({address:y,abi:B,functionName:"getOrder",args:[r]}),d.readContract({address:y,abi:B,functionName:"quoteFill",args:[r]}),Et(d)]),e=Ct(g),l=Number(e.status),h=Rt(l);if(l===0||G(e.owner,N))throw new u(`Hookr order #${r} does not exist.`);if(l!==1)throw new u(`Hookr order #${r} is not open (current status: ${h}).`);let A=BigInt(e.expiry);if(A<b)throw new u(`Hookr order #${r} is expired (expiry ${A} < current timestamp ${b}).`);let f=Number(e.key.tickSpacing),$=Number(e.key.fee);if(!Number.isInteger(f)||f<=0)throw new u(`Hookr order #${r} has an invalid pool tickSpacing (${f}).`);if(e.amountIn<=0n||e.amountIn>Y)throw new u(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>Y)throw new u(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let C=a(e.key.hooks);E(e.recipient,[C]);let it=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:C},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Pt(it),D=L(n.minBounty,"minBounty"),F=D!==void 0&&D>w.minBounty?D:w.minBounty;if(e.bounty<F)throw new u(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${F} wei).`);if(e.bounty>w.maxBounty)throw new u(`Hookr order #${r} bounty (${e.bounty} wei) exceeds maximum bounty bound (${w.maxBounty} wei).`);let I=Dt(m),ut=e.zeroForOne?e.key.currency0:e.key.currency1,st=e.zeroForOne?e.key.currency1:e.key.currency0,[x,p]=await Promise.all([tt(d,ut,s),tt(d,st,s)]),S=L(n.minAmountOut,"minAmountOut"),v=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<v)throw new u(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${v} base units).`);let at=nt({abi:B,functionName:"fill",args:[r]}),mt=t.formatAmount(e.amountIn.toString(),x.decimals),dt=t.formatAmount(I.amountOut.toString(),p.decimals),ct=t.formatAmount(e.minAmountOut.toString(),p.decimals),lt=t.formatAmount(e.bounty.toString(),18),yt=S===void 0?"":` Caller minAmountOut ${S} base units is a quote pre-check only, not enforced on chain; fill(uint256) enforces the order minimum of ${e.minAmountOut} base units.`,q=`Fill Hookr order #${r}: maker's escrow pays ${mt} ${T(x.symbol)} (${e.amountIn} base units of ${x.address}); net output goes to ${a(e.recipient)} (quoted ${dt} ${T(p.symbol)}, order minimum ${ct} ${T(p.symbol)}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${lt} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${yt}`,M=t.unsignedTx({to:y,data:at,value:"0",chainId:s,description:q}),z=await t.preview([M],o),bt=et(z,t.formatAmount),K={token:x,amount:e.amountIn.toString()},U={token:p,amount:e.minAmountOut.toString()},ft={token:p,amount:I.amountOut.toString()},j={token:{...k,chainId:s},amount:e.bounty.toString()},pt={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:C},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:K,minAmountOut:U,bounty:j,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},kt={minBounty:{token:{...k,chainId:s},amount:w.minBounty.toString()},defaultBounty:{token:{...k,chainId:s},amount:w.defaultBounty.toString()},maxBounty:{token:{...k,chainId:s},amount:w.maxBounty.toString()}};return{txs:[M],summary:`${q} Preview deltas: ${bt}.`,preview:z,orderId:r.toString(),fillable:!0,amountIn:K,minAmountOut:U,quotedAmountOut:ft,bounty:j,bountyBounds:kt,order:pt}}catch(o){throw new u(t.plainError(o))}}}}function Nt(t){return{name:"hookr_claim_bounty",inputSchema:{type:"object",properties:{to:{type:"string",description:"Optional recipient address for the claimed native ETH bounty (must be the signing wallet)."},minBounty:{type:"string",description:"Optional minimum claimable bounty in wei (decimal base-unit string)."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},additionalProperties:!1},async execute(n,i){try{rt(n),H(i);let o=a(i),s=ot(n.chainId),r=n.to!==void 0&&n.to!==null?E(String(n.to)):E(o);if(r!==o)throw new u("Hookr bounty recipient must be the signing wallet.");let g=await t.clientFor(s).readContract({address:y,abi:B,functionName:"bountyOf",args:[o]}),m=BigInt(g);if(m<=0n)throw new u(`No claimable Hookr keeper bounty for ${o}.`);let b=L(n.minBounty,"minBounty");if(b!==void 0&&m<b)throw new u(`Claimable Hookr bounty (${m} wei) is below the requested minimum (${b} wei).`);let e=nt({abi:B,functionName:"claimBounty",args:[r]}),l=t.formatAmount(m.toString(),18),h=t.unsignedTx({to:y,data:e,value:"0",chainId:s,description:`Claim ${l} ETH (${m} wei) of accrued Hookr keeper bounty from ${y} to ${r}.`}),A=await t.preview([h],o),f=et(A,t.formatAmount),$={token:{...k,chainId:s},amount:m.toString()};return{txs:[h],summary:`Claim ${l} ETH (${m} wei) Hookr keeper bounty to ${r}. Preview deltas: ${f}.`,preview:A,recipient:r,claimableBounty:$}}catch(o){throw new u(t.plainError(o))}}}}async function _t(t,n){H(n);let i=a(n),o=t.clientFor(c);try{let s=await o.readContract({address:y,abi:B,functionName:"bountyOf",args:[i]}),r=BigInt(s);if(r<=0n)return[];let d=t.formatAmount(r.toString(),18);return[{module:At,id:`hookr:bounty:${i.toLowerCase()}`,chainId:c,assets:[{token:{...k,chainId:c},amount:r.toString()}],description:`Hookr claimable keeper bounty (${d} ETH)`}]}catch(s){throw new u(t.plainError(s))}}var _=t=>({tools:[Lt(t),Nt(t)],positions:n=>_t(t,n)}),Vt=_,Gt=_,Qt=_;export{At as a,y as b,wt as c,Ot as d,Bt as e,ht as f,It as g,B as h,$t as i,Wt as j,Lt as k,Nt as l,_t as m,_ as n,Vt as o,Gt as p,Qt as q};
@@ -1 +1 @@
1
- import{b as _,c as q,d as F,e as O}from"./M7ZXDLKM.js";import{a as N}from"./DSTMEY5F.js";import{a as M}from"./FV4WZOTD.js";import{a as I}from"./OARVU3RC.js";import{c as E}from"./L646YWDP.js";import{b as P}from"./SPJCSEKP.js";import{a as b}from"./43LI5NKJ.js";import{b as G}from"./IX3GZMTM.js";import{a as r,d as $,i as C,j as y}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as g,erc20Abi as D,parseAbi as W}from"viem";var i=C[r].vaults.steakhouse.address,R=(1n<<256n)-1n,l=W(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]);function S(e){if(typeof e!="bigint"||e<0n||e>R)throw new o("The vault returned an invalid base-unit amount.");return e}function k(e){if(typeof e!="string")throw new o("Amount must be an integer string in base units.");let c=G(e);if(c===0n)throw new o("Amount must be positive.");if(c>R)throw new o("Amount exceeds the uint256 range.");return c}function U(e,c,h=!1){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(w=>!c||!["amount",...h?["force","maxPenaltyAssets","minAmountOut"]:[]].includes(w)))throw new o("Unexpected Steakhouse argument.")}var L=e=>{async function c(t){try{return await t()}catch(s){throw new o(e.plainError(s))}}async function h(){let t=e.clientFor(r);if(await t.getChainId()!==r)throw new o("Steakhouse requires chain 4663.");let s=await t.readContract({address:i,abi:l,functionName:"asset"});if(typeof s!="string"||s.toLowerCase()!==y.toLowerCase())throw new o("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([t.readContract({address:y,abi:D,functionName:"decimals"}),t.readContract({address:i,abi:D,functionName:"decimals"})]);if(a!==$||!Number.isInteger(n)||n<0||n>255)throw new o("The vault returned invalid asset or share decimals.");return{client:t,asset:{address:y,symbol:"USDG",decimals:a,chainId:r},shares:{address:i,symbol:"steakUSDG",decimals:n,chainId:r}}}async function w(t,s){return S(await t.readContract({address:i,abi:D,functionName:"balanceOf",args:[s]}))}async function x(t,s,a){let n=await e.preview(t,s);if(n.changes.length===0)throw new o("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:m,amount:d})=>{let f=d.startsWith("-"),p=e.formatAmount(f?d.slice(1):d,m.decimals);return`${f?"-":""}${p} ${m.symbol} (${m.address}, chain ${m.chainId}, decimals ${m.decimals})`});return{txs:t,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[q(e,"steakhouse_details",i),I(e,"steakhouse_analytics",i),M(e,"steakhouse_manage",i),...N(e,"steakhouse",i),{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>c(async()=>{U(t,!1);let{client:s,asset:a,shares:n}=await h(),u=S(await s.readContract({address:i,abi:l,functionName:"totalAssets"}));return[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:{...T(!1),description:"Deposit USDG in base units (1 USDG = 1000000) for vault shares. Exit with steakhouse_withdraw; check positions after confirmation."},execute:async(t,s)=>c(async()=>{U(t,!0);let a=k(t.amount);b(s);let{asset:n}=await h(),u=[e.approval(n.address,i,a.toString(),r),e.unsignedTx({to:i,data:g({abi:l,functionName:"deposit",args:[a,s]}),value:"0",chainId:r,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return x(u,s,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:{...T(!0),description:"Withdraw USDG in 6-decimal base units, or amount max to redeem every share for USDG. Check positions after confirmation.",properties:{...T(!0).properties,force:{type:"boolean",description:"Explicitly plan a full Morpho V2 force exit with penalty disclosure."},maxPenaltyAssets:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.'},minAmountOut:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: least USDG you must receive, in base units (6 decimals). Example: "1000000" = 1 USDG.'}}},execute:async(t,s)=>c(async()=>{U(t,!0,!0);let a=t.amount==="max"?null:k(t.amount);b(s);let{client:n,asset:u,shares:m}=await h(),d=await w(n,s);if(d===0n)throw new o("The wallet has no Steakhouse shares to withdraw.");if(t.force!==void 0&&typeof t.force!="boolean")throw new o("force must be a boolean.");if(t.force===!0){if(a!==null)throw new o("Force exit currently requires amount max.");let p=E(t.maxPenaltyAssets),j=k(t.minAmountOut),v=await _(e,n,i,s,d,p),A=await e.preview([v.tx],s);return O(A.changes,i,d,j),{txs:[v.tx],preview:A,summary:`${F(v.plan)} ${A.summary}`}}if(t.maxPenaltyAssets!==void 0||t.minAmountOut!==void 0)throw new o("Penalty and output limits require force true.");let f;if(a===null)f=e.unsignedTx({to:i,data:g({abi:l,functionName:"redeem",args:[d,s,s]}),value:"0",chainId:r,description:`Redeem all ${e.formatAmount(d.toString(),m.decimals)} steakUSDG shares.`});else{let p=S(await n.readContract({address:i,abi:l,functionName:"previewWithdraw",args:[a]}));if(p===0n||p>d)throw new o("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:i,data:g({abi:l,functionName:"withdraw",args:[a,s,s]}),value:"0",chainId:r,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return x([f],s,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:t=>c(async()=>{b(t);let{client:s,asset:a,shares:n}=await h(),u=await w(s,t);if(u===0n)return[];let m=S(await s.readContract({address:i,abi:l,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${r}:${i.toLowerCase()}`,chainId:r,assets:[{token:a,amount:m.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${i}, chain ${r}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function T(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`Amount of USDG in base units (USDG has 6 decimals)${e?", or max to redeem every share":""}. Example: "1000000" = 1 USDG.`}}}}var te=e=>P("steakhouse",[L(e)]);export{L as a,te as b};
1
+ import{b as _,c as q,d as F,e as O}from"./FGEGJOAA.js";import{a as N}from"./6F527FLN.js";import{a as M}from"./ND32LJWI.js";import{a as I}from"./YBLJ75U5.js";import{c as E}from"./X24YTJST.js";import{b as P}from"./SPJCSEKP.js";import{a as b}from"./43LI5NKJ.js";import{b as G}from"./IX3GZMTM.js";import{b as r,e as $,j as C,k as y}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as g,erc20Abi as D,parseAbi as W}from"viem";var i=C[r].vaults.steakhouse.address,R=(1n<<256n)-1n,l=W(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]);function S(e){if(typeof e!="bigint"||e<0n||e>R)throw new o("The vault returned an invalid base-unit amount.");return e}function k(e){if(typeof e!="string")throw new o("Amount must be an integer string in base units.");let c=G(e);if(c===0n)throw new o("Amount must be positive.");if(c>R)throw new o("Amount exceeds the uint256 range.");return c}function U(e,c,h=!1){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(w=>!c||!["amount",...h?["force","maxPenaltyAssets","minAmountOut"]:[]].includes(w)))throw new o("Unexpected Steakhouse argument.")}var L=e=>{async function c(t){try{return await t()}catch(s){throw new o(e.plainError(s))}}async function h(){let t=e.clientFor(r);if(await t.getChainId()!==r)throw new o("Steakhouse requires chain 4663.");let s=await t.readContract({address:i,abi:l,functionName:"asset"});if(typeof s!="string"||s.toLowerCase()!==y.toLowerCase())throw new o("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([t.readContract({address:y,abi:D,functionName:"decimals"}),t.readContract({address:i,abi:D,functionName:"decimals"})]);if(a!==$||!Number.isInteger(n)||n<0||n>255)throw new o("The vault returned invalid asset or share decimals.");return{client:t,asset:{address:y,symbol:"USDG",decimals:a,chainId:r},shares:{address:i,symbol:"steakUSDG",decimals:n,chainId:r}}}async function w(t,s){return S(await t.readContract({address:i,abi:D,functionName:"balanceOf",args:[s]}))}async function x(t,s,a){let n=await e.preview(t,s);if(n.changes.length===0)throw new o("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:m,amount:d})=>{let f=d.startsWith("-"),p=e.formatAmount(f?d.slice(1):d,m.decimals);return`${f?"-":""}${p} ${m.symbol} (${m.address}, chain ${m.chainId}, decimals ${m.decimals})`});return{txs:t,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[q(e,"steakhouse_details",i),I(e,"steakhouse_analytics",i),M(e,"steakhouse_manage",i),...N(e,"steakhouse",i),{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>c(async()=>{U(t,!1);let{client:s,asset:a,shares:n}=await h(),u=S(await s.readContract({address:i,abi:l,functionName:"totalAssets"}));return[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:{...T(!1),description:"Deposit USDG in base units (1 USDG = 1000000) for vault shares. Exit with steakhouse_withdraw; check positions after confirmation."},execute:async(t,s)=>c(async()=>{U(t,!0);let a=k(t.amount);b(s);let{asset:n}=await h(),u=[e.approval(n.address,i,a.toString(),r),e.unsignedTx({to:i,data:g({abi:l,functionName:"deposit",args:[a,s]}),value:"0",chainId:r,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return x(u,s,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:{...T(!0),description:"Withdraw USDG in 6-decimal base units, or amount max to redeem every share for USDG. Check positions after confirmation.",properties:{...T(!0).properties,force:{type:"boolean",description:"Explicitly plan a full Morpho V2 force exit with penalty disclosure."},maxPenaltyAssets:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.'},minAmountOut:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: least USDG you must receive, in base units (6 decimals). Example: "1000000" = 1 USDG.'}}},execute:async(t,s)=>c(async()=>{U(t,!0,!0);let a=t.amount==="max"?null:k(t.amount);b(s);let{client:n,asset:u,shares:m}=await h(),d=await w(n,s);if(d===0n)throw new o("The wallet has no Steakhouse shares to withdraw.");if(t.force!==void 0&&typeof t.force!="boolean")throw new o("force must be a boolean.");if(t.force===!0){if(a!==null)throw new o("Force exit currently requires amount max.");let p=E(t.maxPenaltyAssets),j=k(t.minAmountOut),v=await _(e,n,i,s,d,p),A=await e.preview([v.tx],s);return O(A.changes,i,d,j),{txs:[v.tx],preview:A,summary:`${F(v.plan)} ${A.summary}`}}if(t.maxPenaltyAssets!==void 0||t.minAmountOut!==void 0)throw new o("Penalty and output limits require force true.");let f;if(a===null)f=e.unsignedTx({to:i,data:g({abi:l,functionName:"redeem",args:[d,s,s]}),value:"0",chainId:r,description:`Redeem all ${e.formatAmount(d.toString(),m.decimals)} steakUSDG shares.`});else{let p=S(await n.readContract({address:i,abi:l,functionName:"previewWithdraw",args:[a]}));if(p===0n||p>d)throw new o("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:i,data:g({abi:l,functionName:"withdraw",args:[a,s,s]}),value:"0",chainId:r,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return x([f],s,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:t=>c(async()=>{b(t);let{client:s,asset:a,shares:n}=await h(),u=await w(s,t);if(u===0n)return[];let m=S(await s.readContract({address:i,abi:l,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${r}:${i.toLowerCase()}`,chainId:r,assets:[{token:a,amount:m.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${i}, chain ${r}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function T(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`Amount of USDG in base units (USDG has 6 decimals)${e?", or max to redeem every share":""}. Example: "1000000" = 1 USDG.`}}}}var te=e=>P("steakhouse",[L(e)]);export{L as a,te as b};
@@ -1,2 +1,2 @@
1
- import{t as T}from"./7QKYDNF6.js";import{b as C,c as N,d as E}from"./FWIFTPSE.js";import{b as M}from"./2MZXTOZU.js";import{b as O,la as S}from"./7VC53B5X.js";import{a as R}from"./P4UQGWCP.js";import{c as v}from"./SCG5HWMN.js";import{e as y}from"./NWNYJ26T.js";import{a as m,i as _}from"./FWD4L3CJ.js";import{a as p}from"./XSD5NL7J.js";import{getAddress as x,isAddress as k}from"viem";function P(i){if(typeof i!="string"||!i.trim()||i.length>200)throw new p("Provide nonempty filter text of at most 200 characters.");return i}function $(i,u){if(typeof i!="number"||!Number.isSafeInteger(i)||i<0||i>u)throw new p(`Choose a pagination integer from 0 to ${u}.`);return i}var w={morpho:{assess:"morpho_status",enter:"morpho_supply_collateral",exit:"morpho_withdraw_collateral"},steakhouse:{assess:"steakhouse_list",enter:"steakhouse_deposit",exit:"steakhouse_withdraw"},spark:{assess:"spark_list",enter:"spark_deposit",exit:"spark_withdraw"},netnet:{assess:"netnet_list",enter:"netnet_deposit",exit:"netnet_withdraw"},longbow:{assess:"longbow_list",enter:"longbow_deposit",exit:"longbow_withdraw"},grove:{assess:"grove_list",enter:"grove_deposit",exit:"grove_withdraw"},beefy:{assess:"beefy_list",enter:"beefy_deposit",exit:"beefy_withdraw"},uniswap:{assess:"uniswap_list_positions",enter:"uniswap_add",exit:"uniswap_remove"},layerbank:{assess:"layerbank_list",enter:"layerbank_deposit",exit:"layerbank_withdraw"}},h=_[m].vaults,L={steakhouse:[h.steakhouse.address],spark:[h.spark.address],netnet:[h.netnet.address],longbow:[h.longbowCore.address,h.longbowFrontier.address,h.longbowEth.address],grove:[h.groveAlm.address],beefy:R.vaults.map(i=>i.earnContractAddress),layerbank:[M]},U=new Set(T.map(i=>i.marketId.toLowerCase()));function q(i,u){return Object.hasOwn(L,i)&&typeof u=="string"&&k(u,{strict:!1})&&L[i].some(g=>g.toLowerCase()===u.toLowerCase())}var Z=i=>{let u=(t,n,r)=>({name:`merkl_${t}`,inputSchema:{type:"object",properties:n,additionalProperties:!1},execute:async(c,e)=>{try{let s=Object.keys(c).find(d=>!Object.hasOwn(n,d));if(s)throw new p(`Unsupported Merkl input: ${s}.`);return await r(c,e)}catch(s){throw new p(i.plainError(s))}}}),g={page:{type:"integer",minimum:0,maximum:1e4,description:"Zero-based page number."},items:{type:"integer",minimum:1,maximum:100,description:"Maximum entries per page, from 1 to 100."}},A=async(t,n)=>{let r=new URL(`https://api.merkl.xyz/v4/${t}`);for(let[c,e]of Object.entries(n))r.searchParams.set(c,e);return v(i.http,r.toString(),{method:"GET",headers:{"User-Agent":"oak-core/merkl"}},c=>Array.isArray(c)||y(c))},b=t=>{let n=$(t.items??20,100);if(!n)throw new p("Choose at least one item per page.");return{page:String($(t.page??0,1e4)),items:String(n)}};return{tools:[u("opportunities",{...g,protocol:{type:"string",description:"Protocol identifier to filter opportunities."},name:{type:"string",description:"Opportunity name search text."},explorerAddress:{type:"string",description:"Pool or market contract address to filter opportunities."}},async t=>{let n={chainId:String(m),campaigns:"true",...b(t)};if(t.protocol!==void 0&&(n.mainProtocolId=P(t.protocol)),t.name!==void 0&&(n.name=P(t.name)),t.explorerAddress!==void 0){if(typeof t.explorerAddress!="string"||!k(t.explorerAddress,{strict:!1}))throw new p("Provide a pool or market explorer address.");n.explorerAddress=x(t.explorerAddress)}let r=await A("opportunities",n);if(!Array.isArray(r)||!r.every(e=>y(e)&&typeof e.id=="string"&&Number.isSafeInteger(e.chainId)))throw new p("Merkl returned unexpected opportunities.");return{opportunities:r.filter(e=>e.chainId===m).map(e=>{let s=(y(e.protocol)?e.protocol.id:void 0)??e.mainProtocolId??e.mainProtocol,d=typeof s=="string"?s.toLowerCase():"",o;d==="morpho"&&e.action==="LEND"?e.type==="MORPHOCOLLATERAL"?[e.marketId,e.identifier,e.explorerAddress].some(I=>typeof I=="string"&&U.has(I.toLowerCase()))&&(o=w.morpho):typeof e.type=="string"&&(e.type==="ERC20LOGPROCESSOR"||e.type.includes("MORPHOVAULT"))&&typeof e.explorerAddress=="string"&&k(e.explorerAddress,{strict:!1})&&x(e.explorerAddress)===_[m].vaults.steakhouse.address&&(o=w.steakhouse):d==="uniswap"?e.type==="UNISWAP_V4"&&e.action==="POOL"&&(o=w.uniswap):q(d,e.explorerAddress)&&(e.action==="LEND"||e.action==="STAKE")&&(o=w[d]);let l=e.action==="POOL"||o?.enter==="uniswap_add",a=l?E(e.campaigns,Math.floor(Date.now()/1e3)):void 0,f=l&&a?{lpWarning:`Illustration for $100; no deposit amount has been selected.
1
+ import{t as T}from"./JPPQDELB.js";import{b as C,c as N,d as E}from"./3PU2SD3U.js";import{b as M}from"./WAKZWSHB.js";import{b as O,la as S}from"./V5YSJKRH.js";import{a as R}from"./P4UQGWCP.js";import{c as v}from"./SCG5HWMN.js";import{e as y}from"./NWNYJ26T.js";import{b as m,j as _}from"./TI727O2H.js";import{a as p}from"./XSD5NL7J.js";import{getAddress as x,isAddress as k}from"viem";function P(i){if(typeof i!="string"||!i.trim()||i.length>200)throw new p("Provide nonempty filter text of at most 200 characters.");return i}function $(i,u){if(typeof i!="number"||!Number.isSafeInteger(i)||i<0||i>u)throw new p(`Choose a pagination integer from 0 to ${u}.`);return i}var w={morpho:{assess:"morpho_status",enter:"morpho_supply_collateral",exit:"morpho_withdraw_collateral"},steakhouse:{assess:"steakhouse_list",enter:"steakhouse_deposit",exit:"steakhouse_withdraw"},spark:{assess:"spark_list",enter:"spark_deposit",exit:"spark_withdraw"},netnet:{assess:"netnet_list",enter:"netnet_deposit",exit:"netnet_withdraw"},longbow:{assess:"longbow_list",enter:"longbow_deposit",exit:"longbow_withdraw"},grove:{assess:"grove_list",enter:"grove_deposit",exit:"grove_withdraw"},beefy:{assess:"beefy_list",enter:"beefy_deposit",exit:"beefy_withdraw"},uniswap:{assess:"uniswap_list_positions",enter:"uniswap_add",exit:"uniswap_remove"},layerbank:{assess:"layerbank_list",enter:"layerbank_deposit",exit:"layerbank_withdraw"}},h=_[m].vaults,L={steakhouse:[h.steakhouse.address],spark:[h.spark.address],netnet:[h.netnet.address],longbow:[h.longbowCore.address,h.longbowFrontier.address,h.longbowEth.address],grove:[h.groveAlm.address],beefy:R.vaults.map(i=>i.earnContractAddress),layerbank:[M]},U=new Set(T.map(i=>i.marketId.toLowerCase()));function q(i,u){return Object.hasOwn(L,i)&&typeof u=="string"&&k(u,{strict:!1})&&L[i].some(g=>g.toLowerCase()===u.toLowerCase())}var Z=i=>{let u=(t,n,r)=>({name:`merkl_${t}`,inputSchema:{type:"object",properties:n,additionalProperties:!1},execute:async(c,e)=>{try{let s=Object.keys(c).find(d=>!Object.hasOwn(n,d));if(s)throw new p(`Unsupported Merkl input: ${s}.`);return await r(c,e)}catch(s){throw new p(i.plainError(s))}}}),g={page:{type:"integer",minimum:0,maximum:1e4,description:"Zero-based page number."},items:{type:"integer",minimum:1,maximum:100,description:"Maximum entries per page, from 1 to 100."}},A=async(t,n)=>{let r=new URL(`https://api.merkl.xyz/v4/${t}`);for(let[c,e]of Object.entries(n))r.searchParams.set(c,e);return v(i.http,r.toString(),{method:"GET",headers:{"User-Agent":"oak-core/merkl"}},c=>Array.isArray(c)||y(c))},b=t=>{let n=$(t.items??20,100);if(!n)throw new p("Choose at least one item per page.");return{page:String($(t.page??0,1e4)),items:String(n)}};return{tools:[u("opportunities",{...g,protocol:{type:"string",description:"Protocol identifier to filter opportunities."},name:{type:"string",description:"Opportunity name search text."},explorerAddress:{type:"string",description:"Pool or market contract address to filter opportunities."}},async t=>{let n={chainId:String(m),campaigns:"true",...b(t)};if(t.protocol!==void 0&&(n.mainProtocolId=P(t.protocol)),t.name!==void 0&&(n.name=P(t.name)),t.explorerAddress!==void 0){if(typeof t.explorerAddress!="string"||!k(t.explorerAddress,{strict:!1}))throw new p("Provide a pool or market explorer address.");n.explorerAddress=x(t.explorerAddress)}let r=await A("opportunities",n);if(!Array.isArray(r)||!r.every(e=>y(e)&&typeof e.id=="string"&&Number.isSafeInteger(e.chainId)))throw new p("Merkl returned unexpected opportunities.");return{opportunities:r.filter(e=>e.chainId===m).map(e=>{let s=(y(e.protocol)?e.protocol.id:void 0)??e.mainProtocolId??e.mainProtocol,d=typeof s=="string"?s.toLowerCase():"",o;d==="morpho"&&e.action==="LEND"?e.type==="MORPHOCOLLATERAL"?[e.marketId,e.identifier,e.explorerAddress].some(I=>typeof I=="string"&&U.has(I.toLowerCase()))&&(o=w.morpho):typeof e.type=="string"&&(e.type==="ERC20LOGPROCESSOR"||e.type.includes("MORPHOVAULT"))&&typeof e.explorerAddress=="string"&&k(e.explorerAddress,{strict:!1})&&x(e.explorerAddress)===_[m].vaults.steakhouse.address&&(o=w.steakhouse):d==="uniswap"?e.type==="UNISWAP_V4"&&e.action==="POOL"&&(o=w.uniswap):q(d,e.explorerAddress)&&(e.action==="LEND"||e.action==="STAKE")&&(o=w[d]);let l=e.action==="POOL"||o?.enter==="uniswap_add",a=l?E(e.campaigns,Math.floor(Date.now()/1e3)):void 0,f=l&&a?{lpWarning:`Illustration for $100; no deposit amount has been selected.
2
2
  ${C({apr:typeof e.apr=="number"?e.apr:a.aprPct,endDate:typeof e.endTimestamp=="number"||typeof e.endTimestamp=="string"?e.endTimestamp:a.endsAt,amountUsd:100,outOfRangeIncentivized:a.outOfRangeIncentivized,feeWeightPct:a.feeWeightPct,creator:d==="uniswap"?a.creator:void 0})}`}:{};return{...e,oak:{...o?{candidateTools:o}:{},...f,destinationVerificationRequired:!0,eligibility:"Read campaign conditions; no wallet eligibility has been verified."}}}),...b(t),hasMore:r.length===Number(n.items),summary:"Powered by Merkl \u2014 https://app.merkl.xyz. Public, untrusted campaign data includes conditions and destinations. Candidate Oak tools require a matching verified market/vault and a supported entry AND exit. APR is indicative; no rewards are promised."}}),u("campaigns",{...g,creator:{type:"string",description:"Campaign creator address to filter."},tokenSymbol:{type:"string",description:"Reward token symbol to filter campaigns."},opportunityId:{type:"string",pattern:"^\\d{1,30}$",description:"Merkl opportunity identifier as a decimal string of 1 to 30 digits."}},async t=>{if(t.opportunityId!==void 0&&(t.creator!==void 0||t.tokenSymbol!==void 0))throw new p("Use creator and tokenSymbol without opportunityId; the opportunity endpoint does not support those filters.");if(t.opportunityId!==void 0&&(typeof t.opportunityId!="string"||!/^\d{1,30}$/.test(t.opportunityId)))throw new p("Provide an opportunityId as a decimal string of 1 to 30 digits.");let n={chainId:String(m),withOpportunity:"true",...b(t)};if(t.creator!==void 0){if(typeof t.creator!="string"||!k(t.creator,{strict:!1}))throw new p("Provide a creator address.");n.creatorAddress=x(t.creator)}t.tokenSymbol!==void 0&&(n.tokenSymbol=P(t.tokenSymbol));let r=t.opportunityId===void 0?"campaigns":`opportunities/${t.opportunityId}/campaigns`,c=await A(r,t.opportunityId===void 0?n:{}),e=t.opportunityId!==void 0&&y(c)?c:void 0;if(e&&e.chainId!==m)throw new p(`Merkl opportunity must be on chain ${m}.`);let s=t.opportunityId===void 0?c:e?.campaigns;if(!Array.isArray(s)||!s.every(f=>y(f)&&(typeof f.id=="string"||typeof f.id=="number")))throw new p("Merkl returned unexpected campaigns.");let d=e?s.filter(f=>f.distributionChainId===m):s,o=Number(n.page)*Number(n.items),l=t.opportunityId===void 0?d:d.slice(o,o+Number(n.items)),a=t.opportunityId===void 0?d.length===Number(n.items):o+Number(n.items)<d.length;return{campaigns:l,...e?{opportunity:{id:e.id,name:e.name,chainId:e.chainId,protocol:y(e.protocol)?{id:e.protocol.id,name:e.protocol.name}:void 0,explorerAddress:e.explorerAddress,identifier:e.identifier}}:{},chainId:m,...b(t),hasMore:a,summary:"Powered by Merkl \u2014 https://app.merkl.xyz. Campaign rules, budgets, timing, exclusions and configuration are public API data; verify the reward distribution chain and destination before entering."}}),u("earning_status",{view:{enum:["active","breakdowns","stats","claims"],description:"active lists earning opportunities; breakdowns shows reward details; stats shows totals; claims lists claims."},...g},async(t,n)=>{if(!k(n,{strict:!1}))throw new p("Provide a valid connected wallet address.");let r=t.view??"active";if(!["active","breakdowns","stats","claims"].includes(String(r)))throw new p("Choose active, breakdowns, stats or claims.");let c=r==="claims"?"claims":r==="breakdowns"?`users/${n}/rewards/chains/${m}/breakdowns`:`users/${n}/rewards/${r==="active"?"active-opportunities":"stats"}`,{page:e,items:s}=b(t),d=r==="breakdowns"?{}:{chainId:String(m)};r==="claims"&&(d.recipient=n);let o=await A(c,d),l=Number(e)*Number(s),a=Array.isArray(o)?o:r==="breakdowns"&&y(o)&&Array.isArray(o.opportunities)?o.opportunities:void 0,f=a?Array.isArray(o)?a.slice(l,l+Number(s)):{...o,opportunities:a.slice(l,l+Number(s))}:o,D=r==="active"&&Array.isArray(a)&&a.length===0?`${O(S,{after_deposit:N()})} `:"";return{view:r,chainId:m,wallet:n,data:f,...a?{page:e,items:s,hasMore:l+Number(s)<a.length}:{},summary:`${D}Powered by Merkl \u2014 https://app.merkl.xyz. API earning attribution and history can lag onchain state; pending earnings are not claimable. Private or restricted attribution may be omitted by Merkl. Recheck merkl_rewards before a claim.`}})]}};export{Z as a};
@@ -1 +1 @@
1
- import{d as l,e as N,f as T}from"./7D73A6KS.js";import{a as D}from"./JKD2B6OX.js";import{a as w,c as o,d as u,e as y,g as b}from"./2MZXTOZU.js";import{a as U}from"./43LI5NKJ.js";import{b as A}from"./66F5ZH34.js";import{h as S,n as x}from"./NWNYJ26T.js";import{a as p}from"./FWD4L3CJ.js";import{a as n}from"./XSD5NL7J.js";import{encodeFunctionData as G}from"viem";function $(e,s){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(t=>t!=="amount"))throw new n("Provide only the amount for this LayerBank action.");return s&&e.amount==="max"?"max":x(e.amount,"Amount must be positive and fit uint256.",{notString:"Amount must be a positive base-unit integer string.",positive:!0})}function k(e,s){return e.changes.filter(t=>t.token.chainId===p&&S(t.token.address,s.address)).reduce((t,i)=>{if(i.token.decimals!==s.decimals||typeof i.amount!="string"||!/^-?\d+$/.test(i.amount)||BigInt(i.amount)<-y||BigInt(i.amount)>y)throw new n("LayerBank preview returned invalid token metadata or amounts.");return t+BigInt(i.amount)},0n)}function z(e){let s=t=>async(i,d)=>{try{let m=$(i,t);U(d),N(e);let v=e.clientFor(p),r=await D(v);if(!r.active)throw new n("LayerBank reserve is inactive. Nothing was signed.");if(r.paused)throw new n("LayerBank reserve is paused. Nothing was signed.");if(!t&&r.frozen)throw new n("LayerBank reserve is frozen for deposits. Nothing was signed.");let c=await T(v,t?u:o,d,r.blockNumber),a=m==="max"?c:m;if(t){if(c===0n)throw new n("This wallet has no lRobUSDG to withdraw. Nothing was signed.");if(a>c)throw new n("The withdrawal exceeds this wallet\u2019s lRobUSDG balance. Nothing was signed.");if(r.cashUsdgBase===0n)throw new n("LayerBank has no cash on hand for a withdrawal right now. Please try again later. Nothing was signed.");if(a>r.cashUsdgBase){let g=r.cashUsdgBase;return{status:"unavailable",offer:{tool:"layerbank_withdraw",arguments:{amount:g.toString()},amount:l(o,g),requiresConfirmation:!0},summary:`LayerBank has only ${e.formatAmount(g.toString(),6)} USDG in cash on hand. Request that smaller amount only if you agree; Oak will check it again. Nothing was signed.`}}}else{if(a>r.capRoomBase)throw new n("The deposit exceeds LayerBank\u2019s current supply cap room. Nothing was signed.");if(a>c)throw new n("The deposit exceeds this wallet\u2019s USDG balance. Nothing was signed.")}let f=e.formatAmount(a.toString(),6),L=t?G({abi:b,functionName:"withdraw",args:[o.address,m==="max"?y:a,d]}):G({abi:b,functionName:"supply",args:[o.address,a,d,0]}),B=[...t?[]:[e.approval(o.address,w,a.toString(),p)],e.unsignedTx({to:w,data:L,value:"0",chainId:p,description:t?`Withdraw ${m==="max"?"all ":""}${f} USDG from LayerBank to this wallet.`:`Supply ${f} USDG to LayerBank for this wallet.`})],h=await e.preview(B,d);if(t?k(h,o)<a:k(h,o)!==-a||k(h,u)<a-1n)throw new n("LayerBank preview does not match the requested input and minimum receipt. Nothing was signed.");return{txs:B,preview:h,amounts:{assets:l(o,a),...t?{receiptBalance:l(u,c)}:{expectedReceipt:l(u,a),minimumReceipt:l(u,a-1n)}},summary:`${t?`Withdraw ${m==="max"?"the full measured balance of ":""}${f} USDG to this wallet.`:`Approve exactly ${f} USDG to LayerBank pool ${w}, then supply for this wallet.`} Receipts are checked in simulation; the pool encodes no output minimum.`}}catch(m){throw new n(e.plainError(m))}};return[{name:"layerbank_deposit",inputSchema:{type:"object",properties:{amount:A('Positive USDG amount in base units (6 decimals): "1000000" = 1 USDG.')},required:["amount"],additionalProperties:!1},execute:s(!1)},{name:"layerbank_withdraw",inputSchema:{type:"object",properties:{amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:'USDG amount in base units (6 decimals): "1000000" = 1 USDG; max withdraws the full balance.'}},required:["amount"],additionalProperties:!1},execute:s(!0)}]}export{z as a};
1
+ import{d as l,e as N,f as T}from"./VB36EHIR.js";import{a as D}from"./MSRCJ2BS.js";import{a as w,c as o,d as u,e as y,g as b}from"./WAKZWSHB.js";import{a as U}from"./43LI5NKJ.js";import{b as A}from"./66F5ZH34.js";import{h as S,n as x}from"./NWNYJ26T.js";import{b as p}from"./TI727O2H.js";import{a as n}from"./XSD5NL7J.js";import{encodeFunctionData as G}from"viem";function $(e,s){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(t=>t!=="amount"))throw new n("Provide only the amount for this LayerBank action.");return s&&e.amount==="max"?"max":x(e.amount,"Amount must be positive and fit uint256.",{notString:"Amount must be a positive base-unit integer string.",positive:!0})}function k(e,s){return e.changes.filter(t=>t.token.chainId===p&&S(t.token.address,s.address)).reduce((t,i)=>{if(i.token.decimals!==s.decimals||typeof i.amount!="string"||!/^-?\d+$/.test(i.amount)||BigInt(i.amount)<-y||BigInt(i.amount)>y)throw new n("LayerBank preview returned invalid token metadata or amounts.");return t+BigInt(i.amount)},0n)}function z(e){let s=t=>async(i,d)=>{try{let m=$(i,t);U(d),N(e);let v=e.clientFor(p),r=await D(v);if(!r.active)throw new n("LayerBank reserve is inactive. Nothing was signed.");if(r.paused)throw new n("LayerBank reserve is paused. Nothing was signed.");if(!t&&r.frozen)throw new n("LayerBank reserve is frozen for deposits. Nothing was signed.");let c=await T(v,t?u:o,d,r.blockNumber),a=m==="max"?c:m;if(t){if(c===0n)throw new n("This wallet has no lRobUSDG to withdraw. Nothing was signed.");if(a>c)throw new n("The withdrawal exceeds this wallet\u2019s lRobUSDG balance. Nothing was signed.");if(r.cashUsdgBase===0n)throw new n("LayerBank has no cash on hand for a withdrawal right now. Please try again later. Nothing was signed.");if(a>r.cashUsdgBase){let g=r.cashUsdgBase;return{status:"unavailable",offer:{tool:"layerbank_withdraw",arguments:{amount:g.toString()},amount:l(o,g),requiresConfirmation:!0},summary:`LayerBank has only ${e.formatAmount(g.toString(),6)} USDG in cash on hand. Request that smaller amount only if you agree; Oak will check it again. Nothing was signed.`}}}else{if(a>r.capRoomBase)throw new n("The deposit exceeds LayerBank\u2019s current supply cap room. Nothing was signed.");if(a>c)throw new n("The deposit exceeds this wallet\u2019s USDG balance. Nothing was signed.")}let f=e.formatAmount(a.toString(),6),L=t?G({abi:b,functionName:"withdraw",args:[o.address,m==="max"?y:a,d]}):G({abi:b,functionName:"supply",args:[o.address,a,d,0]}),B=[...t?[]:[e.approval(o.address,w,a.toString(),p)],e.unsignedTx({to:w,data:L,value:"0",chainId:p,description:t?`Withdraw ${m==="max"?"all ":""}${f} USDG from LayerBank to this wallet.`:`Supply ${f} USDG to LayerBank for this wallet.`})],h=await e.preview(B,d);if(t?k(h,o)<a:k(h,o)!==-a||k(h,u)<a-1n)throw new n("LayerBank preview does not match the requested input and minimum receipt. Nothing was signed.");return{txs:B,preview:h,amounts:{assets:l(o,a),...t?{receiptBalance:l(u,c)}:{expectedReceipt:l(u,a),minimumReceipt:l(u,a-1n)}},summary:`${t?`Withdraw ${m==="max"?"the full measured balance of ":""}${f} USDG to this wallet.`:`Approve exactly ${f} USDG to LayerBank pool ${w}, then supply for this wallet.`} Receipts are checked in simulation; the pool encodes no output minimum.`}}catch(m){throw new n(e.plainError(m))}};return[{name:"layerbank_deposit",inputSchema:{type:"object",properties:{amount:A('Positive USDG amount in base units (6 decimals): "1000000" = 1 USDG.')},required:["amount"],additionalProperties:!1},execute:s(!1)},{name:"layerbank_withdraw",inputSchema:{type:"object",properties:{amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:'USDG amount in base units (6 decimals): "1000000" = 1 USDG; max withdraws the full balance.'}},required:["amount"],additionalProperties:!1},execute:s(!0)}]}export{z as a};
@@ -1 +1 @@
1
- import{a as g}from"./X5V2Z2NM.js";import{a as m}from"./43LI5NKJ.js";import{a as k}from"./66F5ZH34.js";import{e as A,g as u,i as b}from"./NWNYJ26T.js";import{a as l,i as x,s as y}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{b as w}from"./JXOEJPJ4.js";import{Buffer as v}from"node:buffer";import{decodeEventLog as $}from"viem";var R="Profile contents and oak.registrar are mutable, self-asserted metadata, not registry-validated claims or proof of provenance. Oak registration always writes the public oak.registrar = oak marker on Robinhood Chain. Anyone can see it, and the transaction stays in the public history even if the marker is changed later.",B="oak.registrar",D="0x6f616b",L=k("Agent ID as a decimal uint256 integer string."),j={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},q={type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"32-byte hex value."},z={type:"string",pattern:"^0x([0-9a-fA-F]{2})*$"},T="0x0000000000000000000000000000000000000000";function h(t){let e=t.network??"mainnet",{chainId:n,identityRegistry:r}=y[e],s=e==="mainnet"?x[l].identity:void 0;return{network:e,chainId:n,registry:r,registryId:`eip155:${n}:${r}`,reputation:s?.reputationRegistry.address,validation:s?.validationRegistry.address}}function K(t){let{chainId:e,reputation:n}=h(t);if(!n)throw new o("Oak has no pinned ERC-8004 reputation registry for this network.");return{chainId:e,address:n}}function V(t){let{chainId:e,validation:n}=h(t);if(!n)throw new o("Oak has no pinned ERC-8004 validation registry for this network.");return{chainId:e,address:n}}function Z(t){return u(t,T)}function G(t){if(typeof t!="string"||!/^[0-9]+$/.test(t)||t.length>78||BigInt(t)>=2n**256n)throw new o("Provide an agent ID as a decimal uint256 integer string.");return BigInt(t)}function J(t,e){return b(t,`Provide a valid ${e} address.`)}function Q(t,e){let n=h(t).chainId;if(e!==void 0&&e!==n)throw new o(`ERC-8004 actions are supported only on chain ${n}.`)}function X(t,e){if(typeof t!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t))throw new o(`Provide ${e} as 32-byte hex.`);return t.toLowerCase()}function I(t,e,n,r=!0){if(t===void 0){if(r)return"";throw new o(`Provide ${e}.`)}if(typeof t!="string"||!r&&!t.trim()||t.length>n||w(t))throw new o(`${e} must be plain text of at most ${n} characters.`);return t}function Y(t,e){if(typeof t!="string"||!t.trim()||t.length>2048)throw new o(`Provide a valid ${e}.`);try{let n=new URL(t);if(!["https:","ipfs:"].includes(n.protocol)||!n.hostname||n.username||n.password||w(t))throw new Error}catch{throw new o(`${e} must be an HTTPS or IPFS URI without credentials.`)}return t}function tt(t){let e=/^data:application\/json;base64,([A-Za-z0-9+/=]+)$/.exec(t);if(e)try{let n=JSON.parse(v.from(e[1],"base64").toString("utf8"));return A(n)?n:void 0}catch{return}}async function C(t,e,n,r,s=!0){let i=await t.preview(e,n),a=i.changes.map(({amount:d,token:f})=>{let c=d.startsWith("-");return`${c?"-":""}${t.formatAmount(c?d.slice(1):d,f.decimals)} ${f.symbol} (${f.address}, chain ${f.chainId})`});return{txs:e,summary:`${i.summary} ${a.join("; ")} ${s?`${R} `:""}${r}`}}async function et(t,e,n,r="update this profile"){let{chainId:s,registry:i}=h(t),a=t.clientFor(s),d=await a.readContract({address:i,abi:g,functionName:"ownerOf",args:[e]});if(m(d),u(d,n))return d;let[f,c]=await Promise.all([a.readContract({address:i,abi:g,functionName:"getApproved",args:[e]}),a.readContract({address:i,abi:g,functionName:"isApprovedForAll",args:[d,n]})]);if(m(f),typeof c!="boolean")throw new o("The registry returned invalid operator approval data.");if(!u(f,n)&&!c)throw new o(`Only the agent owner or an approved operator can ${r}.`);return d}async function nt(t,e,n){let{chainId:r,registry:s}=h(t),i=t.clientFor(r),a=await i.readContract({address:s,abi:g,functionName:"ownerOf",args:[e]});if(m(a),u(a,n))return a;if(await i.readContract({address:s,abi:g,functionName:"isApprovedForAll",args:[a,n]})!==!0)throw new o("Only the agent owner or an operator approved for all of its agents can change the token approval.");return a}async function H(t,e,n,r,s){let{chainId:i,registry:a}=h(t),d=s??a;if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new o("Provide the mined transaction hash.");let f=t.clientFor(i),c=await f.getTransactionReceipt({hash:e});if(!c)throw new o("The transaction is not mined yet. Try again after confirmation.");if(c.status!=="success"||!c.to||!u(c.to,d)||!u(c.from,n)||!u(c.transactionHash,e))throw new o("The receipt is not a successful matching registry transaction.");let p=await f.getTransaction({hash:e});if(p.chainId!==i||p.value!==0n||!p.to||!u(p.to,d)||!u(p.from,n))throw new o("The transaction does not match this chain, registry and wallet.");if(!(typeof r=="function"?typeof p.input=="string"&&r(p.input):typeof p.input=="string"&&u(p.input,r)))throw new o("The mined transaction calldata does not match the exact operation Oak built.");return c}function rt(t,e,n,r){let s=t.logs.filter(i=>u(i.address,e)&&!i.removed).flatMap(i=>{try{let a=$({abi:n,topics:i.topics,data:i.data,strict:!0});return a.eventName===r?[a.args]:[]}catch{return[]}});if(s.length!==1)throw new o(`The receipt must contain one matching ${r} event.`);return s[0]}function ot(t){let e=I(t,"metadata key",128,!1);if(e==="agentWallet")throw new o("The key agentWallet is reserved: use erc8004_set_wallet / erc8004_unset_wallet, which prove control of the wallet.");return e}function it(t){if(t.value===void 0==(t.text===void 0))throw new o("Provide exactly one of value (0x hex bytes) or text (UTF-8).");let e;if(t.value!==void 0){if(typeof t.value!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(t.value))throw new o("Metadata value must be 0x-prefixed hex bytes.");e=t.value}else{if(typeof t.text!="string")throw new o("Metadata text must be a string.");e=`0x${v.from(t.text,"utf8").toString("hex")}`}if((e.length-2)/2>4096)throw new o("Metadata values are limited to 4096 bytes.");return e}async function at(t,e,n,r){let{chainId:s}=h(t);if(n.transactionHash!==void 0){let a=await H(t,n.transactionHash,e,r.matcher??r.data,r.to);return r.verify(a)}await r.authority();let i=t.unsignedTx({to:r.to,data:r.data,value:"0",chainId:s,description:r.description});return C(t,[i],e,r.summary,!1)}export{R as a,B as b,D as c,L as d,j as e,q as f,z as g,h,K as i,V as j,Z as k,G as l,J as m,Q as n,X as o,I as p,Y as q,tt as r,C as s,et as t,nt as u,H as v,rt as w,ot as x,it as y,at as z};
1
+ import{a as g}from"./X5V2Z2NM.js";import{a as m}from"./43LI5NKJ.js";import{a as k}from"./66F5ZH34.js";import{e as A,g as u,i as b}from"./NWNYJ26T.js";import{b as l,j as x,t as y}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{b as w}from"./JXOEJPJ4.js";import{Buffer as v}from"node:buffer";import{decodeEventLog as $}from"viem";var R="Profile contents and oak.registrar are mutable, self-asserted metadata, not registry-validated claims or proof of provenance. Oak registration always writes the public oak.registrar = oak marker on Robinhood Chain. Anyone can see it, and the transaction stays in the public history even if the marker is changed later.",B="oak.registrar",D="0x6f616b",L=k("Agent ID as a decimal uint256 integer string."),j={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},q={type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"32-byte hex value."},z={type:"string",pattern:"^0x([0-9a-fA-F]{2})*$"},T="0x0000000000000000000000000000000000000000";function h(t){let e=t.network??"mainnet",{chainId:n,identityRegistry:r}=y[e],s=e==="mainnet"?x[l].identity:void 0;return{network:e,chainId:n,registry:r,registryId:`eip155:${n}:${r}`,reputation:s?.reputationRegistry.address,validation:s?.validationRegistry.address}}function K(t){let{chainId:e,reputation:n}=h(t);if(!n)throw new o("Oak has no pinned ERC-8004 reputation registry for this network.");return{chainId:e,address:n}}function V(t){let{chainId:e,validation:n}=h(t);if(!n)throw new o("Oak has no pinned ERC-8004 validation registry for this network.");return{chainId:e,address:n}}function Z(t){return u(t,T)}function G(t){if(typeof t!="string"||!/^[0-9]+$/.test(t)||t.length>78||BigInt(t)>=2n**256n)throw new o("Provide an agent ID as a decimal uint256 integer string.");return BigInt(t)}function J(t,e){return b(t,`Provide a valid ${e} address.`)}function Q(t,e){let n=h(t).chainId;if(e!==void 0&&e!==n)throw new o(`ERC-8004 actions are supported only on chain ${n}.`)}function X(t,e){if(typeof t!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t))throw new o(`Provide ${e} as 32-byte hex.`);return t.toLowerCase()}function I(t,e,n,r=!0){if(t===void 0){if(r)return"";throw new o(`Provide ${e}.`)}if(typeof t!="string"||!r&&!t.trim()||t.length>n||w(t))throw new o(`${e} must be plain text of at most ${n} characters.`);return t}function Y(t,e){if(typeof t!="string"||!t.trim()||t.length>2048)throw new o(`Provide a valid ${e}.`);try{let n=new URL(t);if(!["https:","ipfs:"].includes(n.protocol)||!n.hostname||n.username||n.password||w(t))throw new Error}catch{throw new o(`${e} must be an HTTPS or IPFS URI without credentials.`)}return t}function tt(t){let e=/^data:application\/json;base64,([A-Za-z0-9+/=]+)$/.exec(t);if(e)try{let n=JSON.parse(v.from(e[1],"base64").toString("utf8"));return A(n)?n:void 0}catch{return}}async function C(t,e,n,r,s=!0){let i=await t.preview(e,n),a=i.changes.map(({amount:d,token:f})=>{let c=d.startsWith("-");return`${c?"-":""}${t.formatAmount(c?d.slice(1):d,f.decimals)} ${f.symbol} (${f.address}, chain ${f.chainId})`});return{txs:e,summary:`${i.summary} ${a.join("; ")} ${s?`${R} `:""}${r}`}}async function et(t,e,n,r="update this profile"){let{chainId:s,registry:i}=h(t),a=t.clientFor(s),d=await a.readContract({address:i,abi:g,functionName:"ownerOf",args:[e]});if(m(d),u(d,n))return d;let[f,c]=await Promise.all([a.readContract({address:i,abi:g,functionName:"getApproved",args:[e]}),a.readContract({address:i,abi:g,functionName:"isApprovedForAll",args:[d,n]})]);if(m(f),typeof c!="boolean")throw new o("The registry returned invalid operator approval data.");if(!u(f,n)&&!c)throw new o(`Only the agent owner or an approved operator can ${r}.`);return d}async function nt(t,e,n){let{chainId:r,registry:s}=h(t),i=t.clientFor(r),a=await i.readContract({address:s,abi:g,functionName:"ownerOf",args:[e]});if(m(a),u(a,n))return a;if(await i.readContract({address:s,abi:g,functionName:"isApprovedForAll",args:[a,n]})!==!0)throw new o("Only the agent owner or an operator approved for all of its agents can change the token approval.");return a}async function H(t,e,n,r,s){let{chainId:i,registry:a}=h(t),d=s??a;if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new o("Provide the mined transaction hash.");let f=t.clientFor(i),c=await f.getTransactionReceipt({hash:e});if(!c)throw new o("The transaction is not mined yet. Try again after confirmation.");if(c.status!=="success"||!c.to||!u(c.to,d)||!u(c.from,n)||!u(c.transactionHash,e))throw new o("The receipt is not a successful matching registry transaction.");let p=await f.getTransaction({hash:e});if(p.chainId!==i||p.value!==0n||!p.to||!u(p.to,d)||!u(p.from,n))throw new o("The transaction does not match this chain, registry and wallet.");if(!(typeof r=="function"?typeof p.input=="string"&&r(p.input):typeof p.input=="string"&&u(p.input,r)))throw new o("The mined transaction calldata does not match the exact operation Oak built.");return c}function rt(t,e,n,r){let s=t.logs.filter(i=>u(i.address,e)&&!i.removed).flatMap(i=>{try{let a=$({abi:n,topics:i.topics,data:i.data,strict:!0});return a.eventName===r?[a.args]:[]}catch{return[]}});if(s.length!==1)throw new o(`The receipt must contain one matching ${r} event.`);return s[0]}function ot(t){let e=I(t,"metadata key",128,!1);if(e==="agentWallet")throw new o("The key agentWallet is reserved: use erc8004_set_wallet / erc8004_unset_wallet, which prove control of the wallet.");return e}function it(t){if(t.value===void 0==(t.text===void 0))throw new o("Provide exactly one of value (0x hex bytes) or text (UTF-8).");let e;if(t.value!==void 0){if(typeof t.value!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(t.value))throw new o("Metadata value must be 0x-prefixed hex bytes.");e=t.value}else{if(typeof t.text!="string")throw new o("Metadata text must be a string.");e=`0x${v.from(t.text,"utf8").toString("hex")}`}if((e.length-2)/2>4096)throw new o("Metadata values are limited to 4096 bytes.");return e}async function at(t,e,n,r){let{chainId:s}=h(t);if(n.transactionHash!==void 0){let a=await H(t,n.transactionHash,e,r.matcher??r.data,r.to);return r.verify(a)}await r.authority();let i=t.unsignedTx({to:r.to,data:r.data,value:"0",chainId:s,description:r.description});return C(t,[i],e,r.summary,!1)}export{R as a,B as b,D as c,L as d,j as e,q as f,z as g,h,K as i,V as j,Z as k,G as l,J as m,Q as n,X as o,I as p,Y as q,tt as r,C as s,et as t,nt as u,H as v,rt as w,ot as x,it as y,at as z};
@@ -1,2 +1,2 @@
1
- import{f as k,g as F,i as M,n as _,o as w,p as z}from"./RPB46QAC.js";import{$ as N,U as A,Z as T,_ as I,aa as O,b as s,ba as W,ca as y,da as D,ea as R,fa as S,ga as x,ha as U,ia as b,ja as B,ka as C}from"./7VC53B5X.js";import{getAddress as H,isAddress as G}from"viem";function K(e){if(e==null)return;let r=e instanceof Date?e.getTime()/1e3:typeof e=="string"?/^\d{1,12}$/.test(e)?Number(e):Date.parse(e)/1e3:e;return typeof r=="number"&&Number.isFinite(r)?Math.floor(r):void 0}var a=e=>typeof e=="number"&&Number.isFinite(e),$=e=>w(e).replace(/\.?0+$/,"");function j(e){let r=e.nowSec??Math.floor(Date.now()/1e3),f=K(e.endDate),i=a(e.apr)&&e.apr>=0?e.apr:void 0,o=a(e.amountUsd)&&e.amountUsd>0?e.amountUsd:void 0,g={addButton:U,declineButton:b};if(i===void 0||f===void 0||f<=r)return{text:s(x,{}),readable:!1,notWorth:!0,defaultButton:b,...g};let l=z(f),u=[s(I,{apr:$(i),end_date:l})];e.outOfRangeIncentivized===!1&&u.push(s(N,{})),a(e.feeWeightPct)&&e.feeWeightPct>0&&e.feeWeightPct<=100&&u.push(s(O,{w:$(e.feeWeightPct)}));let d=!1,c=[];if(o!==void 0){let n=(f-r)/86400,t=M({amountUsd:o,ratePct:i,days:n}),m=k(e.gasUsd);d=F({gross:t,costs:m.usd,amount:o}).tooSmall,u.push(s(W,{amount_usd:_(o),per_day_usd:_(o*i/100/365),gross_usd:_(t),end_date:l}),s(y,{gas_usd:_(m.usd)})),d&&c.push(s(S,{})),m.estimatedHigh&&c.push(s(A,{}))}u.push(s(D,{}),...c);let p=typeof e.creator=="string"&&G(e.creator,{strict:!1})?H(e.creator):void 0;return{text:s(T,{worth_line:u.join(" "),funder_line:p?`${s(R,{creator:p})}
1
+ import{f as k,g as F,i as M,n as _,o as w,p as z}from"./H3E7UD2X.js";import{$ as N,U as A,Z as T,_ as I,aa as O,b as s,ba as W,ca as y,da as D,ea as R,fa as S,ga as x,ha as U,ia as b,ja as B,ka as C}from"./V5YSJKRH.js";import{getAddress as H,isAddress as G}from"viem";function K(e){if(e==null)return;let r=e instanceof Date?e.getTime()/1e3:typeof e=="string"?/^\d{1,12}$/.test(e)?Number(e):Date.parse(e)/1e3:e;return typeof r=="number"&&Number.isFinite(r)?Math.floor(r):void 0}var a=e=>typeof e=="number"&&Number.isFinite(e),$=e=>w(e).replace(/\.?0+$/,"");function j(e){let r=e.nowSec??Math.floor(Date.now()/1e3),f=K(e.endDate),i=a(e.apr)&&e.apr>=0?e.apr:void 0,o=a(e.amountUsd)&&e.amountUsd>0?e.amountUsd:void 0,g={addButton:U,declineButton:b};if(i===void 0||f===void 0||f<=r)return{text:s(x,{}),readable:!1,notWorth:!0,defaultButton:b,...g};let l=z(f),u=[s(I,{apr:$(i),end_date:l})];e.outOfRangeIncentivized===!1&&u.push(s(N,{})),a(e.feeWeightPct)&&e.feeWeightPct>0&&e.feeWeightPct<=100&&u.push(s(O,{w:$(e.feeWeightPct)}));let d=!1,c=[];if(o!==void 0){let n=(f-r)/86400,t=M({amountUsd:o,ratePct:i,days:n}),m=k(e.gasUsd);d=F({gross:t,costs:m.usd,amount:o}).tooSmall,u.push(s(W,{amount_usd:_(o),per_day_usd:_(o*i/100/365),gross_usd:_(t),end_date:l}),s(y,{gas_usd:_(m.usd)})),d&&c.push(s(S,{})),m.estimatedHigh&&c.push(s(A,{}))}u.push(s(D,{}),...c);let p=typeof e.creator=="string"&&G(e.creator,{strict:!1})?H(e.creator):void 0;return{text:s(T,{worth_line:u.join(" "),funder_line:p?`${s(R,{creator:p})}
2
2
  `:"",end_date:l}),readable:!0,notWorth:d,...d?{defaultButton:b}:{},...g}}function X(e){return j(e).text}function Y(e){let r=a(e)&&e>0?s(C,{time:new Date(e*1e3).toISOString().slice(0,16).replace("T"," ")}):"";return s(B,{last_update_clause:r})}var h=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),E=e=>{if(a(e)&&Number.isSafeInteger(e)&&e>0)return e;if(typeof e=="string"&&/^\d{1,12}$/.test(e))return Number(e)};function P(e){if(!(e.length===0||e.some(r=>r===void 0)))return e.every(r=>r===e[0])?e[0]:void 0}function Z(e,r,f=4663){if(!Array.isArray(e))return{live:0};let i=e.filter(h).filter(n=>{if(n.distributionChainId!==void 0&&Number(n.distributionChainId)!==f)return!1;let t=E(n.startTimestamp),m=E(n.endTimestamp);return m!==void 0&&m>r&&(t===void 0||t<=r)});if(i.length===0)return{live:0};let o=i.map(n=>a(n.apr)&&n.apr>=0?n.apr:void 0),g=i.map(n=>h(n.params)?n.params:{}),l=g.map(n=>{let t=typeof n.weightFees=="string"&&/^\d{1,5}$/.test(n.weightFees)?Number(n.weightFees):n.weightFees;return a(t)&&Number.isInteger(t)&&t>=0&&t<=1e4?t/100:void 0}),u=i.map(n=>{let t=typeof n.creatorAddress=="string"?n.creatorAddress:h(n.creator)&&typeof n.creator.address=="string"?n.creator.address:void 0;return t!==void 0&&G(t,{strict:!1})?H(t):void 0}),d={live:i.length,endsAt:Math.min(...i.map(n=>E(n.endTimestamp)))};o.every(a)&&(d.aprPct=o.reduce((n,t)=>n+t,0));let c=P(g.map(n=>typeof n.isOutOfRangeIncentivized=="boolean"?n.isOutOfRangeIncentivized:void 0));c!==void 0&&(d.outOfRangeIncentivized=c);let p=P(l);p!==void 0&&(d.feeWeightPct=p);let L=P(u);return L!==void 0&&(d.creator=L),d}export{j as a,X as b,Y as c,Z as d};
@@ -1 +1 @@
1
- import{a as H}from"./66F5ZH34.js";import{c as B,f as j,g as b,k as F,n as G}from"./NWNYJ26T.js";import{a as k,i as z}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{encodeFunctionData as Q,erc20Abi as O,parseAbi as oe,zeroHash as J}from"viem";var ne=z[k].meridian,S=ne.PredictionMarketEscrow.address,T={address:ne.CollateralToken_USDe.address,chainId:k,symbol:"USDe",decimals:18},se="https://api.predict.meridian.xyz/graphql",ae="query GetOpenConditions($now: Int!, $first: Int!, $after: String, $search: String, $conditionIds: [Bytes!], $resolvers: [Address!]) { conditions(first: $first, after: $after, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now }, search: $search, conditionIds: $conditionIds, resolvers: $resolvers }) { totalCount pageInfo { hasNextPage endCursor } nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",de="query GetHolderPositions($holder: Address!, $first: Int!, $after: String) { positions(first: $first, after: $after, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { totalCount pageInfo { hasNextPage endCursor } nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",U=oe(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},V={type:"string",minLength:1,maxLength:4096,description:"Opaque nextCursor returned by the previous page."},E=25,W={type:"integer",minimum:1,maximum:E},ce=1e3;function Y(e,p){if(e===void 0)return p;if(!Number.isSafeInteger(e)||e<1||e>E)throw new a("Provide a Meridian page limit from 1 to 25.");return e}function Z(e){if(e===void 0)return;let p=()=>new a("Provide the opaque Meridian nextCursor returned by the previous page.");if(typeof e!="string"||e.length>4096||!/^[A-Za-z0-9+/_-]+={0,2}$/.test(e))throw p();try{let c=Buffer.from(e,"base64url");if(c.toString("base64url")!==e.replace(/=+$/,"").replace(/\+/g,"-").replace(/\//g,"_"))throw p();let m=C(JSON.parse(c.toString("utf8")));if(typeof m.k!="string"||!m.k||typeof m.id!="string"||!m.id)throw p()}catch{throw p()}return e}function X(e,p,c,m=!1){let l=C(e),f=C(l.pageInfo),P=Array.isArray(l.nodes)?l.nodes.filter(q=>!m||N(C(q).balance)!=="0").length:0;if(!Array.isArray(l.nodes)||l.nodes.length>p||!Number.isSafeInteger(l.totalCount)||l.totalCount<P||typeof f.hasNextPage!="boolean"||c===void 0&&!f.hasNextPage&&l.totalCount>l.nodes.length||f.endCursor!==null&&(typeof f.endCursor!="string"||!f.endCursor.trim()||f.endCursor.length>4096)||f.hasNextPage&&(l.nodes.length===0||f.endCursor===null||f.endCursor===c))throw new a("Meridian returned invalid pagination; retry the scan from the first page.");return{nodes:l.nodes,totalCount:l.totalCount,nextCursor:f.hasNextPage?f.endCursor:null,complete:!f.hasNextPage&&c===void 0}}function C(e){return j(e,"Meridian returned an unexpected response.")}function A(e){if(typeof e!="string"||!e.trim())throw new a("Meridian returned an invalid text field.");return e}function I(e){return F(e,"Provide a valid Meridian contract or wallet address.")}function v(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new a("Provide a valid Meridian prediction or pick configuration ID.");return e}function R(e){return G(e,"Meridian amount exceeds the uint256 range.",{notString:"Meridian amounts must be integer strings in base units."}).toString()}function N(e){return e===0?"0":R(e)}function D(e){if(typeof e!="bigint"||e<0n)throw new a("Meridian returned an invalid on-chain amount.");return R(e.toString())}function ue(e,p){return e.chainId===p.chainId&&b(e.address,p.address)}function ee(e,p){let c=C(e),m=C(c.pickConfig),l=I(c.holder),f=I(m.marketAddress);if(c.chainId!==k||!b(l,p))throw new a("Meridian returned a position for a different wallet or chain.");if(!b(f,S))throw new a("This Meridian position uses an unsupported escrow contract.");if(typeof m.resolved!="boolean"||m.result!==null&&typeof m.result!="string")throw new a("Meridian returned an invalid resolution.");let P=v(c.pickConfigId);if(!b(v(m.pickConfigId),P))throw new a("Meridian returned mismatched pick configuration IDs.");if(c.side!=="PREDICTOR"&&c.side!=="COUNTERPARTY")throw new a("Meridian returned an invalid position side.");return{id:A(c.id),chainId:k,holder:l,side:c.side,balance:N(c.balance),tokenAddress:I(c.tokenAddress),pickConfigId:P,userCollateral:N(c.userCollateral),totalPayout:N(c.totalPayout),prediction:{predictionId:v(C(c.prediction).predictionId)},pickConfig:{pickConfigId:P,marketAddress:f,resolved:m.resolved,result:m.result}}}var le=e=>{async function p(t){try{return await t()}catch(o){throw new a(e.plainError(o))}}async function c(){let t=e.clientFor(k);if(await t.getChainId()!==k)throw new a("Meridian requires an RPC on chain 4663.");return t}async function m(t,o,r){let s=new URL(se);s.searchParams.set("op",t),s.searchParams.set("query",o),s.searchParams.set("variables",JSON.stringify(r));let n=await e.http(s.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!n.ok)throw new a(`Meridian returned HTTP ${n.status}. Please try again.`);let u;try{u=await n.json()}catch{throw new a("Meridian returned malformed JSON.")}let d=C(u);if(d.errors!==void 0&&(!Array.isArray(d.errors)||d.errors.length>0))throw new a("Meridian could not complete the GraphQL query. Please try again.");return C(d.data)}async function l(t,o=10,r){I(t);let s=await m("GetHolderPositions",de,{holder:t,first:o,...r===void 0?{}:{after:r}});return X(s.positions,o,r,!0)}async function f(t,o){let r=[],s=new Set,n=new Set,u,d,h=0;for(let g=0;g<ce;g++){let w=await l(t,E,u);if(d!==void 0&&d!==w.totalCount)throw new a("Meridian positions changed during pagination; retry from the first page.");d=w.totalCount;for(let x of w.nodes){let i=C(x),y=A(i.id);if(n.has(y))throw new a("Meridian repeated a position during pagination; retry from the first page.");n.add(y),N(i.balance)!=="0"&&h++,(o===void 0||b(I(i.tokenAddress),o))&&r.push(ee(x,t))}if(w.nextCursor===null){if(h>d||n.size<d)throw new a("Meridian returned an incomplete positions scan; retry from the first page.");return r}if(s.has(w.nextCursor))throw new a("Meridian repeated a cursor; retry from the first page.");s.add(w.nextCursor),u=w.nextCursor}throw new a("Meridian positions scan exceeded 1000 pages. Use meridian_positions with limit and cursor to inspect pages; redeem a known settled positionToken directly.")}async function P(t,o){if(t.length===0)return[];let r=await c();return(await Promise.all(t.map(async n=>{let[u,d,h]=await Promise.all([r.readContract({address:n.tokenAddress,abi:O,functionName:"balanceOf",args:[o]}),r.readContract({address:n.tokenAddress,abi:O,functionName:"decimals"}),r.readContract({address:n.tokenAddress,abi:O,functionName:"symbol"})]);if(!Number.isInteger(d)||d<0||d>255)throw new a("Meridian returned invalid position token decimals.");let g={address:n.tokenAddress,chainId:k,decimals:d,symbol:A(h)},w=D(u),x=n.pickConfig.resolved?{token:{...T},amount:D(await r.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[n.pickConfigId,n.tokenAddress,BigInt(w)]}))}:null;return{module:"meridian",id:n.id,chainId:k,assets:[{token:g,amount:w}],description:`Meridian ${n.side.toLowerCase()} position; ${n.pickConfig.resolved?n.pickConfig.result??"resolved":"unresolved"}.`,holder:n.holder,side:n.side,pickConfigId:n.pickConfigId,prediction:n.prediction,pickConfig:n.pickConfig,userCollateral:{token:{...T},amount:n.userCollateral},totalPayout:{token:{...T},amount:n.totalPayout},claimable:x}}))).filter(n=>BigInt(n.assets[0].amount)>0n)}async function q(t){return P(await f(t),t)}function _(t){return e.unsignedTx({to:S,chainId:k,value:"0",data:Q({abi:U,functionName:"settle",args:[t,J]}),description:`Settle Meridian prediction ${t}.`})}function L(t,o,r){let s=o.changes.map(n=>{let u=n.amount.startsWith("-"),d=e.formatAmount(u?n.amount.slice(1):n.amount,n.token.decimals);return`${u?"-":"+"}${d} ${n.token.symbol} (${n.token.address}, chain ${n.token.chainId})`});return{txs:t,preview:o,summary:`${r} ${o.summary}${s.length?` Changes: ${s.join("; ")}.`:""}`}}async function te(t){let o=Y(t.limit,20),r=Z(t.cursor);if(r!==void 0&&t.asOf===void 0)throw new a("Pass the previous Meridian browse asOf with cursor to keep the same time filter.");let s=t.asOf===void 0?Math.floor(Date.now()/1e3):Number(R(t.asOf));if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new a("Provide Meridian asOf as Unix seconds within the GraphQL Int range.");let n;if(t.search!==void 0&&(n=A(t.search).trim(),n.length>500))throw new a("Keep the Meridian market search to 500 characters.");let u=t.conditionId===void 0?void 0:v(t.conditionId),d=t.resolver===void 0?void 0:I(t.resolver),h=await m("GetOpenConditions",ae,{now:s,first:o,...r===void 0?{}:{after:r},...n===void 0?{}:{search:n},...u===void 0?{}:{conditionIds:[u]},...d===void 0?{}:{resolvers:[d]}}),g=X(h.conditions,o,r),w=g.nodes.map(x=>{let i=C(x);if(!Number.isSafeInteger(i.endTime)||i.endTime<0||i.estimatedPrice!==null&&(typeof i.estimatedPrice!="number"||!Number.isFinite(i.estimatedPrice)||i.estimatedPrice<0||i.estimatedPrice>1))throw new a("Meridian returned invalid market pricing or time.");let y=v(i.conditionId),M=I(i.resolver);if(u!==void 0&&!b(y,u)||d!==void 0&&!b(M,d))throw new a("Meridian returned a different condition or resolver than requested.");return{conditionId:y,resolver:M,question:A(i.question),shortName:i.shortName===null?null:A(i.shortName),optionName:i.optionName===null?null:A(i.optionName),endTime:String(i.endTime),estimatedPrice:i.estimatedPrice===null?null:String(i.estimatedPrice),marketType:i.marketType===null?null:A(i.marketType)}});return{chainId:k,collateral:{...T},totalCount:g.totalCount,markets:w,limit:o,nextCursor:g.nextCursor,complete:g.complete,asOf:String(s)}}async function ie(t,o){let r=I(t.positionToken),s=R(t.amount);if(BigInt(s)===0n)throw new a("Provide a positive Meridian redemption amount.");let n=await c(),u=D(await n.readContract({address:r,abi:O,functionName:"balanceOf",args:[o]}));if(BigInt(s)>BigInt(u))throw new a("The redemption amount exceeds the wallet position balance.");let d=e.unsignedTx({to:S,chainId:k,value:"0",data:Q({abi:U,functionName:"redeem",args:[r,BigInt(s),J]}),description:`Redeem ${s} Meridian position base units for USDe.`}),h=[d],g;try{g=await e.preview(h,o)}catch(i){if(!/\breverted\b/i.test(e.plainError(i)))throw i;let y=await f(o,r);if(y.length!==1)throw new a("Direct Meridian redemption reverted and no unique indexed prediction was found for this token. Retry indexing or use meridian_settle with the known predictionId first.");let M=y[0];if(M.pickConfig.resolved){let re=D(await n.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[M.pickConfigId,r,BigInt(s)]}));if(BigInt(re)===0n)throw i}h=[_(M.prediction.predictionId),d],g=await e.preview(h,o)}let w=g.changes.filter(i=>ue(i.token,T)&&i.token.decimals===T.decimals).reduce((i,y)=>i+BigInt(y.amount),0n),x=g.changes.filter(i=>i.token.chainId===k&&b(i.token.address,r)).reduce((i,y)=>i+BigInt(y.amount),0n);if(w<=0n||x!==-BigInt(s))throw new a("Meridian preview did not show the requested position burn and a positive USDe payout.");return L(h,g,h.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function $(t,o,r,s,n){return{name:t,inputSchema:{type:"object",properties:o,required:r,additionalProperties:!1,description:s},execute:(u,d)=>p(async()=>{if(C(u),I(d),Object.keys(u).some(h=>!Object.hasOwn(o,h))||r.some(h=>u[h]===void 0))throw new a("Provide only the required Meridian tool inputs.");return n(u,d)})}}return{tools:[$("meridian_browse",{search:{type:"string",minLength:1,maxLength:500,description:"Search text for open conditions."},cursor:V,limit:{...W,description:"Maximum results per page, from 1 to 25."},conditionId:{...K,description:"Condition identifier as a 0x-prefixed 32-byte hex string."},resolver:{...B,description:"Condition resolver contract address on chain 4663."},asOf:H("Reuse the returned Unix seconds with cursor.")},[],"Search open Meridian conditions or look up a conditionId/resolver. Follow nextCursor with the same filters and asOf.",te),$("meridian_positions",{cursor:V,limit:{...W,description:"Maximum results per page, from 1 to 25."}},[],"Page through indexed Meridian positions with on-chain balances and claimability. Follow nextCursor until null; indexing can lag transfers.",async(t,o)=>{let r=Y(t.limit,10),s=Z(t.cursor),n=await l(o,r,s);return{positions:await P(n.nodes.map(u=>ee(u,o)),o),totalCount:n.totalCount,limit:r,nextCursor:n.nextCursor,complete:n.complete,scope:"Indexed positions with current on-chain balances. Index totalCount may exclude zero-balance rows. Indexing can lag transfers; redeem known settled tokens directly."}}),$("meridian_settle",{predictionId:{...K,description:"Prediction identifier as a 0x-prefixed 32-byte hex string."}},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(t,o)=>{let r=_(v(t.predictionId));await c();let s=[r];return L(s,await e.preview(s,o),"Settle the Meridian prediction. Unsigned transaction only.")}),$("meridian_redeem",{positionToken:{...B,description:"Meridian position token contract address on chain 4663."},amount:H('Position token amount in base units using its decimals; for an 18-decimal position token, "1000000000000000000" = 1 position token.')},["positionToken","amount"],"Preview redemption of a known position token directly; scan all indexed pages for settlement first if required. No approval or typed signature.",ie)],positions:t=>p(()=>q(t))}},we=le;export{le as a,we as b};
1
+ import{a as H}from"./66F5ZH34.js";import{c as B,f as j,g as b,k as F,n as G}from"./NWNYJ26T.js";import{b as k,j as z}from"./TI727O2H.js";import{a}from"./XSD5NL7J.js";import{encodeFunctionData as Q,erc20Abi as O,parseAbi as oe,zeroHash as J}from"viem";var ne=z[k].meridian,S=ne.PredictionMarketEscrow.address,T={address:ne.CollateralToken_USDe.address,chainId:k,symbol:"USDe",decimals:18},se="https://api.predict.meridian.xyz/graphql",ae="query GetOpenConditions($now: Int!, $first: Int!, $after: String, $search: String, $conditionIds: [Bytes!], $resolvers: [Address!]) { conditions(first: $first, after: $after, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now }, search: $search, conditionIds: $conditionIds, resolvers: $resolvers }) { totalCount pageInfo { hasNextPage endCursor } nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",de="query GetHolderPositions($holder: Address!, $first: Int!, $after: String) { positions(first: $first, after: $after, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { totalCount pageInfo { hasNextPage endCursor } nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",U=oe(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},V={type:"string",minLength:1,maxLength:4096,description:"Opaque nextCursor returned by the previous page."},E=25,W={type:"integer",minimum:1,maximum:E},ce=1e3;function Y(e,p){if(e===void 0)return p;if(!Number.isSafeInteger(e)||e<1||e>E)throw new a("Provide a Meridian page limit from 1 to 25.");return e}function Z(e){if(e===void 0)return;let p=()=>new a("Provide the opaque Meridian nextCursor returned by the previous page.");if(typeof e!="string"||e.length>4096||!/^[A-Za-z0-9+/_-]+={0,2}$/.test(e))throw p();try{let c=Buffer.from(e,"base64url");if(c.toString("base64url")!==e.replace(/=+$/,"").replace(/\+/g,"-").replace(/\//g,"_"))throw p();let m=C(JSON.parse(c.toString("utf8")));if(typeof m.k!="string"||!m.k||typeof m.id!="string"||!m.id)throw p()}catch{throw p()}return e}function X(e,p,c,m=!1){let l=C(e),f=C(l.pageInfo),P=Array.isArray(l.nodes)?l.nodes.filter(q=>!m||N(C(q).balance)!=="0").length:0;if(!Array.isArray(l.nodes)||l.nodes.length>p||!Number.isSafeInteger(l.totalCount)||l.totalCount<P||typeof f.hasNextPage!="boolean"||c===void 0&&!f.hasNextPage&&l.totalCount>l.nodes.length||f.endCursor!==null&&(typeof f.endCursor!="string"||!f.endCursor.trim()||f.endCursor.length>4096)||f.hasNextPage&&(l.nodes.length===0||f.endCursor===null||f.endCursor===c))throw new a("Meridian returned invalid pagination; retry the scan from the first page.");return{nodes:l.nodes,totalCount:l.totalCount,nextCursor:f.hasNextPage?f.endCursor:null,complete:!f.hasNextPage&&c===void 0}}function C(e){return j(e,"Meridian returned an unexpected response.")}function A(e){if(typeof e!="string"||!e.trim())throw new a("Meridian returned an invalid text field.");return e}function I(e){return F(e,"Provide a valid Meridian contract or wallet address.")}function v(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new a("Provide a valid Meridian prediction or pick configuration ID.");return e}function R(e){return G(e,"Meridian amount exceeds the uint256 range.",{notString:"Meridian amounts must be integer strings in base units."}).toString()}function N(e){return e===0?"0":R(e)}function D(e){if(typeof e!="bigint"||e<0n)throw new a("Meridian returned an invalid on-chain amount.");return R(e.toString())}function ue(e,p){return e.chainId===p.chainId&&b(e.address,p.address)}function ee(e,p){let c=C(e),m=C(c.pickConfig),l=I(c.holder),f=I(m.marketAddress);if(c.chainId!==k||!b(l,p))throw new a("Meridian returned a position for a different wallet or chain.");if(!b(f,S))throw new a("This Meridian position uses an unsupported escrow contract.");if(typeof m.resolved!="boolean"||m.result!==null&&typeof m.result!="string")throw new a("Meridian returned an invalid resolution.");let P=v(c.pickConfigId);if(!b(v(m.pickConfigId),P))throw new a("Meridian returned mismatched pick configuration IDs.");if(c.side!=="PREDICTOR"&&c.side!=="COUNTERPARTY")throw new a("Meridian returned an invalid position side.");return{id:A(c.id),chainId:k,holder:l,side:c.side,balance:N(c.balance),tokenAddress:I(c.tokenAddress),pickConfigId:P,userCollateral:N(c.userCollateral),totalPayout:N(c.totalPayout),prediction:{predictionId:v(C(c.prediction).predictionId)},pickConfig:{pickConfigId:P,marketAddress:f,resolved:m.resolved,result:m.result}}}var le=e=>{async function p(t){try{return await t()}catch(o){throw new a(e.plainError(o))}}async function c(){let t=e.clientFor(k);if(await t.getChainId()!==k)throw new a("Meridian requires an RPC on chain 4663.");return t}async function m(t,o,r){let s=new URL(se);s.searchParams.set("op",t),s.searchParams.set("query",o),s.searchParams.set("variables",JSON.stringify(r));let n=await e.http(s.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!n.ok)throw new a(`Meridian returned HTTP ${n.status}. Please try again.`);let u;try{u=await n.json()}catch{throw new a("Meridian returned malformed JSON.")}let d=C(u);if(d.errors!==void 0&&(!Array.isArray(d.errors)||d.errors.length>0))throw new a("Meridian could not complete the GraphQL query. Please try again.");return C(d.data)}async function l(t,o=10,r){I(t);let s=await m("GetHolderPositions",de,{holder:t,first:o,...r===void 0?{}:{after:r}});return X(s.positions,o,r,!0)}async function f(t,o){let r=[],s=new Set,n=new Set,u,d,h=0;for(let g=0;g<ce;g++){let w=await l(t,E,u);if(d!==void 0&&d!==w.totalCount)throw new a("Meridian positions changed during pagination; retry from the first page.");d=w.totalCount;for(let x of w.nodes){let i=C(x),y=A(i.id);if(n.has(y))throw new a("Meridian repeated a position during pagination; retry from the first page.");n.add(y),N(i.balance)!=="0"&&h++,(o===void 0||b(I(i.tokenAddress),o))&&r.push(ee(x,t))}if(w.nextCursor===null){if(h>d||n.size<d)throw new a("Meridian returned an incomplete positions scan; retry from the first page.");return r}if(s.has(w.nextCursor))throw new a("Meridian repeated a cursor; retry from the first page.");s.add(w.nextCursor),u=w.nextCursor}throw new a("Meridian positions scan exceeded 1000 pages. Use meridian_positions with limit and cursor to inspect pages; redeem a known settled positionToken directly.")}async function P(t,o){if(t.length===0)return[];let r=await c();return(await Promise.all(t.map(async n=>{let[u,d,h]=await Promise.all([r.readContract({address:n.tokenAddress,abi:O,functionName:"balanceOf",args:[o]}),r.readContract({address:n.tokenAddress,abi:O,functionName:"decimals"}),r.readContract({address:n.tokenAddress,abi:O,functionName:"symbol"})]);if(!Number.isInteger(d)||d<0||d>255)throw new a("Meridian returned invalid position token decimals.");let g={address:n.tokenAddress,chainId:k,decimals:d,symbol:A(h)},w=D(u),x=n.pickConfig.resolved?{token:{...T},amount:D(await r.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[n.pickConfigId,n.tokenAddress,BigInt(w)]}))}:null;return{module:"meridian",id:n.id,chainId:k,assets:[{token:g,amount:w}],description:`Meridian ${n.side.toLowerCase()} position; ${n.pickConfig.resolved?n.pickConfig.result??"resolved":"unresolved"}.`,holder:n.holder,side:n.side,pickConfigId:n.pickConfigId,prediction:n.prediction,pickConfig:n.pickConfig,userCollateral:{token:{...T},amount:n.userCollateral},totalPayout:{token:{...T},amount:n.totalPayout},claimable:x}}))).filter(n=>BigInt(n.assets[0].amount)>0n)}async function q(t){return P(await f(t),t)}function _(t){return e.unsignedTx({to:S,chainId:k,value:"0",data:Q({abi:U,functionName:"settle",args:[t,J]}),description:`Settle Meridian prediction ${t}.`})}function L(t,o,r){let s=o.changes.map(n=>{let u=n.amount.startsWith("-"),d=e.formatAmount(u?n.amount.slice(1):n.amount,n.token.decimals);return`${u?"-":"+"}${d} ${n.token.symbol} (${n.token.address}, chain ${n.token.chainId})`});return{txs:t,preview:o,summary:`${r} ${o.summary}${s.length?` Changes: ${s.join("; ")}.`:""}`}}async function te(t){let o=Y(t.limit,20),r=Z(t.cursor);if(r!==void 0&&t.asOf===void 0)throw new a("Pass the previous Meridian browse asOf with cursor to keep the same time filter.");let s=t.asOf===void 0?Math.floor(Date.now()/1e3):Number(R(t.asOf));if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new a("Provide Meridian asOf as Unix seconds within the GraphQL Int range.");let n;if(t.search!==void 0&&(n=A(t.search).trim(),n.length>500))throw new a("Keep the Meridian market search to 500 characters.");let u=t.conditionId===void 0?void 0:v(t.conditionId),d=t.resolver===void 0?void 0:I(t.resolver),h=await m("GetOpenConditions",ae,{now:s,first:o,...r===void 0?{}:{after:r},...n===void 0?{}:{search:n},...u===void 0?{}:{conditionIds:[u]},...d===void 0?{}:{resolvers:[d]}}),g=X(h.conditions,o,r),w=g.nodes.map(x=>{let i=C(x);if(!Number.isSafeInteger(i.endTime)||i.endTime<0||i.estimatedPrice!==null&&(typeof i.estimatedPrice!="number"||!Number.isFinite(i.estimatedPrice)||i.estimatedPrice<0||i.estimatedPrice>1))throw new a("Meridian returned invalid market pricing or time.");let y=v(i.conditionId),M=I(i.resolver);if(u!==void 0&&!b(y,u)||d!==void 0&&!b(M,d))throw new a("Meridian returned a different condition or resolver than requested.");return{conditionId:y,resolver:M,question:A(i.question),shortName:i.shortName===null?null:A(i.shortName),optionName:i.optionName===null?null:A(i.optionName),endTime:String(i.endTime),estimatedPrice:i.estimatedPrice===null?null:String(i.estimatedPrice),marketType:i.marketType===null?null:A(i.marketType)}});return{chainId:k,collateral:{...T},totalCount:g.totalCount,markets:w,limit:o,nextCursor:g.nextCursor,complete:g.complete,asOf:String(s)}}async function ie(t,o){let r=I(t.positionToken),s=R(t.amount);if(BigInt(s)===0n)throw new a("Provide a positive Meridian redemption amount.");let n=await c(),u=D(await n.readContract({address:r,abi:O,functionName:"balanceOf",args:[o]}));if(BigInt(s)>BigInt(u))throw new a("The redemption amount exceeds the wallet position balance.");let d=e.unsignedTx({to:S,chainId:k,value:"0",data:Q({abi:U,functionName:"redeem",args:[r,BigInt(s),J]}),description:`Redeem ${s} Meridian position base units for USDe.`}),h=[d],g;try{g=await e.preview(h,o)}catch(i){if(!/\breverted\b/i.test(e.plainError(i)))throw i;let y=await f(o,r);if(y.length!==1)throw new a("Direct Meridian redemption reverted and no unique indexed prediction was found for this token. Retry indexing or use meridian_settle with the known predictionId first.");let M=y[0];if(M.pickConfig.resolved){let re=D(await n.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[M.pickConfigId,r,BigInt(s)]}));if(BigInt(re)===0n)throw i}h=[_(M.prediction.predictionId),d],g=await e.preview(h,o)}let w=g.changes.filter(i=>ue(i.token,T)&&i.token.decimals===T.decimals).reduce((i,y)=>i+BigInt(y.amount),0n),x=g.changes.filter(i=>i.token.chainId===k&&b(i.token.address,r)).reduce((i,y)=>i+BigInt(y.amount),0n);if(w<=0n||x!==-BigInt(s))throw new a("Meridian preview did not show the requested position burn and a positive USDe payout.");return L(h,g,h.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function $(t,o,r,s,n){return{name:t,inputSchema:{type:"object",properties:o,required:r,additionalProperties:!1,description:s},execute:(u,d)=>p(async()=>{if(C(u),I(d),Object.keys(u).some(h=>!Object.hasOwn(o,h))||r.some(h=>u[h]===void 0))throw new a("Provide only the required Meridian tool inputs.");return n(u,d)})}}return{tools:[$("meridian_browse",{search:{type:"string",minLength:1,maxLength:500,description:"Search text for open conditions."},cursor:V,limit:{...W,description:"Maximum results per page, from 1 to 25."},conditionId:{...K,description:"Condition identifier as a 0x-prefixed 32-byte hex string."},resolver:{...B,description:"Condition resolver contract address on chain 4663."},asOf:H("Reuse the returned Unix seconds with cursor.")},[],"Search open Meridian conditions or look up a conditionId/resolver. Follow nextCursor with the same filters and asOf.",te),$("meridian_positions",{cursor:V,limit:{...W,description:"Maximum results per page, from 1 to 25."}},[],"Page through indexed Meridian positions with on-chain balances and claimability. Follow nextCursor until null; indexing can lag transfers.",async(t,o)=>{let r=Y(t.limit,10),s=Z(t.cursor),n=await l(o,r,s);return{positions:await P(n.nodes.map(u=>ee(u,o)),o),totalCount:n.totalCount,limit:r,nextCursor:n.nextCursor,complete:n.complete,scope:"Indexed positions with current on-chain balances. Index totalCount may exclude zero-balance rows. Indexing can lag transfers; redeem known settled tokens directly."}}),$("meridian_settle",{predictionId:{...K,description:"Prediction identifier as a 0x-prefixed 32-byte hex string."}},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(t,o)=>{let r=_(v(t.predictionId));await c();let s=[r];return L(s,await e.preview(s,o),"Settle the Meridian prediction. Unsigned transaction only.")}),$("meridian_redeem",{positionToken:{...B,description:"Meridian position token contract address on chain 4663."},amount:H('Position token amount in base units using its decimals; for an 18-decimal position token, "1000000000000000000" = 1 position token.')},["positionToken","amount"],"Preview redemption of a known position token directly; scan all indexed pages for settlement first if required. No approval or typed signature.",ie)],positions:t=>p(()=>q(t))}},we=le;export{le as a,we as b};
@@ -0,0 +1,2 @@
1
+ import{g as c}from"./NWNYJ26T.js";import{b as a,j as l}from"./TI727O2H.js";import{a as f}from"./XSD5NL7J.js";import{formatUnits as b,getAddress as d,hashTypedData as w,parseAbi as I}from"viem";var p=d("0x8BE478c754D9124D11e78dB20F5bf4dA45403275"),h=d("0x0c5091235A25bBFD3F5a009cBe04120D0CBAD573"),x=6228n,_="https://priors.trade/prove",$="https://priors.trade/invite",m=1800,k=3600,S=/^[0-9a-f]{32}$/,A=/^priors-invite:(\d{1,10}):(\d{1,12}):(0x[0-9a-fA-F]{130})$/,g=I(["function amount() view returns (uint256)","function unusedAfter() view returns (uint64)","function bonds(uint256 agentId) view returns ((address depositor, uint64 at, uint256 amount, uint256 qualifiedAt))","function releasable(uint256 agentId) view returns (bool)","function unusedReleaseAt(uint256 agentId) view returns (uint256)","function progress(uint256 agentId) view returns (uint256 repaid, uint256 needed)","function deposit(uint256 agentId)","function release(uint256 agentId)","error AlreadyBonded(uint256 agentId)","error NotOwner(uint256 agentId)","error AgentDefaulted(uint256 agentId)","error NoBond(uint256 agentId)","error NotReleasable(uint256 agentId)"]);async function E(e,t){let r=e.clientFor(a),n=await r.getBlockNumber({cacheTime:0}),[i,o,s]=await Promise.all([r.readContract({address:p,abi:g,functionName:"amount",blockNumber:n}),r.readContract({address:p,abi:g,functionName:"unusedAfter",blockNumber:n}),r.readContract({address:p,abi:g,functionName:"unusedReleaseAt",args:[t],blockNumber:n})]);if(typeof i!="bigint"||i<0n||typeof o!="bigint"||o<0n||typeof s!="bigint"||s<0n)throw new f("Priors bond terms are unavailable. Read amount, unusedAfter and unusedReleaseAt again before posting a bond.");return{amount:i.toString(),unusedAfter:o.toString(),unusedReleaseAt:s.toString(),blockNumber:n.toString(),summary:`Bond first: the starter line requires ${b(i,6)} USDG locked for at least ${o} seconds (${Number(o)/86400} days) after posting${s?`; unusedReleaseAt(${t}) is ${s} Unix seconds`:"; the exact release time is read after posting"}. Release requires no line and no open loan; default can forfeit the bond. Invites are not guaranteed. The credit score can lag qualifying repayments.`}}var R="(uint256 agentId, uint256 sponsorId, address owner, uint256 maxPremiumBps, uint256 nonce, uint256 deadline)",B=I(["function agentId() view returns (uint256)","function firstLined(uint256 id) view returns (bool)","function inviteDigest(uint256 id, uint64 expiry) view returns (bytes32)","function inviters(address who) view returns (bool)","function inviteUsed(bytes32 digest) view returns (bool)","function epochRoom() view returns (uint256)","function rules() view returns (uint256 reserveBps, uint256 firstLine, uint256 secondLine, uint256 epochCap, uint64 epochLength, uint64 minSeasoning, uint256 minQualified, uint256 minScore, uint64 idleAfter)",`function firstLine(uint256 id, uint64 expiry, bytes invite, ${R} c, bytes consentSig)`,"error NotAdopted()","error AlreadyLined(uint256 agentId)","error OwnerDefaulted(address owner)","error EpochCapReached(uint256 wanted, uint256 left)","error NotInvited(uint256 agentId, address signer)","error InviteExpired(uint256 agentId, uint64 expiry)","error InviteUsed(uint256 agentId)","error BadConsent()","error ConsentExpired()","error PremiumTooHigh(uint256 bps, uint256 cap)","error InsufficientBacking(uint256 rootId, uint256 requested, uint256 free)","error AgentDefaulted(uint256 agentId)","error IsRoot(uint256 agentId)","error V1Busy(uint256 agentId)","error LoanOpen(uint256 agentId)","error InvalidAgent(uint256 id)","error Paused()","error ECDSAInvalidSignature()","error ECDSAInvalidSignatureLength(uint256 length)","error ECDSAInvalidSignatureS(bytes32 s)"]),v={Consent:[{name:"agentId",type:"uint256"},{name:"sponsorId",type:"uint256"},{name:"owner",type:"address"},{name:"maxPremiumBps",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};function D(){return{name:"Priors Credit",version:"2",chainId:a,verifyingContract:d(l[4663].priors.pool.address)}}function q(e){return{domain:{...D()},types:{Consent:v.Consent.map(t=>({...t}))},primaryType:"Consent",message:{agentId:e.agentId,sponsorId:x.toString(),owner:d(e.owner),maxPremiumBps:"0",nonce:e.nonce,deadline:e.deadline}}}function L(e){return w(e)}function U(e,t){return w({domain:{name:"Priors Treasury",version:"4",chainId:a,verifyingContract:h},types:{Invite:[{name:"agentId",type:"uint256"},{name:"expiry",type:"uint64"}]},primaryType:"Invite",message:{agentId:e,expiry:t}})}function O(e,t,r){return["priors.trade seat request","",`I own agent #${e} on Robinhood Chain and I am asking for a seat.`,"Asked from the priors.trade start page","","This signature only proves ownership. It sends no transaction and moves no funds.","",`request: ${t}`,`expires: ${new Date(r*1e3).toISOString().replace(".000","")}`].join(`
2
+ `)}var u=e=>typeof e=="string"?JSON.stringify(e.length>80?`${e.slice(0,80)}...`:e):typeof e=="number"?String(e):e===null?"null":typeof e;function V(e,t){let r=o=>({ok:!1,why:o});if(!e||typeof e!="object"||Array.isArray(e))return r("its answer is not the bot's form");let n=e;if(n.ok!==!0)return{ok:!1,refused:!0,why:typeof n.error=="string"&&n.error?n.error:"it answered no, with no reason"};if(typeof n.agentId!="string"&&typeof n.agentId!="number"||String(n.agentId)!==t.agentId)return r(`it is for agent ${u(n.agentId)}, not agent #${t.agentId}`);if(typeof n.owner!="string"||!c(n.owner,t.owner))return r(`it names ${u(n.owner)} as the agent's owner, not this wallet (${t.owner})`);if(typeof n.n!="string"||!S.test(n.n))return r(`its request ${u(n.n)} is not the bot's form (32 hex digits)`);if(typeof n.exp!="number"||!Number.isSafeInteger(n.exp))return r(`its expiry ${u(n.exp)} is not a time`);if(n.exp<=t.now)return r(`its expiry (${new Date(n.exp*1e3).toISOString()}) has already passed`);if(n.exp>t.now+m+300)return r(`its expiry (${new Date(n.exp*1e3).toISOString()}) is further away than the bot's ${m/60} minutes`);let i=O(t.agentId,n.n,n.exp);if(typeof n.message!="string")return r("it carries no message");if(n.message!==i){let o=0;for(;o<i.length&&n.message[o]===i[o];)o++;return r(`its message is not the bot's own form for agent #${t.agentId}, request ${n.n} and that expiry: the two first differ at character ${o+1} of ${i.length}`)}return{ok:!0,n:n.n,exp:n.exp,message:i}}function H(e,t,r){let n=A.exec(typeof e=="string"?e:"");if(!n)return{ok:!1,why:"it is not an invite code (priors-invite:<id>:<expiry>:<signature>)"};if(n[1]!==t)return{ok:!1,why:`it is for agent #${n[1]}, not agent #${t}`};let i=Number(n[2]);return i<=r?{ok:!1,why:`it expired at ${new Date(i*1e3).toISOString()}`}:{ok:!0,expiry:BigInt(n[2]),signature:n[3]}}var y=e=>`${new Date(e*1e3).toISOString().slice(0,16).replace("T"," ")} UTC`;function F(e){let t=typeof e.reopensAt=="number"&&Number.isSafeInteger(e.reopensAt)&&e.reopensAt>0?e.reopensAt:null;switch(e.reason){case"default":return"A default on this wallet's record stops new lines for its agents, so a bond would bring no invite.";case"day":return"Today's automatic invites are taken. New ones open at 00:00 UTC: call priors_starter_line again after that.";case"room":return e.held===!0&&t?`This week's first lines are held by invites that haven't been used yet. One may be free after ${y(t)}: call priors_starter_line again then.`:`This week's first lines are taken.${t?` New ones open after ${y(t)}: call priors_starter_line again then.`:" Come back next week."}`;case"owner":return`This wallet already used its ${typeof e.perOwner=="number"&&Number.isSafeInteger(e.perOwner)&&e.perOwner>0?e.perOwner:2} automatic invites, so a bond would bring no invite.`;case"waiting":return"Another agent of this wallet has an invite waiting. Use it, or let it expire, before asking for this one.";case"backing":return"The treasury can't back a new line right now. Try again later.";default:return"Automatic invites aren't open right now, so a bond would bring no invite. Try again later."}}export{p as a,h as b,x as c,_ as d,$ as e,m as f,k as g,S as h,A as i,g as j,E as k,B as l,v as m,D as n,q as o,L as p,U as q,O as r,V as s,H as t,F as u};
@@ -1 +1 @@
1
- import{a as d,b as f}from"./UQEEF5W5.js";import{a}from"./P4UQGWCP.js";import{g as s}from"./NWNYJ26T.js";import{a as n}from"./XSD5NL7J.js";import{getAddress as m,keccak256 as u}from"viem";var l=a.vaults;function c(t,o=!0){let e=l.find(r=>s(r.earnContractAddress,t));if(!e&&o)throw new n("This Beefy vault is not in the pinned chain 4663 standard-vault inventory.");return e}async function v(t,o,e){c(o);let[r,i]=await Promise.all([t.getCode({address:m(o),blockNumber:e}),t.getCode({address:d,blockNumber:e})]),p=`0x363d3d373d3d3d363d73${d.slice(2).toLowerCase()}5af43d82803e903d91602b57fd5bf3`;if(r?.toLowerCase()!==p||!i||u(i)!==f)throw new n("The Beefy standard vault or implementation no longer matches its verified code.")}export{l as a,c as b,v as c};
1
+ import{a as d,b as f}from"./PDPTJMTJ.js";import{a}from"./P4UQGWCP.js";import{g as s}from"./NWNYJ26T.js";import{a as n}from"./XSD5NL7J.js";import{getAddress as m,keccak256 as u}from"viem";var l=a.vaults;function c(t,o=!0){let e=l.find(r=>s(r.earnContractAddress,t));if(!e&&o)throw new n("This Beefy vault is not in the pinned chain 4663 standard-vault inventory.");return e}async function v(t,o,e){c(o);let[r,i]=await Promise.all([t.getCode({address:m(o),blockNumber:e}),t.getCode({address:d,blockNumber:e})]),p=`0x363d3d373d3d3d363d73${d.slice(2).toLowerCase()}5af43d82803e903d91602b57fd5bf3`;if(r?.toLowerCase()!==p||!i||u(i)!==f)throw new n("The Beefy standard vault or implementation no longer matches its verified code.")}export{l as a,c as b,v as c};